From f73e850fdce6d46aa05cab820060fa0c0f48f9d8 Mon Sep 17 00:00:00 2001 From: lebao3105 Date: Tue, 13 Jan 2026 23:13:02 +0700 Subject: Improved Free Pascal Compiler support --- xmake/languages/pascal/load.lua | 21 +++++++++++++++++++-- xmake/languages/pascal/xmake.lua | 29 +++++++++++++++++++++++++++-- xmake/modules/core/tools/fpc.lua | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index 24cbee327..5e0979a30 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -30,6 +30,11 @@ 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" + , "target.set_languagemode" -- option.add_xxx , "option.add_links" , "option.add_syslinks" @@ -38,6 +43,11 @@ function _get_apis() , "option.add_arflags" , "option.add_shflags" , "option.add_rpathdirs" + , "option.add_unitdirs" + , "option.add_includedirs" + , "option.add_defines" + , "option.add_undefines" + , "option.set_languagemode" -- package.add_xxx , "package.add_links" , "package.add_syslinks" @@ -47,6 +57,10 @@ function _get_apis() , "package.add_shflags" , "package.add_rpathdirs" , "package.add_linkdirs" + , "package.add_unitdirs" + , "package.add_includedirs" + , "package.add_defines" + , "package.add_undefines" -- toolchain.add_xxx , "toolchain.add_links" , "toolchain.add_syslinks" @@ -56,6 +70,11 @@ 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_languagemode" } apis.paths = { -- target.add_xxx @@ -70,5 +89,3 @@ end function main() return {apis = _get_apis()} end - - diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua index 0b7c2ae05..deb0231dd 100644 --- a/xmake/languages/pascal/xmake.lua +++ b/xmake/languages/pascal/xmake.lua @@ -32,17 +32,38 @@ language("pascal") set_nameflags { object = { - "target.symbols" + "config.includedirs" + , "config.unitdirs" + , "target.symbols" , "target.warnings" + , "target.defines" + , "target.undefines" + , "target.includedirs" + , "target.unitdirs" + , "target.languagemode" , "target.optimize:check" , "target.vectorexts:check" + , "toolchain.includedirs" + , "toolchain.unitdirs" + , "toolchain.languagemode" + , "toolchain.defines" + , "toolchain.undefines" } , binary = { "config.linkdirs" + , "config.includedirs" + , "config.unitdirs" + , "config.defines" + , "config.undefines" , "target.linkdirs" , "target.rpathdirs" , "target.strip" , "target.symbols" + , "target.defines" + , "target.undefines" + , "target.includedirs" + , "target.unitdirs" + , "target.languagemode" , "toolchain.linkdirs" , "toolchain.rpathdirs" , "config.links" @@ -53,6 +74,11 @@ language("pascal") , "config.syslinks" , "target.syslinks" , "toolchain.syslinks" + , "toolchain.includedirs" + , "toolchain.unitdirs" + , "toolchain.languagemode" + , "toolchain.defines" + , "toolchain.undefines" } , shared = { "config.linkdirs" @@ -87,4 +113,3 @@ language("pascal") , {nil, "linkdirs", "kv", nil, "The Link Search Directories" } } } - diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index 18298cd6c..15216ce96 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -102,6 +102,41 @@ function nf_frameworkdir(self, frameworkdir) return {"-k-F", path.translate(frameworkdir)} end +-- make the includedir flag +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} +end + +-- make the undefine flag +function nf_undefine(self, macro) + return {"-u" .. macro} +end + +-- make the language flag +function nf_languagemode(self, language) + local table = { + pascal = "-Mfpc", + fpc = "-Mfpc", + objfpc = "-Mobjfpc", + delphi = "-Mdelphi", + macpas = "-Mmacpas", + isopas = "-Miso", + extendedpascal = "-Mextendedpascal", + delphiunicode = "-Mdelphiunicode", + } + return table[language] +end + -- make the build arguments list function buildargv(self, sourcefiles, targetkind, targetfile, flags) return self:program(), table.join(flags, "-o" .. targetfile, sourcefiles) @@ -112,4 +147,3 @@ function build(self, sourcefiles, targetkind, targetfile, flags) os.mkdir(path.directory(targetfile)) os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags)) end - -- cgit v1.3.1 From c4893018e56ddd2c6a4e8cdba47feb020c20f1af Mon Sep 17 00:00:00 2001 From: lebao3105 Date: Wed, 14 Jan 2026 16:00:46 +0700 Subject: Change set_languagemode to add_languages --- xmake/languages/pascal/load.lua | 6 +++--- xmake/modules/core/tools/fpc.lua | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index 5e0979a30..41fe76d7a 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -34,7 +34,7 @@ function _get_apis() , "target.add_includedirs" , "target.add_defines" , "target.add_undefines" - , "target.set_languagemode" + , "target.add_languages" -- option.add_xxx , "option.add_links" , "option.add_syslinks" @@ -47,7 +47,7 @@ function _get_apis() , "option.add_includedirs" , "option.add_defines" , "option.add_undefines" - , "option.set_languagemode" + , "option.add_languages" -- package.add_xxx , "package.add_links" , "package.add_syslinks" @@ -74,7 +74,7 @@ function _get_apis() , "toolchain.add_includedirs" , "toolchain.add_defines" , "toolchain.add_undefines" - , "toolchain.set_languagemode" + , "toolchain.add_languages" } apis.paths = { -- target.add_xxx diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index 15216ce96..49be3156d 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -123,8 +123,8 @@ function nf_undefine(self, macro) end -- make the language flag -function nf_languagemode(self, language) - local table = { +function nf_language(self, language) + local mode = { pascal = "-Mfpc", fpc = "-Mfpc", objfpc = "-Mobjfpc", @@ -134,7 +134,7 @@ function nf_languagemode(self, language) extendedpascal = "-Mextendedpascal", delphiunicode = "-Mdelphiunicode", } - return table[language] + return mode[language] end -- make the build arguments list -- cgit v1.3.1 From ba8452539e6a85d5e8cd1aaa9310a0fb5ba77c02 Mon Sep 17 00:00:00 2001 From: lebao3105 Date: Wed, 14 Jan 2026 16:12:51 +0700 Subject: Add missing package.set_languages nameflag --- xmake/languages/pascal/load.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index 41fe76d7a..a1cd1f6d0 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -34,7 +34,6 @@ function _get_apis() , "target.add_includedirs" , "target.add_defines" , "target.add_undefines" - , "target.add_languages" -- option.add_xxx , "option.add_links" , "option.add_syslinks" @@ -47,7 +46,6 @@ function _get_apis() , "option.add_includedirs" , "option.add_defines" , "option.add_undefines" - , "option.add_languages" -- package.add_xxx , "package.add_links" , "package.add_syslinks" @@ -74,7 +72,16 @@ function _get_apis() , "toolchain.add_includedirs" , "toolchain.add_defines" , "toolchain.add_undefines" - , "toolchain.add_languages" + , "toolchain.set_languages" + -- target.set_xxx + , "target.set_languages" + -- option.set_xxx + , "option.set_languages" + -- package.set_xxx + , "package.set_languages" + -- toolchain.set_xxx + , "toolchain.set_languages" + } apis.paths = { -- target.add_xxx -- cgit v1.3.1 From 18ffb736a64aa3cd79310da253f9277d8b8ca279 Mon Sep 17 00:00:00 2001 From: lebao3105 Date: Sun, 18 Jan 2026 17:30:10 +0700 Subject: feat: Add exceptions & objectdirs nameflags --- xmake/languages/pascal/load.lua | 9 ++++- xmake/languages/pascal/xmake.lua | 74 +++++++++++++++++++++++++--------------- xmake/modules/core/tools/fpc.lua | 14 ++++++-- 3 files changed, 67 insertions(+), 30 deletions(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index a1cd1f6d0..e23e7696a 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -75,13 +75,20 @@ function _get_apis() , "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 = { -- target.add_xxx diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua index deb0231dd..75806b56b 100644 --- a/xmake/languages/pascal/xmake.lua +++ b/xmake/languages/pascal/xmake.lua @@ -34,66 +34,86 @@ language("pascal") object = { "config.includedirs" , "config.unitdirs" + , "target.linkdirs" + , "target.rpathdirs" + , "target.strip" , "target.symbols" , "target.warnings" , "target.defines" , "target.undefines" , "target.includedirs" , "target.unitdirs" - , "target.languagemode" + , "target.objectdirs" + , "target.exceptions" + , "target.languages" , "target.optimize:check" , "target.vectorexts:check" , "toolchain.includedirs" , "toolchain.unitdirs" - , "toolchain.languagemode" + , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" + , "toolchain.objectdirs" + , "toolchain.exceptions" + , "toolchain.linkdirs" + , "toolchain.rpathdirs" + , "toolchain.strip" } , binary = { - "config.linkdirs" - , "config.includedirs" + "config.includedirs" , "config.unitdirs" - , "config.defines" - , "config.undefines" , "target.linkdirs" , "target.rpathdirs" , "target.strip" , "target.symbols" + , "target.warnings" , "target.defines" , "target.undefines" , "target.includedirs" , "target.unitdirs" - , "target.languagemode" - , "toolchain.linkdirs" - , "toolchain.rpathdirs" - , "config.links" - , "target.links" - , "target.frameworks" - , "target.frameworkdirs" - , "toolchain.links" - , "config.syslinks" - , "target.syslinks" - , "toolchain.syslinks" + , "target.objectdirs" + , "target.exceptions" + , "target.languages" + , "target.optimize:check" + , "target.vectorexts:check" , "toolchain.includedirs" , "toolchain.unitdirs" - , "toolchain.languagemode" + , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" + , "toolchain.objectdirs" + , "toolchain.exceptions" + , "toolchain.linkdirs" + , "toolchain.rpathdirs" + , "toolchain.strip" } , shared = { - "config.linkdirs" + "config.includedirs" + , "config.unitdirs" , "target.linkdirs" + , "target.rpathdirs" , "target.strip" , "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" , "toolchain.linkdirs" - , "config.links" - , "target.links" - , "target.frameworks" - , "target.frameworkdirs" - , "toolchain.links" - , "config.syslinks" - , "target.syslinks" - , "toolchain.syslinks" + , "toolchain.rpathdirs" + , "toolchain.strip" } } diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index 49be3156d..79cc4d62a 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -104,7 +104,7 @@ end -- make the includedir flag function nf_includedir(self, includedir) - return {"-FI" .. path.translate(includedir)} + return {"-Fi" .. path.translate(includedir)} end -- make the unitdir flag @@ -134,7 +134,17 @@ function nf_language(self, language) extendedpascal = "-Mextendedpascal", delphiunicode = "-Mdelphiunicode", } - return mode[language] + return mode[language:lower()] +end + +-- make the exception flag +function nf_exception(self, exp) + return {exp:startswith("no-") 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 -- cgit v1.3.1 From 0e9aa3375f073fd9987867574854f0445d6a3971 Mon Sep 17 00:00:00 2001 From: lebao3105 Date: Sun, 18 Jan 2026 18:24:02 +0700 Subject: Update nameflags list --- xmake/languages/pascal/xmake.lua | 28 ++++++++++++++++++++++------ xmake/modules/core/tools/fpc.lua | 4 +++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua index 75806b56b..2ff4c0615 100644 --- a/xmake/languages/pascal/xmake.lua +++ b/xmake/languages/pascal/xmake.lua @@ -34,9 +34,6 @@ language("pascal") object = { "config.includedirs" , "config.unitdirs" - , "target.linkdirs" - , "target.rpathdirs" - , "target.strip" , "target.symbols" , "target.warnings" , "target.defines" @@ -55,15 +52,20 @@ language("pascal") , "toolchain.undefines" , "toolchain.objectdirs" , "toolchain.exceptions" - , "toolchain.linkdirs" - , "toolchain.rpathdirs" - , "toolchain.strip" } , binary = { "config.includedirs" , "config.unitdirs" + , "config.linkdirs" + , "config.frameworks" + , "config.frameworkdirs" + , "config.rpathdirs" + , "config.syslinks" , "target.linkdirs" , "target.rpathdirs" + , "target.syslinks" + , "target.frameworks" + , "target.frameworkdirs" , "target.strip" , "target.symbols" , "target.warnings" @@ -86,12 +88,23 @@ language("pascal") , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.strip" + , "toolchain.syslinks" + , "toolchain.frameworks" + , "toolchain.frameworkdirs" } , shared = { "config.includedirs" , "config.unitdirs" + , "config.linkdirs" + , "config.frameworks" + , "config.frameworkdirs" + , "config.rpathdirs" + , "config.syslinks" , "target.linkdirs" , "target.rpathdirs" + , "target.syslinks" + , "target.frameworks" + , "target.frameworkdirs" , "target.strip" , "target.symbols" , "target.warnings" @@ -114,6 +127,9 @@ language("pascal") , "toolchain.linkdirs" , "toolchain.rpathdirs" , "toolchain.strip" + , "toolchain.syslinks" + , "toolchain.frameworks" + , "toolchain.frameworkdirs" } } diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index 79cc4d62a..b6d7e80c2 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -138,8 +138,10 @@ function nf_language(self, language) end -- make the exception flag +-- considering this applies to all dialects, +-- make this only accept on/off function nf_exception(self, exp) - return {exp:startswith("no-") and "-Sx-" or "-Sx"} + return {exp == "off" and "-Sx-" or "-Sx"} end -- make the objectdir flag -- cgit v1.3.1 From df870ffd7cf1b7c4cb5df311f437ffef03678178 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 24 Jan 2026 00:55:36 +0800 Subject: improve fpc --- xmake/core/tool/compiler.lua | 47 ++++++++++++++++++++++++++-------------- xmake/languages/pascal/load.lua | 8 ------- xmake/languages/pascal/xmake.lua | 15 ------------- 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 -- cgit v1.3.1 From 4d40ef4dc24a62b0995bd7d13dab7d4fcad98f46 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 24 Jan 2026 21:07:24 +0800 Subject: fix fpc --- .github/workflows/cosmocc.yml | 4 ++-- xmake/modules/core/tools/fpc.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cosmocc.yml b/.github/workflows/cosmocc.yml index 5f4479561..4bcfa9a2c 100644 --- a/.github/workflows/cosmocc.yml +++ b/.github/workflows/cosmocc.yml @@ -55,8 +55,8 @@ jobs: RUN_PROBABILITY: ${{ vars.COSMOCC_RUN_PROBABILITY || '0.5' }} build: - needs: check - if: needs.check.outputs.should-run == 'true' + #needs: check + #if: needs.check.outputs.should-run == 'true' strategy: matrix: os: [ubuntu-latest, macos-15-intel] diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index f207061dc..c08fcef14 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -151,7 +151,7 @@ function buildargv(self, sourcefiles, targetkind, targetfile, flags, opt) end -- build the target file -function build(self, sourcefiles, targetkind, targetfile, flags) +function build(self, sourcefiles, targetkind, targetfile, flags, opt) os.mkdir(path.directory(targetfile)) - os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags)) + os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags, opt)) end -- cgit v1.3.1 From f4af385406eec4868b776c1fc32d7468dc303cc4 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 24 Jan 2026 22:44:34 +0800 Subject: revert compile --- xmake/core/tool/compiler.lua | 66 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua index e2125abcc..dce7bf532 100644 --- a/xmake/core/tool/compiler.lua +++ b/xmake/core/tool/compiler.lua @@ -203,6 +203,7 @@ function compiler.load(sourcekind, target) return instance end +--[[ -- build the source files (compile and link) function compiler:build(sourcefiles, targetfile, opt) opt = opt or {} @@ -267,6 +268,62 @@ function compiler:buildargv(sourcefiles, targetfile, opt) targetkind = target:kind() end return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags, opt) +end]] + +-- build the source files (compile and link) +function compiler:build(sourcefiles, targetfile, opt) + opt = opt or {} + + -- get compile flags + local compflags = opt.compflags + if not compflags then + -- patch sourcefile to get flags of the given source file + if type(sourcefiles) == "string" then + opt.sourcefile = sourcefiles + end + compflags = self:compflags(opt) + end + + -- make flags + local flags = compflags + if opt.target then + flags = table.join(flags, opt.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() + end + return sandbox.load(self:_tool().build, self:_tool(), sourcefiles, targetkind or "binary", targetfile, flags) +end + +-- get the build arguments list (compile and link) +function compiler:buildargv(sourcefiles, targetfile, opt) + opt = opt or {} + + -- get compile flags + local compflags = opt.compflags + if not compflags then + -- patch sourcefile to get flags of the given source file + if type(sourcefiles) == "string" then + opt.sourcefile = sourcefiles + end + compflags = self:compflags(opt) + end + + -- make flags + local flags = compflags + if opt.target then + flags = table.join(flags, opt.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() + end + return self:_tool():buildargv(sourcefiles, targetkind or "binary", targetfile, flags) end -- get the build command @@ -277,11 +334,12 @@ 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 + end]] -- get compile flags local compflags = opt.compflags @@ -294,6 +352,8 @@ 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) @@ -302,11 +362,13 @@ end -- get the compile arguments list function compiler:compargv(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 + end]] -- get compile flags local compflags = opt.compflags -- cgit v1.3.1 From 709b454524f08e7ba01f7872194fc29d3d448dec Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 25 Jan 2026 15:20:56 +0800 Subject: fix pascal apis --- xmake/languages/pascal/load.lua | 13 ------- xmake/languages/pascal/xmake.lua | 81 +++++++++++++++++----------------------- xmake/rules/pascal/xmake.lua | 14 +++++++ 3 files changed, 48 insertions(+), 60 deletions(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index cb6c3117f..07f25e8b8 100644 --- a/xmake/languages/pascal/load.lua +++ b/xmake/languages/pascal/load.lua @@ -68,19 +68,6 @@ function _get_apis() , "toolchain.add_includedirs" , "toolchain.add_defines" , "toolchain.add_undefines" - , "toolchain.set_languages" - -- target.set_xxx - , "target.set_languages" - , "target.set_exceptions" - -- option.set_xxx - , "option.set_languages" - , "option.set_exceptions" - -- package.set_xxx - , "package.set_languages" - , "package.set_exceptions" - -- toolchain.set_xxx - , "toolchain.set_languages" - , "toolchain.set_exceptions" } apis.paths = { -- target.add_xxx diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua index feafb5440..de31378af 100644 --- a/xmake/languages/pascal/xmake.lua +++ b/xmake/languages/pascal/xmake.lua @@ -33,88 +33,75 @@ language("pascal") set_nameflags { object = { "config.includedirs" + , "config.frameworkdirs" + , "config.frameworks" , "target.symbols" , "target.warnings" + , "target.fpmodels" + , "target.optimize:check" + , "target.vectorexts:check" + , "target.languages" + , "target.includedirs" , "target.defines" , "target.undefines" - , "target.includedirs" + , "target.frameworkdirs" + , "target.frameworks" , "target.exceptions" - , "target.languages" - , "target.optimize:check" - , "target.vectorexts:check" + , "target.encodings" + , "target.forceincludes" , "toolchain.includedirs" - , "toolchain.languages" , "toolchain.defines" , "toolchain.undefines" + , "toolchain.frameworkdirs" + , "toolchain.frameworks" , "toolchain.exceptions" + , "toolchain.languages" } , binary = { - "config.includedirs" - , "config.linkdirs" - , "config.frameworks" + "config.linkdirs" , "config.frameworkdirs" + , "config.frameworks" , "config.rpathdirs" , "config.syslinks" , "target.linkdirs" - , "target.rpathdirs" - , "target.syslinks" - , "target.frameworks" , "target.frameworkdirs" + , "target.rpathdirs" , "target.strip" , "target.symbols" - , "target.warnings" - , "target.defines" - , "target.undefines" - , "target.includedirs" - , "target.exceptions" - , "target.languages" , "target.optimize:check" - , "target.vectorexts:check" - , "toolchain.includedirs" - , "toolchain.languages" - , "toolchain.defines" - , "toolchain.undefines" - , "toolchain.exceptions" , "toolchain.linkdirs" , "toolchain.rpathdirs" - , "toolchain.strip" - , "toolchain.syslinks" - , "toolchain.frameworks" , "toolchain.frameworkdirs" + , "config.links" + , "target.links" + , "toolchain.links" + , "target.frameworks" + , "toolchain.frameworks" + , "target.syslinks" + , "toolchain.syslinks" } , shared = { - "config.includedirs" - , "config.linkdirs" - , "config.frameworks" + "config.linkdirs" , "config.frameworkdirs" + , "config.frameworks" , "config.rpathdirs" , "config.syslinks" , "target.linkdirs" - , "target.rpathdirs" - , "target.syslinks" - , "target.frameworks" , "target.frameworkdirs" + , "target.rpathdirs" , "target.strip" , "target.symbols" - , "target.warnings" - , "target.defines" - , "target.undefines" - , "target.includedirs" - , "target.exceptions" - , "target.languages" , "target.optimize:check" - , "target.vectorexts:check" - , "toolchain.includedirs" - , "toolchain.languages" - , "toolchain.defines" - , "toolchain.undefines" - , "toolchain.exceptions" , "toolchain.linkdirs" , "toolchain.rpathdirs" - , "toolchain.strip" - , "toolchain.syslinks" - , "toolchain.frameworks" , "toolchain.frameworkdirs" + , "config.links" + , "target.links" + , "toolchain.links" + , "target.frameworks" + , "toolchain.frameworks" + , "target.syslinks" + , "toolchain.syslinks" } } diff --git a/xmake/rules/pascal/xmake.lua b/xmake/rules/pascal/xmake.lua index 4b318702b..03b027e07 100644 --- a/xmake/rules/pascal/xmake.lua +++ b/xmake/rules/pascal/xmake.lua @@ -31,3 +31,17 @@ rule("pascal") -- inherit links and linkdirs of all dependent targets by default add_deps("utils.inherit.links") + + -- support `add_files("src/*.o")` and `add_files("src/*.a")` to merge object and archive files to target + add_deps("utils.merge.object", "utils.merge.archive") + + -- we attempt to extract symbols to the independent file and + -- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled + add_deps("utils.symbols.extract") + + -- add platform rules + add_deps("platform.wasm") + add_deps("platform.windows") + + -- add linker rules + add_deps("linker") -- cgit v1.3.1 From 998581c1cc5af94486d9f631a64e7721a3f84031 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 25 Jan 2026 19:02:45 +0800 Subject: fix add_includedirs for pascal --- xmake/languages/pascal/load.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/languages/pascal/load.lua b/xmake/languages/pascal/load.lua index 07f25e8b8..45b007272 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_includedirs" , "target.add_defines" , "target.add_undefines" -- option.add_xxx @@ -72,6 +71,7 @@ function _get_apis() apis.paths = { -- target.add_xxx "target.add_linkdirs" + , "target.add_includedirs" , "target.add_frameworkdirs" -- option.add_xxx , "option.add_linkdirs" -- cgit v1.3.1