From abd58c9c0e5043d73b127de9cd387e416bd5090f Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 8 Apr 2025 00:44:33 +0800 Subject: prepare targets for more generators --- xmake/plugins/project/make/makefile.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'xmake/plugins/project/make/makefile.lua') diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua index 3d4d5507f..e123943de 100644 --- a/xmake/plugins/project/make/makefile.lua +++ b/xmake/plugins/project/make/makefile.lua @@ -687,10 +687,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 +716,5 @@ function make(outputdir) -- close the makefile makefile:close() - - -- leave project directory os.cd(oldir) end -- cgit v1.3.1 From 260f07164381c235422ec7150e26396604fabdb5 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 9 Apr 2025 23:47:05 +0800 Subject: improve makefile generator --- xmake/plugins/project/make/makefile.lua | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'xmake/plugins/project/make/makefile.lua') diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua index e123943de..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("") -- cgit v1.3.1