X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/308dc7bdfb924370cfd205f656eb0e83191d01a9..b3db2950b11fc5f3abd9ecdae855746e2d19c836:/src/main.c diff --git a/src/main.c b/src/main.c index 296cf0d..c94c805 100644 --- a/src/main.c +++ b/src/main.c @@ -53,6 +53,7 @@ extern GList *include_files; extern GHashTable *gtk_doc_hash; char *filebase; +char *fullfilebase; static char *funcbase; static char *pfuncbase; static char *macrobase; @@ -63,6 +64,8 @@ static char *pmacrotype; static char *typebase; static char *ptypebase; +char *output_dir = NULL; + static int signals = 0; /* number of signals */ static int set_properties = 0; /* number of named (set) properties */ static int get_properties = 0; /* number of named (get) properties */ @@ -122,6 +125,13 @@ make_bases (void) filebase = replace_sep (((Class *)class)->otype, '-'); gob_strdown (filebase); + if (output_dir != NULL && + output_dir[0] != '\0') { + fullfilebase = g_build_filename (output_dir, filebase, NULL); + } else { + fullfilebase = g_strdup (filebase); + } + funcbase = replace_sep (((Class *)class)->otype, '_'); gob_strdown (funcbase); @@ -1581,21 +1591,6 @@ make_argument (Argument *a) #define value_for_print(str, alt) (str != NULL ? str : alt) -static char * -make_me_type (const char *type, const char *alt) -{ - if (type == NULL) - return g_strdup (alt); - /* HACK! just in case someone made this - * work with 2.0.0 by using the TYPE - * macro directly */ - if ((strstr (type, "_TYPE_") != NULL || - strstr (type, "TYPE_") == type) && - strchr (type, ':') == NULL) - return g_strdup (type); - return make_pre_macro (type, "TYPE"); -} - static void make_property (Property *p) { @@ -2945,18 +2940,18 @@ open_files(void) char *outfile, *outfileh, *outfileph; if ( ! for_cpp) - outfile = g_strconcat (filebase, ".c", NULL); + outfile = g_strconcat (fullfilebase, ".c", NULL); else - outfile = g_strconcat (filebase, ".cc", NULL); + outfile = g_strconcat (fullfilebase, ".cc", NULL); if (no_touch_headers) - outfileh = g_strconcat ("#gob#", filebase, ".h#gob#", NULL); + outfileh = g_strconcat (fullfilebase, ".h#gob#", NULL); else - outfileh = g_strconcat (filebase, ".h", NULL); + outfileh = g_strconcat (fullfilebase, ".h", NULL); if ((privates > 0 || protecteds > 0 || private_header == PRIVATE_HEADER_ALWAYS) && private_header != PRIVATE_HEADER_NEVER) - outfileph = g_strconcat (filebase, "-private.h", NULL); + outfileph = g_strconcat (fullfilebase, "-private.h", NULL); else outfileph = NULL; @@ -3934,10 +3929,10 @@ print_help(void) "really changed\n" "\t--always-private-header Always create a private header " "file,\n" - "\t even if it would be empty " - "[default]\n" + "\t even if it would be empty\n" "\t--ondemand-private-header Create private header only when " "needed\n" + "\t [default]\n" "\t--no-private-header Don't create a private header, " "put private\n" "\t structure and protected " @@ -3956,7 +3951,9 @@ print_help(void) "\t--no-lines Don't print '#line' to output\n" "\t--no-self-alias Don't create self type and macro " "aliases\n" - "\t--no-kill-underscores Ignored for compatibility\n"); + "\t--no-kill-underscores Ignored for compatibility\n" + "\t-o,--output-dir The directory where output " + "should be placed\n"); } static void @@ -4058,6 +4055,21 @@ parse_options(int argc, char *argv[]) use_m4_clean=TRUE; m4_opts = TRUE; m4_commandline=g_strdup(M4_COMMANDLINE); + } else if (strcmp (argv[i], "-o") == 0 || + strcmp (argv[i], "--output-dir") == 0) { + if (i+1 < argc) { + output_dir = g_strdup (argv[i+1]); + i++; + } else { + output_dir = NULL; + } + } else if (strncmp (argv[i], "-o=", strlen ("-o=")) == 0 || + strncmp (argv[i], + "--output-dir=", + strlen ("--output-dir=")) == 0) { + char *p = strchr (argv[i], '='); + g_assert (p != NULL); + output_dir = g_strdup (p+1); } else if(strcmp(argv[i], "--")==0) { /*further arguments are files*/ no_opts = TRUE; @@ -4110,8 +4122,8 @@ parse_options(int argc, char *argv[]) static void compare_and_move_header(void) { - char *hfnew = g_strconcat("#gob#", filebase, ".h#gob#", NULL); - char *hf = g_strconcat(filebase, ".h", NULL); + char *hfnew = g_strconcat(fullfilebase, ".h#gob#", NULL); + char *hf = g_strconcat(fullfilebase, ".h", NULL); struct stat s; if(stat(hf, &s) == 0) { char *s;