[gnome-builder] buildtarget: add get_argv vfunc
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buildtarget: add get_argv vfunc
- Date: Thu, 23 Nov 2017 01:09:39 +0000 (UTC)
commit 4d131727a302f0da537fffb60e8390cd2e5aa1fa
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 22 16:47:29 2017 -0800
buildtarget: add get_argv vfunc
This allows us to have multiple parameters as arguments for
the given build target.
src/libide/buildsystem/ide-build-target.c | 34 +++++++++++++++++++++++++++++
src/libide/buildsystem/ide-build-target.h | 13 ++++++----
2 files changed, 42 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/buildsystem/ide-build-target.c b/src/libide/buildsystem/ide-build-target.c
index 3e0ad2d..890e547 100644
--- a/src/libide/buildsystem/ide-build-target.c
+++ b/src/libide/buildsystem/ide-build-target.c
@@ -88,3 +88,37 @@ ide_build_target_compare (const IdeBuildTarget *left,
return ide_build_target_get_priority ((IdeBuildTarget *)left) -
ide_build_target_get_priority ((IdeBuildTarget *)right);
}
+
+/**
+ * ide_build_target_get_argv:
+ * @self: a #IdeBuildTarget
+ *
+ * Gets the arguments used to run the target.
+ *
+ * Returns: (transfer full): A #GStrv containing the arguments to
+ * run the target.
+ *
+ * Since: 3.28
+ */
+gchar **
+ide_build_target_get_argv (IdeBuildTarget *self)
+{
+ g_autofree gchar *name = NULL;
+ g_auto(GStrv) argv = NULL;
+
+ g_return_val_if_fail (IDE_IS_BUILD_TARGET (self), NULL);
+
+ if (IDE_BUILD_TARGET_GET_IFACE (self)->get_argv)
+ argv = IDE_BUILD_TARGET_GET_IFACE (self)->get_argv (self);
+
+ if (argv == NULL || *argv == NULL)
+ {
+ g_clear_pointer (&argv, g_strfreev);
+
+ argv = g_new (gchar *, 2);
+ argv[0] = ide_build_target_get_name (self);
+ argv[1] = NULL;
+ }
+
+ return g_steal_pointer (&argv);
+}
diff --git a/src/libide/buildsystem/ide-build-target.h b/src/libide/buildsystem/ide-build-target.h
index ae46c31..7af3904 100644
--- a/src/libide/buildsystem/ide-build-target.h
+++ b/src/libide/buildsystem/ide-build-target.h
@@ -37,16 +37,19 @@ struct _IdeBuildTargetInterface
GFile *(*get_install_directory) (IdeBuildTarget *self);
gchar *(*get_name) (IdeBuildTarget *self);
gint (*get_priority) (IdeBuildTarget *self);
+ gchar **(*get_argv) (IdeBuildTarget *self);
};
IDE_AVAILABLE_IN_ALL
-GFile *ide_build_target_get_install_directory (IdeBuildTarget *self);
+GFile *ide_build_target_get_install_directory (IdeBuildTarget *self);
IDE_AVAILABLE_IN_ALL
-gchar *ide_build_target_get_name (IdeBuildTarget *self);
+gchar *ide_build_target_get_name (IdeBuildTarget *self);
IDE_AVAILABLE_IN_3_28
-gint ide_build_target_get_priority (IdeBuildTarget *self);
+gint ide_build_target_get_priority (IdeBuildTarget *self);
IDE_AVAILABLE_IN_3_28
-gboolean ide_build_target_compare (const IdeBuildTarget *left,
- const IdeBuildTarget *right);
+gchar **ide_build_target_get_argv (IdeBuildTarget *self);
+IDE_AVAILABLE_IN_3_28
+gboolean ide_build_target_compare (const IdeBuildTarget *left,
+ const IdeBuildTarget *right);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]