Skip to content

Commit

Permalink
Disable asm-processor for progress calculation (#185)
Browse files Browse the repository at this point in the history
* Disable asm-processor by default

* Keep asm_processor by default, use --no-asm-processor instead for progress calculation only

* Only upload files once

---------

Co-authored-by: Luke Street <[email protected]>
  • Loading branch information
cadmic and encounter authored Sep 20, 2024
1 parent e7fc78e commit fdcc13f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 17 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ jobs:
build:
container: ghcr.io/zeldaret/oot-gc-vc-build:main
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
matching: [true, false]
defaults:
run:
shell: bash
Expand All @@ -30,13 +34,21 @@ jobs:

# Build the project
- name: Build
if: matrix.matching
run: |
python configure.py --map --binutils /binutils --compilers /compilers
ninja all_source build/{mq-j,mq-u,mq-e,ce-j,ce-u,ce-e}/progress.json build/report.json
# Build the project (non-matching)
- name: Build (non-matching)
if: ${{ !matrix.matching }}
run: |
python configure.py --map --binutils /binutils --compilers /compilers --non-matching --no-asm-processor
ninja all_source build/{mq-j,mq-u,mq-e,ce-j,ce-u,ce-e}/progress.json build/report.json
# Upload progress if we're on the main branch
- name: Upload progress
if: github.ref == 'refs/heads/main'
if: ${{ !matrix.matching && github.ref == 'refs/heads/main' }}
continue-on-error: true
env:
PROGRESS_SLUG: oot-gc
Expand All @@ -49,13 +61,15 @@ jobs:
# Upload map files
- name: Upload map
if: matrix.matching
uses: actions/upload-artifact@v4
with:
name: combined_maps
path: build/**/*.MAP

# Upload progress report
- name: Upload report
if: ${{ !matrix.matching }}
uses: actions/upload-artifact@v4
with:
name: combined_report
Expand Down
6 changes: 6 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
action="store_true",
help="create non-matching build for modding",
)
parser.add_argument(
"--no-asm-processor",
action="store_true",
help="disable asm_processor for progress calculation",
)
parser.add_argument(
"--build-dir",
metavar="DIR",
Expand Down Expand Up @@ -143,6 +148,7 @@
config.generate_map = args.map
config.sjiswrap_path = args.sjiswrap
config.non_matching = args.non_matching
config.asm_processor = not args.no_asm_processor

if not is_windows():
config.wrapper = args.wrapper
Expand Down
42 changes: 26 additions & 16 deletions tools/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ def set_default(key: str, value: Any) -> None:
obj.ctx_path = build_dir / "src" / f"{base_name}.ctx"
return obj

def completed(self, version: str) -> bool:
return version in self.completed_versions
def completed(self, config: "ProjectConfig", version: str) -> bool:
complete = version in self.completed_versions
# Don't consider asm_processor objects "complete" if asm_processor is disabled
if self.options["asm_processor"] and not config.asm_processor:
complete = False
return complete


class ProgressCategory:
Expand Down Expand Up @@ -132,6 +136,7 @@ def __init__(self) -> None:
self.objdiff_path: Optional[Path] = None # If None, download

# Project config
self.asm_processor: bool = True # Enable asm_processor
self.build_rels: bool = True # Build REL files
self.config_dir: Path = Path("config") # Config directory
self.debug: bool = False # Build with debug info
Expand Down Expand Up @@ -775,8 +780,8 @@ def c_build(obj: Object, src_path: Path) -> Optional[Path]:

# Add MWCC build rule
lib_name = obj.options["lib"]
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed(version)})")
if obj.options["asm_processor"]:
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed(config, version)})")
if config.asm_processor and obj.options["asm_processor"]:
n.build(
outputs=obj.src_obj_path,
rule=(
Expand Down Expand Up @@ -862,7 +867,7 @@ def asm_build(

# Add assembler build rule
lib_name = obj.options["lib"]
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed})")
n.comment(f"{obj.name}: {lib_name} (linked {obj.completed(config, version)})")
n.build(
outputs=obj_path,
rule="as",
Expand All @@ -886,7 +891,7 @@ def add_unit(build_obj, link_step: LinkStep):
link_step.add(obj_path)
return

link_built_obj = obj.completed(version)
link_built_obj = obj.completed(config, version)
built_obj_path: Optional[Path] = None
if obj.src_path is not None and obj.src_path.exists():
if obj.src_path.suffix in (".c", ".cp", ".cpp"):
Expand All @@ -898,7 +903,7 @@ def add_unit(build_obj, link_step: LinkStep):
else:
sys.exit(f"Unknown source file type {obj.src_path}")
else:
if config.warn_missing_source or obj.completed(version):
if config.warn_missing_source or obj.completed(config, version):
print(f"Missing source file {obj.src_path}")
link_built_obj = False

Expand Down Expand Up @@ -1106,7 +1111,7 @@ def add_unit(build_obj, link_step: LinkStep):

# Generate objdiff.json
def generate_objdiff_config(
config: ProjectConfig,
config: ProjectConfig,
version_objects: Dict[str, Dict[str, Object]],
build_configs: Dict[str, Dict[str, Any]],
) -> None:
Expand Down Expand Up @@ -1164,14 +1169,17 @@ def generate_objdiff_config(
"Wii/1.7": "mwcc_43_213",
}

def add_unit(build_obj: Dict[str, Any], version: str, progress_categories: List[str]) -> None:
def add_unit(
build_obj: Dict[str, Any], version: str, progress_categories: List[str]
) -> None:
obj_path, obj_name = build_obj["object"], build_obj["name"]
base_object = Path(obj_name).with_suffix("")
unit_config: Dict[str, Any] = {
"name": Path(version) / base_object,
"target_path": obj_path,
"metadata": {
"auto_generated": build_obj["autogenerated"],
"progress_categories": progress_categories,
},
}

Expand Down Expand Up @@ -1225,12 +1233,14 @@ def keep_flag(flag):
progress_categories.extend(map(lambda x: f"{version}.{x}", category_opt))
elif category_opt is not None:
progress_categories.append(f"{version}.{category_opt}")
unit_config["metadata"].update({
"complete": obj.completed(version),
"reverse_fn_order": reverse_fn_order,
"source_path": obj.src_path,
"progress_categories": progress_categories,
})
unit_config["metadata"].update(
{
"complete": obj.completed(config, version),
"reverse_fn_order": reverse_fn_order,
"source_path": obj.src_path,
"progress_categories": progress_categories,
}
)
objdiff_config["units"].append(unit_config)

for version, build_config in build_configs.items():
Expand Down Expand Up @@ -1321,7 +1331,7 @@ def add(self, build_obj: Dict[str, Any]) -> None:
return

obj = objects.get(build_obj["name"])
if obj is None or not obj.completed(version) or obj.options["asm_processor"]:
if obj is None or not obj.completed(config, version):
return

self.code_progress += build_obj["code_size"]
Expand Down

0 comments on commit fdcc13f

Please sign in to comment.