mirror of
https://github.com/zeldaret/tww.git
synced 2025-02-19 22:41:00 +00:00
matDL build rule: Allow specifying global/local scope
This commit is contained in:
parent
89c74d0133
commit
a25031175e
@ -2217,6 +2217,8 @@ extract:
|
||||
header: assets/g_dTree_shadowMatDL.h
|
||||
header_type: none
|
||||
custom_type: matDL
|
||||
custom_data:
|
||||
scope: global
|
||||
|
||||
- symbol: l_chainS3TCTEX!.data:0x803769e0
|
||||
binary: assets/l_chainS3TCTEX__d_chain.bin
|
||||
|
@ -1801,6 +1801,8 @@ extract:
|
||||
header: assets/g_dTree_shadowMatDL.h
|
||||
header_type: none
|
||||
custom_type: matDL
|
||||
custom_data:
|
||||
scope: global
|
||||
|
||||
- symbol: l_chainS3TCTEX!.data:0x80369e80
|
||||
binary: assets/l_chainS3TCTEX__d_chain.bin
|
||||
|
@ -1813,6 +1813,8 @@ extract:
|
||||
header: assets/g_dTree_shadowMatDL.h
|
||||
header_type: none
|
||||
custom_type: matDL
|
||||
custom_data:
|
||||
scope: global
|
||||
|
||||
- symbol: l_chainS3TCTEX!.data:0x8037d6c0
|
||||
binary: assets/l_chainS3TCTEX__d_chain.bin
|
||||
|
@ -1741,7 +1741,7 @@ config.libs = [
|
||||
config.custom_build_rules = [
|
||||
{
|
||||
"name": "convert_matDL",
|
||||
"command": "$python tools/converters/matDL_dis.py $in $out --symbol $symbol",
|
||||
"command": "$python tools/converters/matDL_dis.py $in $out --symbol $symbol --scope $scope",
|
||||
"description": "CONVERT $symbol",
|
||||
},
|
||||
]
|
||||
@ -1755,6 +1755,7 @@ out_dir = config.build_dir / version
|
||||
# This generates the build steps needed for preprocessing
|
||||
def emit_build_rule(asset):
|
||||
steps = config.custom_build_steps.setdefault("pre-compile", [])
|
||||
custom_data = asset.get("custom_data") or {}
|
||||
|
||||
match asset.get("custom_type"):
|
||||
case None:
|
||||
@ -1768,6 +1769,7 @@ def emit_build_rule(asset):
|
||||
"outputs": out_dir / "include" / asset["header"],
|
||||
"variables": {
|
||||
"symbol": asset["symbol"],
|
||||
"scope": custom_data.get("scope", "local")
|
||||
},
|
||||
"implicit": Path("tools/converters/matDL_dis.py"),
|
||||
}
|
||||
|
@ -322,7 +322,7 @@ def read_u16(binary_file):
|
||||
return struct.unpack(">H", chunk)[0]
|
||||
|
||||
|
||||
def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name):
|
||||
def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name, scope):
|
||||
# Load data
|
||||
macro_name = os.path.splitext(os.path.basename(src_path))[0]
|
||||
with open(src_path, "rb") as binary_file, open(dest_path, "w") as c_file:
|
||||
@ -340,8 +340,13 @@ def convert_binary_to_matDL_c_source(src_path, dest_path, symbol_name):
|
||||
line_with_escape = line + (" "*(99-len(line))) + "\\\n"
|
||||
c_file.write(line_with_escape)
|
||||
|
||||
if scope == "local":
|
||||
var_def_prefix = "static "
|
||||
else:
|
||||
var_def_prefix = ""
|
||||
|
||||
write_macro_line(f"#define {macro_name}(TEX_NAME)")
|
||||
write_macro_line(f"u8 {symbol_name}[] ALIGN_DECL(32) = {{")
|
||||
write_macro_line(f"{var_def_prefix}u8 {symbol_name}[] ALIGN_DECL(32) = {{")
|
||||
|
||||
while True:
|
||||
command_type = read_u8(binary_file)
|
||||
@ -407,10 +412,20 @@ def main():
|
||||
)
|
||||
parser.add_argument("src_path", type=str, help="Binary source file path")
|
||||
parser.add_argument("dest_path", type=str, help="Destination C include file path")
|
||||
parser.add_argument("--symbol", type=str, help="Symbol name")
|
||||
parser.add_argument(
|
||||
"--symbol",
|
||||
type=str,
|
||||
help="Symbol name",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--scope",
|
||||
choices=["global", "local"],
|
||||
default="local",
|
||||
help="The scope of the symbol",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
convert_binary_to_matDL_c_source(args.src_path, args.dest_path, args.symbol)
|
||||
convert_binary_to_matDL_c_source(args.src_path, args.dest_path, args.symbol, args.scope)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user