diff options
| author | ruki <[email protected]> | 2026-01-24 00:55:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-24 00:55:36 +0800 |
| commit | df870ffd7cf1b7c4cb5df311f437ffef03678178 (patch) | |
| tree | 9d9c3850454f431321866fad080d6c01658ecd3e | |
| parent | 0e9aa3375f073fd9987867574854f0445d6a3971 (diff) | |
improve fpc
| -rw-r--r-- | xmake/core/tool/compiler.lua | 47 | ||||
| -rw-r--r-- | xmake/languages/pascal/load.lua | 8 | ||||
| -rw-r--r-- | xmake/languages/pascal/xmake.lua | 15 | ||||
| -rw-r--r-- | xmake/modules/core/tools/fpc.lua | 20 |
4 files changed, 39 insertions, 51 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 diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index e23e7696a..cb6c3117f 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -30,7 +30,6 @@ function _get_apis() , "target.add_arflags" , "target.add_shflags" , "target.add_rpathdirs" -- @note do not translate path, it's usually an absolute path or contains $ORIGIN/@loader_path - , "target.add_unitdirs" , "target.add_includedirs" , "target.add_defines" , "target.add_undefines" @@ -42,7 +41,6 @@ function _get_apis() , "option.add_arflags" , "option.add_shflags" , "option.add_rpathdirs" - , "option.add_unitdirs" , "option.add_includedirs" , "option.add_defines" , "option.add_undefines" @@ -55,7 +53,6 @@ function _get_apis() , "package.add_shflags" , "package.add_rpathdirs" , "package.add_linkdirs" - , "package.add_unitdirs" , "package.add_includedirs" , "package.add_defines" , "package.add_undefines" @@ -68,26 +65,21 @@ function _get_apis() , "toolchain.add_shflags" , "toolchain.add_rpathdirs" , "toolchain.add_linkdirs" - , "toolchain.add_unitdirs" , "toolchain.add_includedirs" , "toolchain.add_defines" , "toolchain.add_undefines" , "toolchain.set_languages" -- target.set_xxx , "target.set_languages" - , "target.set_objectdirs" , "target.set_exceptions" -- option.set_xxx , "option.set_languages" - , "option.set_objectdirs" , "option.set_exceptions" -- package.set_xxx , "package.set_languages" - , "package.set_objectdirs" , "package.set_exceptions" -- toolchain.set_xxx , "toolchain.set_languages" - , "toolchain.set_objectdirs" , "toolchain.set_exceptions" } apis.paths = { diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua index 2ff4c0615..feafb5440 100644 --- a/xmake/languages/pascal/xmake.lua +++ b/xmake/languages/pascal/xmake.lua @@ -33,29 +33,23 @@ language("pascal") set_nameflags { object = { "config.includedirs" - , "config.unitdirs" , "target.symbols" , "target.warnings" , "target.defines" , "target.undefines" , "target.includedirs" - , "target.unitdirs" - , "target.objectdirs" , "target.exceptions" , "target.languages" , "target.optimize:check" , "target.vectorexts:check" , "toolchain.includedirs" - , "toolchain.unitdirs" , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" - , "toolchain.objectdirs" , "toolchain.exceptions" } , binary = { "config.includedirs" - , "config.unitdirs" , "config.linkdirs" , "config.frameworks" , "config.frameworkdirs" @@ -72,18 +66,14 @@ language("pascal") , "target.defines" , "target.undefines" , "target.includedirs" - , "target.unitdirs" - , "target.objectdirs" , "target.exceptions" , "target.languages" , "target.optimize:check" , "target.vectorexts:check" , "toolchain.includedirs" - , "toolchain.unitdirs" , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" - , "toolchain.objectdirs" , "toolchain.exceptions" , "toolchain.linkdirs" , "toolchain.rpathdirs" @@ -94,7 +84,6 @@ language("pascal") } , shared = { "config.includedirs" - , "config.unitdirs" , "config.linkdirs" , "config.frameworks" , "config.frameworkdirs" @@ -111,18 +100,14 @@ language("pascal") , "target.defines" , "target.undefines" , "target.includedirs" - , "target.unitdirs" - , "target.objectdirs" , "target.exceptions" , "target.languages" , "target.optimize:check" , "target.vectorexts:check" , "toolchain.includedirs" - , "toolchain.unitdirs" , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" - , "toolchain.objectdirs" , "toolchain.exceptions" , "toolchain.linkdirs" , "toolchain.rpathdirs" diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index b6d7e80c2..f207061dc 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -107,11 +107,6 @@ function nf_includedir(self, includedir) return {"-Fi" .. path.translate(includedir)} end --- make the unitdir flag -function nf_unitdir(self, unitdir) - return {"-Fu" .. path.translate(unitdir)} -end - -- make the define flag function nf_define(self, macro) return {"-d" .. macro} @@ -144,14 +139,15 @@ function nf_exception(self, exp) return {exp == "off" and "-Sx-" or "-Sx"} end --- make the objectdir flag -function nf_objectdir(self, objectdir) - return {"-FU" .. path.translate(objectdir)} -end - -- make the build arguments list -function buildargv(self, sourcefiles, targetkind, targetfile, flags) - return self:program(), table.join(flags, "-o" .. targetfile, sourcefiles) +function buildargv(self, sourcefiles, targetkind, targetfile, flags, opt) + opt = opt or {} + local extraflags = {} + local objectdir = opt.target and opt.target:objectdir() + if objectdir then + table.insert(extraflags, "-FU" .. path.translate(objectdir)) + end + return self:program(), table.join(flags, extraflags, "-o" .. targetfile, sourcefiles) end -- build the target file |
