Add -B prefix support. Small consistency cleanups.

This commit is contained in:
Dimitrie O. Paun 2004-03-09 01:34:00 +00:00 committed by Alexandre Julliard
parent 76b7787b58
commit fb1ae96cf7
3 changed files with 39 additions and 16 deletions

View File

@ -273,11 +273,26 @@ file_type get_lib_type(strarray* path, const char* library, char** file)
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;
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 @@ void spawn(const strarray* args)
exit(3);
}
free(prog);
strarray_free(arr);
}

View File

@ -62,6 +62,6 @@ char* get_basename(const char* file);
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;

View File

@ -160,6 +160,7 @@ struct options
int noshortwchar;
int gui_app;
int compile_only;
const char* prefix;
const char* output_name;
strarray* lib_dirs;
strarray* linker_args;
@ -314,7 +315,7 @@ static void compile(struct options* opts)
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)
@ -487,7 +488,7 @@ static void build(struct options* opts)
}
}
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 @@ static void build(struct options* opts)
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 @@ static void build(struct options* opts)
strarray_add(link_args, "-lc");
}
spawn(link_args);
spawn(opts->prefix, link_args);
/* create the loader script */
if (generate_app_loader)
@ -557,7 +558,7 @@ static void forward(int argc, char **argv, struct options* opts)
for( j = 1; j < argc; j++ )
strarray_add(args, argv[j]);
spawn(args);
spawn(opts->prefix, args);
}
/*
@ -637,6 +638,7 @@ int main(int argc, char **argv)
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 @@ int main(int argc, char **argv)
/* 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 */