MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / resolve

Method resolve

tools/project.py:79–126  ·  view source on GitHub ↗
(self, config: "ProjectConfig", lib: Library)

Source from the content-addressed store, hash-verified

77 self.ctx_path: Optional[Path] = None
78
79 def resolve(self, config: "ProjectConfig", lib: Library) -> "Object":
80 # Use object options, then library options
81 obj = Object(self.completed, self.name, **lib)
82 for key, value in self.options.items():
83 if value is not None or key not in obj.options:
84 obj.options[key] = value
85
86 # Use default options from config
87 def set_default(key: str, value: Any) -> None:
88 if obj.options[key] is None:
89 obj.options[key] = value
90
91 set_default("add_to_all", True)
92 set_default("asflags", config.asflags)
93 set_default("asm_dir", config.asm_dir)
94 set_default("host", False)
95 set_default("mw_version", config.linker_version)
96 set_default("scratch_preset_id", config.scratch_preset_id)
97 set_default("shift_jis", config.shift_jis)
98 set_default("src_dir", config.src_dir)
99
100 # Validate progress categories
101 def check_category(category: str):
102 if not any(category == c.id for c in config.progress_categories):
103 sys.exit(
104 f"Progress category '{category}' missing from config.progress_categories"
105 )
106
107 progress_category = obj.options["progress_category"]
108 if isinstance(progress_category, list):
109 for category in progress_category:
110 check_category(category)
111 elif progress_category is not None:
112 check_category(progress_category)
113
114 # Resolve paths
115 build_dir = config.out_path()
116 obj.src_path = Path(obj.options["src_dir"]) / obj.options["source"]
117 if obj.options["asm_dir"] is not None:
118 obj.asm_path = (
119 Path(obj.options["asm_dir"]) / obj.options["source"]
120 ).with_suffix(".s")
121 base_name = Path(self.name).with_suffix("")
122 obj.src_obj_path = build_dir / "src" / f"{base_name}.o"
123 obj.asm_obj_path = build_dir / "mod" / f"{base_name}.o"
124 obj.host_obj_path = build_dir / "host" / f"{base_name}.o"
125 obj.ctx_path = build_dir / "src" / f"{base_name}.ctx"
126 return obj
127
128
129class ProgressCategory:

Callers 3

objectsMethod · 0.80
default_formatFunction · 0.80
extract_info.pyFile · 0.80

Calls 2

ObjectClass · 0.85
out_pathMethod · 0.80

Tested by

no test coverage detected