Allow adding re-configure dependencies and doing non-matching builds (#22)

* Fix type checking errors with config version

* Add optional reconfigure dependency list to project config

* Add non-matching build option
Skips hash check and progress output

* Uncomment `config.reconfig_deps` assignment

* Change default target for non-matching instead of stubbing check/progress
This commit is contained in:
Nathan 2024-05-18 14:50:32 -06:00 committed by GitHub
parent d102696838
commit cf654dd8ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 5 deletions

View File

@ -105,10 +105,16 @@ parser.add_argument(
action="store_true", action="store_true",
help="print verbose output", help="print verbose output",
) )
parser.add_argument(
"--non-matching",
dest="non_matching",
action="store_true",
help="builds equivalent (but non-matching) or modded objects",
)
args = parser.parse_args() args = parser.parse_args()
config = ProjectConfig() config = ProjectConfig()
config.version = args.version config.version = str(args.version)
version_num = VERSIONS.index(config.version) version_num = VERSIONS.index(config.version)
# Apply arguments # Apply arguments
@ -118,6 +124,7 @@ config.binutils_path = args.binutils
config.compilers_path = args.compilers config.compilers_path = args.compilers
config.debug = args.debug config.debug = args.debug
config.generate_map = args.map config.generate_map = args.map
config.non_matching = args.non_matching
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
@ -146,6 +153,8 @@ config.ldflags = [
"-nodefaults", "-nodefaults",
# "-listclosure", # Uncomment for Wii linkers # "-listclosure", # Uncomment for Wii linkers
] ]
# Use for any additional files that should cause a re-configure when modified
config.reconfig_deps = []
# Base flags, common to most GC/Wii games. # Base flags, common to most GC/Wii games.
# Generally leave untouched, with overrides added below. # Generally leave untouched, with overrides added below.
@ -220,8 +229,9 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
} }
Matching = True Matching = True # Object matches and should be linked
NonMatching = False NonMatching = False # Object does not match and should not be linked
Equivalent = config.non_matching # Object should be linked when configured with --non-matching
config.warn_missing_config = True config.warn_missing_config = True
config.warn_missing_source = False config.warn_missing_source = False

View File

@ -71,6 +71,7 @@ class ProjectConfig:
self.sjiswrap_path: Optional[Path] = None # If None, download self.sjiswrap_path: Optional[Path] = None # If None, download
# Project config # Project config
self.non_matching: bool = False
self.build_rels: bool = True # Build REL files self.build_rels: bool = True # Build REL files
self.check_sha_path: Optional[Path] = None # Path to version.sha1 self.check_sha_path: Optional[Path] = None # Path to version.sha1
self.config_path: Optional[Path] = None # Path to config.yml self.config_path: Optional[Path] = None # Path to config.yml
@ -90,6 +91,9 @@ class ProjectConfig:
self.shift_jis = ( self.shift_jis = (
True # Convert source files from UTF-8 to Shift JIS automatically True # Convert source files from UTF-8 to Shift JIS automatically
) )
self.reconfig_deps: Optional[List[Path]] = (
None # Additional re-configuration dependency files
)
# Progress output and progress.json config # Progress output and progress.json config
self.progress_all: bool = True # Include combined "all" category self.progress_all: bool = True # Include combined "all" category
@ -553,6 +557,7 @@ def generate_build_ninja(
) )
n.newline() n.newline()
link_outputs: List[Path] = []
if build_config: if build_config:
link_steps: List[LinkStep] = [] link_steps: List[LinkStep] = []
used_compiler_versions: Set[str] = set() used_compiler_versions: Set[str] = set()
@ -760,6 +765,7 @@ def generate_build_ninja(
### ###
for step in link_steps: for step in link_steps:
step.write(n) step.write(n)
link_outputs.append(step.output())
n.newline() n.newline()
### ###
@ -861,7 +867,7 @@ def generate_build_ninja(
outputs=ok_path, outputs=ok_path,
rule="check", rule="check",
inputs=config.check_sha_path, inputs=config.check_sha_path,
implicit=[dtk, *map(lambda step: step.output(), link_steps)], implicit=[dtk, *link_outputs],
) )
n.newline() n.newline()
@ -961,6 +967,7 @@ def generate_build_ninja(
configure_script, configure_script,
python_lib, python_lib,
python_lib_dir / "ninja_syntax.py", python_lib_dir / "ninja_syntax.py",
*(config.reconfig_deps or [])
], ],
) )
n.newline() n.newline()
@ -970,6 +977,9 @@ def generate_build_ninja(
### ###
n.comment("Default rule") n.comment("Default rule")
if build_config: if build_config:
if config.non_matching:
n.default(link_outputs)
else:
n.default(progress_path) n.default(progress_path)
else: else:
n.default(build_config_path) n.default(build_config_path)