summaryrefslogtreecommitdiff
path: root/xmake/plugins/project/make/makefile.lua
diff options
context:
space:
mode:
authorChristian Rendina <[email protected]>2025-04-10 09:50:37 +0200
committerChristian Rendina <[email protected]>2025-04-10 09:50:37 +0200
commit78723913d76fb8b615df34541236b8ea588d30db (patch)
treeb6b6ff550e4a2f73d94c63a61876cec31a4b3ae3 /xmake/plugins/project/make/makefile.lua
parent2051c13f735a626f7b6fd8b98aa69f01fd9cef7e (diff)
parentfd49b7754c6709a87b5beb5526788bbc1a663965 (diff)
Merge branch 'dev' of https://github.com/xmake-io/xmake into dev
Diffstat (limited to 'xmake/plugins/project/make/makefile.lua')
-rw-r--r--xmake/plugins/project/make/makefile.lua28
1 files changed, 9 insertions, 19 deletions
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua
index 3d4d5507f..79277b3f1 100644
--- a/xmake/plugins/project/make/makefile.lua
+++ b/xmake/plugins/project/make/makefile.lua
@@ -27,7 +27,6 @@ import("core.language.language")
import("core.platform.platform")
import("lib.detect.find_tool")
import("private.utils.batchcmds")
-import("private.utils.rule_groups")
import("plugins.project.utils.target_cmds", {rootdir = os.programdir()})
-- tranlate path
@@ -469,14 +468,11 @@ function _add_build_phony(makefile, target)
end
-- add custom commands before building target
-function _add_build_custom_commands_before(makefile, target, sourcegroups, outputdir)
+function _add_build_custom_commands_before(makefile, target, outputdir)
-- add before commands
-- we use irpairs(groups), because the last group that should be given the highest priority.
- local cmds_before = {}
- target_cmds.get_target_buildcmd(target, cmds_before, {suffix = "before"})
- target_cmds.get_target_buildcmd_sourcegroups(target, cmds_before, sourcegroups, {suffix = "before"})
- target_cmds.get_target_buildcmd_sourcegroups(target, cmds_before, sourcegroups)
+ local cmds_before = target_cmds.get_target_buildcmds(target, {stages = {"before", "on"}})
local targetname = target:name()
local label = "precmds_" .. targetname
@@ -494,10 +490,8 @@ function _add_build_custom_commands_before(makefile, target, sourcegroups, outpu
end
-- add custom commands after building target
-function _add_build_custom_commands_after(makefile, target, sourcegroups, outputdir)
- local cmds_after = {}
- target_cmds.get_target_buildcmd_sourcegroups(target, cmds_after, sourcegroups, {suffix = "after"})
- target_cmds.get_target_buildcmd(target, cmds_after, {suffix = "after"})
+function _add_build_custom_commands_after(makefile, target, outputdir)
+ local cmds_after = target_cmds.get_target_buildcmds(target, {stages = {"after"}})
if #cmds_after > 0 then
for _, cmd in ipairs(cmds_after) do
local command = _get_command_string(cmd, outputdir)
@@ -514,11 +508,8 @@ function _add_build_target(makefile, target, targetflags, outputdir)
-- https://github.com/xmake-io/xmake/issues/2337
target:data_set("plugin.project.kind", "makefile")
- -- build sourcebatch groups first
- local sourcegroups = rule_groups.build_sourcebatch_groups(target, target:sourcebatches())
-
-- add custom commands before building target
- local precmds_label = _add_build_custom_commands_before(makefile, target, sourcegroups, outputdir)
+ local precmds_label = _add_build_custom_commands_before(makefile, target, outputdir)
-- is phony target?
if target:is_phony() then
@@ -602,7 +593,7 @@ function _add_build_target(makefile, target, targetflags, outputdir)
makefile:writef("\t$(VV)%s\n", command)
-- add custom commands after building target
- _add_build_custom_commands_after(makefile, target, sourcegroups, outputdir)
+ _add_build_custom_commands_after(makefile, target, outputdir)
-- end
makefile:print("")
@@ -687,10 +678,11 @@ function _add_clean(makefile, outputdir)
end
function make(outputdir)
-
- -- enter project directory
local oldir = os.cd(os.projectdir())
+ -- prepare targets
+ target_cmds.prepare_targets()
+
-- open the makefile
local makefile = io.open(path.join(outputdir, "makefile"), "w")
@@ -715,7 +707,5 @@ function make(outputdir)
-- close the makefile
makefile:close()
-
- -- leave project directory
os.cd(oldir)
end