papermario/tools/splat/util/options.py
Ethan Roseman 647db26552
Mass function rename from Star Rod + a couple funcs (#298)
* .

* yaml update

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "cd690f725d"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "cd690f725d"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* separate main bss syms

* renames and one match

* SR symbol rename

* fix symbol_addrs

* git subrepo pull tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "5fa8aa24ca"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "5fa8aa24ca"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "2f68596"

* remove old artifacts
2021-06-30 11:27:12 +09:00

90 lines
2.6 KiB
Python

from typing import Dict, List, Optional
from pathlib import Path
from util import log
opts = {}
def initialize(config: Dict, config_path: str, base_path=None, target_path=None):
global opts
opts = dict(config.get("options", {}))
if base_path:
opts["base_path"] = Path(base_path)
else:
if not "base_path" in opts:
log.error("Error: Base output dir not specified as a command line arg or via the config yaml (base_path)")
opts["base_path"] = Path(config_path).parent / opts["base_path"]
if not target_path:
if "target_path" not in opts:
log.error("Error: Target binary path not specified as a command line arg or via the config yaml (target_path)")
def set(opt, val):
opts[opt] = val
def get(opt, default=None):
return opts.get(opt, default)
def get_platform() -> str:
return opts.get("platform", "n64")
def get_compiler() -> str:
return opts.get("compiler", "IDO")
def get_header_encoding() -> str:
return opts.get("header_encoding", "ASCII")
def get_subalign() -> int:
return opts.get("subalign", 16)
def mode_active(mode):
return mode in opts["modes"] or "all" in opts["modes"]
def get_base_path() -> Path:
return Path(opts["base_path"])
def get_asset_path() -> Path:
return get_base_path() / opts.get("asset_path", "assets")
def get_target_path() -> Path:
return get_base_path() / opts["target_path"]
def get_src_path() -> Path:
return get_base_path() / opts.get("src_path", "src")
def get_asm_path() -> Path:
return get_base_path() / opts.get("asm_path", "asm")
def get_cache_path():
return get_base_path() / opts.get("cache_path", ".splat_cache")
def get_undefined_funcs_auto_path():
return get_base_path() / opts.get("undefined_funcs_auto_path", "undefined_funcs_auto.txt")
def get_undefined_syms_auto_path():
return get_base_path() / opts.get("undefined_syms_auto_path", "undefined_syms_auto.txt")
def get_symbol_addrs_path():
return get_base_path() / opts.get("symbol_addrs_path", "symbol_addrs.txt")
def get_build_path():
# TODO maybe can just return build_path...
return Path(get_base_path() / opts.get("build_path", "build")).relative_to(get_base_path())
def get_ld_script_path():
return get_base_path() / opts.get("ld_script_path", f"{opts.get('basename')}.ld")
def get_linker_symbol_header_path() -> Optional[Path]:
if "linker_symbol_header_path" in opts:
return get_base_path() / str(opts["linker_symbol_header_path"])
else:
return None
def get_extensions_path():
ext_opt = opts.get("extensions_path")
if not ext_opt:
return None
return get_base_path() / ext_opt