premake / premake/premake-core
[Question] Invoking action from another action
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 654
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 13
Description
I understand that it's probably better to implement it with a shell script, but I was wondering if it was possible to write some virtual action which calls one of the "real" actions (e.g. gmake2) based on environment settings or other external info.
Feeding this snippet to the premake5 virtual_action --interactive works correctly:
_ACTION = "gmake2"
require(_ACTION)
premake.action.set(_ACTION)
premake.action.initialize(premake.action.get(_ACTION).trigger)
premake.main.preBake()
premake.main.bake()
premake.main.postBake()
premake.main.validate()
premake.main.preAction()
premake.main.callAction()
...but using that code from virtual action's execute function produces the following error:
Error: [string "src/base/workspace.lua"]:17: attempt to get length of a nil value (field 'configs')
stack traceback:
[string "gmake/gmake.lua"]:20: in function 'gmake.defaultconfig'
[string "gmake/gmake.lua"]:76: in function 'gmake.header'
[string "gmake/gmake_workspace.lua"]:7: in function 'gmake.generate_workspace'
[string "src/base/premake.lua"]:48: in local 'fn'
[string "src/base/premake.lua"]:11: in function 'premake.capture'
[string "src/base/premake.lua"]:46: in function 'premake.generate'
[string "gmake/_preload.lua"]:16: in local 'onWorkspace'
[string "src/base/action.lua"]:49: in field 'call'
[string "src/_premake_main.lua"]:185: in field 'callAction'
/tmp/test/premake5.lua:121: in field 'execute'
[string "src/base/action.lua"]:65: in field 'call'
[string "src/_premake_main.lua"]:185: in field '?'
[string "src/base/_foundation.lua"]:58: in function 'premake.callArray'
[string "src/_premake_main.lua"]:212: in function '_premake_main'
It looks like we're trying to callAction on an unbaked workspace, though we should've called p.workspace.bake(self) before.
Any help appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the virtual action's execute function and compare its call sequence with the working premake5 virtual_action --interactive snippet. Read src/base/action.lua, src/_premake_main.lua, and the workspace bake path mentioned in the report, then reproduce the gmake2 failure. Done means the supported behavior for invoking a real action from a virtual action is established and the unbaked-workspace failure is addressed or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100