Consume 4jlibs via wrap fallback

This commit is contained in:
MatthewBeshay 2026-03-20 11:32:15 +11:00
parent 1845c64ad4
commit 6c4306258b
3 changed files with 30 additions and 19 deletions

2
.gitignore vendored
View file

@ -19,8 +19,6 @@
!/subprojects/ !/subprojects/
/subprojects/* /subprojects/*
!/subprojects/*.wrap !/subprojects/*.wrap
!/subprojects/4jlibs/
!/subprojects/4jlibs/**
/scripts/__pycache__/ /scripts/__pycache__/
!/.clang-format !/.clang-format
!/.git-blame-ignore-revs !/.git-blame-ignore-revs

View file

@ -48,14 +48,10 @@ if host_machine.system() == 'linux'
] ]
endif endif
render_dep = dependency('4j-render', required: false) render_dep = dependency('4j-render', fallback: ['4jlibs', 'render_dep'])
input_dep = dependency('4j-input', required: false) input_dep = dependency('4j-input', fallback: ['4jlibs', 'input_dep'])
profile_dep = dependency('4j-profile', required: false) profile_dep = dependency('4j-profile', fallback: ['4jlibs', 'profile_dep'])
storage_dep = dependency('4j-storage', required: false) storage_dep = dependency('4j-storage', fallback: ['4jlibs', 'storage_dep'])
if not render_dep.found() or not input_dep.found() or not profile_dep.found() or not storage_dep.found()
subdir('4jlibs/builddef')
endif
subdir('Minecraft.Assets') subdir('Minecraft.Assets')
subdir('Minecraft.World') subdir('Minecraft.World')

View file

@ -3,6 +3,7 @@
from __future__ import annotations from __future__ import annotations
import argparse import argparse
import site
import shutil import shutil
import subprocess import subprocess
import sys import sys
@ -28,13 +29,30 @@ def require_clean_destination(dest: Path) -> None:
raise SystemExit(f"Destination already exists: {dest}") raise SystemExit(f"Destination already exists: {dest}")
def ensure_filter_repo() -> None: def resolve_filter_repo_command() -> list[str]:
try: script_name = "git-filter-repo.exe" if sys.platform == "win32" else "git-filter-repo"
run(["git", "filter-repo", "--help"])
except subprocess.CalledProcessError as exc: path_candidates = [
raise SystemExit( shutil.which("git-filter-repo"),
"git-filter-repo is required. Install it first and rerun this script." shutil.which(script_name),
) from exc ]
user_script_dirs = [
Path(site.USER_BASE) / "Scripts",
Path(site.getusersitepackages()).parent / "Scripts",
]
for script_dir in user_script_dirs:
user_scripts = script_dir / script_name
path_candidates.append(str(user_scripts) if user_scripts.exists() else None)
for candidate in path_candidates:
if candidate:
return [candidate]
raise SystemExit(
"git-filter-repo is required. Install it first and rerun this script."
)
def clone_source(source: Path, dest: Path) -> None: def clone_source(source: Path, dest: Path) -> None:
@ -42,7 +60,7 @@ def clone_source(source: Path, dest: Path) -> None:
def filter_history(dest: Path) -> None: def filter_history(dest: Path) -> None:
cmd = ["git", "filter-repo", "--force"] cmd = resolve_filter_repo_command() + ["--force"]
for path in PATHS_TO_KEEP: for path in PATHS_TO_KEEP:
cmd.extend(["--path", path]) cmd.extend(["--path", path])
run(cmd, cwd=dest) run(cmd, cwd=dest)
@ -100,7 +118,6 @@ def main() -> int:
destination = args.destination.resolve() destination = args.destination.resolve()
require_clean_destination(destination) require_clean_destination(destination)
ensure_filter_repo()
clone_source(source, destination) clone_source(source, destination)
filter_history(destination) filter_history(destination)
rewrite_staged_layout(destination) rewrite_staged_layout(destination)