mirror of
https://github.com/AntonioND/architectds.git
synced 2025-06-18 16:45:32 -04:00
core: Extract ninja rules generation out of NDS ROM object
This will be required for DSL files as well.
This commit is contained in:
parent
258d1fea78
commit
e42a00b12f
@ -133,6 +133,137 @@ def gen_out_file_list(in_files, in_prefix, out_prefix, in_suffix, out_suffix):
|
||||
|
||||
return files
|
||||
|
||||
def gen_rules_tools(destination):
|
||||
'''
|
||||
This generates rules for all possible tools used to generate NDS ROMs and
|
||||
saves it to the destination object.
|
||||
'''
|
||||
|
||||
destination.print(
|
||||
'# File generated by architectds\n'
|
||||
'\n'
|
||||
f'BLOCKSDS = {BLOCKSDS}\n'
|
||||
f'BLOCKSDSEXT = {BLOCKSDSEXT}\n'
|
||||
f'WONDERFUL_TOOLCHAIN = {WONDERFUL_TOOLCHAIN}\n'
|
||||
'\n'
|
||||
'ARM_NONE_EABI_PATH = ${WONDERFUL_TOOLCHAIN}/toolchain/gcc-arm-none-eabi/bin/\n'
|
||||
'LLVM_TEAK_PATH = ${WONDERFUL_TOOLCHAIN}/toolchain/llvm-teak/bin/\n'
|
||||
'\n'
|
||||
'PREFIX = ${ARM_NONE_EABI_PATH}arm-none-eabi-\n'
|
||||
'CC_ARM = ${PREFIX}gcc\n'
|
||||
'CXX_ARM = ${PREFIX}g++\n'
|
||||
'\n'
|
||||
'CC_TEAK = ${LLVM_TEAK_PATH}clang\n'
|
||||
'CXX_TEAK = ${LLVM_TEAK_PATH}clang++\n'
|
||||
'LD_TEAK = ${LLVM_TEAK_PATH}ld.lld\n'
|
||||
'\n'
|
||||
'BIN2C = ${BLOCKSDS}/tools/bin2c/bin2c\n'
|
||||
'GRIT = ${BLOCKSDS}/tools/grit/grit\n'
|
||||
'SQUEEZERW = ${BLOCKSDS}/tools/squeezer/squeezerw\n'
|
||||
'MMUTIL = ${BLOCKSDS}/tools/mmutil/mmutil\n'
|
||||
'NDSTOOL = ${BLOCKSDS}/tools/ndstool/ndstool\n'
|
||||
'TEAKTOOL = ${BLOCKSDS}/tools/teaktool/teaktool\n'
|
||||
'DSLTOOL = ${BLOCKSDS}/tools/dsltool/dsltool\n'
|
||||
'\n'
|
||||
)
|
||||
|
||||
# In MinGW, paths for executable files must start with 'C:/', but
|
||||
# python3 expects them to start with '/c/'.
|
||||
blocksdsext = BLOCKSDSEXT.replace('C:/', '/c/')
|
||||
destination.print(
|
||||
f'OBJ2DL = python3 {blocksdsext}/nitro-engine/tools/obj2dl/obj2dl.py\n'
|
||||
f'MD5_TO_DSMA = python3 {blocksdsext}/nitro-engine/tools/md5_to_dsma/md5_to_dsma.py\n'
|
||||
)
|
||||
|
||||
destination.print(
|
||||
'PTEXCONV = ${BLOCKSDSEXT}/ptexconv/ptexconv\n'
|
||||
'\n'
|
||||
'rule makedir\n'
|
||||
' command = mkdir $out\n'
|
||||
'\n'
|
||||
'rule copy\n'
|
||||
' command = cp $in $out\n'
|
||||
'\n'
|
||||
'rule bin2c\n'
|
||||
' command = ${BIN2C} $in $outdir\n'
|
||||
'\n'
|
||||
# mmutil crashes when there are two processes generating soundbanks
|
||||
# at the same time.
|
||||
'pool mmutil_pool\n'
|
||||
' depth = 1\n'
|
||||
'\n'
|
||||
'rule mmutil\n'
|
||||
' command = ${MMUTIL} $in -d -o${soundbank_bin} -h${soundbank_info_h}\n'
|
||||
' pool = mmutil_pool\n'
|
||||
'\n'
|
||||
'rule as_arm\n'
|
||||
' command = ${CC_ARM} ${asflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cc_arm\n'
|
||||
' command = ${CC_ARM} ${cflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cxx_arm\n'
|
||||
' command = ${CXX_ARM} ${cxxflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule ld_cc_arm\n'
|
||||
' command = ${CC_ARM} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule ld_cxx_arm\n'
|
||||
' command = ${CXX_ARM} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule as_teak\n'
|
||||
' command = ${CC_TEAK} ${asflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cc_teak\n'
|
||||
' command = ${CC_TEAK} ${cflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cxx_teak\n'
|
||||
' command = ${CXX_TEAK} ${cxxflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule ld_teak\n'
|
||||
' command = ${LD_TEAK} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule teaktool\n'
|
||||
' command = ${TEAKTOOL} -i $in -o $out\n'
|
||||
'\n'
|
||||
'rule dsltool\n'
|
||||
' command = ${DSLTOOL} -i ${elf_path} -o $out ${args}\n'
|
||||
'\n'
|
||||
'rule ndstool\n'
|
||||
' command = ${NDSTOOL} -c $out -7 ${arm7elf} -9 ${arm9elf} -b ${game_icon} ${game_full_title} ${ndstool_nitrofs_flags}\n'
|
||||
'\n'
|
||||
'rule grit\n'
|
||||
' command = ${GRIT} ${in_path_img} ${options} -o ${grit_out_path}\n'
|
||||
'\n'
|
||||
'rule squeezerw\n'
|
||||
' command = ${SQUEEZERW} ${args}\n'
|
||||
'\n'
|
||||
'rule grit_nf_shared\n'
|
||||
' command = ${GRIT} ${in_files_png} ${options}\n'
|
||||
'\n'
|
||||
'rule obj2dl\n'
|
||||
' command = ${OBJ2DL} --input ${in_path_obj} --output $out ${args}\n'
|
||||
'\n'
|
||||
'rule md5_to_dsma\n'
|
||||
' command = ${MD5_TO_DSMA} ${args}\n'
|
||||
'\n'
|
||||
'rule ptexconv\n'
|
||||
' command = ${PTEXCONV} ${args}\n'
|
||||
'\n'
|
||||
)
|
||||
|
||||
class GenericBinary():
|
||||
'''
|
||||
Class that defines any binary that may be built as a combination of multiple
|
||||
@ -2068,135 +2199,6 @@ class NdsRom(GenericBinary):
|
||||
# Other binaries don't require special handling
|
||||
pass
|
||||
|
||||
def _gen_rules_tools(self):
|
||||
'''
|
||||
This generates rules for all possible tools used to generate NDS ROMs.
|
||||
'''
|
||||
|
||||
self.print(
|
||||
'# File generated by architectds\n'
|
||||
'\n'
|
||||
f'BLOCKSDS = {BLOCKSDS}\n'
|
||||
f'BLOCKSDSEXT = {BLOCKSDSEXT}\n'
|
||||
f'WONDERFUL_TOOLCHAIN = {WONDERFUL_TOOLCHAIN}\n'
|
||||
'\n'
|
||||
'ARM_NONE_EABI_PATH = ${WONDERFUL_TOOLCHAIN}/toolchain/gcc-arm-none-eabi/bin/\n'
|
||||
'LLVM_TEAK_PATH = ${WONDERFUL_TOOLCHAIN}/toolchain/llvm-teak/bin/\n'
|
||||
'\n'
|
||||
'PREFIX = ${ARM_NONE_EABI_PATH}arm-none-eabi-\n'
|
||||
'CC_ARM = ${PREFIX}gcc\n'
|
||||
'CXX_ARM = ${PREFIX}g++\n'
|
||||
'\n'
|
||||
'CC_TEAK = ${LLVM_TEAK_PATH}clang\n'
|
||||
'CXX_TEAK = ${LLVM_TEAK_PATH}clang++\n'
|
||||
'LD_TEAK = ${LLVM_TEAK_PATH}ld.lld\n'
|
||||
'\n'
|
||||
'BIN2C = ${BLOCKSDS}/tools/bin2c/bin2c\n'
|
||||
'GRIT = ${BLOCKSDS}/tools/grit/grit\n'
|
||||
'SQUEEZERW = ${BLOCKSDS}/tools/squeezer/squeezerw\n'
|
||||
'MMUTIL = ${BLOCKSDS}/tools/mmutil/mmutil\n'
|
||||
'NDSTOOL = ${BLOCKSDS}/tools/ndstool/ndstool\n'
|
||||
'TEAKTOOL = ${BLOCKSDS}/tools/teaktool/teaktool\n'
|
||||
'DSLTOOL = ${BLOCKSDS}/tools/dsltool/dsltool\n'
|
||||
'\n'
|
||||
)
|
||||
|
||||
# In MinGW, paths for executable files must start with 'C:/', but
|
||||
# python3 expects them to start with '/c/'.
|
||||
blocksdsext = BLOCKSDSEXT.replace('C:/', '/c/')
|
||||
self.print(
|
||||
f'OBJ2DL = python3 {blocksdsext}/nitro-engine/tools/obj2dl/obj2dl.py\n'
|
||||
f'MD5_TO_DSMA = python3 {blocksdsext}/nitro-engine/tools/md5_to_dsma/md5_to_dsma.py\n'
|
||||
)
|
||||
|
||||
self.print(
|
||||
'PTEXCONV = ${BLOCKSDSEXT}/ptexconv/ptexconv\n'
|
||||
'\n'
|
||||
'rule makedir\n'
|
||||
' command = mkdir $out\n'
|
||||
'\n'
|
||||
'rule copy\n'
|
||||
' command = cp $in $out\n'
|
||||
'\n'
|
||||
'rule bin2c\n'
|
||||
' command = ${BIN2C} $in $outdir\n'
|
||||
'\n'
|
||||
# mmutil crashes when there are two processes generating soundbanks
|
||||
# at the same time.
|
||||
'pool mmutil_pool\n'
|
||||
' depth = 1\n'
|
||||
'\n'
|
||||
'rule mmutil\n'
|
||||
' command = ${MMUTIL} $in -d -o${soundbank_bin} -h${soundbank_info_h}\n'
|
||||
' pool = mmutil_pool\n'
|
||||
'\n'
|
||||
'rule as_arm\n'
|
||||
' command = ${CC_ARM} ${asflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cc_arm\n'
|
||||
' command = ${CC_ARM} ${cflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cxx_arm\n'
|
||||
' command = ${CXX_ARM} ${cxxflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule ld_cc_arm\n'
|
||||
' command = ${CC_ARM} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule ld_cxx_arm\n'
|
||||
' command = ${CXX_ARM} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule as_teak\n'
|
||||
' command = ${CC_TEAK} ${asflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cc_teak\n'
|
||||
' command = ${CC_TEAK} ${cflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule cxx_teak\n'
|
||||
' command = ${CXX_TEAK} ${cxxflags} -MMD -MP -c -o $out $in\n'
|
||||
' deps = gcc\n'
|
||||
' depfile = ${dep}\n'
|
||||
'\n'
|
||||
'rule ld_teak\n'
|
||||
' command = ${LD_TEAK} -o $out $in ${ldflags}\n'
|
||||
'\n'
|
||||
'rule teaktool\n'
|
||||
' command = ${TEAKTOOL} -i $in -o $out\n'
|
||||
'\n'
|
||||
'rule dsltool\n'
|
||||
' command = ${DSLTOOL} -i ${elf_path} -o $out ${args}\n'
|
||||
'\n'
|
||||
'rule ndstool\n'
|
||||
' command = ${NDSTOOL} -c $out -7 ${arm7elf} -9 ${arm9elf} -b ${game_icon} ${game_full_title} ${ndstool_nitrofs_flags}\n'
|
||||
'\n'
|
||||
'rule grit\n'
|
||||
' command = ${GRIT} ${in_path_img} ${options} -o ${grit_out_path}\n'
|
||||
'\n'
|
||||
'rule squeezerw\n'
|
||||
' command = ${SQUEEZERW} ${args}\n'
|
||||
'\n'
|
||||
'rule grit_nf_shared\n'
|
||||
' command = ${GRIT} ${in_files_png} ${options}\n'
|
||||
'\n'
|
||||
'rule obj2dl\n'
|
||||
' command = ${OBJ2DL} --input ${in_path_obj} --output $out ${args}\n'
|
||||
'\n'
|
||||
'rule md5_to_dsma\n'
|
||||
' command = ${MD5_TO_DSMA} ${args}\n'
|
||||
'\n'
|
||||
'rule ptexconv\n'
|
||||
' command = ${PTEXCONV} ${args}\n'
|
||||
'\n'
|
||||
)
|
||||
|
||||
def _gen_rules_nds(self):
|
||||
'''
|
||||
@ -2248,7 +2250,7 @@ class NdsRom(GenericBinary):
|
||||
binaries or NitroFS, are optional.
|
||||
'''
|
||||
# General rules for all used tools
|
||||
self._gen_rules_tools()
|
||||
gen_rules_tools(self)
|
||||
|
||||
# Rules to build each sub-binary
|
||||
for binary in self.sub_binaries:
|
||||
|
Loading…
Reference in New Issue
Block a user