Brought back tools/mkpsexe_from_yaml.py and tools/mkraw_exe_from_yaml.py tools.

They were easier to understand and modify than using `tools/process_path.py` in zbuild.
This commit is contained in:
Filipe Rodrigues 2023-10-15 11:01:34 +01:00
parent 3b6805a94a
commit 313f586eaa
3 changed files with 88 additions and 21 deletions

View File

@ -0,0 +1,37 @@
#!/bin/env python3
"""
Calls the `mkpsexe` linker using a `yaml` manifest
"""
# Import
import argparse
from pathlib import Path
import subprocess
import yaml
import util
def main(args):
"""
Main function
"""
config = yaml.safe_load(open(args.input_yaml, encoding="utf-8"))
input_dir = Path(args.input_yaml).parent
elf_path = util.process_path(config["elf"], input_dir)
license_path = util.process_path(config["license"], input_dir)
resize_text = config.get("resize_text")
resize_args = ["--resize-text", str(resize_text)] if resize_text is not None else []
args = [args.mkpsexe_bin, elf_path, "-o", args.output, "--license", license_path] + resize_args
subprocess.run(args, check=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="`mkpsexe` wrapper")
parser.add_argument("input_yaml", type=str)
parser.add_argument("-o", dest="output", type=str, required=True)
parser.add_argument("--mkpsexe-bin", dest="mkpsexe_bin", type=str, required=True)
args = parser.parse_args()
main(args)

View File

@ -0,0 +1,33 @@
#!/bin/env python3
"""
Calls the `raw_exe` linker using a `yaml` manifest
"""
# Import
import argparse
from pathlib import Path
import subprocess
import yaml
import util
def main(args):
"""
Main function
"""
config = yaml.safe_load(open(args.input_yaml, encoding="utf-8"))
input_dir = Path(args.input_yaml).parent
elf_path = util.process_path(config["elf"], input_dir)
subprocess.run([args.objcopy_bin, elf_path, f"--dump-section=.text={args.output}"], check=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="`mkraw_exe` wrapper")
parser.add_argument("input_yaml", type=str)
parser.add_argument("-o", dest="output", type=str, required=True)
parser.add_argument("--objcopy-bin", dest="objcopy_bin", type=str, required=True)
args = parser.parse_args()
main(args)

View File

@ -22,7 +22,9 @@ alias:
# Other tools
generate_psx_iso_deps : tools/generate_psx_iso_deps.py
generate_compare_deps : tools/generate_compare_deps.py
mkpsexe_from_yaml : tools/mkpsexe_from_yaml.py
mkpsexe_from_yaml_deps : tools/mkpsexe_from_yaml_deps.py
mkraw_exe_from_yaml : tools/mkraw_exe_from_yaml.py
mkraw_exe_from_yaml_deps: tools/mkraw_exe_from_yaml_deps.py
ld_from_yaml : tools/ld_from_yaml.py
ld_from_yaml_deps : tools/ld_from_yaml_deps.py
@ -265,25 +267,18 @@ rules:
out: [$(psexe)]
deps:
- $(psexe_yaml)
- $(mkpsexe_from_yaml)
- $(mkpsexe)
- deps_file: $(psexe_deps)
- static: $(psexe::dir_name)/
exec:
- - $(mkpsexe)
- - $(python3)
- $(process_path)
- --input-dir=$(psexe_yaml::dir_name)/
- [$(yq), -rj, .elf, $(psexe_yaml)]
- '--output=$(psexe)'
- '--license'
- - $(python3)
- $(process_path)
- --input-dir=$(psexe_yaml::dir_name)/
- [$(yq), -rj, .license, $(psexe_yaml)]
- strip_on_fail:
- printf
- '--resize-text=%s'
- [yq, -rje, .resize_text, $(psexe_yaml)]
- - $(python3)
- $(mkpsexe_from_yaml)
- $(psexe_yaml)
- -o
- $(psexe)
- --mkpsexe-bin
- $(mkpsexe)
# Psexe dependencies
psexe_deps:
@ -306,15 +301,17 @@ rules:
out: [$(raw_exe)]
deps:
- $(raw_exe_yaml)
- $(mkraw_exe_from_yaml)
- deps_file: $(raw_exe_deps)
- static: $(raw_exe::dir_name)/
exec:
- - $(objcopy)
- - $(python3)
- $(process_path)
- --input-dir=$(raw_exe_yaml::dir_name)/
- [$(yq), -rj, .elf, $(raw_exe_yaml)]
- '--dump-section=.text=$(raw_exe)'
- - $(python3)
- $(mkraw_exe_from_yaml)
- $(raw_exe_yaml)
- -o
- $(raw_exe)
- --objcopy-bin
- $(objcopy)
# Raw exe dependencies
raw_exe_deps: