summaryrefslogtreecommitdiff
path: root/xmake/core/tool/compiler.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-24 00:55:36 +0800
committerruki <[email protected]>2026-01-24 00:55:36 +0800
commitdf870ffd7cf1b7c4cb5df311f437ffef03678178 (patch)
tree9d9c3850454f431321866fad080d6c01658ecd3e /xmake/core/tool/compiler.lua
parent0e9aa3375f073fd9987867574854f0445d6a3971 (diff)
improve fpc
Diffstat (limited to 'xmake/core/tool/compiler.lua')
-rw-r--r--xmake/core/tool/compiler.lua47
1 files changed, 31 insertions, 16 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index ff8ce6a5d..e2125abcc 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -206,6 +206,11 @@ end
-- build the source files (compile and link)
function compiler:build(sourcefiles, targetfile, opt)
opt = opt or {}
+ local target = opt.target or self:target()
+ if not opt.target and target then
+ opt = table.copy(opt)
+ opt.target = target
+ end
-- get compile flags
local compflags = opt.compflags
@@ -219,21 +224,26 @@ function compiler:build(sourcefiles, targetfile, opt)
-- make flags
local flags = compflags
- if opt.target then
- flags = table.join(flags, opt.target:linkflags())
+ if target then
+ flags = table.join(flags, target:linkflags())
end
-- get target kind
local targetkind = opt.targetkind
- if not targetkind and opt.target and opt.target.targetkind then
- targetkind = opt.target:kind()
+ if not targetkind and target and target.targetkind then
+ targetkind = target:kind()
end
- return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags)
+ return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags, opt)
end
-- get the build arguments list (compile and link)
function compiler:buildargv(sourcefiles, targetfile, opt)
opt = opt or {}
+ local target = opt.target or self:target()
+ if not opt.target and target then
+ opt = table.copy(opt)
+ opt.target = target
+ end
-- get compile flags
local compflags = opt.compflags
@@ -247,16 +257,16 @@ function compiler:buildargv(sourcefiles, targetfile, opt)
-- make flags
local flags = compflags
- if opt.target then
- flags = table.join(flags, opt.target:linkflags())
+ if target then
+ flags = table.join(flags, target:linkflags())
end
-- get target kind
local targetkind = opt.targetkind
- if not targetkind and opt.target and opt.target.targetkind then
- targetkind = opt.target:kind()
+ if not targetkind and target and target.targetkind then
+ targetkind = target:kind()
end
- return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags)
+ return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags, opt)
end
-- get the build command
@@ -266,9 +276,14 @@ end
-- compile the source files
function compiler:compile(sourcefiles, objectfile, opt)
+ opt = opt or {}
+ local target = opt.target or self:target()
+ if not opt.target and target then
+ opt = table.copy(opt)
+ opt.target = target
+ end
-- get compile flags
- opt = opt or {}
local compflags = opt.compflags
if not compflags then
-- patch sourcefile to get flags of the given source file
@@ -279,8 +294,6 @@ function compiler:compile(sourcefiles, objectfile, opt)
end
-- compile it
- opt = table.copy(opt)
- opt.target = self:target()
profiler:enter(self:name(), "compile", sourcefiles)
local ok, errors = sandbox.load(self:_tool().compile, self:_tool(), sourcefiles, objectfile, opt.dependinfo, compflags, opt)
profiler:leave(self:name(), "compile", sourcefiles)
@@ -289,9 +302,11 @@ end
-- get the compile arguments list
function compiler:compargv(sourcefiles, objectfile, opt)
-
- -- init options
- opt = opt or {}
+ local target = opt.target or self:target()
+ if not opt.target and target then
+ opt = table.copy(opt)
+ opt.target = target
+ end
-- get compile flags
local compflags = opt.compflags