Skip to content

Commit 3cdb8d9

Browse files
committed
Made headeronly targets appears as phony targets (so it doesn't ask for a linker it doesn't requires)
1 parent 9b1b539 commit 3cdb8d9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

xmake/plugins/project/make/makefile.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ function _add_toolchains(makefile, outputdir)
334334

335335
-- add toolchains from targets
336336
for targetname, target in pairs(project.targets()) do
337-
if not target:is_phony() then
337+
if not _phony_or_headeronly(target) then
338338
local program = _get_program_from_target(target, target:linker():kind())
339339
if program then
340340
makefile:print("%s_%s=%s", targetname, target:linker():kind():upper(), program)
@@ -353,10 +353,14 @@ function _add_toolchains(makefile, outputdir)
353353
makefile:print("")
354354
end
355355

356+
function _phony_or_headeronly(target)
357+
return target:is_phony() or target:is_headeronly()
358+
end
359+
356360
-- add flags
357361
function _add_flags(makefile, targetflags, outputdir)
358362
for targetname, target in pairs(project.targets()) do
359-
if not target:is_phony() then
363+
if not _phony_or_headeronly(target) then
360364
for _, sourcebatch in pairs(target:sourcebatches()) do
361365
local sourcekind = sourcebatch.sourcekind
362366
if sourcekind then
@@ -512,7 +516,7 @@ function _add_build_target(makefile, target, targetflags, outputdir)
512516
local precmds_label = _add_build_custom_commands_before(makefile, target, outputdir)
513517

514518
-- is phony target?
515-
if target:is_phony() then
519+
if _phony_or_headeronly(target) then
516520
return _add_build_phony(makefile, target)
517521
end
518522

@@ -539,7 +543,7 @@ function _add_build_target(makefile, target, targetflags, outputdir)
539543
-- make dependence for the dependent targets
540544
for _, depname in ipairs(target:get("deps")) do
541545
local dep = project.target(depname, {namespace = target:namespace()})
542-
makefile:write(" " .. (dep:is_phony() and depname or _get_relative_unix_path(dep:targetfile(), outputdir)))
546+
makefile:write(" " .. (_phony_or_headeronly(dep) and depname or _get_relative_unix_path(dep:targetfile(), outputdir)))
543547
end
544548

545549
-- make dependence for objects
@@ -650,7 +654,7 @@ function _add_clean_target(makefile, target, outputdir)
650654
makefile:write(" clean_" .. dep)
651655
end
652656
makefile:print("")
653-
if not target:is_phony() then
657+
if not _phony_or_headeronly(target) then
654658
_add_remove_files(makefile, target:targetfile(), outputdir)
655659
_add_remove_files(makefile, target:symbolfile(), outputdir)
656660
_add_remove_files(makefile, target:objectfiles(), outputdir)

0 commit comments

Comments
 (0)