summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-04 00:58:26 +0800
committerruki <[email protected]>2021-09-04 00:58:26 +0800
commitc4b3c9836293e77fcfc87b3e8f788cc974b1e59a (patch)
treece9d93b6a99b750d31d73982e929f16e122a3cb6 /xmake
parent836284af26a6d4edb1670cd6266d31c16b43ba2c (diff)
add pascal shared template
Diffstat (limited to 'xmake')
-rw-r--r--xmake/templates/pascal/shared/project/src/foo.pas19
-rw-r--r--xmake/templates/pascal/shared/project/src/main.pas13
-rw-r--r--xmake/templates/pascal/shared/project/xmake.lua12
-rw-r--r--xmake/templates/pascal/shared/template.lua2
-rw-r--r--xmake/toolchains/fpc/xmake.lua3
5 files changed, 49 insertions, 0 deletions
diff --git a/xmake/templates/pascal/shared/project/src/foo.pas b/xmake/templates/pascal/shared/project/src/foo.pas
new file mode 100644
index 000000000..788950f46
--- /dev/null
+++ b/xmake/templates/pascal/shared/project/src/foo.pas
@@ -0,0 +1,19 @@
+library foo;
+
+{$mode objfpc}{$H+}
+
+function fib(n : Int64) : Int64; cdecl;
+begin
+ if n > 1 then
+ begin
+ Result := fib(n - 1) + fib(n - 2);
+ end
+ else
+ Result := 1;
+end;
+
+exports
+ fib;
+end.
+
+
diff --git a/xmake/templates/pascal/shared/project/src/main.pas b/xmake/templates/pascal/shared/project/src/main.pas
new file mode 100644
index 000000000..02d5e88d0
--- /dev/null
+++ b/xmake/templates/pascal/shared/project/src/main.pas
@@ -0,0 +1,13 @@
+program hello;
+
+function fib(n: Int64): Int64;
+ cdecl; external 'foo';
+
+var
+ Value: Integer;
+begin
+ Value := 5;
+ WriteLn(fib(Value));
+end.
+
+
diff --git a/xmake/templates/pascal/shared/project/xmake.lua b/xmake/templates/pascal/shared/project/xmake.lua
new file mode 100644
index 000000000..dd29cf486
--- /dev/null
+++ b/xmake/templates/pascal/shared/project/xmake.lua
@@ -0,0 +1,12 @@
+add_rules("mode.debug", "mode.release")
+target("foo")
+ set_kind("shared")
+ add_files("src/foo.pas")
+
+target("${TARGETNAME}")
+ set_kind("binary")
+ add_deps("foo")
+ add_files("src/main.pas")
+
+
+${FAQ}
diff --git a/xmake/templates/pascal/shared/template.lua b/xmake/templates/pascal/shared/template.lua
new file mode 100644
index 000000000..d7ec5bae4
--- /dev/null
+++ b/xmake/templates/pascal/shared/template.lua
@@ -0,0 +1,2 @@
+template("shared")
+ add_configfiles("xmake.lua")
diff --git a/xmake/toolchains/fpc/xmake.lua b/xmake/toolchains/fpc/xmake.lua
index 82c7f6dc8..0d9cba292 100644
--- a/xmake/toolchains/fpc/xmake.lua
+++ b/xmake/toolchains/fpc/xmake.lua
@@ -35,4 +35,7 @@ toolchain("fpc")
on_load(function (toolchain)
toolchain:set("pcshflags", "-Sd")
toolchain:set("pcldflags", "-Sd")
+ if toolchain:is_plat("linux") then
+ toolchain:add("pcldflags", "-k-lc")
+ end
end)