Skip to content

Commit

Permalink
port the asm-processor changes from oot-gc
Browse files Browse the repository at this point in the history
Co-authored-by: encounter <549122+encounter@users.noreply.github.com>
Co-authored-by: cadmic <146315916+cadmic@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 21, 2024
1 parent 522a825 commit 47e1b94
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 20 deletions.
24 changes: 20 additions & 4 deletions .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,30 +34,42 @@ jobs:

# Build the project
- name: Build
if: matrix.matching
run: |
python configure.py --map --binutils /binutils --compilers /compilers
ninja all_source build/oot-j/progress.json build/report.json
ninja all_source build/{oot-j}/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/{oot-j}/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-vc
PROGRESS_API_KEY: ${{ secrets.PROGRESS_API_KEY }}
run: |
python tools/upload_progress.py -b https://progress.decomp.club/ \
-p $PROGRESS_SLUG -v oot-j build/oot-j/progress.json
for version in {oot-j}; do
python tools/upload_progress.py -b https://progress.decomp.club/ \
-p $PROGRESS_SLUG -v $version build/$version/progress.json
done
# 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 @@ -33,6 +33,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 @@ -124,6 +129,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 47e1b94

Please sign in to comment.