MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / create_ninja_file

Function create_ninja_file

tools/system_libs.py:193–292  ·  view source on GitHub ↗
(input_files, filename, libname, cflags, asflags=None, customize_build_flags=None)

Source from the content-addressed store, hash-verified

191
192
193def create_ninja_file(input_files, filename, libname, cflags, asflags=None, customize_build_flags=None):
194 if asflags is None:
195 asflags = []
196
197 join_cmd = shlex.join if os.name == 'posix' else subprocess.list2cmdline
198
199 out = f'''\
200# Automatically generated by tools/system_libs.py. DO NOT EDIT
201
202ninja_required_version = 1.5
203
204ASFLAGS = {join_cmd(asflags)}
205CFLAGS = {join_cmd(cflags)}
206EMCC = {shared.EMCC}
207EMXX = {shared.EMXX}
208EMAR = {shared.EMAR}
209
210rule cc
211 depfile = $out.d
212 command = $EMCC -MD -MF $out.d $CFLAGS -c $in -o $out
213 description = CC $out
214
215rule cxx
216 depfile = $out.d
217 command = $EMXX -MD -MF $out.d $CFLAGS -c $in -o $out
218 description = CXX $out
219
220rule asm
221 command = $EMCC $ASFLAGS -c $in -o $out
222 description = ASM $out
223
224rule asm_cpp
225 depfile = $out.d
226 command = $EMCC -MD -MF $out.d $CFLAGS -c $in -o $out
227 description = ASM $out
228
229rule direct_cc
230 depfile = $with_depfile
231 command = $EMCC -MD -MF $with_depfile $CFLAGS -c $in -o $out
232 description = CC $out
233
234rule archive
235 # Workaround command line too long issue (https://github.com/ninja-build/ninja/pull/217) by using a response file.
236 rspfile = $out.rsp
237 rspfile_content = $in
238 command = $EMAR cr $out @$rspfile
239 description = AR $out
240
241'''
242 suffix = utils.suffix(libname)
243 build_dir = os.path.dirname(filename)
244
245 if suffix == '.o':
246 assert len(input_files) == 1
247 input_file = escape_ninja_path(input_files[0])
248 depfile = utils.unsuffixed_basename(input_file) + '.d'
249 out += f'build {escape_ninja_path(libname)}: direct_cc {input_file}\n'
250 out += f' with_depfile = {depfile}\n'

Callers 1

generate_ninjaMethod · 0.85

Calls 7

escape_ninja_pathFunction · 0.85
get_top_level_ninja_fileFunction · 0.85
lowerMethod · 0.80
appendMethod · 0.80
write_fileMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected