Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

The glslang check is a function, so the Xcode fixture can mock it (CI red)

LNPANDY6b1e6370e087
diff --git a/dm/ios/tests/test_xcode_workflow.py b/dm/ios/tests/test_xcode_workflow.py
index 83a9790d..d185224b 100644
--- a/dm/ios/tests/test_xcode_workflow.py
+++ b/dm/ios/tests/test_xcode_workflow.py
@@ -50,7 +50,7 @@ class XcodePipelineTests(unittest.TestCase):
(extraction / 'ExeFS').mkdir()
mocks = {}
for name, value in {
- 'scan_nsps': (int(registered.id, 16), fam), 'check_prereqs': None, 'check_metal': None,
+ 'scan_nsps': (int(registered.id, 16), fam), 'check_prereqs': None, 'check_metal': None, 'check_glslang': None,
'free_gb': 10000, 'build_nx_extract': root / 'nx_extract',
'extract': extraction, 'can_clone': False, 'build_mismatch': [],
'extract_aoc': None, 'rewrite': profile, 'split_shaders': 'fixture-key',
diff --git a/scripts/build_ipa_from_nsp.py b/scripts/build_ipa_from_nsp.py
index fe9c6f96..30c2c798 100755
--- a/scripts/build_ipa_from_nsp.py
+++ b/scripts/build_ipa_from_nsp.py
@@ -1597,6 +1597,15 @@ def check_metal(py, repo, env):
raise BuildError(msg.replace('set DM_ALLOW_OTHER_METAL=1 (the NSP script\'s --allow-other-metal)', 'ALLOW_OTHER_METAL = True (--allow-other-metal)'))
+def check_glslang(env):
+ """An OpenGL game's GLSL goes through glslangValidator; build_gl_shaders checks for it, but only
+ after the extraction and the runtime capture have run for minutes, and it raises before
+ layer_shaders creates gl_shaders.log — so the GUI showed a failure with no log to read (issue
+ #71). Checked before those steps, as check_metal is and for the same reason."""
+ if not shutil.which('glslangValidator', path=env['PATH']):
+ raise BuildError("glslangValidator is not installed: an OpenGL game's GLSL shaders need it to compile to SPIR-V (brew install glslang)")
+
+
def shader_regressions(py, repo, lib_dir, chain, logs):
"""dm/gfx/tools/shader_regressions.py on the Mac libraries (dmsh_build.py writes its build report there in an iOS build too): shaders that translated in this game's previous build
and fail with this chain stop the build, unless ALLOW_SHADER_REGRESSIONS. The chain is one for every game, so a change can break a game its author never ran (GitHub issue #272)"""
@@ -2070,11 +2079,7 @@ def main(args=None):
if gfx == 'vulkan': say(f'Vulkan game ({src["graphics"][1]}): vk_shaders.py translates the shaders instead of the NVN shader chain')
if gfx == 'gl': say(f'OpenGL game ({src["graphics"][1]}): gl_shaders.py translates the shaders instead of the NVN shader chain')
if gfx == 'nvn': check_metal(py, repo, env) # before the captures and the shader split, which take minutes
- # Same reason as check_metal: build_gl_shaders checks for glslangValidator, but by then the
- # extraction and the capture have run for minutes, and the check raises before layer_shaders
- # creates gl_shaders.log — so the GUI showed a failure with no log to read (issue #71).
- if gfx == 'gl' and not shutil.which('glslangValidator', path=env['PATH']):
- raise BuildError("glslangValidator is not installed: an OpenGL game's GLSL shaders need it to compile to SPIR-V (brew install glslang)")
+ if gfx == 'gl': check_glslang(env)
for on, k in ((glslc, 'glslc_capture'), (vkcap, 'vk_capture'), (glcap, 'gl_capture'), (uedec, 'ue_decode'), (gfx == 'nvn' and src['oodle_packs'][0], 'oodle_packs'), (gfx == 'nvn' and src['ue_legacy'][0], 'ue_legacy')):
if on: say(src[k][1])
PROG.add(glslc + vkcap + glcap + uedec + (gfx == 'nvn'))
diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.py
index 60043bff..fe1670e4 100644
--- a/scripts/sync_upstream.py
+++ b/scripts/sync_upstream.py
@@ -737,13 +737,22 @@ def rmtree(p):
# but by then the extraction and the capture have run for minutes, and the check raises before
# layer_shaders creates gl_shaders.log, so the failure had no log to read (issue #71). Checked
# next to check_metal, which is in the same place for the same reason.
- P.append(('GL shader tool check', 'glslangValidator is not installed', [(
+ P.append(('GL shader tool check', 'check_glslang(env)', [(
" if gfx == 'nvn': check_metal(py, repo, env) # before the captures and the shader split, which take minutes\n",
- """ if gfx == 'nvn': check_metal(py, repo, env) # before the captures and the shader split, which take minutes
- # Same reason as check_metal: build_gl_shaders checks for glslangValidator, but by then the
- # extraction and the capture have run for minutes, and the check raises before layer_shaders
- # creates gl_shaders.log — so the GUI showed a failure with no log to read (issue #71).
- if gfx == 'gl' and not shutil.which('glslangValidator', path=env['PATH']):
+ " if gfx == 'nvn': check_metal(py, repo, env) # before the captures and the shader split, which take minutes\n"
+ " if gfx == 'gl': check_glslang(env)\n"), (
+ # the function itself, beside check_metal
+ """ raise BuildError(msg.replace('set DM_ALLOW_OTHER_METAL=1 (the NSP script\\'s --allow-other-metal)', 'ALLOW_OTHER_METAL = True (--allow-other-metal)'))
+""",
+ """ raise BuildError(msg.replace('set DM_ALLOW_OTHER_METAL=1 (the NSP script\\'s --allow-other-metal)', 'ALLOW_OTHER_METAL = True (--allow-other-metal)'))
+
+
+def check_glslang(env):
+ \"\"\"An OpenGL game's GLSL goes through glslangValidator; build_gl_shaders checks for it, but only
+ after the extraction and the runtime capture have run for minutes, and it raises before
+ layer_shaders creates gl_shaders.log — so the GUI showed a failure with no log to read (issue
+ #71). Checked before those steps, as check_metal is and for the same reason.\"\"\"
+ if not shutil.which('glslangValidator', path=env['PATH']):
raise BuildError("glslangValidator is not installed: an OpenGL game's GLSL shaders need it to compile to SPIR-V (brew install glslang)")
""")]))
for name, marker, pairs in P: