Refactor dependency chain on pokedex data NARCs and text banks

- All affected targets no longer take a list of source files as input
and instead derive source-files from the SPECIES environment variable.
- Text banks no longer depend on auto-generated constants, which means
that changing a constant does not implicitly soil the text bank archive.
This commit is contained in:
Rachel 2025-01-29 23:05:52 -08:00
parent 2e4e858081
commit 7c99b08629
6 changed files with 35 additions and 40 deletions

View File

@ -113,3 +113,6 @@ endforeach
species_txt = files('species.txt')
text_banks_txt = files('text_banks.txt')
py_consts_env = environment()
py_consts_env.append('PYTHONPATH', meson.project_build_root())

View File

@ -35,6 +35,7 @@ poke_icon_files = []
pokegra_files = []
otherpoke_index = {} # otherpoke uses a unique, non-uniform structure
pokemon_data_root = meson.current_source_dir()
# 1. These static files must always exist.
icons_shared = files(
@ -102,6 +103,7 @@ endforeach
# use of it.
species_env = environment()
species_env.append('SPECIES', species_dirnames, separator: ';')
species_env.append('PYTHONPATH', meson.project_build_root()) # For python scripts
# Order of extra personal files for mon forms
@ -195,7 +197,7 @@ datagen_species_out = custom_target('datagen_species_out',
command: [
datagen_species_exe,
meson.current_build_dir(),
meson.current_source_dir(),
pokemon_data_root,
form_data_order,
files('move_tutors.json'),
],
@ -261,8 +263,7 @@ pl_otherpoke_narc = custom_target('pl_otherpoke.narc',
pl_pokezukan_narc = custom_target('pl_pokezukan.narc',
output: 'pl_pokezukan.narc',
input: species_data_files,
env: json2bin_env,
env: py_consts_env,
command: [
make_pl_pokezukan_py,
'--narc', narc_exe,
@ -275,8 +276,7 @@ pl_pokezukan_narc = custom_target('pl_pokezukan.narc',
shinzukan_narc = custom_target('shinzukan.narc',
output: 'shinzukan.narc',
input: species_data_files,
env: json2bin_env,
env: py_consts_env,
command: [
make_shinzukan_py,
'--narc', narc_exe,
@ -300,16 +300,8 @@ pl_growtbl_narc = custom_target('pl_growtbl.narc',
]
)
pokedex_data_srcs = files()
foreach pokemon : species_dirnames
pokedex_data_srcs += files(pokemon / 'data.json')
endforeach
pokedex_data_narc = custom_target('zukan_data.narc',
output: 'zukan_data.narc',
input: pokedex_data_srcs,
env: json2bin_env,
depends: [ py_consts_generators ],
command: [
make_pokedex_data_py,
'--narc', narc_exe,
@ -317,15 +309,14 @@ pokedex_data_narc = custom_target('zukan_data.narc',
'--private-dir', '@PRIVATE_DIR@',
'--output-dir', '@OUTDIR@',
'giratina_origin',
pokedex_data_srcs
]
],
env: species_env,
depends: [ py_consts_generators ],
depend_files: [ species_data_files ],
)
pokedex_data_giratina_altered_narc = custom_target('zukan_data_gira.narc',
output: 'zukan_data_gira.narc',
input: pokedex_data_srcs,
env: json2bin_env,
depends: [ py_consts_generators ],
command: [
make_pokedex_data_py,
'--narc', narc_exe,
@ -333,8 +324,10 @@ pokedex_data_giratina_altered_narc = custom_target('zukan_data_gira.narc',
'--private-dir', '@PRIVATE_DIR@',
'--output-dir', '@OUTDIR@',
'giratina_altered',
pokedex_data_srcs
]
],
env: species_env,
depends: [ py_consts_generators ],
depend_files: [ species_data_files ],
)
species_header_target = meson.current_build_dir()
@ -342,7 +335,7 @@ species_header_target = meson.current_build_dir()
gen_species_headers = custom_target('gen_species_headers',
output: 'footprint_data.h',
input: species_data_files,
env: json2bin_env,
env: py_consts_env,
depends: [ py_consts_generators ],
command: [
make_species_tables_py,

View File

@ -71,15 +71,13 @@ gmm_to_bin_gen = generator(msgenc_exe,
# 5. Set up targets which build generated text banks and build the final NARC.
pokedex_text_banks = custom_target('pokedex_text_banks',
output: pokedex_text_bank_names,
input: pokedex_data_srcs,
env: json2bin_env,
depends: [ py_consts_generators ],
command: [
make_pokedex_message_banks_py,
'--source-dir', '@CURRENT_SOURCE_DIR@',
make_pokedex_text_banks_py,
'--source-dir', pokemon_data_root,
'--output-dir', '@OUTDIR@',
pokedex_data_srcs
]
],
env: species_env,
depend_files: [ species_data_files ],
)
text_bank_files += pokedex_text_banks

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import json
import os
import pathlib
import subprocess
@ -9,6 +10,9 @@ from generated.pokemon_types import PokemonType
from generated.species import Species
SPECIES_DIRS = os.environ['SPECIES'].split(';')
argparser = argparse.ArgumentParser(
prog='make_pokedex_data_py',
description='Packs the archive containing Pokedex sorting'
@ -27,9 +31,6 @@ argparser.add_argument('-o', '--output-dir',
help='Path to the output directory (where the NARC will be made)')
argparser.add_argument('giratina_form',
help='String of either giratina_origin or giratina_altered')
argparser.add_argument('src_files',
nargs='+',
help='List of files to process in-order')
args = argparser.parse_args()
source_dir = pathlib.Path(args.source_dir)
@ -67,7 +68,8 @@ heightData = [0 for i in range(NUM_POKEMON)]
weightData = [0 for i in range(NUM_POKEMON)]
nameData = ['' for i in range(NUM_POKEMON)]
for i, file in enumerate(args.src_files):
for i, species_dir in enumerate(SPECIES_DIRS):
file = source_dir / species_dir / 'data.json'
with open(file, 'r', encoding='utf-8') as data_file:
pkdata = json.load(data_file)
pk_name = pkdata['name'].lower()

View File

@ -1,10 +1,11 @@
#!/usr/bin/env python3
import argparse
import json
import os
import pathlib
import xml.etree.ElementTree as ET
from generated.species import Species
SPECIES_DIRS = os.environ['SPECIES'].split(';')
argparser = argparse.ArgumentParser(
prog='make_pokedex_message_banks_py',
@ -12,13 +13,10 @@ argparser = argparse.ArgumentParser(
)
argparser.add_argument('-s', '--source-dir',
required=True,
help='Path to the source directory (res/text/pokedex_message_banks)')
help='Path to the pokemon sources directory (res/pokemon)')
argparser.add_argument('-o', '--output-dir',
required=True,
help='Path to the output directory (where the gmm files will be made)')
argparser.add_argument('src_files',
nargs='+',
help='List of files to process in-order')
args = argparser.parse_args()
source_dir = pathlib.Path(args.source_dir)
@ -58,7 +56,7 @@ def Convert_Height(decimeters):
return f'{feet}{inches:02}'
# variables
NUM_POKEMON = len(Species)
NUM_POKEMON = len(SPECIES_DIRS)
name_data = ['' for i in range(NUM_POKEMON)]
name_articles = ['' for i in range(NUM_POKEMON)]
@ -71,7 +69,8 @@ name_number = ['' for i in range(NUM_POKEMON-2)]
dex_categories = ['' for i in range(NUM_POKEMON-2)]
# collect data
for i, file in enumerate(args.src_files):
for i, species_dir in enumerate(SPECIES_DIRS):
file = source_dir / species_dir / 'data.json'
with open(file, 'r', encoding='utf-8') as data_file:
pkdata = json.load(data_file)
pokemon_name = pkdata['name']

View File

@ -7,5 +7,5 @@ make_shinzukan_py = find_program('make_shinzukan.py', native: true)
make_pl_growtbl_py = find_program('make_pl_growtbl.py', native: true)
make_species_tables_py = find_program('make_species_tables.py', native: true)
make_pokedex_data_py = find_program('make_pokedex_data.py', native: true)
make_pokedex_message_banks_py = find_program('make_pokedex_message_banks.py', native: true)
make_pokedex_text_banks_py = find_program('make_pokedex_text_banks.py', native: true)
make_pokedex_enc_platinum_py = find_program('make_pokedex_enc_platinum.py', native: true)