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 );
extern char *strupper(char *s);
extern int strendswith(const char* str, const char* end);
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_addv( struct strarray *array, char * const *argv );
extern void strarray_free( struct strarray *array );
......@@ -246,7 +246,7 @@ extern int output( const char *format, ... )
extern void output_cfi( const char *format, ... )
__attribute__ ((__format__ (__printf__, 1, 2)));
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_ld_command(void);
extern const char *get_nm_command(void);
......@@ -357,9 +357,9 @@ extern FILE *output_file;
extern const char *output_file_name;
extern char **lib_path;
extern char *as_command;
extern char *ld_command;
extern char *nm_command;
extern struct strarray *as_command;
extern struct strarray *ld_command;
extern struct strarray *nm_command;
extern char *cpu_option;
#endif /* __WINE_BUILD_H */
......@@ -1322,7 +1322,7 @@ void output_imports( DLLSPEC *spec )
/* output an import library for a Win32 module and additional object files */
void output_import_lib( DLLSPEC *spec, char **argv )
{
struct strarray *args = strarray_init();
struct strarray *args;
char *def_file;
if (target_platform != PLATFORM_WINDOWS)
......@@ -1336,14 +1336,15 @@ void output_import_lib( DLLSPEC *spec, char **argv )
fclose( output_file );
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 );
strarray_free( args );
if (argv[0])
{
args = strarray_init();
strarray_add( args, find_tool( "ar", NULL ), "rs", output_file_name, NULL );
args = find_tool( "ar", NULL );
strarray_add( args, "rs", output_file_name, NULL );
strarray_addv( args, argv );
spawn( args );
strarray_free( args );
......
......@@ -84,9 +84,9 @@ const char *output_file_name = NULL;
static const char *output_file_source_name;
static int fake_module;
char *as_command = NULL;
char *ld_command = NULL;
char *nm_command = NULL;
struct strarray *as_command = NULL;
struct strarray *ld_command = NULL;
struct strarray *nm_command = NULL;
char *cpu_option = NULL;
static int nb_res_files;
......@@ -474,7 +474,7 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
set_exec_mode( MODE_IMPLIB );
break;
case LONG_OPT_ASCMD:
as_command = xstrdup( optarg );
as_command = strarray_fromstring( optarg, " " );
break;
case LONG_OPT_FAKE_MODULE:
fake_module = 1;
......@@ -486,10 +486,10 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
spec->characteristics |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
break;
case LONG_OPT_LDCMD:
ld_command = xstrdup( optarg );
ld_command = strarray_fromstring( optarg, " " );
break;
case LONG_OPT_NMCMD:
nm_command = xstrdup( optarg );
nm_command = strarray_fromstring( optarg, " " );
break;
case LONG_OPT_NXCOMPAT:
if (optarg[0] == 'n' || optarg[0] == 'N')
......
......@@ -680,8 +680,8 @@ void output_res_o_file( DLLSPEC *spec )
close( fd );
free( output_buffer );
args = strarray_init();
strarray_add( args, find_tool( "windres", NULL ), "-i", res_file, "-o", output_file_name, NULL );
args = find_tool( "windres", NULL );
strarray_add( args, "-i", res_file, "-o", output_file_name, NULL );
spawn( args );
strarray_free( args );
......
......@@ -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) );
array->count = 0;
array->max = 16;
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;
}
......@@ -172,6 +183,19 @@ void strarray_addv( struct strarray *array, char * const *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 )
{
free( array->str );
......@@ -277,7 +301,7 @@ void spawn( struct strarray *args )
}
/* 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 unsigned int count, maxlen;
......@@ -338,7 +362,8 @@ char *find_tool( const char *name, const char * const *names )
strcpy( p, *names );
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 );
names++;
......@@ -349,7 +374,7 @@ char *find_tool( const char *name, const char * const *names )
struct strarray *get_as_command(void)
{
static int as_is_clang = 0;
struct strarray *args = strarray_init();
struct strarray *args;
if (!as_command)
{
......@@ -366,7 +391,7 @@ struct strarray *get_as_command(void)
if (!as_command)
fatal_error( "cannot find suitable assembler\n" );
strarray_add_one( args, as_command );
args = strarray_copy( as_command );
if (as_is_clang)
{
......@@ -401,7 +426,7 @@ struct strarray *get_as_command(void)
struct strarray *get_ld_command(void)
{
struct strarray *args = strarray_init();
struct strarray *args;
if (!ld_command)
{
......@@ -412,7 +437,7 @@ struct strarray *get_ld_command(void)
if (!ld_command)
fatal_error( "cannot find suitable linker\n" );
strarray_add_one( args, ld_command );
args = strarray_copy( ld_command );
if (force_pointer_size)
{
......@@ -450,7 +475,9 @@ const char *get_nm_command(void)
if (!nm_command)
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 */
......
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