From 5f0796dbd2f2805f105b4289f40e0ec3b8f66cc7 Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Tue, 2 Mar 2004 06:53:16 +0000 Subject: [PATCH] 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. --- tools/winegcc/utils.c | 7 +++++++ tools/winegcc/utils.h | 1 + tools/winegcc/winegcc.c | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c index 5f1bb3731a7..35381680d67 100644 --- a/tools/winegcc/utils.c +++ b/tools/winegcc/utils.c @@ -118,6 +118,13 @@ void strarray_add(strarray* arr, const char* str) 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 042f2673cec..54ee5b78ddc 100644 --- a/tools/winegcc/utils.h +++ b/tools/winegcc/utils.h @@ -48,6 +48,7 @@ strarray* strarray_alloc(void); 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 2b4cf44476d..12c2f0b962e 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -165,6 +165,7 @@ struct options strarray* lib_dirs; strarray *linker_args; strarray *compiler_args; + strarray* winebuild_args; strarray* files; }; @@ -336,8 +337,8 @@ static void build(struct options* opts) 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 @@ static void build(struct options* opts) 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 @@ static void build(struct options* opts) 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 @@ static void build(struct options* opts) 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 @@ int main(int argc, char **argv) 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 @@ int main(int argc, char **argv) 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)