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

Class Object

tools/project.py:48–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48class Object:
49 def __init__(self, completed: bool, name: str, **options: Any) -> None:
50 self.name = name
51 self.completed = completed
52 self.options: Dict[str, Any] = {
53 "add_to_all": None,
54 "asflags": None,
55 "asm_dir": None,
56 "cflags": None,
57 "extra_asflags": [],
58 "extra_cflags": [],
59 "extra_clang_flags": [],
60 "host": None,
61 "lib": None,
62 "mw_version": None,
63 "progress_category": None,
64 "scratch_preset_id": None,
65 "shift_jis": None,
66 "source": name,
67 "src_dir": None,
68 }
69 self.options.update(options)
70
71 # Internal
72 self.src_path: Optional[Path] = None
73 self.asm_path: Optional[Path] = None
74 self.src_obj_path: Optional[Path] = None
75 self.asm_obj_path: Optional[Path] = None
76 self.host_obj_path: Optional[Path] = None
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 )

Callers 2

configure.pyFile · 0.90
resolveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected