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
c878a0a4
Commit
c878a0a4
authored
Sep 23, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winebuild: Use strarrays for the argument lists.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d6d5a217
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
52 deletions
+59
-52
build.h
tools/winebuild/build.h
+4
-4
import.c
tools/winebuild/import.c
+10
-10
main.c
tools/winebuild/main.c
+33
-28
spec32.c
tools/winebuild/spec32.c
+12
-10
No files found.
tools/winebuild/build.h
View file @
c878a0a4
...
...
@@ -313,7 +313,7 @@ extern void add_import_dll( const char *name, const char *filename );
extern
void
add_delayed_import
(
const
char
*
name
);
extern
void
add_extra_ld_symbol
(
const
char
*
name
);
extern
void
add_spec_extra_ld_symbol
(
const
char
*
name
);
extern
void
read_undef_symbols
(
DLLSPEC
*
spec
,
char
**
argv
);
extern
void
read_undef_symbols
(
DLLSPEC
*
spec
,
struct
strarray
files
);
extern
void
resolve_imports
(
DLLSPEC
*
spec
);
extern
int
is_undefined
(
const
char
*
name
);
extern
int
has_imports
(
void
);
...
...
@@ -322,7 +322,7 @@ extern void output_module( DLLSPEC *spec );
extern
void
output_stubs
(
DLLSPEC
*
spec
);
extern
void
output_syscalls
(
DLLSPEC
*
spec
);
extern
void
output_imports
(
DLLSPEC
*
spec
);
extern
void
output_static_lib
(
DLLSPEC
*
spec
,
char
**
argv
);
extern
void
output_static_lib
(
DLLSPEC
*
spec
,
struct
strarray
files
);
extern
void
output_exports
(
DLLSPEC
*
spec
);
extern
int
load_res32_file
(
const
char
*
name
,
DLLSPEC
*
spec
);
extern
void
output_resources
(
DLLSPEC
*
spec
);
...
...
@@ -339,8 +339,8 @@ extern void output_spec16_file( DLLSPEC *spec );
extern
void
output_fake_module16
(
DLLSPEC
*
spec16
);
extern
void
output_res_o_file
(
DLLSPEC
*
spec
);
extern
void
output_asm_relays16
(
void
);
extern
void
make_builtin_files
(
char
*
argv
[]
);
extern
void
fixup_constructors
(
char
*
argv
[]
);
extern
void
make_builtin_files
(
struct
strarray
files
);
extern
void
fixup_constructors
(
struct
strarray
files
);
extern
void
add_16bit_exports
(
DLLSPEC
*
spec32
,
DLLSPEC
*
spec16
);
extern
int
parse_spec_file
(
FILE
*
file
,
DLLSPEC
*
spec
);
...
...
tools/winebuild/import.c
View file @
c878a0a4
...
...
@@ -600,7 +600,7 @@ static char *create_undef_symbols_file( DLLSPEC *spec )
/* combine a list of object files with ld into a single object file */
/* returns the name of the combined file */
static
const
char
*
ldcombine_files
(
DLLSPEC
*
spec
,
char
**
argv
)
static
const
char
*
ldcombine_files
(
DLLSPEC
*
spec
,
struct
strarray
files
)
{
char
*
ld_tmp_file
,
*
undef_file
;
struct
strarray
args
=
get_ld_command
();
...
...
@@ -612,13 +612,13 @@ static const char *ldcombine_files( DLLSPEC *spec, char **argv )
strarray_add
(
&
args
,
"-o"
);
strarray_add
(
&
args
,
ld_tmp_file
);
if
(
undef_file
)
strarray_add
(
&
args
,
undef_file
);
while
(
*
argv
)
strarray_add
(
&
args
,
*
argv
++
);
strarray_addall
(
&
args
,
files
);
spawn
(
args
);
return
ld_tmp_file
;
}
/* read in the list of undefined symbols */
void
read_undef_symbols
(
DLLSPEC
*
spec
,
char
**
argv
)
void
read_undef_symbols
(
DLLSPEC
*
spec
,
struct
strarray
files
)
{
size_t
prefix_len
;
FILE
*
f
;
...
...
@@ -627,14 +627,14 @@ void read_undef_symbols( DLLSPEC *spec, char **argv )
int
err
;
const
char
*
name
;
if
(
!
argv
[
0
]
)
return
;
if
(
!
files
.
count
)
return
;
add_extra_undef_symbols
(
spec
);
strcpy
(
name_prefix
,
asm_name
(
""
)
);
prefix_len
=
strlen
(
name_prefix
);
name
=
ldcombine_files
(
spec
,
argv
);
name
=
ldcombine_files
(
spec
,
files
);
cmd
=
strmake
(
"%s -u %s"
,
prog
,
name
);
if
(
verbose
)
...
...
@@ -1604,7 +1604,7 @@ static void assemble_files( const char *prefix )
}
/* build a library from the current asm files and any additional object files in argv */
static
void
build_library
(
const
char
*
output_name
,
char
**
argv
,
int
create
)
static
void
build_library
(
const
char
*
output_name
,
struct
strarray
files
,
int
create
)
{
struct
strarray
args
;
...
...
@@ -1621,7 +1621,7 @@ static void build_library( const char *output_name, char **argv, int create )
strarray_add
(
&
args
,
strmake
(
"-out:%s"
,
output_name
));
}
strarray_addall
(
&
args
,
as_files
);
while
(
*
argv
)
strarray_add
(
&
args
,
*
argv
++
);
strarray_addall
(
&
args
,
files
);
if
(
create
)
unlink
(
output_name
);
spawn
(
args
);
...
...
@@ -1739,16 +1739,16 @@ static void build_unix_import_lib( DLLSPEC *spec )
}
/* output an import library for a Win32 module and additional object files */
void
output_static_lib
(
DLLSPEC
*
spec
,
char
**
argv
)
void
output_static_lib
(
DLLSPEC
*
spec
,
struct
strarray
files
)
{
if
(
is_pe
())
{
if
(
spec
)
build_windows_import_lib
(
output_file_name
,
spec
);
if
(
argv
[
0
]
||
!
spec
)
build_library
(
output_file_name
,
argv
,
!
spec
);
if
(
files
.
count
||
!
spec
)
build_library
(
output_file_name
,
files
,
!
spec
);
}
else
{
if
(
spec
)
build_unix_import_lib
(
spec
);
build_library
(
output_file_name
,
argv
,
1
);
build_library
(
output_file_name
,
files
,
1
);
}
}
tools/winebuild/main.c
View file @
c878a0a4
...
...
@@ -87,6 +87,7 @@ FILE *output_file = NULL;
const
char
*
output_file_name
=
NULL
;
static
int
fake_module
;
static
const
struct
strarray
empty_strarray
;
struct
strarray
lib_path
=
{
0
};
struct
strarray
tools_path
=
{
0
};
struct
strarray
as_command
=
{
0
};
...
...
@@ -442,11 +443,12 @@ static const char *get_default_entry_point( const DLLSPEC *spec )
}
/* parse options from the argv array and remove all the recognized ones */
static
char
**
parse_options
(
int
argc
,
char
**
argv
,
DLLSPEC
*
spec
)
static
struct
strarray
parse_options
(
int
argc
,
char
**
argv
,
DLLSPEC
*
spec
)
{
char
*
p
;
int
optc
;
int
save_temps
=
0
;
struct
strarray
files
=
empty_strarray
;
while
((
optc
=
getopt_long
(
argc
,
argv
,
short_options
,
long_options
,
NULL
))
!=
-
1
)
{
...
...
@@ -639,21 +641,22 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec )
break
;
}
return
&
argv
[
optind
];
while
(
argv
[
optind
])
strarray_add
(
&
files
,
argv
[
optind
++
]
);
return
files
;
}
/* load all specified resource files */
static
void
load_resources
(
char
*
argv
[]
,
DLLSPEC
*
spec
)
static
struct
strarray
load_resources
(
struct
strarray
files
,
DLLSPEC
*
spec
)
{
struct
strarray
ret
=
empty_strarray
;
int
i
;
char
**
ptr
,
**
last
;
switch
(
spec
->
type
)
{
case
SPEC_WIN16
:
for
(
i
=
0
;
i
<
res_files
.
count
;
i
++
)
load_res16_file
(
res_files
.
str
[
i
],
spec
);
break
;
return
files
;
case
SPEC_WIN32
:
for
(
i
=
0
;
i
<
res_files
.
count
;
i
++
)
...
...
@@ -663,29 +666,30 @@ static void load_resources( char *argv[], DLLSPEC *spec )
}
/* load any resource file found in the remaining arguments */
for
(
ptr
=
last
=
argv
;
*
ptr
;
ptr
++
)
for
(
i
=
0
;
i
<
files
.
count
;
i
++
)
{
if
(
!
load_res32_file
(
*
ptr
,
spec
))
*
last
++
=
*
ptr
;
/* not a resource file, keep it in the list */
if
(
!
load_res32_file
(
files
.
str
[
i
]
,
spec
))
strarray_add
(
&
ret
,
files
.
str
[
i
]
)
;
/* not a resource file, keep it in the list */
}
*
last
=
NULL
;
break
;
}
return
ret
;
}
/* add input files that look like import libs to the import list */
static
void
load_import_libs
(
char
*
argv
[]
)
static
struct
strarray
load_import_libs
(
struct
strarray
files
)
{
char
**
ptr
,
**
last
;
struct
strarray
ret
=
empty_strarray
;
int
i
;
for
(
ptr
=
last
=
argv
;
*
ptr
;
ptr
++
)
for
(
i
=
0
;
i
<
files
.
count
;
i
++
)
{
if
(
strendswith
(
*
ptr
,
".def"
))
add_import_dll
(
NULL
,
*
ptr
);
if
(
strendswith
(
files
.
str
[
i
]
,
".def"
))
add_import_dll
(
NULL
,
files
.
str
[
i
]
);
else
*
last
++
=
*
ptr
;
/* not an import dll, keep it in the list */
strarray_add
(
&
ret
,
files
.
str
[
i
]
)
;
/* not an import dll, keep it in the list */
}
*
last
=
NULL
;
return
ret
;
}
static
int
parse_input_file
(
DLLSPEC
*
spec
)
...
...
@@ -710,6 +714,7 @@ static int parse_input_file( DLLSPEC *spec )
int
main
(
int
argc
,
char
**
argv
)
{
DLLSPEC
*
spec
=
alloc_dll_spec
();
struct
strarray
files
;
#ifdef SIGHUP
signal
(
SIGHUP
,
exit_on_signal
);
...
...
@@ -717,7 +722,7 @@ int main(int argc, char **argv)
signal
(
SIGTERM
,
exit_on_signal
);
signal
(
SIGINT
,
exit_on_signal
);
argv
=
parse_options
(
argc
,
argv
,
spec
);
files
=
parse_options
(
argc
,
argv
,
spec
);
atexit
(
cleanup
);
/* make sure we remove the output file on exit */
switch
(
exec_mode
)
...
...
@@ -727,7 +732,7 @@ int main(int argc, char **argv)
spec
->
characteristics
|=
IMAGE_FILE_DLL
;
/* fall through */
case
MODE_EXE
:
load_resources
(
argv
,
spec
);
files
=
load_resources
(
files
,
spec
);
if
(
spec_file_name
&&
!
parse_input_file
(
spec
))
break
;
if
(
!
spec
->
init_func
&&
!
unix_lib
)
spec
->
init_func
=
xstrdup
(
get_default_entry_point
(
spec
));
...
...
@@ -739,15 +744,15 @@ int main(int argc, char **argv)
}
if
(
!
is_pe
())
{
load_import_libs
(
argv
);
read_undef_symbols
(
spec
,
argv
);
files
=
load_import_libs
(
files
);
read_undef_symbols
(
spec
,
files
);
resolve_imports
(
spec
);
}
if
(
spec
->
type
==
SPEC_WIN16
)
output_spec16_file
(
spec
);
else
output_spec32_file
(
spec
);
break
;
case
MODE_DEF
:
if
(
argv
[
0
])
fatal_error
(
"file argument '%s' not allowed in this mode
\n
"
,
argv
[
0
]
);
if
(
files
.
count
)
fatal_error
(
"file argument '%s' not allowed in this mode
\n
"
,
files
.
str
[
0
]
);
if
(
!
spec_file_name
)
fatal_error
(
"missing .spec file
\n
"
);
if
(
!
parse_input_file
(
spec
))
break
;
open_output_file
();
...
...
@@ -757,21 +762,21 @@ int main(int argc, char **argv)
case
MODE_IMPLIB
:
if
(
!
spec_file_name
)
fatal_error
(
"missing .spec file
\n
"
);
if
(
!
parse_input_file
(
spec
))
break
;
output_static_lib
(
spec
,
argv
);
output_static_lib
(
spec
,
files
);
break
;
case
MODE_STATICLIB
:
output_static_lib
(
NULL
,
argv
);
output_static_lib
(
NULL
,
files
);
break
;
case
MODE_BUILTIN
:
if
(
!
argv
[
0
]
)
fatal_error
(
"missing file argument for --builtin option
\n
"
);
make_builtin_files
(
argv
);
if
(
!
files
.
count
)
fatal_error
(
"missing file argument for --builtin option
\n
"
);
make_builtin_files
(
files
);
break
;
case
MODE_FIXUP_CTORS
:
if
(
!
argv
[
0
]
)
fatal_error
(
"missing file argument for --fixup-ctors option
\n
"
);
fixup_constructors
(
argv
);
if
(
!
files
.
count
)
fatal_error
(
"missing file argument for --fixup-ctors option
\n
"
);
fixup_constructors
(
files
);
break
;
case
MODE_RESOURCES
:
load_resources
(
argv
,
spec
);
files
=
load_resources
(
files
,
spec
);
output_res_o_file
(
spec
);
break
;
default:
...
...
tools/winebuild/spec32.c
View file @
c878a0a4
...
...
@@ -1061,7 +1061,7 @@ void output_def_file( DLLSPEC *spec, int import_only )
/*******************************************************************
* make_builtin_files
*/
void
make_builtin_files
(
char
*
argv
[]
)
void
make_builtin_files
(
struct
strarray
files
)
{
int
i
,
fd
;
struct
...
...
@@ -1071,13 +1071,14 @@ void make_builtin_files( char *argv[] )
unsigned
int
e_lfanew
;
}
header
;
for
(
i
=
0
;
argv
[
i
]
;
i
++
)
for
(
i
=
0
;
i
<
files
.
count
;
i
++
)
{
if
((
fd
=
open
(
argv
[
i
],
O_RDWR
|
O_BINARY
))
==
-
1
)
fatal_perror
(
"Cannot open %s"
,
argv
[
i
]
);
if
((
fd
=
open
(
files
.
str
[
i
],
O_RDWR
|
O_BINARY
))
==
-
1
)
fatal_perror
(
"Cannot open %s"
,
files
.
str
[
i
]
);
if
(
read
(
fd
,
&
header
,
sizeof
(
header
)
)
==
sizeof
(
header
)
&&
!
memcmp
(
&
header
.
e_magic
,
"MZ"
,
2
))
{
if
(
header
.
e_lfanew
<
sizeof
(
header
)
+
sizeof
(
builtin_signature
))
fatal_error
(
"%s: Not enough space (%x) for Wine signature
\n
"
,
argv
[
i
],
header
.
e_lfanew
);
fatal_error
(
"%s: Not enough space (%x) for Wine signature
\n
"
,
files
.
str
[
i
],
header
.
e_lfanew
);
write
(
fd
,
builtin_signature
,
sizeof
(
builtin_signature
)
);
if
(
prefer_native
)
...
...
@@ -1093,7 +1094,7 @@ void make_builtin_files( char *argv[] )
}
}
}
else
fatal_error
(
"%s: Unrecognized file format
\n
"
,
argv
[
i
]
);
else
fatal_error
(
"%s: Unrecognized file format
\n
"
,
files
.
str
[
i
]
);
close
(
fd
);
}
}
...
...
@@ -1239,19 +1240,20 @@ static void fixup_elf64( const char *name, int fd, void *header, size_t header_s
/*******************************************************************
* fixup_constructors
*/
void
fixup_constructors
(
char
*
argv
[]
)
void
fixup_constructors
(
struct
strarray
files
)
{
int
i
,
fd
,
size
;
unsigned
int
header
[
64
];
for
(
i
=
0
;
argv
[
i
]
;
i
++
)
for
(
i
=
0
;
i
<
files
.
count
;
i
++
)
{
if
((
fd
=
open
(
argv
[
i
],
O_RDWR
|
O_BINARY
))
==
-
1
)
fatal_perror
(
"Cannot open %s"
,
argv
[
i
]
);
if
((
fd
=
open
(
files
.
str
[
i
],
O_RDWR
|
O_BINARY
))
==
-
1
)
fatal_perror
(
"Cannot open %s"
,
files
.
str
[
i
]
);
size
=
read
(
fd
,
&
header
,
sizeof
(
header
)
);
if
(
size
>
5
)
{
if
(
!
memcmp
(
header
,
"
\177
ELF
\001
"
,
5
))
fixup_elf32
(
argv
[
i
],
fd
,
header
,
size
);
else
if
(
!
memcmp
(
header
,
"
\177
ELF
\002
"
,
5
))
fixup_elf64
(
argv
[
i
],
fd
,
header
,
size
);
if
(
!
memcmp
(
header
,
"
\177
ELF
\001
"
,
5
))
fixup_elf32
(
files
.
str
[
i
],
fd
,
header
,
size
);
else
if
(
!
memcmp
(
header
,
"
\177
ELF
\002
"
,
5
))
fixup_elf64
(
files
.
str
[
i
],
fd
,
header
,
size
);
}
close
(
fd
);
}
...
...
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