Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b03059cb
Commit
b03059cb
authored
Aug 02, 2010
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebuild: Add a spawn() helper function to avoid starting a shell where possible.
parent
f51e696c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
79 deletions
+121
-79
build.h
tools/winebuild/build.h
+14
-2
import.c
tools/winebuild/import.c
+17
-41
res32.c
tools/winebuild/res32.c
+5
-9
utils.c
tools/winebuild/utils.c
+85
-27
No files found.
tools/winebuild/build.h
View file @
b03059cb
...
@@ -135,6 +135,13 @@ extern char *target_alias;
...
@@ -135,6 +135,13 @@ extern char *target_alias;
extern
enum
target_cpu
target_cpu
;
extern
enum
target_cpu
target_cpu
;
extern
enum
target_platform
target_platform
;
extern
enum
target_platform
target_platform
;
struct
strarray
{
const
char
**
str
;
unsigned
int
count
;
unsigned
int
max
;
};
/* entry point flags */
/* entry point flags */
#define FLAG_NORELAY 0x01
/* don't use relay debugging for this function */
#define FLAG_NORELAY 0x01
/* don't use relay debugging for this function */
#define FLAG_NONAME 0x02
/* don't export function by name */
#define FLAG_NONAME 0x02
/* don't export function by name */
...
@@ -200,6 +207,10 @@ extern char *xstrdup( const char *str );
...
@@ -200,6 +207,10 @@ 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
void
strarray_add
(
struct
strarray
*
array
,
...
);
extern
void
strarray_addv
(
struct
strarray
*
array
,
char
*
const
*
argv
);
extern
void
strarray_free
(
struct
strarray
*
array
);
extern
DECLSPEC_NORETURN
void
fatal_error
(
const
char
*
msg
,
...
)
extern
DECLSPEC_NORETURN
void
fatal_error
(
const
char
*
msg
,
...
)
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
extern
DECLSPEC_NORETURN
void
fatal_perror
(
const
char
*
msg
,
...
)
extern
DECLSPEC_NORETURN
void
fatal_perror
(
const
char
*
msg
,
...
)
...
@@ -212,9 +223,10 @@ extern int output( const char *format, ... )
...
@@ -212,9 +223,10 @@ extern int output( const char *format, ... )
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
__attribute__
((
__format__
(
__printf__
,
1
,
2
)));
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
char
*
find_tool
(
const
char
*
name
,
const
char
*
const
*
names
);
extern
char
*
find_tool
(
const
char
*
name
,
const
char
*
const
*
names
);
extern
const
char
*
get_as_command
(
void
);
extern
struct
strarray
*
get_as_command
(
void
);
extern
const
char
*
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
);
extern
char
*
get_temp_file_name
(
const
char
*
prefix
,
const
char
*
suffix
);
extern
char
*
get_temp_file_name
(
const
char
*
prefix
,
const
char
*
suffix
);
extern
void
output_standard_file_header
(
void
);
extern
void
output_standard_file_header
(
void
);
...
...
tools/winebuild/import.c
View file @
b03059cb
...
@@ -524,23 +524,16 @@ static char *create_undef_symbols_file( DLLSPEC *spec )
...
@@ -524,23 +524,16 @@ static char *create_undef_symbols_file( DLLSPEC *spec )
/* returns the name of the combined file */
/* returns the name of the combined file */
static
const
char
*
ldcombine_files
(
DLLSPEC
*
spec
,
char
**
argv
)
static
const
char
*
ldcombine_files
(
DLLSPEC
*
spec
,
char
**
argv
)
{
{
unsigned
int
i
,
len
=
0
;
char
*
ld_tmp_file
,
*
undef_file
;
const
char
*
prog
=
get_ld_command
();
struct
strarray
*
args
=
get_ld_command
();
char
*
cmd
,
*
p
,
*
ld_tmp_file
,
*
undef_file
;
int
err
;
undef_file
=
create_undef_symbols_file
(
spec
);
undef_file
=
create_undef_symbols_file
(
spec
);
len
+=
strlen
(
undef_file
)
+
1
;
ld_tmp_file
=
get_temp_file_name
(
output_file_name
,
".o"
);
ld_tmp_file
=
get_temp_file_name
(
output_file_name
,
".o"
);
for
(
i
=
0
;
argv
[
i
];
i
++
)
len
+=
strlen
(
argv
[
i
])
+
1
;
cmd
=
p
=
xmalloc
(
len
+
strlen
(
ld_tmp_file
)
+
8
+
strlen
(
prog
)
);
strarray_add
(
args
,
"-r"
,
"-o"
,
ld_tmp_file
,
undef_file
,
NULL
);
p
+=
sprintf
(
cmd
,
"%s -r -o %s %s"
,
prog
,
ld_tmp_file
,
undef_file
);
strarray_addv
(
args
,
argv
);
for
(
i
=
0
;
argv
[
i
];
i
++
)
spawn
(
args
);
p
+=
sprintf
(
p
,
" %s"
,
argv
[
i
]
);
strarray_free
(
args
);
if
(
verbose
)
fprintf
(
stderr
,
"%s
\n
"
,
cmd
);
err
=
system
(
cmd
);
if
(
err
)
fatal_error
(
"%s -r failed with status %d
\n
"
,
prog
,
err
);
free
(
cmd
);
return
ld_tmp_file
;
return
ld_tmp_file
;
}
}
...
@@ -1318,9 +1311,8 @@ void output_imports( DLLSPEC *spec )
...
@@ -1318,9 +1311,8 @@ 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
)
{
{
char
*
dlltool
,
*
def_file
;
struct
strarray
*
args
=
strarray_init
();
char
*
cmd
;
char
*
def_file
;
int
err
;
if
(
target_platform
!=
PLATFORM_WINDOWS
)
if
(
target_platform
!=
PLATFORM_WINDOWS
)
fatal_error
(
"Unix-style import libraries not supported yet
\n
"
);
fatal_error
(
"Unix-style import libraries not supported yet
\n
"
);
...
@@ -1333,33 +1325,17 @@ void output_import_lib( DLLSPEC *spec, char **argv )
...
@@ -1333,33 +1325,17 @@ void output_import_lib( DLLSPEC *spec, char **argv )
fclose
(
output_file
);
fclose
(
output_file
);
output_file
=
NULL
;
output_file
=
NULL
;
dlltool
=
find_tool
(
"dlltool"
,
NULL
);
strarray_add
(
args
,
find_tool
(
"dlltool"
,
NULL
),
"-k"
,
"-l"
,
output_file_name
,
"-d"
,
def_file
,
NULL
);
cmd
=
xmalloc
(
strlen
(
dlltool
)
+
strlen
(
output_file_name
)
+
strlen
(
def_file
)
+
12
);
spawn
(
args
);
sprintf
(
cmd
,
"%s -k -l %s -d %s"
,
dlltool
,
output_file_name
,
def_file
);
strarray_free
(
args
);
if
(
verbose
)
fprintf
(
stderr
,
"%s
\n
"
,
cmd
);
err
=
system
(
cmd
);
if
(
err
)
fatal_error
(
"%s failed with status %d
\n
"
,
dlltool
,
err
);
free
(
cmd
);
free
(
dlltool
);
if
(
argv
[
0
])
if
(
argv
[
0
])
{
{
char
*
ar
=
find_tool
(
"ar"
,
NULL
);
args
=
strarray_init
();
int
i
,
len
;
strarray_add
(
args
,
find_tool
(
"ar"
,
NULL
),
"rs"
,
output_file_name
,
NULL
);
strarray_addv
(
args
,
argv
);
for
(
i
=
len
=
0
;
argv
[
i
];
i
++
)
len
+=
strlen
(
argv
[
i
])
+
1
;
spawn
(
args
);
cmd
=
xmalloc
(
strlen
(
ar
)
+
strlen
(
output_file_name
)
+
len
+
5
);
strarray_free
(
args
);
sprintf
(
cmd
,
"%s rs %s"
,
ar
,
output_file_name
);
for
(
i
=
0
;
argv
[
i
];
i
++
)
{
strcat
(
cmd
,
" "
);
strcat
(
cmd
,
argv
[
i
]
);
}
if
(
verbose
)
fprintf
(
stderr
,
"%s
\n
"
,
cmd
);
err
=
system
(
cmd
);
if
(
err
)
fatal_error
(
"%s failed with status %d
\n
"
,
dlltool
,
err
);
free
(
cmd
);
free
(
ar
);
}
}
output_file_name
=
NULL
;
output_file_name
=
NULL
;
}
}
tools/winebuild/res32.c
View file @
b03059cb
...
@@ -601,7 +601,7 @@ void output_res_o_file( DLLSPEC *spec )
...
@@ -601,7 +601,7 @@ void output_res_o_file( DLLSPEC *spec )
{
{
unsigned
int
i
;
unsigned
int
i
;
char
*
res_file
=
NULL
;
char
*
res_file
=
NULL
;
int
fd
,
err
;
int
fd
;
if
(
!
spec
->
nb_resources
)
fatal_error
(
"--resources mode needs at least one resource file as input
\n
"
);
if
(
!
spec
->
nb_resources
)
fatal_error
(
"--resources mode needs at least one resource file as input
\n
"
);
if
(
!
output_file_name
)
fatal_error
(
"No output file name specified
\n
"
);
if
(
!
output_file_name
)
fatal_error
(
"No output file name specified
\n
"
);
...
@@ -656,14 +656,10 @@ void output_res_o_file( DLLSPEC *spec )
...
@@ -656,14 +656,10 @@ void output_res_o_file( DLLSPEC *spec )
if
(
res_file
)
if
(
res_file
)
{
{
char
*
prog
=
find_tool
(
"windres"
,
NULL
);
struct
strarray
*
args
=
strarray_init
();
char
*
cmd
=
xmalloc
(
strlen
(
prog
)
+
strlen
(
res_file
)
+
strlen
(
output_file_name
)
+
9
);
strarray_add
(
args
,
find_tool
(
"windres"
,
NULL
),
"-i"
,
res_file
,
"-o"
,
output_file_name
,
NULL
);
sprintf
(
cmd
,
"%s -i %s -o %s"
,
prog
,
res_file
,
output_file_name
);
spawn
(
args
);
if
(
verbose
)
fprintf
(
stderr
,
"%s
\n
"
,
cmd
);
strarray_free
(
args
);
err
=
system
(
cmd
);
if
(
err
)
fatal_error
(
"%s failed with status %d
\n
"
,
prog
,
err
);
free
(
cmd
);
free
(
prog
);
}
}
output_file_name
=
NULL
;
/* so we don't try to assemble it */
output_file_name
=
NULL
;
/* so we don't try to assemble it */
}
}
tools/winebuild/utils.c
View file @
b03059cb
...
@@ -138,6 +138,46 @@ char *strmake( const char* fmt, ... )
...
@@ -138,6 +138,46 @@ char *strmake( const char* fmt, ... )
}
}
}
}
struct
strarray
*
strarray_init
(
void
)
{
struct
strarray
*
array
=
xmalloc
(
sizeof
(
*
array
)
);
array
->
count
=
0
;
array
->
max
=
16
;
array
->
str
=
xmalloc
(
array
->
max
*
sizeof
(
*
array
->
str
)
);
return
array
;
}
static
void
strarray_add_one
(
struct
strarray
*
array
,
const
char
*
str
)
{
if
(
array
->
count
==
array
->
max
)
{
array
->
max
*=
2
;
array
->
str
=
xrealloc
(
array
->
str
,
array
->
max
*
sizeof
(
*
array
->
str
)
);
}
array
->
str
[
array
->
count
++
]
=
str
;
}
void
strarray_add
(
struct
strarray
*
array
,
...
)
{
va_list
valist
;
const
char
*
str
;
va_start
(
valist
,
array
);
while
((
str
=
va_arg
(
valist
,
const
char
*
)))
strarray_add_one
(
array
,
str
);
va_end
(
valist
);
}
void
strarray_addv
(
struct
strarray
*
array
,
char
*
const
*
argv
)
{
while
(
*
argv
)
strarray_add_one
(
array
,
*
argv
++
);
}
void
strarray_free
(
struct
strarray
*
array
)
{
free
(
array
->
str
);
free
(
array
);
}
void
fatal_error
(
const
char
*
msg
,
...
)
void
fatal_error
(
const
char
*
msg
,
...
)
{
{
va_list
valist
;
va_list
valist
;
...
@@ -218,6 +258,24 @@ int output( const char *format, ... )
...
@@ -218,6 +258,24 @@ int output( const char *format, ... )
return
ret
;
return
ret
;
}
}
void
spawn
(
struct
strarray
*
args
)
{
unsigned
int
i
;
int
status
;
strarray_add_one
(
args
,
NULL
);
if
(
verbose
)
for
(
i
=
0
;
args
->
str
[
i
];
i
++
)
fprintf
(
stderr
,
"%s%c"
,
args
->
str
[
i
],
args
->
str
[
i
+
1
]
?
' '
:
'\n'
);
if
((
status
=
spawnvp
(
_P_WAIT
,
args
->
str
[
0
],
args
->
str
)))
{
if
(
status
>
0
)
fatal_error
(
"%s failed with status %u
\n
"
,
args
->
str
[
0
],
status
);
else
fatal_perror
(
"winebuild"
);
exit
(
1
);
}
}
/* 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
)
char
*
find_tool
(
const
char
*
name
,
const
char
*
const
*
names
)
{
{
...
@@ -282,53 +340,59 @@ char *find_tool( const char *name, const char * const *names )
...
@@ -282,53 +340,59 @@ char *find_tool( const char *name, const char * const *names )
return
xstrdup
(
name
);
return
xstrdup
(
name
);
}
}
const
char
*
get_as_command
(
void
)
struct
strarray
*
get_as_command
(
void
)
{
{
struct
strarray
*
args
=
strarray_init
();
if
(
!
as_command
)
if
(
!
as_command
)
{
{
static
const
char
*
const
commands
[]
=
{
"gas"
,
"as"
,
NULL
};
static
const
char
*
const
commands
[]
=
{
"gas"
,
"as"
,
NULL
};
as_command
=
find_tool
(
"as"
,
commands
);
as_command
=
find_tool
(
"as"
,
commands
);
}
strarray_add_one
(
args
,
as_command
);
if
(
force_pointer_size
)
if
(
force_pointer_size
)
{
{
const
char
*
args
=
(
target_platform
==
PLATFORM_APPLE
)
?
switch
(
target_platform
)
((
force_pointer_size
==
8
)
?
" -arch x86_64"
:
" -arch i386"
)
:
{
((
force_pointer_size
==
8
)
?
" --64"
:
" --32"
);
case
PLATFORM_APPLE
:
as_command
=
xrealloc
(
as_command
,
strlen
(
as_command
)
+
strlen
(
args
)
+
1
);
strarray_add
(
args
,
"-arch"
,
(
force_pointer_size
==
8
)
?
"x86_64"
:
"i386"
,
NULL
);
strcat
(
as_command
,
args
);
break
;
default:
strarray_add_one
(
args
,
(
force_pointer_size
==
8
)
?
"--64"
:
"--32"
);
break
;
}
}
}
}
return
a
s_command
;
return
a
rgs
;
}
}
const
char
*
get_ld_command
(
void
)
struct
strarray
*
get_ld_command
(
void
)
{
{
struct
strarray
*
args
=
strarray_init
();
if
(
!
ld_command
)
if
(
!
ld_command
)
{
{
static
const
char
*
const
commands
[]
=
{
"ld"
,
"gld"
,
NULL
};
static
const
char
*
const
commands
[]
=
{
"ld"
,
"gld"
,
NULL
};
ld_command
=
find_tool
(
"ld"
,
commands
);
ld_command
=
find_tool
(
"ld"
,
commands
);
}
strarray_add_one
(
args
,
ld_command
);
if
(
force_pointer_size
)
if
(
force_pointer_size
)
{
{
const
char
*
args
;
switch
(
target_platform
)
switch
(
target_platform
)
{
{
case
PLATFORM_APPLE
:
case
PLATFORM_APPLE
:
args
=
(
force_pointer_size
==
8
)
?
" -arch x86_64"
:
" -arch i386"
;
strarray_add
(
args
,
"-arch"
,
(
force_pointer_size
==
8
)
?
"x86_64"
:
"i386"
,
NULL
)
;
break
;
break
;
case
PLATFORM_FREEBSD
:
case
PLATFORM_FREEBSD
:
args
=
(
force_pointer_size
==
8
)
?
" -m elf_x86_64_fbsd"
:
" -m elf_i386_fbsd"
;
strarray_add
(
args
,
"-m"
,
(
force_pointer_size
==
8
)
?
"elf_x86_64_fbsd"
:
"elf_i386_fbsd"
,
NULL
)
;
break
;
break
;
default:
default:
args
=
(
force_pointer_size
==
8
)
?
" -m elf_x86_64"
:
" -m elf_i386"
;
strarray_add
(
args
,
"-m"
,
(
force_pointer_size
==
8
)
?
"elf_x86_64"
:
"elf_i386"
,
NULL
)
;
break
;
break
;
}
}
ld_command
=
xrealloc
(
ld_command
,
strlen
(
ld_command
)
+
strlen
(
args
)
+
1
);
strcat
(
ld_command
,
args
);
}
}
}
return
args
;
return
ld_command
;
}
}
const
char
*
get_nm_command
(
void
)
const
char
*
get_nm_command
(
void
)
...
@@ -614,16 +678,10 @@ int remove_stdcall_decoration( char *name )
...
@@ -614,16 +678,10 @@ int remove_stdcall_decoration( char *name )
*/
*/
void
assemble_file
(
const
char
*
src_file
,
const
char
*
obj_file
)
void
assemble_file
(
const
char
*
src_file
,
const
char
*
obj_file
)
{
{
const
char
*
prog
=
get_as_command
();
struct
strarray
*
args
=
get_as_command
();
char
*
cmd
;
strarray_add
(
args
,
"-o"
,
obj_file
,
src_file
,
NULL
);
int
err
;
spawn
(
args
);
strarray_free
(
args
);
cmd
=
xmalloc
(
strlen
(
prog
)
+
strlen
(
obj_file
)
+
strlen
(
src_file
)
+
6
);
sprintf
(
cmd
,
"%s -o %s %s"
,
prog
,
obj_file
,
src_file
);
if
(
verbose
)
fprintf
(
stderr
,
"%s
\n
"
,
cmd
);
err
=
system
(
cmd
);
if
(
err
)
fatal_error
(
"%s failed with status %d
\n
"
,
prog
,
err
);
free
(
cmd
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment