papermario/tools/splat/util/options.py
Ethan Roseman 3315d6010f
Splat refactor (#257)
* all non-world rodata migrated

* data disasm

* kinda working

* updated yaml

* bloop

* linker header

* configure 2.0

* bin

* mass rename to remove code_

* pause rename

* battle partner stuff

* whew

* more renames

* more renames

* more renaming

* it builds!

* updates

* remove main prefix

* one more thing

* crc, yay0

* .data, .rodata, .bss

* img

* dead_atan2

* it buildsgit add -A

* split battle/partner/6FAD10

* rm &s on sleepy_sheep syms

* sha1sum ninja rule description

* OK but commented out PaperMarioMapFS and PaperMarioNpcSprites

* uncomment

* fix mapfs

* match func_8003CFB4

* .

* clean up and name npc_iter_no_op

* npc.c

* enable cc warnings

* name npc_find_near

* use singular options.asset_path

* smores

* cc_dsl only when needed

* kinda fix configure for splat refactor2

* ok!

* new msg format

* remove old msg format docs

* slight bug fixes, splat adjustment

* git subrepo pull (merge) --force tools/splat

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

* git subrepo pull (merge) --force tools/splat

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

* Update symbol addrs

* git subrepo pull tools/splat

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

Co-authored-by: Alex Bates <hi@imalex.xyz>
2021-04-13 16:47:52 +09:00

86 lines
2.5 KiB
Python

from typing import Dict, 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_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():
return get_base_path() / opts.get("build_path", "build")
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