Skip to content

NSP script: --platform mac prepares a game for a Mac run and skips the iOS shaders, app and IPA - #82

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:nsp-mac-only
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:nsp-mac-only

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

A development option: --platform mac (or PLATFORM = 'mac' in the settings block for Spyder) prepares a game to run on the Mac and stops there. It skips the iOS shader libraries, the Xcode project, the app build and the IPA. For Mario Kart 8 Deluxe that saves about half the shader time (around 30,000 iOS libraries) and the ~12 GB IPA when all you want is a Mac run to test or debug. The default stays ios, which builds exactly as before.

Mac mode

  • Unchanged: extract, DLC, rewrite, chain header, the run-time captures / decodes, heap check and shader split.
  • "Mac shaders": own_compilers.py without IOSOUT (an inherited one is dropped). Vulkan and GL games build their Mac library without --ios.
  • "Mac host": the script's existing build_mac_host builds the host into <id>_build/tools/dmhost, honouring DM_GAMES_DIR / DM_GAMES_FIRST for provisional and derived profiles. The checkout's dm/host/dmhost is left alone. It also writes the button-icon font into <id>_build/font.
  • Extracted files: kept whatever --keep-extracted says, since the Mac run reads the RomFS.
  • Run command: printed at the end from the run's real paths, with DM_NVN_SHMAP for NVN games, DM_AOC_DIR with DLC, and the --env-file switches. The save goes to <id>_build/run/save.
  • Refused combinations: --prepare-xcode, and an Intel Mac.

Reuse

  • The Mac outputs get their own keys (shader/mac-b-<chain>.key, shader/vk.key / gl.key). An iOS build writes both keys, so a folder already built for iOS needs no shader work in Mac mode.
  • An iOS build after a Mac build takes the Mac Metal libraries from the compile cache but translates the shaders again. dmsh_build.py's per-shader cache key includes the iOS settings, and changing that would change every profile's chain version, so it is left as it is.
  • The host build is reused while its compile line, sources, generated profile header, chain header, libvpx, clang and SDK are unchanged.

Checked

  • dm/tools/tests: all 24 pass, 9 of them new in test_nsp_mac.py.
  • Hades in Mac mode: Mac stages only, run command printed, exit 0. A second run reuses every stage, the host included (about 2 s).
  • Not run: an NVN game, GL game or provisional / derived profile in Mac mode end to end. Those paths are covered by the unit tests with the build tools stubbed.

Docs: a section "A Mac-only build for development" in docs/development.md, with a pointer from "Build by hand (Mac)". README is unchanged, since it is player-facing.

Rebased onto 86d9ba1 (one chain version for every game) and f4f0a85: the Mac key follows the single chain version, a Mac-only build reuses the Mac libraries only while shader/cache/b-<chain> has a full build's inputs.tsv stamp, and makes c1_full.tsv / cb_extent.tsv like an iOS build. The ios default behaves exactly as on main. dm/tools/tests: 34 pass (11 in test_nsp_mac.py, two new for the stamp). Hades in Mac mode: Mac stages only, run command printed, exit 0.

…M = 'mac' in Spyder; ios stays the default and builds as before). It runs the steps the Mac host needs: extraction, rewrite, run-time captures and decodes, heap check and shader split. It builds only the Mac shader libraries: dmsh_build.py without IOSOUT (one inherited from the caller's environment is dropped), and a Vulkan or GL game's library without --ios. Then it builds the Mac host for the profile into <id>_build/tools/dmhost (make's compile line, DM_GAMES_DIR / DM_GAMES_FIRST as for the captures) and the button-icon font into <id>_build/font. It skips the iOS shaders, the Xcode project and the IPA, and keeps the extracted files whatever --keep-extracted says. Its last line is the command that runs the game: DM_ROOT, DM_ROMFS, DM_SAVE / DM_TEMP in <id>_build/run (kept from run to run), DM_MSL_DIR, DM_FONT_DIR, DM_AOC_DIR with DLC, DM_NVN_SHMAP for an NVN game (the host outside dm/host does not find the shader map beside itself), DM_LANG, DM_WINDOW=1, DM_AUDIO=1 and the --env-file switches. Why: a developer who only runs a game on the Mac waited for the iOS shaders (Mario Kart 8 Deluxe: about 30,000, roughly doubling the shader time) and needed room for the IPA (about 12 GB). The Mac stays a development host (GitHub issue seedds#64), so this is a script option, not a Mac app. It needs Apple silicon and cannot be combined with --prepare-xcode.

Reuse: each shader output now has its own key, named after the one chain version (DMSH_CHAIN in dm/gfx/nvn/dmsh_chain.h). The iOS libraries keep shader/ios/b-<chain>.key and shader/ios/vk.key / gl.key. The Mac's are shader/mac-b-<chain>.key (outside shader/cache, whose b-* entries dmsh_build.py reads as library folders) and shader/vk.key / gl.key. An iOS build writes both keys, since it builds the Mac's libraries too, and a Mac-only build is reused after either, so a folder already packed as an IPA needs no shader work. Either key is taken only while the Mac libraries carry a full dmsh_build.py run's stamp (b-<chain>/inputs.tsv), and c1_full.tsv / cb_extent.tsv that do not name it are made again from them (chain_tables, as for the IPA); a Mac-only full build stamps the Mac libraries and writes both tables itself. An iOS build after a Mac-only one still makes the iPhone's libraries. It translates again (dmsh_build.py's per-shader cache keys include the iOS compile convention), but takes the Mac libraries from the Metal compile cache. The Mac host build (build_mac_host, also used by the captures, the heap check and the Oodle decodes) is now reused while its compile line, the sources of the folders it compiles from (the chain header dm/gfx/nvn/dmsh_chain.h among them), the generated profile header, libvpx, the third-party headers, clang and the macOS SDK are unchanged. The Vulkan and GL shader steps share one function (layer_shaders). The default ios platform builds as before.

docs/development.md documents the option (an example, the Spyder setting, a section "A Mac-only build for development" with the run command and the reuse rules), and "Build by hand (Mac)" points to it. README.md is unchanged: the option is for developers.

Checked: dm/tools/tests (34 tests, 11 in test_nsp_mac.py: Mac-only shader builds without --ios or IOSOUT, the keys, reuse after an iOS build, a rebuild for iOS after a Mac-only build, no reuse of Mac libraries without a stamp, a stale table made again on reuse, the environment file). Hades in Mac mode, from its folder built for Xcode earlier: 5 stages (nx_extract, extract reused, rewrite rerun for the split rewriter in 8 s, 74 Vulkan shaders for the Mac in 4 s, Mac host in 17 s). The iOS output in shader/ios was untouched, there was no Xcode step or IPA, the run command was printed and the exit code was 0. The game itself was not started.
seedds added a commit that referenced this pull request Oct 23, 2026
…g a game on this Mac needs, from PR #82

A development option; the Mac is the development host, not a platform for players. The same steps up to the
shaders (extraction, DLC, rewrite, run-time captures and decodes, heap check, shader split), then only the
Mac's: dmsh_build.py without IOSOUT (an inherited one is dropped), a Vulkan or GL game's library without --ios,
the Mac host for the profile into <id>_build/tools/dmhost (build_mac_host, through DM_GAMES_DIR /
DM_GAMES_FIRST for a provisional or derived profile) and the button-icon font into <id>_build/font. No iOS
shaders, Xcode project or IPA; the extracted files are kept whatever KEEP_EXTRACTED says, and the last line is
the command that runs the game (its save in <id>_build/run/save, DM_NVN_SHMAP for an NVN game, DM_AOC_DIR
with DLC, the --env-file switches). It refuses --prepare-xcode and an Intel Mac.

Reuse: the Mac libraries have a key of their own (shader/mac-b-<chain>.key beside the cache folder,
shader/vk.key / gl.key), which an iOS build writes too, so a Mac-only build after an IPA reuses its shaders;
either key only while the Mac libraries carry a full build's stamp (inputs.tsv). An iOS build after a Mac-only
one translates again (dmsh_build.py's per-shader keys include the iOS compile convention) and takes the Mac
libraries from the Metal compile cache. build_mac_host now has a reuse key too (the compile line, the sources and
headers of the folders it compiles, the generated profile header, libvpx, the third-party headers, clang and the
SDK), which also saves the rebuild for the Oodle / LZ5 decodes and the run-time captures. build_vk_shaders and
build_gl_shaders share layer_shaders. The default (ios) path builds as before.

Checked: dm/tools/tests 34 of 34 (11 in the new test_nsp_mac.py); Hades in Mac mode ran the Mac stages only,
printed the run command and exited 0, and a second run reused every stage, the host included (2 s); the host it
built boots Hades from that command. Breath of the Wild (NVN, with DLC) in Mac mode restored its 19,592 shaders
from the cache, printed a command with DM_AOC_DIR and DM_NVN_SHMAP, and the host booted it from that command into
play. Not run end to end here: a GL, provisional or derived game in Mac mode, and an IPA after a Mac-only build
(unit tests with the tools stubbed).

Co-authored-by: v0lumehi <[email protected]>
@seedds

seedds commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Thanks! Ported as 98a91a6, unchanged.

I checked that build_mac_host's new reuse key covers everything the host's compile line reads: the folders' sources and headers, the generated profile header, libvpx, stb_vorbis, the Vulkan headers, clang and the SDK.

Checked here:

  • Tests: dm/tools/tests 34 of 34.
  • Hades (Vulkan), Mac mode:
    • It ran only the Mac stages and exited 0.
    • A second run reused every stage, the host included.
    • The printed command booted the game.
  • Breath of the Wild (NVN, with DLC), Mac mode:
    • It restored its 19,592 shaders from the cache.
    • It printed a command with DM_AOC_DIR and DM_NVN_SHMAP.
    • That command booted it into play.

Not run here: a GL, provisional or derived game in Mac mode, and an IPA after a Mac-only build. The unit tests cover those.

@seedds seedds closed this Oct 23, 2026
@v0lumehi
v0lumehi deleted the nsp-mac-only branch October 24, 2026 07:53
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…g a game on this Mac needs, from PR seedds#82

A development option; the Mac is the development host, not a platform for players. The same steps up to the
shaders (extraction, DLC, rewrite, run-time captures and decodes, heap check, shader split), then only the
Mac's: dmsh_build.py without IOSOUT (an inherited one is dropped), a Vulkan or GL game's library without --ios,
the Mac host for the profile into <id>_build/tools/dmhost (build_mac_host, through DM_GAMES_DIR /
DM_GAMES_FIRST for a provisional or derived profile) and the button-icon font into <id>_build/font. No iOS
shaders, Xcode project or IPA; the extracted files are kept whatever KEEP_EXTRACTED says, and the last line is
the command that runs the game (its save in <id>_build/run/save, DM_NVN_SHMAP for an NVN game, DM_AOC_DIR
with DLC, the --env-file switches). It refuses --prepare-xcode and an Intel Mac.

Reuse: the Mac libraries have a key of their own (shader/mac-b-<chain>.key beside the cache folder,
shader/vk.key / gl.key), which an iOS build writes too, so a Mac-only build after an IPA reuses its shaders;
either key only while the Mac libraries carry a full build's stamp (inputs.tsv). An iOS build after a Mac-only
one translates again (dmsh_build.py's per-shader keys include the iOS compile convention) and takes the Mac
libraries from the Metal compile cache. build_mac_host now has a reuse key too (the compile line, the sources and
headers of the folders it compiles, the generated profile header, libvpx, the third-party headers, clang and the
SDK), which also saves the rebuild for the Oodle / LZ5 decodes and the run-time captures. build_vk_shaders and
build_gl_shaders share layer_shaders. The default (ios) path builds as before.

Checked: dm/tools/tests 34 of 34 (11 in the new test_nsp_mac.py); Hades in Mac mode ran the Mac stages only,
printed the run command and exited 0, and a second run reused every stage, the host included (2 s); the host it
built boots Hades from that command. Breath of the Wild (NVN, with DLC) in Mac mode restored its 19,592 shaders
from the cache, printed a command with DM_AOC_DIR and DM_NVN_SHMAP, and the host booted it from that command into
play. Not run end to end here: a GL, provisional or derived game in Mac mode, and an IPA after a Mac-only build
(unit tests with the tools stubbed).

Co-authored-by: v0lumehi <[email protected]>
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.

2 participants