summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-02 23:34:28 +0800
committerruki <[email protected]>2021-09-02 23:34:28 +0800
commitb47154e928d5fa960365a205420912ae1363ba53 (patch)
tree53d42d5a36a0391fd78a09f69503ca44bb1ee3a2
parentae7c9e6398f72b314d6601a324d5fbf3829c547b (diff)
use build mode for fpc
-rw-r--r--xmake/languages/pascal/xmake.lua2
-rw-r--r--xmake/modules/core/tools/fpc.lua47
-rw-r--r--xmake/rules/pascal/xmake.lua15
-rw-r--r--xmake/toolchains/fpc/xmake.lua7
4 files changed, 16 insertions, 55 deletions
diff --git a/xmake/languages/pascal/xmake.lua b/xmake/languages/pascal/xmake.lua
index bdf82f290..ba052ef36 100644
--- a/xmake/languages/pascal/xmake.lua
+++ b/xmake/languages/pascal/xmake.lua
@@ -22,7 +22,7 @@ language("pascal")
add_rules("pascal")
set_sourcekinds {pc = {".pas", ".pp"}}
set_sourceflags {pc = "pcflags"}
- set_targetkinds {binary = "ld", static = "ar", shared = "sh"}
+ set_targetkinds {binary = "pcld", static = "pcar", shared = "pcsh"}
set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"}
set_langkinds {pascal = "pc"}
set_mixingkinds("pc", "cc", "cxx", "as")
diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua
index b83fd6ea8..65662de4c 100644
--- a/xmake/modules/core/tools/fpc.lua
+++ b/xmake/modules/core/tools/fpc.lua
@@ -22,61 +22,32 @@
import("core.base.option")
import("core.project.config")
import("core.project.project")
-import("core.project.target")
-- init it
function init(self)
end
--- make the strip flag
-function nf_strip(self, level)
-end
-
--- make the define flag
-function nf_define(self, macro)
- return "-D" .. macro
-end
-
-- make the optimize flag
function nf_optimize(self, level)
end
--- make the link flag
-function nf_link(self, lib)
- return "-l" .. lib
-end
-
--- make the syslink flag
-function nf_syslink(self, lib)
- return nf_link(self, lib)
+-- make the symbol flag
+function nf_symbol(self, level)
end
-- make the linkdir flag
function nf_linkdir(self, dir)
- return {"-L", dir}
+ return {"-L" .. dir}
end
--- make the link arguments list
-function linkargv(self, objectfiles, targetkind, targetfile, flags)
- local argv = {}
- return self:program(), argv
+-- make the build arguments list
+function buildargv(self, sourcefiles, targetkind, targetfile, flags)
+ return self:program(), table.join(flags, "-o" .. targetfile, sourcefiles)
end
--- link the target file
-function link(self, objectfiles, targetkind, targetfile, flags)
+-- build the target file
+function build(self, sourcefiles, targetkind, targetfile, flags)
os.mkdir(path.directory(targetfile))
- os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags))
-end
-
--- make the compile arguments list
-function compargv(self, sourcefile, objectfile, flags)
- return self:program(), table.join("-Sd", "-Cn", flags, "-FE" .. path.directory(objectfile), sourcefile)
-end
-
--- compile the source file
-function compile(self, sourcefile, objectfile, dependinfo, flags)
- os.mkdir(path.directory(objectfile))
- os.runv(compargv(self, sourcefile, objectfile, flags))
- os.mv(path.join(path.directory(objectfile), path.basename(sourcefile) .. ".o"), objectfile)
+ os.runv(buildargv(self, sourcefiles, targetkind, targetfile, flags))
end
diff --git a/xmake/rules/pascal/xmake.lua b/xmake/rules/pascal/xmake.lua
index bca2bc3ce..5961c08d3 100644
--- a/xmake/rules/pascal/xmake.lua
+++ b/xmake/rules/pascal/xmake.lua
@@ -21,13 +21,7 @@
-- define rule: pascal.build
rule("pascal.build")
set_sourcekinds("pc")
- on_load(function (target)
- -- we disable to build across targets in parallel, because the source files may depend on other target modules
- target:set("policy", "build.across_targets_in_parallel", false)
- end)
- on_build_files(function (target, sourcebatch, opt)
- import("private.action.build.object").build(target, sourcebatch, opt)
- end)
+ on_build("build.target")
-- define rule: pascal
rule("pascal")
@@ -37,10 +31,3 @@ 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")
diff --git a/xmake/toolchains/fpc/xmake.lua b/xmake/toolchains/fpc/xmake.lua
index b59f21376..5fab445af 100644
--- a/xmake/toolchains/fpc/xmake.lua
+++ b/xmake/toolchains/fpc/xmake.lua
@@ -27,9 +27,12 @@ toolchain("fpc")
-- set toolset
set_toolset("pc", "$(env PC)", "fpc")
--- set_toolset("pcld", "$(env PC)", "fpc")
--- set_toolset("pcsh", "$(env PC)", "fpc")
+ set_toolset("pcld", "$(env PC)", "fpc")
+ set_toolset("pcsh", "$(env PC)", "fpc")
+ set_toolset("pcar", "$(env PC)", "fpc")
-- on load
on_load(function (toolchain)
+ toolchain:set("pcshflags", "")
+ toolchain:set("pcldflags", "")
end)