Skip to content

fix(build): CMake defines _PSP_FW_VERSION; samples build together - #161

Merged
dogo merged 5 commits into
masterfrom
fix/build-consistency
Nov 5, 2026
Merged

dogo merged 5 commits into
masterfrom
fix/build-consistency

Conversation

@dogo

@dogo dogo commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Make and CMake now select the same savedata firmware path. The 13 sample CMake projects share linking, packaging and asset handling through cmake/OSLibSample.cmake, with each executable and package written into its own build directory.

Problem Fix
CMake defined PSP_FW_VERSION, while savedata tests _PSP_FW_VERSION Define _PSP_FW_VERSION=371, matching PSPSDK Make builds
Third-party sources must retain the same preprocessing as Make Undefine that macro for those sources; intraFont's libccc.c retains its existing stdio path
Aggregate samples overwrote shared EBOOT/SFO outputs and collided with helloWorld/ on case-insensitive filesystems Use CMAKE_CURRENT_BINARY_DIR for each sample's executable and package
Asset copying included build trees and could copy a nested build into itself Exclude ancestors of the active binary directory using separator-aware comparison, and directories containing CMake caches recursively
Sample CMake files duplicated SDK lookup, libraries, packaging and asset copying Share that setup in OSLibSample.cmake; retain each sample's library order and additional dependencies
Target names differed from project directories; rectAndFonts emitted dialog and shapes used the Hello World title Match target/executable names to directory names and case; correct the package titles
The C++ sample's source/header could be copied as assets Exclude .cpp and .hpp alongside existing source/build exclusions
samples/audio/
  Resources/                  -> copied as assets
  cbuild/                     -> excluded (completed standalone build)
  build/debug/                -> excluded (active or completed nested build)

samples/cbuild/
  audio/EBOOT.PBP
  helloWorld/EBOOT.PBP
  ...                         -> one package per sample

The branch incorporates master through 4ca7d2b, including the merged fixes from #155–160. The integration and additional build fixes are committed as a7f728d; 94c75d5 centralizes and standardizes the sample CMake projects.

Evidence

Validation of the integrated tree:

  • Before: configuring the actual helloWorld sample with a binary directory beneath build/debug generated a copy from build into build/debug/build. The PSP build failed with File name too long, exit 2, after creating about 270 MiB of recursive copies.
    After: the PSP toolchain successfully builds audio/build/debug; its EBOOT exists, its BGM is byte-identical to the source, and no build parent or nested cache is copied into it.
  • All 13 standalone sample builds and a fresh combined build pass. The combined output has 13 packages, no copied standalone/nested build caches, and a byte-identical audio asset.
  • The exact updated asset loop also passes native checks for the first configure before a cache exists, completed direct/nested caches, a legitimate build/ asset alongside build-debug/, and Resources/ preservation. All 13 samples now use that guard through the shared helper.
  • The final standardization passes all 13 standalone builds, 13 targets in the combined build, and the nested audio/build/debug build with the PSP toolchain. Actual PARAM.SFO and embedded EBOOT titles match all 13 expected titles. Executable names match directory names and case; rectAndFonts emits rectAndFonts, and shapes is titled Shapes Sample. C++ sources/headers are excluded from copied assets.
  • All original named libraries, their order and per-sample extras are retained. Native fixture checks also cover the shared helper's asset handling.
  • Make and CMake library builds both pass with PSP GCC 15.2. Both have 102 compilation units: CMake keeps firmware 371 on 49 owned units and undefines it on 53 third-party units.
  • Actual Make/CMake preprocessing produces identical token streams for saveload.c: one key helper and all seven calls. libccc.c preprocessing is also equivalent and retains stdio.
  • Both archives expose the same 630 global symbols. This is symbol parity, not a claim of binary or full runtime equivalence; Make uses O2 and CMake Release uses O3.
  • The integrated host suite passes 6/6 with ASan/UBSan; the existing HTTP runner cleanup check passes.

CI now builds the nested audio case before the aggregate build, checks package isolation, rejects copied CMake caches/build parents, and compares representative assets byte-for-byte. It also requires the rectAndFonts executable, rejects its old dialog output, and rejects copied C++ sources/headers in shapes. YAML, shell syntax and contamination/corruption fixture checks pass.

No examples or savedata compatibility tests were executed on a real PSP during this validation.

Merge Danger

Door: two-way

Blast Radius: CMake builds

  • CMake-built libraries now copy the savedata key as Make-built libraries already did. Compatibility with saves previously produced by CMake without that key has not been verified on hardware.
  • Applications using cmake/PSP.cmake receive the SDK-compatible firmware macro.
  • Aggregate sample packages move into per-sample directories.
  • Sample CMake target and executable names now match their folder names, including case. Scripts invoking old target names must be updated; aliases are not retained. The separate Makefile targets are unchanged.
  • Asset directories containing CMake caches, and ancestors of the active binary directory, are excluded. Ordinary sample resources remain copied.

dogo added 2 commits November 4, 2026 00:12
The code tests _PSP_FW_VERSION (savedata's key, in all 7 dialogs), which
the PSPSDK's build.mak defines for Make builds; cmake/PSP.cmake defined
PSP_FW_VERSION instead. The same source then built two libraries: in
the CMake one, oslSetSavedataKey and its calls were compiled out.

PSP.cmake now defines both. Third-party sources keep it undefined, as
the Makefile's CFLAGS_THIRD_PARTY does: intraFont's libccc has an sceIo
path under #ifdef _PSP_FW_VERSION that neither build uses (its error
check tests _PSP, which nothing defines).

Preprocessed src/saveload.c: oslSetSavedataKey() appears 8 times with
Make, 0 with CMake on master, 8 now. Comparing the symbols of all 102
objects between the two builds, the rest only differ in functions that
CMake's -O3 inlines.
Every sample put its executable, PARAM.SFO, EBOOT.PBP and assets in
CMAKE_BINARY_DIR. Built one at a time that is the sample's own build
directory, but samples/CMakeLists.txt builds them all in one tree: the
13 samples overwrote each other's EBOOT.PBP (one left at the end), and
on macOS's case-insensitive filesystem the helloworld executable
collides with the helloWorld/ directory. They now use
CMAKE_CURRENT_BINARY_DIR, which is the same directory when a sample is
built alone.

The combined build now gives 13 EBOOT.PBP, one per sample directory,
and nothing at the top; building helloWorld and map alone still puts
EBOOT.PBP in their cbuild/. CI builds the samples together too and
checks there is one EBOOT.PBP per sample (its macOS runners cover the
case-insensitive case).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T04:53:02.012114Z 94c75d5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bc77000877

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/Build.yml Resolved
dogo added 3 commits November 4, 2026 00:21
Each sample copies every non-source entry of its directory next to its
EBOOT.PBP, build directories included. A sample built alone has its
build tree (cbuild/) inside that directory, so every rebuild copied it
into itself (cbuild/cbuild/cbuild/EBOOT.PBP, ELFs and CMakeFiles
included), and the combined build copied each standalone build into
its own output. That is why the new CI check counted 39 EBOOT.PBP for
13 samples on every runner; reported by the Codex review on #161.

The copy now skips directories holding a CMakeCache.txt and the build
directory itself (no cache yet on the first configure). The CI check
also counts only cbuild/<sample>/EBOOT.PBP.

Running the workflow's two samples steps in a copy of the tree: 39
packages and 39 nested copies before, 13 and 0 now; audio rebuilt three
times on its own keeps one EBOOT.PBP and still copies its Resources/.
@dogo
dogo merged commit be529c6 into master Nov 5, 2026
14 checks passed
@dogo
dogo deleted the fix/build-consistency branch November 5, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant