SF.net SVN: geany: [1348] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Thu Mar 1 11:38:14 UTC 2007
Revision: 1348
http://svn.sourceforge.net/geany/?rev=1348&view=rev
Author: ntrel
Date: 2007-03-01 03:38:14 -0800 (Thu, 01 Mar 2007)
Log Message:
-----------
Run Make All and Make Custom from the project base directory, if set.
Add project_get_make_dir().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/build.c
trunk/src/project.c
trunk/src/project.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-03-01 10:54:37 UTC (rev 1347)
+++ trunk/ChangeLog 2007-03-01 11:38:14 UTC (rev 1348)
@@ -1,3 +1,10 @@
+2007-03-01 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/build.c, src/project.c, src/project.h:
+ Run Make All and Make Custom from the project base directory, if set.
+ Add project_get_make_dir().
+
+
2007-03-01 Enrico Tröger <enrico.troeger at uvena.de>
* src/tools.c, src/utils.c:
Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c 2007-03-01 10:54:37 UTC (rev 1347)
+++ trunk/src/build.c 2007-03-01 11:38:14 UTC (rev 1348)
@@ -48,6 +48,7 @@
#include "document.h"
#include "keybindings.h"
#include "vte.h"
+#include "project.h"
BuildInfo build_info = {GBO_COMPILE, 0, NULL, GEANY_FILETYPES_ALL, NULL};
@@ -75,7 +76,7 @@
static gboolean build_iofunc(GIOChannel *ioc, GIOCondition cond, gpointer data);
static gboolean build_create_shellscript(const gint idx, const gchar *fname, const gchar *cmd,
gboolean autoclose);
-static GPid build_spawn_cmd(gint idx, const gchar *cmd);
+static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir);
static void on_make_target_dialog_response(GtkDialog *dialog, gint response, gpointer user_data);
static void on_make_target_entry_activate(GtkEntry *entry, gpointer user_data);
static void set_stop_button(gboolean stop);
@@ -116,7 +117,7 @@
build_info.type = GBO_BUILD;
}
- return build_spawn_cmd(idx, cmd);
+ return build_spawn_cmd(idx, cmd, NULL);
}
@@ -280,6 +281,7 @@
GPid build_make_file(gint idx, gint build_opts)
{
GString *cmdstr;
+ const gchar *dir = NULL;
GPid pid;
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
@@ -300,14 +302,16 @@
{
build_info.type = GBO_MAKE_CUSTOM;
g_string_append(cmdstr, build_info.custom_target);
+ dir = project_get_make_dir();
}
else // GBO_MAKE_ALL
{
build_info.type = GBO_MAKE_ALL;
g_string_append(cmdstr, "all");
+ dir = project_get_make_dir();
}
- pid = build_spawn_cmd(idx, cmdstr->str);
+ pid = build_spawn_cmd(idx, cmdstr->str, dir); // if dir is NULL, idx filename is used
g_string_free(cmdstr, TRUE);
return pid;
}
@@ -322,7 +326,7 @@
cmd = doc_list[idx].file_type->programs->compiler;
build_info.type = GBO_COMPILE;
- return build_spawn_cmd(idx, cmd);
+ return build_spawn_cmd(idx, cmd, NULL);
}
@@ -397,13 +401,15 @@
g_free(locale_filename);
build_info.type = GBO_BUILD;
- pid = build_spawn_cmd(idx, cmdstr->str);
+ pid = build_spawn_cmd(idx, cmdstr->str, NULL);
g_string_free(cmdstr, TRUE);
return pid;
}
-static GPid build_spawn_cmd(gint idx, const gchar *cmd)
+/* dir is the UTF-8 working directory to run cmd in. It can be NULL to use the
+ * idx document directory */
+static GPid build_spawn_cmd(gint idx, const gchar *cmd, const gchar *dir)
{
GError *error = NULL;
gchar **argv;
@@ -434,19 +440,22 @@
g_free(tmp);
g_free(executable);
- utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
-
argv = g_new0(gchar *, 4);
argv[0] = g_strdup("/bin/sh");
argv[1] = g_strdup("-c");
argv[2] = cmd_string;
argv[3] = NULL;
- working_dir = g_path_get_dirname(locale_filename);
- utf8_working_dir = g_path_get_dirname(doc_list[idx].file_name);
+ utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
+ utf8_working_dir = (dir != NULL) ? g_strdup(dir) :
+ g_path_get_dirname(doc_list[idx].file_name);
+ working_dir = utils_get_locale_from_utf8(utf8_working_dir);
+
gtk_list_store_clear(msgwindow.store_compiler);
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_COMPILER);
msgwin_compiler_add_fmt(COLOR_BLUE, _("%s (in directory: %s)"), utf8_cmd_string, utf8_working_dir);
- gtk_notebook_set_current_page(GTK_NOTEBOOK(msgwindow.notebook), MSG_COMPILER);
+ g_free(utf8_working_dir);
+ g_free(utf8_cmd_string);
// set the build info for the message window
g_free(build_info.dir);
@@ -461,8 +470,6 @@
g_strfreev(argv);
g_error_free(error);
g_free(working_dir);
- g_free(utf8_working_dir);
- g_free(utf8_cmd_string);
g_free(locale_filename);
error = NULL;
return (GPid) 0;
@@ -481,8 +488,6 @@
build_iofunc, GINT_TO_POINTER(1));
g_strfreev(argv);
- g_free(utf8_working_dir);
- g_free(utf8_cmd_string);
g_free(working_dir);
g_free(locale_filename);
Modified: trunk/src/project.c
===================================================================
--- trunk/src/project.c 2007-03-01 10:54:37 UTC (rev 1347)
+++ trunk/src/project.c 2007-03-01 11:38:14 UTC (rev 1348)
@@ -701,3 +701,13 @@
return TRUE;
}
+
+
+const gchar *project_get_make_dir()
+{
+ if (app->project != NULL)
+ return app->project->base_path;
+ else
+ return NULL;
+}
+
Modified: trunk/src/project.h
===================================================================
--- trunk/src/project.h 2007-03-01 10:54:37 UTC (rev 1347)
+++ trunk/src/project.h 2007-03-01 11:38:14 UTC (rev 1348)
@@ -51,4 +51,6 @@
void project_properties();
+const gchar *project_get_make_dir();
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list