winegcc: add support for -B prefix
Dimitrie O. Paun
dimi at intelliware.ca
Mon Mar 8 13:15:49 CST 2004
Never used -B before, so I don't know if this is how it's
supposed to behave. Basically, if a prefix is given, I first
look there for the name of the executable. If I find a
file that's executable, I run that. If not, I default to
the original.
ChangeLog
Dimitrie O. Paun <dpaun at rogers.com>
Add -B prefix support. Small consistency cleanups.
Index: tools/winegcc/utils.h
===================================================================
RCS file: /var/cvs/wine/tools/winegcc/utils.h,v
retrieving revision 1.7
diff -u -r1.7 utils.h
--- tools/winegcc/utils.h 3 Mar 2004 20:11:20 -0000 1.7
+++ tools/winegcc/utils.h 8 Mar 2004 18:24:04 -0000
@@ -62,6 +62,6 @@
void create_file(const char* name, int mode, const char* fmt, ...);
file_type get_file_type(const char* filename);
file_type get_lib_type(strarray* path, const char* library, char** file);
-void spawn(const strarray* arr);
+void spawn(const char* prefix, const strarray* arr);
extern int verbose;
Index: tools/winegcc/utils.c
===================================================================
RCS file: /var/cvs/wine/tools/winegcc/utils.c,v
retrieving revision 1.8
diff -u -r1.8 utils.c
--- tools/winegcc/utils.c 3 Mar 2004 20:11:20 -0000 1.8
+++ tools/winegcc/utils.c 8 Mar 2004 18:55:52 -0000
@@ -273,11 +273,26 @@
return file_na;
}
-void spawn(const strarray* args)
+void spawn(const char* prefix, const strarray* args)
{
int i, status;
strarray* arr = strarray_dup(args);
- const char **argv = arr->base;
+ const char** argv = arr->base;
+ char* prog = 0;
+
+ if (prefix)
+ {
+ const char* p;
+ struct stat st;
+
+ if (!(p = strrchr(argv[0], '/'))) p = argv[0];
+ prog = strmake("%s/%s", prefix, p);
+ if (stat(prog, &st) == 0)
+ {
+ if ((st.st_mode & S_IFREG) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ argv[0] = prog;
+ }
+ }
strarray_add(arr, NULL);
if (verbose)
@@ -293,5 +308,6 @@
exit(3);
}
+ free(prog);
strarray_free(arr);
}
--- tools/winegcc/winegcc.c.1 2004-03-08 10:53:37.000000000 -0500
+++ tools/winegcc/winegcc.c 2004-03-08 13:34:54.000000000 -0500
@@ -96,7 +96,7 @@
#include "utils.h"
-static const char *app_loader_template =
+static const char* app_loader_template =
"#!/bin/sh\n"
"\n"
"appname=\"%s\"\n"
@@ -148,7 +148,7 @@
;
static int keep_generated = 0;
-static strarray *tmp_files;
+static strarray* tmp_files;
struct options
{
@@ -160,10 +160,11 @@
int noshortwchar;
int gui_app;
int compile_only;
+ const char* prefix;
const char* output_name;
strarray* lib_dirs;
- strarray *linker_args;
- strarray *compiler_args;
+ strarray* linker_args;
+ strarray* compiler_args;
strarray* winebuild_args;
strarray* files;
};
@@ -180,7 +181,7 @@
char* get_temp_file(const char* prefix, const char* suffix)
{
- char *tmp = strmake("%s-XXXXXX%s", prefix, suffix);
+ char* tmp = strmake("%s-XXXXXX%s", prefix, suffix);
int fd = mkstemps( tmp, strlen(suffix) );
if (fd == -1)
{
@@ -219,7 +220,7 @@
static void compile(struct options* opts)
{
- strarray *comp_args = strarray_alloc();
+ strarray* comp_args = strarray_alloc();
int j, gcc_defs = 0;
switch(opts->processor)
@@ -314,7 +315,7 @@
for ( j = 0; j < opts->files->size; j++ )
strarray_add(comp_args, opts->files->base[j]);
- spawn(comp_args);
+ spawn(opts->prefix, comp_args);
}
static const char* compile_to_object(struct options* opts, const char* file)
@@ -345,7 +346,7 @@
strarray *spec_args, *comp_args, *link_args;
char *spec_c_name, *spec_o_name, *base_file, *base_name;
const char* output_name;
- const char *winebuild = getenv("WINEBUILD");
+ const char* winebuild = getenv("WINEBUILD");
int generate_app_loader = 1;
int j;
@@ -487,7 +488,7 @@
}
}
- spawn(spec_args);
+ spawn(opts->prefix, spec_args);
/* compile the .spec.c file into a .spec.o file */
comp_args = strarray_alloc();
@@ -499,7 +500,7 @@
strarray_add(comp_args, "-c");
strarray_add(comp_args, spec_c_name);
- spawn(comp_args);
+ spawn(opts->prefix, comp_args);
/* link everything together now */
link_args = strarray_alloc();
@@ -539,7 +540,7 @@
strarray_add(link_args, "-lc");
}
- spawn(link_args);
+ spawn(opts->prefix, link_args);
/* create the loader script */
if (generate_app_loader)
@@ -549,7 +550,7 @@
static void forward(int argc, char **argv, struct options* opts)
{
- strarray *args = strarray_alloc();
+ strarray* args = strarray_alloc();
int j;
strarray_addall(args, get_translator(opts));
@@ -557,7 +558,7 @@
for( j = 1; j < argc; j++ )
strarray_add(args, argv[j]);
- spawn(args);
+ spawn(opts->prefix, args);
}
/*
@@ -637,6 +638,7 @@
int raw_compiler_arg, raw_linker_arg;
const char* option_arg;
struct options opts;
+ char* str;
/* setup tmp file removal at exit */
tmp_files = strarray_alloc();
@@ -730,6 +732,11 @@
/* do a bit of semantic analysis */
switch (argv[i][1])
{
+ case 'B':
+ str = strdup(option_arg);
+ if (strendswith(str, "/")) str[strlen(str) - 1] = 0;
+ opts.prefix = str;
+ break;
case 'c': /* compile or assemble */
if (argv[i][2] == 0) opts.compile_only = 1;
/* fall through */
--
Dimi.
More information about the wine-patches
mailing list