Commit f7272176 authored by Alexandre Julliard's avatar Alexandre Julliard

winebuild: Split the names of the as and ld commands to allow arguments.

parent 2daa5367
...@@ -229,7 +229,7 @@ extern char *xstrdup( const char *str ); ...@@ -229,7 +229,7 @@ extern char *xstrdup( const char *str );
extern char *strupper(char *s); extern char *strupper(char *s);
extern int strendswith(const char* str, const char* end); extern int strendswith(const char* str, const char* end);
extern char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 ))); extern char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
extern struct strarray *strarray_init(void); extern struct strarray *strarray_fromstring( const char *str, const char *delim );
extern void strarray_add( struct strarray *array, ... ); extern void strarray_add( struct strarray *array, ... );
extern void strarray_addv( struct strarray *array, char * const *argv ); extern void strarray_addv( struct strarray *array, char * const *argv );
extern void strarray_free( struct strarray *array ); extern void strarray_free( struct strarray *array );
...@@ -246,7 +246,7 @@ extern int output( const char *format, ... ) ...@@ -246,7 +246,7 @@ extern int output( const char *format, ... )
extern void output_cfi( const char *format, ... ) extern void output_cfi( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2))); __attribute__ ((__format__ (__printf__, 1, 2)));
extern void spawn( struct strarray *array ); extern void spawn( struct strarray *array );
extern char *find_tool( const char *name, const char * const *names ); extern struct strarray *find_tool( const char *name, const char * const *names );
extern struct strarray *get_as_command(void); extern struct strarray *get_as_command(void);
extern struct strarray *get_ld_command(void); extern struct strarray *get_ld_command(void);
extern const char *get_nm_command(void); extern const char *get_nm_command(void);
...@@ -357,9 +357,9 @@ extern FILE *output_file; ...@@ -357,9 +357,9 @@ extern FILE *output_file;
extern const char *output_file_name; extern const char *output_file_name;
extern char **lib_path; extern char **lib_path;
extern char *as_command; extern struct strarray *as_command;
extern char *ld_command; extern struct strarray *ld_command;
extern char *nm_command; extern struct strarray *nm_command;
extern char *cpu_option; extern char *cpu_option;
#endif /* __WINE_BUILD_H */ #endif /* __WINE_BUILD_H */
...@@ -1322,7 +1322,7 @@ void output_imports( DLLSPEC *spec ) ...@@ -1322,7 +1322,7 @@ void output_imports( DLLSPEC *spec )
/* output an import library for a Win32 module and additional object files */ /* output an import library for a Win32 module and additional object files */
void output_import_lib( DLLSPEC *spec, char **argv ) void output_import_lib( DLLSPEC *spec, char **argv )
{ {
struct strarray *args = strarray_init(); struct strarray *args;
char *def_file; char *def_file;
if (target_platform != PLATFORM_WINDOWS) if (target_platform != PLATFORM_WINDOWS)
...@@ -1336,14 +1336,15 @@ void output_import_lib( DLLSPEC *spec, char **argv ) ...@@ -1336,14 +1336,15 @@ void output_import_lib( DLLSPEC *spec, char **argv )
fclose( output_file ); fclose( output_file );
output_file = NULL; output_file = NULL;
strarray_add( args, find_tool( "dlltool", NULL ), "-k", "-l", output_file_name, "-d", def_file, NULL ); args = find_tool( "dlltool", NULL );
strarray_add( args, "-k", "-l", output_file_name, "-d", def_file, NULL );
spawn( args ); spawn( args );
strarray_free( args ); strarray_free( args );
if (argv[0]) if (argv[0])
{ {
args = strarray_init(); args = find_tool( "ar", NULL );
strarray_add( args, find_tool( "ar", NULL ), "rs", output_file_name, NULL ); strarray_add( args, "rs", output_file_name, NULL );
strarray_addv( args, argv ); strarray_addv( args, argv );
spawn( args ); spawn( args );
strarray_free( args ); strarray_free( args );
......
...@@ -84,9 +84,9 @@ const char *output_file_name = NULL; ...@@ -84,9 +84,9 @@ const char *output_file_name = NULL;
static const char *output_file_source_name; static const char *output_file_source_name;
static int fake_module; static int fake_module;
char *as_command = NULL; struct strarray *as_command = NULL;
char *ld_command = NULL; struct strarray *ld_command = NULL;
char *nm_command = NULL; struct strarray *nm_command = NULL;
char *cpu_option = NULL; char *cpu_option = NULL;
static int nb_res_files; static int nb_res_files;
...@@ -474,7 +474,7 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) ...@@ -474,7 +474,7 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
set_exec_mode( MODE_IMPLIB ); set_exec_mode( MODE_IMPLIB );
break; break;
case LONG_OPT_ASCMD: case LONG_OPT_ASCMD:
as_command = xstrdup( optarg ); as_command = strarray_fromstring( optarg, " " );
break; break;
case LONG_OPT_FAKE_MODULE: case LONG_OPT_FAKE_MODULE:
fake_module = 1; fake_module = 1;
...@@ -486,10 +486,10 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) ...@@ -486,10 +486,10 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
spec->characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE; spec->characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
break; break;
case LONG_OPT_LDCMD: case LONG_OPT_LDCMD:
ld_command = xstrdup( optarg ); ld_command = strarray_fromstring( optarg, " " );
break; break;
case LONG_OPT_NMCMD: case LONG_OPT_NMCMD:
nm_command = xstrdup( optarg ); nm_command = strarray_fromstring( optarg, " " );
break; break;
case LONG_OPT_NXCOMPAT: case LONG_OPT_NXCOMPAT:
if (optarg[0] == 'n' || optarg[0] == 'N') if (optarg[0] == 'n' || optarg[0] == 'N')
......
...@@ -680,8 +680,8 @@ void output_res_o_file( DLLSPEC *spec ) ...@@ -680,8 +680,8 @@ void output_res_o_file( DLLSPEC *spec )
close( fd ); close( fd );
free( output_buffer ); free( output_buffer );
args = strarray_init(); args = find_tool( "windres", NULL );
strarray_add( args, find_tool( "windres", NULL ), "-i", res_file, "-o", output_file_name, NULL ); strarray_add( args, "-i", res_file, "-o", output_file_name, NULL );
spawn( args ); spawn( args );
strarray_free( args ); strarray_free( args );
......
...@@ -138,12 +138,23 @@ char *strmake( const char* fmt, ... ) ...@@ -138,12 +138,23 @@ char *strmake( const char* fmt, ... )
} }
} }
struct strarray *strarray_init(void) static struct strarray *strarray_init( const char *str )
{ {
struct strarray *array = xmalloc( sizeof(*array) ); struct strarray *array = xmalloc( sizeof(*array) );
array->count = 0; array->count = 0;
array->max = 16; array->max = 16;
array->str = xmalloc( array->max * sizeof(*array->str) ); array->str = xmalloc( array->max * sizeof(*array->str) );
if (str) array->str[array->count++] = str;
return array;
}
static struct strarray *strarray_copy( const struct strarray *src )
{
struct strarray *array = xmalloc( sizeof(*array) );
array->count = src->count;
array->max = src->max;
array->str = xmalloc( array->max * sizeof(*array->str) );
memcpy( array->str, src->str, array->count * sizeof(*array->str) );
return array; return array;
} }
...@@ -172,6 +183,19 @@ void strarray_addv( struct strarray *array, char * const *argv ) ...@@ -172,6 +183,19 @@ void strarray_addv( struct strarray *array, char * const *argv )
while (*argv) strarray_add_one( array, *argv++ ); while (*argv) strarray_add_one( array, *argv++ );
} }
struct strarray *strarray_fromstring( const char *str, const char *delim )
{
const char *tok;
struct strarray *array = strarray_init( NULL );
char *buf = strdup( str );
for (tok = strtok( buf, delim ); tok; tok = strtok( NULL, delim ))
strarray_add_one( array, strdup( tok ));
free( buf );
return array;
}
void strarray_free( struct strarray *array ) void strarray_free( struct strarray *array )
{ {
free( array->str ); free( array->str );
...@@ -277,7 +301,7 @@ void spawn( struct strarray *args ) ...@@ -277,7 +301,7 @@ void spawn( struct strarray *args )
} }
/* find a build tool in the path, trying the various names */ /* find a build tool in the path, trying the various names */
char *find_tool( const char *name, const char * const *names ) struct strarray *find_tool( const char *name, const char * const *names )
{ {
static char **dirs; static char **dirs;
static unsigned int count, maxlen; static unsigned int count, maxlen;
...@@ -338,7 +362,8 @@ char *find_tool( const char *name, const char * const *names ) ...@@ -338,7 +362,8 @@ char *find_tool( const char *name, const char * const *names )
strcpy( p, *names ); strcpy( p, *names );
strcat( p, EXEEXT ); strcat( p, EXEEXT );
if (!stat( file, &st ) && S_ISREG(st.st_mode) && (st.st_mode & 0111)) return file; if (!stat( file, &st ) && S_ISREG(st.st_mode) && (st.st_mode & 0111))
return strarray_init( file );
} }
free( file ); free( file );
names++; names++;
...@@ -349,7 +374,7 @@ char *find_tool( const char *name, const char * const *names ) ...@@ -349,7 +374,7 @@ char *find_tool( const char *name, const char * const *names )
struct strarray *get_as_command(void) struct strarray *get_as_command(void)
{ {
static int as_is_clang = 0; static int as_is_clang = 0;
struct strarray *args = strarray_init(); struct strarray *args;
if (!as_command) if (!as_command)
{ {
...@@ -366,7 +391,7 @@ struct strarray *get_as_command(void) ...@@ -366,7 +391,7 @@ struct strarray *get_as_command(void)
if (!as_command) if (!as_command)
fatal_error( "cannot find suitable assembler\n" ); fatal_error( "cannot find suitable assembler\n" );
strarray_add_one( args, as_command ); args = strarray_copy( as_command );
if (as_is_clang) if (as_is_clang)
{ {
...@@ -401,7 +426,7 @@ struct strarray *get_as_command(void) ...@@ -401,7 +426,7 @@ struct strarray *get_as_command(void)
struct strarray *get_ld_command(void) struct strarray *get_ld_command(void)
{ {
struct strarray *args = strarray_init(); struct strarray *args;
if (!ld_command) if (!ld_command)
{ {
...@@ -412,7 +437,7 @@ struct strarray *get_ld_command(void) ...@@ -412,7 +437,7 @@ struct strarray *get_ld_command(void)
if (!ld_command) if (!ld_command)
fatal_error( "cannot find suitable linker\n" ); fatal_error( "cannot find suitable linker\n" );
strarray_add_one( args, ld_command ); args = strarray_copy( ld_command );
if (force_pointer_size) if (force_pointer_size)
{ {
...@@ -450,7 +475,9 @@ const char *get_nm_command(void) ...@@ -450,7 +475,9 @@ const char *get_nm_command(void)
if (!nm_command) if (!nm_command)
fatal_error( "cannot find suitable name lister\n" ); fatal_error( "cannot find suitable name lister\n" );
return nm_command; if (nm_command->count > 1)
fatal_error( "multiple arguemnts in nm command not supported yet\n" );
return nm_command->str[0];
} }
/* get a name for a temp file, automatically cleaned up on exit */ /* get a name for a temp file, automatically cleaned up on exit */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment