Skip to content

Commit a95140c

Browse files
committed
meson: Use build_subdir when available
Meson 1.10.0 supports a build_subdir parameter to replace the kludge of pasting a directory name and target name together, which meson has never officially supported. Signed-off-by: Keith Packard <[email protected]>
1 parent cf4177a commit a95140c

File tree

3 files changed

+110
-48
lines changed

3 files changed

+110
-48
lines changed

newlib/meson.build

Lines changed: 68 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ foreach params : targets
4747
target = params['name']
4848
target_dir = params['dir']
4949
target_c_args = params['c_args']
50-
target_lib_prefix = params['lib_prefix']
5150

5251
libobjs = []
5352
libsrcs_target = libsrcs
@@ -66,36 +65,75 @@ foreach params : targets
6665
libm_name = 'm'
6766
libnosys_name = 'nosys'
6867

69-
local_lib_c_target = static_library(join_paths(target_dir, target_lib_prefix + libc_name),
70-
libsrcs_target,
71-
install : really_install,
72-
install_dir : instdir,
73-
pic: false,
74-
objects : libobjs,
75-
include_directories: inc,
76-
c_args: target_c_args + c_args)
68+
if meson.version().version_compare('>=1.10')
69+
local_lib_c_target = static_library(libc_name,
70+
libsrcs_target,
71+
build_subdir : target_dir,
72+
install : really_install,
73+
install_dir : instdir,
74+
pic: false,
75+
objects : libobjs,
76+
include_directories: inc,
77+
c_args: target_c_args + c_args)
7778

78-
static_library(join_paths(target_dir, target_lib_prefix + libm_name),
79-
['empty.c'],
80-
install : really_install,
81-
install_dir : instdir,
82-
pic: false,
83-
c_args: target_c_args + c_args,
84-
objects : [])
85-
static_library(join_paths(target_dir, target_lib_prefix + libg_name),
86-
['empty.c'],
87-
install : really_install,
88-
install_dir : instdir,
89-
pic: false,
90-
c_args: target_c_args + c_args,
91-
objects : [])
92-
static_library(join_paths(target_dir, target_lib_prefix + libnosys_name),
93-
['empty.c'],
94-
install : really_install,
95-
install_dir : instdir,
96-
pic: false,
97-
c_args: target_c_args + c_args,
98-
objects : [])
79+
static_library(libm_name,
80+
['empty.c'],
81+
build_subdir : target_dir,
82+
install : really_install,
83+
install_dir : instdir,
84+
pic: false,
85+
c_args: target_c_args + c_args,
86+
objects : [])
87+
static_library(libg_name,
88+
['empty.c'],
89+
build_subdir : target_dir,
90+
install : really_install,
91+
install_dir : instdir,
92+
pic: false,
93+
c_args: target_c_args + c_args,
94+
objects : [])
95+
static_library(libnosys_name,
96+
['empty.c'],
97+
build_subdir : target_dir,
98+
install : really_install,
99+
install_dir : instdir,
100+
pic: false,
101+
c_args: target_c_args + c_args,
102+
objects : [])
103+
else
104+
target_lib_prefix = params['lib_prefix']
105+
106+
local_lib_c_target = static_library(join_paths(target_dir, target_lib_prefix + libc_name),
107+
libsrcs_target,
108+
install : really_install,
109+
install_dir : instdir,
110+
pic: false,
111+
objects : libobjs,
112+
include_directories: inc,
113+
c_args: target_c_args + c_args)
114+
115+
static_library(join_paths(target_dir, target_lib_prefix + libm_name),
116+
['empty.c'],
117+
install : really_install,
118+
install_dir : instdir,
119+
pic: false,
120+
c_args: target_c_args + c_args,
121+
objects : [])
122+
static_library(join_paths(target_dir, target_lib_prefix + libg_name),
123+
['empty.c'],
124+
install : really_install,
125+
install_dir : instdir,
126+
pic: false,
127+
c_args: target_c_args + c_args,
128+
objects : [])
129+
static_library(join_paths(target_dir, target_lib_prefix + libnosys_name),
130+
['empty.c'],
131+
install : really_install,
132+
install_dir : instdir,
133+
pic: false,
134+
c_args: target_c_args + c_args,
135+
objects : [])
136+
endif
99137

100138
set_variable('lib_c' + target, local_lib_c_target)
101139

picocrt/meson.build

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ foreach params : targets
112112
target = params['name']
113113
target_dir = params['dir']
114114
target_c_args = params['c_args'] + stack_c_args
115-
target_lib_prefix = params['lib_prefix']
116115

117116
instdir = join_paths(lib_dir, target_dir)
118117

@@ -129,13 +128,25 @@ foreach params : targets
129128
_link_args = target_c_args + ['-r', '-ffreestanding']
130129

131130
# The normal variant does not call 'exit' after return from main (c lingo: freestanding execution environment)
132-
_crt = executable(join_paths(target_dir, crt_name),
133-
_src,
134-
include_directories : inc,
135-
install : really_install,
136-
install_dir : instdir,
137-
c_args : _c_args,
138-
link_args : _link_args)
131+
132+
if meson.version().version_compare('>=1.10')
133+
_crt = executable(crt_name,
134+
_src,
135+
build_subdir : target_dir,
136+
include_directories : inc,
137+
install : really_install,
138+
install_dir : instdir,
139+
c_args : _c_args,
140+
link_args : _link_args)
141+
else
142+
_crt = executable(join_paths(target_dir, crt_name),
143+
_src,
144+
include_directories : inc,
145+
install : really_install,
146+
install_dir : instdir,
147+
c_args : _c_args,
148+
link_args : _link_args)
149+
endif
139150

140151
if machine['name'] == test_machine
141152
set_variable('crt0' + variant_suffix.underscorify() + target,
@@ -144,14 +155,27 @@ foreach params : targets
144155
endif
145156

146157
if enable_picocrt_lib
147-
static_library(join_paths(target_dir, target_lib_prefix + libcrt_name),
148-
[],
149-
include_directories : inc,
150-
install : really_install,
151-
install_dir : instdir,
152-
c_args : _c_args,
153-
objects: _crt.extract_objects(_src),
154-
pic: false)
158+
if meson.version().version_compare('>=1.10')
159+
static_library(libcrt_name,
160+
[],
161+
build_subdir : target_dir,
162+
include_directories : inc,
163+
install : really_install,
164+
install_dir : instdir,
165+
c_args : _c_args,
166+
objects: _crt.extract_objects(_src),
167+
pic: false)
168+
else
169+
target_lib_prefix = params['lib_prefix']
170+
static_library(join_paths(target_dir, target_lib_prefix + libcrt_name),
171+
[],
172+
include_directories : inc,
173+
install : really_install,
174+
install_dir : instdir,
175+
c_args : _c_args,
176+
objects: _crt.extract_objects(_src),
177+
pic: false)
178+
endif
155179
endif
156180
endforeach
157181
endforeach

semihost/machine/aarch64/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ foreach params : targets
4545
target = params['name']
4646
target_dir = params['dir']
4747
target_c_args = params['c_args']
48-
target_lib_prefix = params['lib_prefix']
4948

5049
instdir = join_paths(lib_dir, target_dir)
5150

@@ -61,6 +60,7 @@ foreach params : targets
6160
c_args : target_c_args + c_args,
6261
pic: false)
6362
else
63+
target_lib_prefix = params['lib_prefix']
6464
_lib = static_library(join_paths(target_dir, target_lib_prefix + libsemihost_raw_name),
6565
lib_semihost_raw_srcs,
6666
install : really_install,
@@ -70,6 +70,6 @@ foreach params : targets
7070
pic: false)
7171
endif
7272

73-
set_variable('lib_semihost_raw' + target, local_lib_semihost_raw_target)
73+
set_variable('lib_semihost_raw' + target, _lib)
7474

7575
endforeach

0 commit comments

Comments
 (0)