aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/anjuta-plugin-sdk.plugin.in1
-rw-r--r--src/plugin.c117
2 files changed, 64 insertions, 54 deletions
diff --git a/src/anjuta-plugin-sdk.plugin.in b/src/anjuta-plugin-sdk.plugin.in
index 1e83011..fdd50cc 100644
--- a/src/anjuta-plugin-sdk.plugin.in
+++ b/src/anjuta-plugin-sdk.plugin.in
@@ -3,3 +3,4 @@ Location=anjuta-plugin-sdk:AnjutaPluginSdk
Icon=anjuta-plugin-sdk.png
_Name=Poky SDK
_Description=A plugin that allows integration with the Poky SDK.
+Interfaces=IAnjutaEnvironment
diff --git a/src/plugin.c b/src/plugin.c
index 2cc6e25..999b65d 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -20,6 +20,7 @@
#include <libanjuta/anjuta-debug.h>
#include <libanjuta/interfaces/ianjuta-document-manager.h>
#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include <libanjuta/interfaces/ianjuta-environment.h>
#include <libanjuta/interfaces/ianjuta-terminal.h>
#include <libgnomevfs/gnome-vfs.h>
@@ -42,8 +43,9 @@
#define SSH_OPTIONS "-o", "CheckHostIP no", "-o", \
"StrictHostKeyChecking no", "-o", "UserKnownHostsFile /dev/null"
-#define CONFIGURE_COMMAND "./configure --host=%s"
-#define AUTOGEN_COMMAND "./autogen.sh --host=%s"
+#define CONFIGURE_COMMAND "/configure"
+#define AUTOGEN_COMMAND "/autogen.sh"
+#define CROSS_COMMAND "--host=%s"
#define DEPLOY_COMMAND "rsync " \
"-e 'ssh -o \"CheckHostIP no\" " \
@@ -1266,55 +1268,6 @@ setup_target (AnjutaPluginSdk *sp)
update_state (sp);
}
-
-static void
-setup_buildable (AnjutaPluginSdk *sp)
-{
- gchar *command = NULL;
- GError *error = NULL;
-
- if (!sp->buildable)
- {
- sp->buildable = anjuta_shell_get_interface (ANJUTA_PLUGIN (sp)->shell, IAnjutaBuildable,
- &error);
-
- if (!sp->buildable)
- {
- g_warning ("Error whilst getting buildable interface: %s", error->message);
- g_clear_error (&error);
- return;
- }
- }
-
- /* For the configure option in the menu */
- command = g_strdup_printf (CONFIGURE_COMMAND, sp->triplet);
-
- ianjuta_buildable_set_command (sp->buildable,
- IANJUTA_BUILDABLE_COMMAND_CONFIGURE, command, &error);
-
- if (error)
- {
- g_warning ("Error setting configure command: %s", error->message);
- g_clear_error (&error);
- }
-
- g_free (command);
-
- /* For the generate option in the menu */
- command = g_strdup_printf (AUTOGEN_COMMAND, sp->triplet);
-
- ianjuta_buildable_set_command (sp->buildable,
- IANJUTA_BUILDABLE_COMMAND_GENERATE, command, &error);
-
- if (error)
- {
- g_warning ("Error setting autogen command: %s", error->message);
- g_clear_error (&error);
- }
-
- g_free (command);
-}
-
#ifdef ANJUTA_2_28_OR_HIGHER
/* Callbacks fired when preferences changed */
static void
@@ -1339,7 +1292,6 @@ triplet_preference_notify_cb (AnjutaPreferences *pref, const gchar *key,
sp->triplet = anjuta_preferences_get (sp->prefs, PREFS_PROP_TRIPLET);
update_environment (sp);
- setup_buildable (sp);
}
static void
@@ -1445,7 +1397,6 @@ triplet_preference_notify_cb (GConfClient *client, guint cnxn_id,
sp->triplet = anjuta_preferences_get (sp->prefs, PREFS_PROP_TRIPLET);
update_environment (sp);
- setup_buildable (sp);
}
static void
@@ -1702,7 +1653,6 @@ anjuta_plugin_sdk_activate (AnjutaPlugin *plugin)
setup_target (sp);
update_environment (sp);
- setup_buildable (sp);
sp->project_root_uri_watch = anjuta_plugin_add_watch (plugin,
"project_root_uri",
@@ -1910,8 +1860,67 @@ ipreferences_iface_init (IAnjutaPreferencesIface* iface)
iface->unmerge = ipreferences_unmerge;
}
+/* IAnjutaEnvironment override implementation */
+static gboolean anjuta_environment_override (IAnjutaEnvironment *obj,
+ gchar **dirp, gchar ***argvp, gchar ***envp, GError **err)
+{
+ AnjutaPluginSdk *sp = (AnjutaPluginSdk *)obj;
+ gchar **new_argv;
+ gsize length = g_strv_length (*argvp);
+ int i;
+
+ if (length < 1)
+ return FALSE;
+
+ if (!sp->triplet) // no override for cross command
+ return TRUE;
+
+ if (g_str_has_suffix(*argvp[0], CONFIGURE_COMMAND) ||
+ g_str_has_suffix(*argvp[0], AUTOGEN_COMMAND)) {
+ new_argv = g_new (gchar*, length + 2);
+ if (!new_argv) {
+ g_error("Error while allocate args when do environment override!");
+ return FALSE;
+ }
+
+ new_argv[0] = g_strconcat(*(argvp[0]), NULL);
+ new_argv[1] = g_strdup_printf (CROSS_COMMAND, sp->triplet);
+
+ for (i = 0; i < length; i++) {
+ if (i)
+ new_argv[1 + i] = g_strconcat(*(*argvp + i), NULL);
+ g_free(*(*argvp + i));
+ }
+
+ /* args must be NULL terminated */
+ new_argv[length+1] = NULL;
+ g_free (*argvp);
+ *argvp = new_argv;
+ }
+
+ return TRUE;
+}
+
+static gchar*
+anjuta_get_real_directory(IAnjutaEnvironment *obj, gchar *dir, GError **err)
+{
+ /* We need not to override directory here */
+ return dir;
+}
+
+
+static void
+ienvironment_iface_init(IAnjutaEnvironmentIface* iface)
+{
+ iface->override = anjuta_environment_override;
+ iface->get_real_directory = anjuta_get_real_directory;
+}
+
ANJUTA_PLUGIN_BEGIN (AnjutaPluginSdk, anjuta_plugin_sdk);
ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_ADD_INTERFACE(ienvironment, IANJUTA_TYPE_ENVIRONMENT);
+
+
ANJUTA_PLUGIN_END;