Alexandre Julliard : winegcc: Forward the -B options to winebuild.

Alexandre Julliard julliard at winehq.org
Tue Sep 10 16:49:29 CDT 2019


Module: wine
Branch: master
Commit: 13850a3eb8c5792cd75ae4fc32a64552fbf1e032
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=13850a3eb8c5792cd75ae4fc32a64552fbf1e032

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Sep 10 17:57:19 2019 +0200

winegcc: Forward the -B options to winebuild.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/winegcc/utils.c   | 37 +++++++++++++++++--------------------
 tools/winegcc/utils.h   |  1 +
 tools/winegcc/winegcc.c | 18 +++++++++++++-----
 3 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c
index a124ef2d34..3197e46e47 100644
--- a/tools/winegcc/utils.c
+++ b/tools/winegcc/utils.c
@@ -297,6 +297,22 @@ file_type get_lib_type(enum target_platform platform, strarray* path, const char
     return file_na;
 }
 
+const char *find_binary( const strarray* prefix, const char *name )
+{
+    unsigned int i;
+
+    if (!prefix) return name;
+    if (strchr( name, '/' )) return name;
+
+    for (i = 0; i < prefix->size; i++)
+    {
+        struct stat st;
+        char *prog = strmake( "%s/%s%s", prefix->base[i], name, EXEEXT );
+        if (stat( prog, &st ) == 0 && S_ISREG( st.st_mode ) && (st.st_mode & 0111)) return prog;
+    }
+    return name;
+}
+
 int spawn(const strarray* prefix, const strarray* args, int ignore_errors)
 {
     unsigned int i;
@@ -307,26 +323,7 @@ int spawn(const strarray* prefix, const strarray* args, int ignore_errors)
 
     strarray_add(arr, NULL);
     argv = arr->base;
-
-    if (prefix)
-    {
-        const char *p = strrchr(argv[0], '/');
-        if (!p) p = argv[0];
-        else p++;
-
-        for (i = 0; i < prefix->size; i++)
-        {
-            struct stat st;
-
-            free( prog );
-            prog = strmake("%s/%s%s", prefix->base[i], p, EXEEXT);
-            if (stat(prog, &st) == 0 && S_ISREG(st.st_mode) && (st.st_mode & 0111))
-            {
-                argv[0] = prog;
-                break;
-            }
-        }
-    }
+    argv[0] = find_binary( prefix, argv[0] );
 
     if (verbose)
     {
diff --git a/tools/winegcc/utils.h b/tools/winegcc/utils.h
index 536fb2d2f9..6056ee7258 100644
--- a/tools/winegcc/utils.h
+++ b/tools/winegcc/utils.h
@@ -83,6 +83,7 @@ void create_file(const char* name, int mode, const char* fmt, ...);
 file_type get_file_type(const char* filename);
 file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
                        const char *suffix, char** file);
+const char *find_binary( const strarray* prefix, const char *name );
 int spawn(const strarray* prefix, const strarray* arr, int ignore_errors);
 
 extern int verbose;
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 9d5828e612..06771262eb 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -300,7 +300,7 @@ static char* get_temp_file(const char* prefix, const char* suffix)
     return tmp;
 }
 
-static char* build_tool_name(struct options *opts, const char* base, const char* deflt)
+static const char* build_tool_name(struct options *opts, const char* base, const char* deflt)
 {
     char* str;
 
@@ -318,12 +318,12 @@ static char* build_tool_name(struct options *opts, const char* base, const char*
     }
     else
         str = xstrdup(deflt);
-    return str;
+    return find_binary( opts->prefix, str );
 }
 
 static const strarray* get_translator(struct options *opts)
 {
-    char *str = NULL;
+    const char *str = NULL;
     strarray *ret;
 
     switch(opts->processor)
@@ -342,7 +342,6 @@ static const strarray* get_translator(struct options *opts)
         assert(0);
     }
     ret = strarray_fromstring( str, " " );
-    free(str);
     if (opts->force_pointer_size)
         strarray_add( ret, strmake("-m%u", 8 * opts->force_pointer_size ));
     return ret;
@@ -847,9 +846,10 @@ static strarray *get_winebuild_args(struct options *opts)
 {
     const char* winebuild = getenv("WINEBUILD");
     strarray *spec_args = strarray_alloc();
+    unsigned int i;
 
     if (!winebuild) winebuild = "winebuild";
-    strarray_add( spec_args, winebuild );
+    strarray_add( spec_args, find_binary( opts->prefix, winebuild ));
     if (verbose) strarray_add( spec_args, "-v" );
     if (keep_generated) strarray_add( spec_args, "--save-temps" );
     if (opts->target)
@@ -857,6 +857,14 @@ static strarray *get_winebuild_args(struct options *opts)
         strarray_add( spec_args, "--target" );
         strarray_add( spec_args, opts->target );
     }
+    if (opts->prefix)
+    {
+        for (i = 0; i < opts->prefix->size; i++)
+        {
+            if (strendswith( opts->prefix->base[i], "/tools/winebuild" )) continue;
+            strarray_add( spec_args, strmake( "-B%s", opts->prefix->base[i] ));
+        }
+    }
     if (!opts->use_msvcrt) strarray_add( spec_args, "-munix" );
     if (opts->unwind_tables) strarray_add( spec_args, "-fasynchronous-unwind-tables" );
     else strarray_add( spec_args, "-fno-asynchronous-unwind-tables" );




More information about the wine-cvs mailing list