MCPcopy Create free account
hub / github.com/doldecomp/mkdd / resolve

Method resolve

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

Source from the content-addressed store, hash-verified

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

Callers 2

objectsMethod · 0.80
default_formatFunction · 0.80

Calls 2

ObjectClass · 0.85
out_pathMethod · 0.80

Tested by

no test coverage detected