Add support for passing options to winebuild via -Wb. Generate only the loader script when given just the .exe.so. Add function to delete element from a strarray.
diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c index 5f1bb37..3538168 100644 --- a/tools/winegcc/utils.c +++ b/tools/winegcc/utils.c
@@ -118,6 +118,13 @@ arr->base[arr->size++] = str; } +void strarray_del(strarray* arr, int i) +{ + if (i < 0 || i >= arr->size) error("Invalid index i=%d", i); + memmove(&arr->base[i], &arr->base[i + 1], (arr->size - i - 1) * sizeof(arr->base[0])); + arr->size--; +} + void strarray_addall(strarray* arr, const strarray* from) { int i;
diff --git a/tools/winegcc/utils.h b/tools/winegcc/utils.h index 042f267..54ee5b7 100644 --- a/tools/winegcc/utils.h +++ b/tools/winegcc/utils.h
@@ -48,6 +48,7 @@ strarray* strarray_dup(const strarray* arr); void strarray_free(strarray* arr); void strarray_add(strarray* arr, const char* str); +void strarray_del(strarray* arr, int i); void strarray_addall(strarray* arr, const strarray* from); strarray* strarray_fromstring(const char* str, const char* delim); char* strarray_tostring(const strarray* arr, const char* sep);
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 2b4cf44..12c2f0b 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c
@@ -165,6 +165,7 @@ strarray* lib_dirs; strarray *linker_args; strarray *compiler_args; + strarray* winebuild_args; strarray* files; }; @@ -336,8 +337,8 @@ char *spec_c_name, *spec_o_name, *base_file, *base_name; const char* output_name; const char *winebuild = getenv("WINEBUILD"); - int j; int generate_app_loader = 1; + int j; if (!winebuild) winebuild = "winebuild"; @@ -361,6 +362,9 @@ if ((base_name = strrchr(base_file, '/'))) base_name++; else base_name = base_file; + if (opts->files->size == 1 && strendswith(opts->files->base[0], ".exe.so")) + goto only_app_loader; + /* prepare the linking path */ lib_dirs = strarray_dup(opts->lib_dirs); for ( j = 0; j < sizeof(stdlibpath)/sizeof(stdlibpath[0]);j++ ) @@ -447,6 +451,9 @@ for ( j = 0; j < lib_paths->size; j++ ) strarray_add(spec_args, lib_paths->base[j]); + for ( j = 0 ; j < opts->winebuild_args->size ; j++ ) + strarray_add(spec_args, opts->winebuild_args->base[j]); + for ( j = 0; j < dll_libs->size; j++ ) strarray_add(spec_args, dll_libs->base[j]); @@ -504,6 +511,7 @@ spawn(link_args); /* create the loader script */ +only_app_loader: if (generate_app_loader) { create_file(base_file, app_loader_template, base_name); @@ -614,6 +622,7 @@ opts.files = strarray_alloc(); opts.linker_args = strarray_alloc(); opts.compiler_args = strarray_alloc(); + opts.winebuild_args = strarray_alloc(); /* determine the processor type */ if (strendswith(argv[0], "winecpp")) opts.processor = proc_pp; @@ -749,6 +758,12 @@ if (strstr(argv[i], "-static")) linking = -1; } + else if (strncmp("-Wb,", argv[i], 4) == 0) + { + strarray* Wb = strarray_fromstring(argv[i] + 4, ","); + strarray_addall(opts.winebuild_args, Wb); + strarray_free(Wb); + } break; case '-': if (strcmp("-static", argv[i]+1) == 0)