Support disabling asm overrides and fix lint errors (#17)

This commit is contained in:
Robin Avery 2024-03-05 00:13:39 -05:00 committed by GitHub
parent 368342ae8b
commit 95c866aa9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -44,7 +44,7 @@ parser.add_argument(
choices=VERSIONS, choices=VERSIONS,
type=str.upper, type=str.upper,
default=VERSIONS[DEFAULT_VERSION], default=VERSIONS[DEFAULT_VERSION],
help=f"version to build", help="version to build",
) )
parser.add_argument( parser.add_argument(
"--build-dir", "--build-dir",
@ -70,6 +70,11 @@ parser.add_argument(
action="store_true", action="store_true",
help="generate map file(s)", help="generate map file(s)",
) )
parser.add_argument(
"--no-asm",
action="store_true",
help="don't incorporate .s files from asm directory",
)
parser.add_argument( parser.add_argument(
"--debug", "--debug",
action="store_true", action="store_true",
@ -115,6 +120,8 @@ config.generate_map = args.map
config.sjiswrap_path = args.sjiswrap config.sjiswrap_path = args.sjiswrap
if not is_windows(): if not is_windows():
config.wrapper = args.wrapper config.wrapper = args.wrapper
if args.no_asm:
config.asm_dir = None
# Tool versions # Tool versions
config.binutils_tag = "2.42-1" config.binutils_tag = "2.42-1"

View File

@ -54,7 +54,9 @@ class ProjectConfig:
self.build_dir: Path = Path("build") # Output build files self.build_dir: Path = Path("build") # Output build files
self.src_dir: Path = Path("src") # C/C++/asm source files self.src_dir: Path = Path("src") # C/C++/asm source files
self.tools_dir: Path = Path("tools") # Python scripts self.tools_dir: Path = Path("tools") # Python scripts
self.asm_dir: Path = Path("asm") # Override incomplete objects (for modding) self.asm_dir: Optional[Path] = Path(
"asm"
) # Override incomplete objects (for modding)
# Tooling # Tooling
self.binutils_tag: Optional[str] = None # Git tag self.binutils_tag: Optional[str] = None # Git tag
@ -676,6 +678,8 @@ def generate_build_ninja(
options[key] = value options[key] = value
unit_src_path = Path(lib.get("src_dir", config.src_dir)) / options["source"] unit_src_path = Path(lib.get("src_dir", config.src_dir)) / options["source"]
unit_asm_path: Optional[Path] = None
if config.asm_dir is not None: if config.asm_dir is not None:
unit_asm_path = ( unit_asm_path = (
Path(lib.get("asm_dir", config.asm_dir)) / options["source"] Path(lib.get("asm_dir", config.asm_dir)) / options["source"]
@ -697,6 +701,7 @@ def generate_build_ninja(
link_built_obj = False link_built_obj = False
# Assembly overrides # Assembly overrides
built_obj_path: Optional[Path] = None
if unit_asm_path is not None and unit_asm_path.exists(): if unit_asm_path is not None and unit_asm_path.exists():
link_built_obj = True link_built_obj = True
built_obj_path = asm_build(obj, options, lib_name, unit_asm_path) built_obj_path = asm_build(obj, options, lib_name, unit_asm_path)