File: plugin-just-build-addin.c

package info (click to toggle)
foundry 1.1~beta-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,552 kB
  • sloc: ansic: 167,487; xml: 417; makefile: 21; sh: 19; javascript: 10
file content (94 lines) | stat: -rw-r--r-- 3,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* plugin-just-build-addin.c
 *
 * Copyright 2025 Christian Hergert
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "config.h"

#include <glib/gi18n-lib.h>

#include "plugin-just-build-addin.h"
#include "plugin-just-build-stage.h"

struct _PluginJustBuildAddin
{
  FoundryBuildAddin  parent_instance;
  FoundryBuildStage *build;
};

G_DEFINE_FINAL_TYPE (PluginJustBuildAddin, plugin_just_build_addin, FOUNDRY_TYPE_BUILD_ADDIN)

static DexFuture *
plugin_just_build_addin_load (FoundryBuildAddin *build_addin)
{
  PluginJustBuildAddin *self = (PluginJustBuildAddin *)build_addin;
  g_autoptr(FoundryBuildPipeline) pipeline = NULL;
  g_autoptr(FoundryContext) context = NULL;
  g_autofree char *build_system = NULL;

  g_assert (PLUGIN_IS_JUST_BUILD_ADDIN (self));

  context = foundry_contextual_dup_context (FOUNDRY_CONTEXTUAL (self));
  pipeline = foundry_build_addin_dup_pipeline (build_addin);
  build_system = foundry_build_pipeline_dup_build_system (pipeline);

  if (foundry_str_equal0 (build_system, "just"))
    {
      g_autofree char *just = g_strdup ("just"); /* TODO: Find just */
      g_autofree char *builddir = foundry_build_pipeline_dup_builddir (pipeline);

      self->build = g_object_new (PLUGIN_TYPE_JUST_BUILD_STAGE,
                                  "context", context,
                                  "just", just,
                                  "kind", "just",
                                  "title", _("Build Just Project"),
                                  NULL);
      foundry_build_pipeline_add_stage (pipeline, self->build);
    }

  return dex_future_new_true ();
}

static DexFuture *
plugin_just_build_addin_unload (FoundryBuildAddin *build_addin)
{
  PluginJustBuildAddin *self = (PluginJustBuildAddin *)build_addin;
  g_autoptr(FoundryBuildPipeline) pipeline = NULL;

  g_assert (PLUGIN_IS_JUST_BUILD_ADDIN (self));

  pipeline = foundry_build_addin_dup_pipeline (build_addin);

  foundry_clear_build_stage (&self->build, pipeline);

  return dex_future_new_true ();
}

static void
plugin_just_build_addin_class_init (PluginJustBuildAddinClass *klass)
{
  FoundryBuildAddinClass *build_addin_class = FOUNDRY_BUILD_ADDIN_CLASS (klass);

  build_addin_class->load = plugin_just_build_addin_load;
  build_addin_class->unload = plugin_just_build_addin_unload;
}

static void
plugin_just_build_addin_init (PluginJustBuildAddin *self)
{
}