fix(xmake): resolve nil global helpers in xmake 3.x callbacks - #56
Closed
FarnaHerry wants to merge 1 commit into
Closed
fix(xmake): resolve nil global helpers in xmake 3.x callbacks#56FarnaHerry wants to merge 1 commit into
FarnaHerry wants to merge 1 commit into
Conversation
What: Move the shared build helpers (compile options, app link options, shadertoy SPIR-V compilation) into xmake/eui_helpers.lua and reach them via import() inside every target/rule callback. Why: xmake 3.x runs on_config, on_load, and after_build callbacks in isolated script scopes where project-level global functions resolve to nil. Every CI configure invocation failed with "attempt to call a nil value (global 'eui_apply_compile_options')" as soon as a rule or target callback ran. The thin global wrappers in xmake.lua only survive because pass-by-reference sites such as on_config(eui_apply_compile_options) capture them before the scope splits; function bodies executed later inside callbacks cannot see them. How: Register xmake/ as a module directory, keep thin global wrappers for the reference-passed sites, and import the module directly where callbacks need to invoke a helper (rule on_config, after_build shadertoy steps). Verified against all four CI backend combinations (OpenGL/Vulkan x GLFW/SDL2): the old script fails with the nil error, the updated script configures cleanly in each case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Move the shared build helpers (compile options, app link options, shadertoy SPIR-V compilation) into
xmake/eui_helpers.luaand reach them viaimport()inside every target/rule callback.Why
xmake 3.x runs
on_config,on_load, andafter_buildcallbacks in isolated script scopes where project-level global functions resolve tonil. Every CI configure invocation fails with:as soon as a rule or target callback runs. The thin global wrappers in
xmake.luaonly survive because pass-by-reference sites such ason_config(eui_apply_compile_options)capture them before the scope splits; function bodies executed later inside callbacks cannot see them.How
xmake/as a module directory viaadd_moduledirs("xmake").on_configsites (soon_config(eui_apply_compile_options)keeps working unchanged).import("eui_helpers")directly where a callback body must invoke a helper (ruleon_config, and the shadertoyafter_buildsteps which previously called the global functions).find_tool/glslangValidator lookups as before.Testing
Reproduced the exact CI failure first: on the base
devscript,xmake f -m release -y --window_backend=glfw --render_backend=vulkan --user_apps=nfails with the nil-value error. After the change, all four backend combinations configure cleanly:--window_backend=glfw --render_backend=vulkan✓--window_backend=sdl2 --render_backend=vulkan✓--window_backend=glfw --render_backend=opengl✓--window_backend=sdl2 --render_backend=opengl✓