diff options
| author | ruki <[email protected]> | 2025-05-13 23:25:52 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-13 23:25:52 +0800 |
| commit | 173069f43f8efee4f99ac217582df24891c1e6db (patch) | |
| tree | 22eae908d6a8eef08a47cd57483423fc5c81b799 /xmake/plugins | |
| parent | 8dd9b97c09ee5c4dabeaa72374c62d40c26c1bab (diff) | |
| parent | 2e432810ac721093764ac1ced7424523d9ba0b17 (diff) | |
Merge pull request #6429 from PierreEVEN/fix-make_ninja_gen-headeronly_target
Fix make ninja gen headeronly target
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/project/make/makefile.lua | 14 | ||||
| -rw-r--r-- | xmake/plugins/project/ninja/build_ninja.lua | 7 |
2 files changed, 14 insertions, 7 deletions
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua index 79277b3f1..e97c50cda 100644 --- a/xmake/plugins/project/make/makefile.lua +++ b/xmake/plugins/project/make/makefile.lua @@ -334,7 +334,7 @@ function _add_toolchains(makefile, outputdir) -- add toolchains from targets for targetname, target in pairs(project.targets()) do - if not target:is_phony() then + if not _phony_or_headeronly(target) then local program = _get_program_from_target(target, target:linker():kind()) if program then makefile:print("%s_%s=%s", targetname, target:linker():kind():upper(), program) @@ -353,10 +353,14 @@ function _add_toolchains(makefile, outputdir) makefile:print("") end +function _phony_or_headeronly(target) + return target:is_phony() or target:is_headeronly() +end + -- add flags function _add_flags(makefile, targetflags, outputdir) for targetname, target in pairs(project.targets()) do - if not target:is_phony() then + if not _phony_or_headeronly(target) then for _, sourcebatch in pairs(target:sourcebatches()) do local sourcekind = sourcebatch.sourcekind if sourcekind then @@ -512,7 +516,7 @@ function _add_build_target(makefile, target, targetflags, outputdir) local precmds_label = _add_build_custom_commands_before(makefile, target, outputdir) -- is phony target? - if target:is_phony() then + if _phony_or_headeronly(target) then return _add_build_phony(makefile, target) end @@ -539,7 +543,7 @@ function _add_build_target(makefile, target, targetflags, outputdir) -- make dependence for the dependent targets for _, depname in ipairs(target:get("deps")) do local dep = project.target(depname, {namespace = target:namespace()}) - makefile:write(" " .. (dep:is_phony() and depname or _get_relative_unix_path(dep:targetfile(), outputdir))) + makefile:write(" " .. (_phony_or_headeronly(dep) and depname or _get_relative_unix_path(dep:targetfile(), outputdir))) end -- make dependence for objects @@ -650,7 +654,7 @@ function _add_clean_target(makefile, target, outputdir) makefile:write(" clean_" .. dep) end makefile:print("") - if not target:is_phony() then + if not _phony_or_headeronly(target) then _add_remove_files(makefile, target:targetfile(), outputdir) _add_remove_files(makefile, target:symbolfile(), outputdir) _add_remove_files(makefile, target:objectfiles(), outputdir) diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua index 11be6f4ae..87bd29e7d 100644 --- a/xmake/plugins/project/ninja/build_ninja.lua +++ b/xmake/plugins/project/ninja/build_ninja.lua @@ -352,7 +352,7 @@ function _add_build_for_target(ninjafile, target, outputdir) target:data_set("plugin.project.kind", "ninja") -- is phony target? - if target:is_phony() then + if target:is_phony() or target:is_headeronly() then return _add_build_for_phony(ninjafile, target) end @@ -378,7 +378,10 @@ function _add_build_for_target(ninjafile, target, outputdir) ninjafile:print(" || $") ninjafile:write(" ") for _, dep in ipairs(deps) do - ninjafile:write(" " .. _get_relative_unix_path(project.target(dep, {namespace = target:namespace()}):targetfile(), outputdir)) + local dep_target = project.target(dep, {namespace = target:namespace()}); + if not dep_target:is_headeronly() then + ninjafile:write(" " .. _get_relative_unix_path(dep_target:targetfile(), outputdir)) + end end end ninjafile:print("") |
