Skip to content

fix(xmake): resolve nil global helpers in xmake 3.x callbacks - #56

Closed
FarnaHerry wants to merge 1 commit into
sudoevolve:devfrom
FarnaHerry:fix/xmake3-callback-helpers
Closed

fix(xmake): resolve nil global helpers in xmake 3.x callbacks#56
FarnaHerry wants to merge 1 commit into
sudoevolve:devfrom
FarnaHerry:fix/xmake3-callback-helpers

Conversation

@FarnaHerry

Copy link
Copy Markdown
Contributor

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 fails with:

error: attempt to call a nil value (global 'eui_apply_compile_options')

as soon as a rule or target callback runs. 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 via add_moduledirs("xmake").
  • Keep thin global wrappers for the reference-passed on_config sites (so on_config(eui_apply_compile_options) keeps working unchanged).
  • import("eui_helpers") directly where a callback body must invoke a helper (rule on_config, and the shadertoy after_build steps which previously called the global functions).
  • The module reuses the same find_tool/glslangValidator lookups as before.

Testing

Reproduced the exact CI failure first: on the base dev script, xmake f -m release -y --window_backend=glfw --render_backend=vulkan --user_apps=n fails 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

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.
@sudoevolve sudoevolve closed this Aug 10, 2026
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