(
config: ProjectConfig,
objects: Dict[str, Object],
build_config: Optional[BuildConfig],
)
| 398 | |
| 399 | # Generate build.ninja |
| 400 | def generate_build_ninja( |
| 401 | config: ProjectConfig, |
| 402 | objects: Dict[str, Object], |
| 403 | build_config: Optional[BuildConfig], |
| 404 | ) -> None: |
| 405 | out = io.StringIO() |
| 406 | n = ninja_syntax.Writer(out) |
| 407 | n.variable("ninja_required_version", "1.3") |
| 408 | n.newline() |
| 409 | |
| 410 | configure_script = Path(os.path.relpath(os.path.abspath(sys.argv[0]))) |
| 411 | python_lib = Path(os.path.relpath(__file__)) |
| 412 | python_lib_dir = python_lib.parent |
| 413 | n.comment("The arguments passed to configure.py, for rerunning it.") |
| 414 | n.variable("configure_args", sys.argv[1:]) |
| 415 | n.variable("python", f'"{sys.executable}"') |
| 416 | n.newline() |
| 417 | |
| 418 | ### |
| 419 | # Variables |
| 420 | ### |
| 421 | n.comment("Variables") |
| 422 | n.variable("ldflags", make_flags_str(config.ldflags)) |
| 423 | if config.linker_version is None: |
| 424 | sys.exit("ProjectConfig.linker_version missing") |
| 425 | n.variable("mw_version", Path(config.linker_version)) |
| 426 | n.newline() |
| 427 | |
| 428 | ### |
| 429 | # Tooling |
| 430 | ### |
| 431 | n.comment("Tooling") |
| 432 | |
| 433 | build_path = config.out_path() |
| 434 | progress_path = build_path / "progress.json" |
| 435 | report_path = build_path / "report.json" |
| 436 | build_tools_path = config.build_dir / "tools" |
| 437 | download_tool = config.tools_dir / "download_tool.py" |
| 438 | n.rule( |
| 439 | name="download_tool", |
| 440 | command=f"$python {download_tool} $tool $out --tag $tag", |
| 441 | description="TOOL $out", |
| 442 | ) |
| 443 | |
| 444 | decompctx = config.tools_dir / "decompctx.py" |
| 445 | n.rule( |
| 446 | name="decompctx", |
| 447 | command=f"$python {decompctx} $in -o $out -d $out.d $includes", |
| 448 | description="CTX $in", |
| 449 | depfile="$out.d", |
| 450 | deps="gcc", |
| 451 | ) |
| 452 | |
| 453 | cargo_rule_written = False |
| 454 | |
| 455 | def write_cargo_rule(): |
| 456 | nonlocal cargo_rule_written |
| 457 | if not cargo_rule_written: |
no test coverage detected