diff options
| author | lebao3105 <[email protected]> | 2026-01-13 23:13:02 +0700 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-23 23:16:31 +0800 |
| commit | f73e850fdce6d46aa05cab820060fa0c0f48f9d8 (patch) | |
| tree | 3843020e19f4b240b5d6ee7691c2548df2b0920f | |
| parent | 865ed17e98b3fa230b342138e3aaa6e9e5093cda (diff) | |
Improved Free Pascal Compiler support
| -rw-r--r-- | xmake/languages/pascal/load.lua | 21 | ||||
| -rw-r--r-- | xmake/languages/pascal/xmake.lua | 29 | ||||
| -rw-r--r-- | 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 - |
