[Resend winegcc07] Don't make unneeded argument lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Moved the wrapper code into a new function

Changelog Only make wrapper argument lists if we're going to use them. Move the spawn()s closer to their arguments


diff -u -r -N tools.5/winewrap.c tools/winewrap.c
--- tools.5/winewrap.c	2003-09-09 10:41:22.000000000 +0100
+++ tools/winewrap.c	2003-09-09 16:52:49.000000000 +0100
@@ -346,16 +346,95 @@
     }
 }
 
+static void create_the_wrapper(char* base_file, char* base_name, int gui_mode, int cpp)
+{
+    char *wrp_temp_name, *wspec_name, *wspec_c_name, *wspec_o_name;
+    char *wrap_c_name, *wrap_o_name;
+    strarray *wwrap_args, *wspec_args, *wcomp_args, *wlink_args;
+    int i;
+
+    wrp_temp_name = tempnam(0, "wwrp");   
+    wspec_name = strmake("%s.spec", wrp_temp_name);
+    wspec_c_name = strmake("%s.c", wspec_name);
+    wspec_o_name = strmake("%s.o", wspec_name);
+
+    wrap_c_name = strmake("%s.c", wrp_temp_name);
+    wrap_o_name = strmake("%s.o", wrp_temp_name);
+
+    /* build wrapper compile argument list */
+    strarray_init(wwrap_args);
+    strarray_add(wwrap_args, "gcc");
+    strarray_add(wwrap_args, "-fPIC");
+    strarray_add(wwrap_args, "-I" INCLUDEDIR "/windows");
+    strarray_add(wwrap_args, "-o");
+    strarray_add(wwrap_args, wrap_o_name);
+    strarray_add(wwrap_args, "-c");
+    strarray_add(wwrap_args, wrap_c_name);
+    strarray_add(wwrap_args, NULL);
+      
+    create_file(wrap_c_name, wrapper_code, base_name, gui_mode);
+    spawn(wwrap_args);
+    strarray_free(wwrap_args);
+    rm_temp_file(wrap_c_name);
+ 
+    /* build wrapper winebuild's argument list */
+    strarray_init(wspec_args);
+    strarray_add(wspec_args, "winebuild");
+    strarray_add(wspec_args, "-o");
+    strarray_add(wspec_args, wspec_c_name);
+    strarray_add(wspec_args, "--exe");
+    strarray_add(wspec_args, strmake("%s.exe", base_name));
+    strarray_add(wspec_args, gui_mode ? "-mgui" : "-mcui");
+    strarray_add(wspec_args, wrap_o_name);
+    for (i = 0; i < lib_files->size; i++)
+	strarray_add(wspec_args, lib_files->base[i]);
+    for (i = 0; i < dll_files->size; i++)
+	strarray_add(wspec_args, dll_files->base[i]);
+    strarray_add(wspec_args, NULL);
+    
+    spawn(wspec_args);
+    strarray_free(wspec_args);
+
+    /* build wrapper gcc's argument list */
+    strarray_init(wcomp_args);
+    strarray_add(wcomp_args, "gcc");
+    strarray_add(wcomp_args, "-fPIC");
+    strarray_add(wcomp_args, "-o");
+    strarray_add(wcomp_args, wspec_o_name);
+    strarray_add(wcomp_args, "-c");
+    strarray_add(wcomp_args, wspec_c_name);
+    strarray_add(wcomp_args, NULL);
+     
+    spawn(wcomp_args);
+    strarray_free(wcomp_args);
+    rm_temp_file(wspec_c_name);
+ 
+    /* build wrapper ld's argument list */
+    strarray_init(wlink_args);
+    strarray_add(wlink_args, cpp ? "g++" : "gcc");
+    strarray_add(wlink_args, "-shared");
+    strarray_add(wlink_args, "-Wl,-Bsymbolic,-z,defs");
+    strarray_add(wlink_args, "-lwine");
+    strarray_add(wlink_args, "-ldl");
+    strarray_add(wlink_args, "-o");
+    strarray_add(wlink_args, strmake("%s.exe.so", base_file));
+    strarray_add(wlink_args, wspec_o_name);
+    strarray_add(wlink_args, wrap_o_name);
+    strarray_add(wlink_args, NULL);
+     
+    spawn(wlink_args);
+    strarray_free(wlink_args);
+    rm_temp_file(wspec_o_name);
+    rm_temp_file(wrap_o_name);
+}
+
 int main(int argc, char **argv)
 {
     char *library = 0, *path = 0;
     int i, len, cpp = 0, no_opt = 0, gui_mode = 0, create_wrapper = -1;
-    char *base_name, *base_file, *app_temp_name, *wrp_temp_name;
+    char *base_name, *base_file, *app_temp_name;
     char *spec_name, *spec_c_name, *spec_o_name;
-    char *wspec_name, *wspec_c_name, *wspec_o_name;
-    char *wrap_c_name, *wrap_o_name;
     strarray *spec_args, *comp_args, *link_args;
-    strarray *wwrap_args, *wspec_args, *wcomp_args, *wlink_args;
    
     strarray_init(arh_files);
     strarray_init(dll_files);
@@ -435,8 +514,6 @@
     add_lib_file("kernel32");
 
     app_temp_name = tempnam(0, "wapp");
-    wrp_temp_name = tempnam(0, "wwrp");
-   
     /* get base filename by removing the .exe extension, if present */ 
     base_file = strdup(output_name);
     len = strlen(base_file);
@@ -451,13 +528,6 @@
     spec_c_name = strmake("%s.c", spec_name);
     spec_o_name = strmake("%s.o", spec_name);
 
-    wspec_name = strmake("%s.spec", wrp_temp_name);
-    wspec_c_name = strmake("%s.c", wspec_name);
-    wspec_o_name = strmake("%s.o", wspec_name);
-
-    wrap_c_name = strmake("%s.c", wrp_temp_name);
-    wrap_o_name = strmake("%s.o", wrp_temp_name);
-
     /* build winebuild's argument list */
     strarray_init(spec_args);
     strarray_add(spec_args, "winebuild");
@@ -465,6 +535,7 @@
     strarray_add(spec_args, spec_c_name);
     if (create_wrapper)
     {
+	create_file(spec_name, gui_mode ? app_gui_spec : app_cui_spec);
 	strarray_add(spec_args, "-F");
 	strarray_add(spec_args, strmake("%s-wrap.dll", base_name));
 	strarray_add(spec_args, "--spec");
@@ -484,6 +555,13 @@
 	strarray_add(spec_args, arh_files->base[i]);
     strarray_add(spec_args, NULL);
 
+    /* run winebuild to get the .spec.c file */
+    spawn(spec_args);
+    strarray_free(spec_args);
+
+    if (create_wrapper)
+        rm_temp_file(spec_name);
+
     /* build gcc's argument list */
     strarray_init(comp_args);
     strarray_add(comp_args, "gcc");
@@ -493,6 +571,10 @@
     strarray_add(comp_args, "-c");
     strarray_add(comp_args, spec_c_name);
     strarray_add(comp_args, NULL);
+
+    spawn(comp_args);
+    strarray_free(comp_args);
+    rm_temp_file(spec_c_name);
     
     /* build ld's argument list */
     strarray_init(link_args);
@@ -517,82 +599,12 @@
 	strarray_add(link_args, arh_files->base[i]);
     strarray_add(link_args, NULL);
   
-    /* build wrapper compile argument list */
-    strarray_init(wwrap_args);
-    strarray_add(wwrap_args, "gcc");
-    strarray_add(wwrap_args, "-fPIC");
-    strarray_add(wwrap_args, "-I" INCLUDEDIR "/windows");
-    strarray_add(wwrap_args, "-o");
-    strarray_add(wwrap_args, wrap_o_name);
-    strarray_add(wwrap_args, "-c");
-    strarray_add(wwrap_args, wrap_c_name);
-    strarray_add(wwrap_args, NULL);
-     
-    /* build wrapper winebuild's argument list */
-    strarray_init(wspec_args);
-    strarray_add(wspec_args, "winebuild");
-    strarray_add(wspec_args, "-o");
-    strarray_add(wspec_args, wspec_c_name);
-    strarray_add(wspec_args, "--exe");
-    strarray_add(wspec_args, strmake("%s.exe", base_name));
-    strarray_add(wspec_args, gui_mode ? "-mgui" : "-mcui");
-    strarray_add(wspec_args, wrap_o_name);
-    for (i = 0; i < dll_files->size; i++)
-	strarray_add(wspec_args, dll_files->base[i]);
-    strarray_add(wspec_args, NULL);
+    spawn(link_args);
+    strarray_free(link_args);
+    rm_temp_file(spec_o_name);
 
-    /* build wrapper gcc's argument list */
-    strarray_init(wcomp_args);
-    strarray_add(wcomp_args, "gcc");
-    strarray_add(wcomp_args, "-fPIC");
-    strarray_add(wcomp_args, "-o");
-    strarray_add(wcomp_args, wspec_o_name);
-    strarray_add(wcomp_args, "-c");
-    strarray_add(wcomp_args, wspec_c_name);
-    strarray_add(wcomp_args, NULL);
-    
-    /* build wrapper ld's argument list */
-    strarray_init(wlink_args);
-    strarray_add(wlink_args, cpp ? "g++" : "gcc");
-    strarray_add(wlink_args, "-shared");
-    strarray_add(wlink_args, "-Wl,-Bsymbolic,-z,defs");
-    strarray_add(wlink_args, "-lwine");
-    strarray_add(wlink_args, "-ldl");
-    strarray_add(wlink_args, "-o");
-    strarray_add(wlink_args, strmake("%s.exe.so", base_file));
-    strarray_add(wlink_args, wspec_o_name);
-    strarray_add(wlink_args, wrap_o_name);
-    strarray_add(wlink_args, NULL);
-    
-    /* run winebuild to get the .spec.c file */
     if (create_wrapper)
-    {
-	create_file(spec_name, gui_mode ? app_gui_spec : app_cui_spec);
-        spawn(spec_args);
-        rm_temp_file(spec_name);
-	spawn(comp_args);
-	rm_temp_file(spec_c_name);
-	spawn(link_args);
-	rm_temp_file(spec_o_name);
-
-	create_file(wrap_c_name, wrapper_code, base_name, gui_mode);
-	spawn(wwrap_args);
-	rm_temp_file(wrap_c_name);
-	spawn(wspec_args);
-	spawn(wcomp_args);
-	rm_temp_file(wspec_c_name);
-	spawn(wlink_args);
-	rm_temp_file(wspec_o_name);
-	rm_temp_file(wrap_o_name);
-    }
-    else
-    {
-	spawn(spec_args);
-	spawn(comp_args);
-	rm_temp_file(spec_c_name);
-	spawn(link_args);
-	rm_temp_file(spec_o_name);
-    }
+	create_the_wrapper(base_file, base_name, gui_mode, cpp);
 
     /* create the loader script */
     create_file(base_file, app_loader_script, base_name);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux