papermario/tools/n64splat/list_objects.py
Ethan Roseman 5e12a46dd4 git subrepo clone (merge) https://github.com/ethteck/n64splat.git tools/n64splat
subrepo:
  subdir:   "tools/n64splat"
  merged:   "7574db712"
upstream:
  origin:   "https://github.com/ethteck/n64splat.git"
  branch:   "master"
  commit:   "7574db712"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"
2021-01-15 10:26:06 +09:00

33 lines
948 B
Python

#! /usr/bin/python3
import argparse
import yaml
from pathlib import PurePath
from split import initialize_segments
parser = argparse.ArgumentParser(description="List output objects for linker script")
parser.add_argument("config", help="path to a compatible config .yaml file")
def main(config_path):
# Load config
with open(config_path) as f:
config = yaml.safe_load(f.read())
options = config.get("options")
replace_ext = options.get("ld_o_replace_extension", True)
# Initialize segments
all_segments = initialize_segments(options, config_path, config["segments"])
for segment in all_segments:
for subdir, path, obj_type, start in segment.get_ld_files():
path = PurePath(subdir) / PurePath(path)
path = path.with_suffix(".o" if replace_ext else path.suffix + ".o")
print(path)
if __name__ == "__main__":
args = parser.parse_args()
main(args.config)