Skip to content

Commit

Permalink
Merge pull request #332 from lhearachel/scrseq-trdata-dependency
Browse files Browse the repository at this point in the history
Add trdata.naix as a dependency of compiler for scr_seq binaries
  • Loading branch information
lhearachel authored Jan 5, 2025
2 parents 03a4d5e + 0b55b97 commit 7fc646f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 41 deletions.
16 changes: 12 additions & 4 deletions res/field/scripts/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1131,14 +1131,25 @@ scr_seq_files = files(
'scripts_route_230.s',
)

# Field scripts have a dependency on `trdata.naix`, and so they require a
# custom generator.
field_script_gen = generator(make_script_bin_sh,
arguments: make_script_bin_args,
depends: [
make_script_bin_deps,
trdata_naix,
],
output: '@BASENAME@',
)

scr_seq_narc_order = files('scripts.order')

scr_seq_narc = custom_target('scr_seq.narc',
output: [
'scr_seq.narc',
'scr_seq.naix',
],
input: s_to_bin_gen.process(
input: field_script_gen.process(
scr_seq_files,
extra_args: ['--out-dir', scr_seq_private_dir]
),
Expand All @@ -1149,9 +1160,6 @@ scr_seq_narc = custom_target('scr_seq.narc',
'--output', '@OUTPUT0@',
'@PRIVATE_DIR@',
],
depends: [
trdata_narc,
],
)

nitrofs_files += scr_seq_narc[0]
Expand Down
52 changes: 26 additions & 26 deletions res/meson.build
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
nitrofs_files = []
naix_headers = []

subdir('pokemon')

### PREBUILT FILES ###
subdir('prebuilt')

### DECOMPILED DATA DIRECTORIES ###
subdir('text') # must be listed first for GMM header targets
# These subpaths are listed because the result of some build-rule inside them
# is a dependency of some later build-rule. e.g., `trdata.naix` is a dependency
# of the files compiled into `scr_seq.narc`.
subdir('pokemon')
subdir('trainers')
subdir('text')

# Common generator for "scripting" files, i.e. field and battle scripts
relative_source_root = fs.relative_to(meson.project_source_root(), meson.project_build_root())
Expand All @@ -17,23 +20,27 @@ copy_gen = generator(find_program('cp'),
output: '@PLAINNAME@'
)

make_script_bin_args = [
'-i', relative_source_root / 'include',
'-i', relative_source_root / 'asm',
'-i', '.' / 'res' / 'text',
'-i', '.' / 'res',
'-i', '.',
'--assembler', arm_none_eabi_gcc_exe.full_path(),
'--objcopy', arm_none_eabi_objcopy_exe.full_path(),
'@EXTRA_ARGS@',
'@INPUT@',
]

make_script_bin_deps = [
message_banks_narc, # for GMM headers
asm_consts_generators, # for ASM headers
c_consts_generators, # for C headers
]

s_to_bin_gen = generator(make_script_bin_sh,
arguments: [
'-i', relative_source_root / 'include',
'-i', relative_source_root / 'asm',
'-i', '.' / 'res' / 'text',
'-i', '.' / 'res',
'-i', '.',
'--assembler', arm_none_eabi_gcc_exe.full_path(),
'--objcopy', arm_none_eabi_objcopy_exe.full_path(),
'@EXTRA_ARGS@',
'@INPUT@',
],
depends: [
message_banks_narc, # for GMM headers
asm_consts_generators, # for ASM headers
c_consts_generators, # for C headers
],
arguments: make_script_bin_args,
depends: make_script_bin_deps,
output: '@BASENAME@'
)

Expand All @@ -57,13 +64,6 @@ nanr_gen = generator(nitrogfx_exe,
output: '@[email protected]'
)

lz_gen = generator(nitrogfx_exe,
arguments: [ '@INPUT@', '@OUTPUT@', '@EXTRA_ARGS@', ],
output: '@[email protected]',
)

subdir('trainers')

subdir('battle')
subdir('field')
subdir('fonts')
Expand Down
20 changes: 9 additions & 11 deletions res/trainers/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ trainer_party_gen = generator(

trainers_order = files('trainers.order')

trdata_narc = custom_target('trdata.narc',
trdata_target = custom_target('trdata.narc',
output: [
'trdata.narc',
'trdata.naix',
Expand All @@ -959,24 +959,22 @@ trdata_narc = custom_target('trdata.narc',
'@PRIVATE_DIR@',
],
)
trdata_narc = trdata_target[0]
trdata_naix = trdata_target[1]

# Do not generate an NAIX for `trpoke.narc`; it would go wholly unused
trpoke_narc = custom_target('trpoke.narc',
output: [
'trpoke.narc',
'trpoke.naix',
],
output: 'trpoke.narc',
input: trainer_party_gen.process(trainer_data_files, env: json2bin_env),
depends: [ py_consts_generators ],
command: [
narc_exe, 'create',
'--naix',
'--order', trainers_order,
'--output', '@OUTPUT0@',
'--output', '@OUTPUT@',
'@PRIVATE_DIR@',
]
)

nitrofs_files += trdata_narc[0]
nitrofs_files += trpoke_narc[0]
naix_headers += trdata_narc[1]
naix_headers += trpoke_narc[1]
nitrofs_files += trdata_narc
nitrofs_files += trpoke_narc
naix_headers += trdata_naix

0 comments on commit 7fc646f

Please sign in to comment.