mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -04:00
package: stage src/ and mods/, and gate on CMakeLists references
Final Fantasy VII shipped a release zip whose CMakeLists.txt compiles
src/ff7_mods.c, but the zip had no src/ at all. Installing it died at
configure with "Cannot find source file" and "No SOURCES given to target:
psx-runtime". The commit that added the widescreen mod plugin updated
CMakeLists.txt but not the packaging allowlist, and nothing checked.
The allowlist in the generated scripts/package_setup_release.sh is a closed
list that has to be kept in sync with CMakeLists.txt by hand, so this is a
class problem, not a one-off: of 23 game repos with a packaging script, all
23 carry mods/ and only 3 stage it; 7 carry src/ and only 2 stage it. Those
3 are hand-patched copies of this same fix, which is the tell.
Two changes:
1. templates/package_setup_release.sh.in stages src/ and mods/ when the
project has them, using the existing EXTRA_PROJECT idiom (copy_proj hard
-fails on a missing path, so they cannot be added unconditionally).
src/ holds game-owned C that CMakeLists compiles in; mods/preloaded/
packages holds the markers those plugins select themselves through, so
without it a mod is built and never enabled.
2. package_setup_host.sh now refuses to zip a stage that cannot configure
itself: every ${CMAKE_CURRENT_SOURCE_DIR}/<rel> the staged CMakeLists.txt
names must exist in the stage. Paths used only inside if(EXISTS "...")
are optional by construction and are skipped, as are globs and paths
built from cmake variables. This turns a silent omission that surfaces on
a user's machine into a release-time failure.
Verified against the real FF7 CMakeLists: the stage as shipped fails naming
exactly src/ff7_mods.c; with src/ staged it passes; the guarded
mods/preloaded/packages reference correctly does not fail a project without
mods/.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L1TpXRJve6WvwyZbSJAbCL
This commit is contained in:
@@ -36,6 +36,19 @@ fi
|
||||
if [[ -f "${ROOT}/game_options.toml" ]]; then
|
||||
EXTRA_PROJECT+=(--project-file game_options.toml)
|
||||
fi
|
||||
# Game-owned C that CMakeLists.txt compiles into the runtime — mod activation
|
||||
# plugins live here (CODEGEN_SETUP_SOURCES "src/<game>_mods.c"). Leaving this
|
||||
# out ships a CMakeLists that references a file the zip does not contain, so
|
||||
# the build dies at configure with "Cannot find source file".
|
||||
if [[ -d "${ROOT}/src" ]]; then
|
||||
EXTRA_PROJECT+=(--project-dir src)
|
||||
fi
|
||||
# Preloaded mod packages (mods/preloaded/packages/<id>). The activation plugin
|
||||
# above is compiled in, but selects itself through these marker files; without
|
||||
# them the mod is built and never enabled.
|
||||
if [[ -d "${ROOT}/mods" ]]; then
|
||||
EXTRA_PROJECT+=(--project-dir mods)
|
||||
fi
|
||||
|
||||
cd "${ROOT}"
|
||||
exec bash "${PACKAGER}" \
|
||||
|
||||
@@ -389,6 +389,37 @@ downloads the toolchain pack (or uses RETCOMM_TOOLCHAIN_DIR), and preserves
|
||||
saves/user config across updates.
|
||||
EOF
|
||||
|
||||
# --- Gate: the staged tree must be able to configure itself ----------------
|
||||
# The project file/dir list is an allowlist, so any path a project adds to
|
||||
# CMakeLists.txt has to be added here too. When that is missed the zip still
|
||||
# builds and only fails on the user's machine, at cmake configure, with
|
||||
# "Cannot find source file". Catch it at package time instead.
|
||||
#
|
||||
# Only unguarded references are required: a path used solely inside
|
||||
# if(EXISTS "...") is optional by construction, and a glob or a path built from
|
||||
# a cmake variable cannot be resolved here.
|
||||
if [[ -f "${STAGE}/CMakeLists.txt" ]]; then
|
||||
cml="${STAGE}/CMakeLists.txt"
|
||||
guarded="$(grep -oE 'if\(EXISTS[[:space:]]+"\$\{CMAKE_CURRENT_SOURCE_DIR\}/[^"]+"' "${cml}" \
|
||||
| sed -E 's|.*\$\{CMAKE_CURRENT_SOURCE_DIR\}/||; s|"$||' | sort -u)"
|
||||
missing_refs=()
|
||||
while IFS= read -r rel; do
|
||||
[[ -z "${rel}" ]] && continue
|
||||
case "${rel}" in *"*"*|*"?"*|*'$'*) continue ;; esac
|
||||
if [[ -n "${guarded}" ]] && grep -qxF -- "${rel}" <<<"${guarded}"; then
|
||||
continue
|
||||
fi
|
||||
[[ -e "${STAGE}/${rel}" ]] || missing_refs+=("${rel}")
|
||||
done < <(grep -oE '\$\{CMAKE_CURRENT_SOURCE_DIR\}/[^"]+' "${cml}" \
|
||||
| sed 's|^\${CMAKE_CURRENT_SOURCE_DIR}/||' | sort -u)
|
||||
if (( ${#missing_refs[@]} )); then
|
||||
echo "error: CMakeLists.txt references paths that are not staged in the zip:" >&2
|
||||
for r in "${missing_refs[@]}"; do echo " - ${r}" >&2; done
|
||||
echo " add them via --project-file / --project-dir in scripts/package_setup_release.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
find "${STAGE}" -exec touch -c {} + 2>/dev/null || find "${STAGE}" -exec touch {} +
|
||||
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user