(input_files, filename, libname, cflags, asflags=None, customize_build_flags=None)
| 191 | |
| 192 | |
| 193 | def 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 | |
| 202 | ninja_required_version = 1.5 |
| 203 | |
| 204 | ASFLAGS = {join_cmd(asflags)} |
| 205 | CFLAGS = {join_cmd(cflags)} |
| 206 | EMCC = {shared.EMCC} |
| 207 | EMXX = {shared.EMXX} |
| 208 | EMAR = {shared.EMAR} |
| 209 | |
| 210 | rule cc |
| 211 | depfile = $out.d |
| 212 | command = $EMCC -MD -MF $out.d $CFLAGS -c $in -o $out |
| 213 | description = CC $out |
| 214 | |
| 215 | rule cxx |
| 216 | depfile = $out.d |
| 217 | command = $EMXX -MD -MF $out.d $CFLAGS -c $in -o $out |
| 218 | description = CXX $out |
| 219 | |
| 220 | rule asm |
| 221 | command = $EMCC $ASFLAGS -c $in -o $out |
| 222 | description = ASM $out |
| 223 | |
| 224 | rule asm_cpp |
| 225 | depfile = $out.d |
| 226 | command = $EMCC -MD -MF $out.d $CFLAGS -c $in -o $out |
| 227 | description = ASM $out |
| 228 | |
| 229 | rule direct_cc |
| 230 | depfile = $with_depfile |
| 231 | command = $EMCC -MD -MF $with_depfile $CFLAGS -c $in -o $out |
| 232 | description = CC $out |
| 233 | |
| 234 | rule 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' |
no test coverage detected