Support specifying a dtk binary (#14)
This commit is contained in:
parent
6debc74abf
commit
1d3192a4aa
44
configure.py
44
configure.py
|
@ -12,11 +12,11 @@
|
|||
# Append --help to see available options.
|
||||
###
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Any
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from tools.project import (
|
||||
Object,
|
||||
ProjectConfig,
|
||||
|
@ -31,91 +31,83 @@ VERSIONS = [
|
|||
"GAMEID", # 0
|
||||
]
|
||||
|
||||
if len(VERSIONS) > 1:
|
||||
versions_str = ", ".join(VERSIONS[:-1]) + f" or {VERSIONS[-1]}"
|
||||
else:
|
||||
versions_str = VERSIONS[0]
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"mode",
|
||||
choices=["configure", "progress"],
|
||||
default="configure",
|
||||
help="configure or progress (default: configure)",
|
||||
help="script mode (default: configure)",
|
||||
nargs="?",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
dest="version",
|
||||
choices=VERSIONS,
|
||||
type=str.upper,
|
||||
default=VERSIONS[DEFAULT_VERSION],
|
||||
help=f"version to build ({versions_str})",
|
||||
help=f"version to build",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--build-dir",
|
||||
dest="build_dir",
|
||||
metavar="DIR",
|
||||
type=Path,
|
||||
default=Path("build"),
|
||||
help="base build directory (default: build)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--binutils",
|
||||
dest="binutils",
|
||||
metavar="BINARY",
|
||||
type=Path,
|
||||
help="path to binutils (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--compilers",
|
||||
dest="compilers",
|
||||
metavar="DIR",
|
||||
type=Path,
|
||||
help="path to compilers (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--map",
|
||||
dest="map",
|
||||
action="store_true",
|
||||
help="generate map file(s)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--debug",
|
||||
dest="debug",
|
||||
action="store_true",
|
||||
help="build with debug info (non-matching)",
|
||||
)
|
||||
if not is_windows():
|
||||
parser.add_argument(
|
||||
"--wrapper",
|
||||
dest="wrapper",
|
||||
metavar="BINARY",
|
||||
type=Path,
|
||||
help="path to wibo or wine (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--build-dtk",
|
||||
dest="build_dtk",
|
||||
"--dtk",
|
||||
metavar="BINARY | DIR",
|
||||
type=Path,
|
||||
help="path to decomp-toolkit source (optional)",
|
||||
help="path to decomp-toolkit binary or source (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--sjiswrap",
|
||||
dest="sjiswrap",
|
||||
metavar="EXE",
|
||||
type=Path,
|
||||
help="path to sjiswrap.exe (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--verbose",
|
||||
dest="verbose",
|
||||
action="store_true",
|
||||
help="print verbose output",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
config = ProjectConfig()
|
||||
config.version = args.version.upper()
|
||||
if config.version not in VERSIONS:
|
||||
sys.exit(f"Invalid version '{config.version}', expected {versions_str}")
|
||||
config.version = args.version
|
||||
version_num = VERSIONS.index(config.version)
|
||||
|
||||
# Apply arguments
|
||||
config.build_dir = args.build_dir
|
||||
config.build_dtk_path = args.build_dtk
|
||||
config.dtk_path = args.dtk
|
||||
config.binutils_path = args.binutils
|
||||
config.compilers_path = args.compilers
|
||||
config.debug = args.debug
|
||||
|
|
|
@ -60,7 +60,7 @@ class ProjectConfig:
|
|||
self.binutils_tag: Optional[str] = None # Git tag
|
||||
self.binutils_path: Optional[Path] = None # If None, download
|
||||
self.dtk_tag: Optional[str] = None # Git tag
|
||||
self.build_dtk_path: Optional[Path] = None # If None, download
|
||||
self.dtk_path: Optional[Path] = None # If None, download
|
||||
self.compilers_tag: Optional[str] = None # 1
|
||||
self.compilers_path: Optional[Path] = None # If None, download
|
||||
self.wibo_tag: Optional[str] = None # Git tag
|
||||
|
@ -82,9 +82,9 @@ class ProjectConfig:
|
|||
self.warn_missing_config: bool = False # Warn on missing unit configuration
|
||||
self.warn_missing_source: bool = False # Warn on missing source file
|
||||
self.rel_strip_partial: bool = True # Generate PLFs with -strip_partial
|
||||
self.rel_empty_file: Optional[str] = (
|
||||
None # Object name for generating empty RELs
|
||||
)
|
||||
self.rel_empty_file: Optional[
|
||||
str
|
||||
] = None # Object name for generating empty RELs
|
||||
self.shift_jis = (
|
||||
True # Convert source files from UTF-8 to Shift JIS automatically
|
||||
)
|
||||
|
@ -242,7 +242,7 @@ def generate_build_ninja(
|
|||
deps="gcc",
|
||||
)
|
||||
|
||||
if config.build_dtk_path:
|
||||
if config.dtk_path:
|
||||
dtk = build_tools_path / "release" / f"dtk{EXE}"
|
||||
n.rule(
|
||||
name="cargo",
|
||||
|
@ -254,8 +254,8 @@ def generate_build_ninja(
|
|||
n.build(
|
||||
outputs=dtk,
|
||||
rule="cargo",
|
||||
inputs=config.build_dtk_path / "Cargo.toml",
|
||||
implicit=config.build_dtk_path / "Cargo.lock",
|
||||
inputs=config.dtk_path / "Cargo.toml",
|
||||
implicit=config.dtk_path / "Cargo.lock",
|
||||
variables={
|
||||
"bin": "dtk",
|
||||
"target": build_tools_path,
|
||||
|
@ -559,7 +559,6 @@ def generate_build_ninja(
|
|||
def c_build(
|
||||
obj: Object, options: Dict[str, Any], lib_name: str, src_path: Path
|
||||
) -> Optional[Path]:
|
||||
|
||||
cflags_str = make_flags_str(options["cflags"])
|
||||
if options["extra_cflags"] is not None:
|
||||
extra_cflags_str = make_flags_str(options["extra_cflags"])
|
||||
|
|
Loading…
Reference in New Issue