diff options
| author | ruki <[email protected]> | 2021-09-03 00:14:46 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-03 00:14:46 +0800 |
| commit | 91a2ebc3edf46a26c00807953e3a22d716bdeb95 (patch) | |
| tree | fb2ad96e161c95f4b6df1b74de87d081160b3227 | |
| parent | 20c34dcaf9ff92ecf08a1cec7e4d1be9836e6067 (diff) | |
add static library for pascal
| -rw-r--r-- | tests/projects/pascal/static/src/foo.pas | 23 | ||||
| -rw-r--r-- | tests/projects/pascal/static/src/main.pas | 14 | ||||
| -rw-r--r-- | tests/projects/pascal/static/xmake.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/core/tools/fpc.lua | 1 |
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/projects/pascal/static/src/foo.pas b/tests/projects/pascal/static/src/foo.pas new file mode 100644 index 000000000..d1952cf21 --- /dev/null +++ b/tests/projects/pascal/static/src/foo.pas @@ -0,0 +1,23 @@ +library foo; + +function SubStr(CString: PChar;FromPos,ToPos: Longint): PChar; cdecl; + +var + Length: Integer; + +begin + Length := StrLen(CString); + SubStr := CString + Length; + if (FromPos > 0) and (ToPos >= FromPos) then + begin + if Length >= FromPos then + SubStr := CString + FromPos; + if Length > ToPos then + CString[ToPos+1] := #0; + end; +end; + +exports + SubStr; + +end. diff --git a/tests/projects/pascal/static/src/main.pas b/tests/projects/pascal/static/src/main.pas new file mode 100644 index 000000000..ccf2e179b --- /dev/null +++ b/tests/projects/pascal/static/src/main.pas @@ -0,0 +1,14 @@ +uses strings; + +function SubStr(const CString: PChar; FromPos, ToPos: longint): PChar; + cdecl; external 'foo'; + +var + s: PChar; + FromPos, ToPos: Integer; +begin + s := strnew('TestMe'); + FromPos := 2; + ToPos := 3; + WriteLn(SubStr(s, FromPos, ToPos)); +end. diff --git a/tests/projects/pascal/static/xmake.lua b/tests/projects/pascal/static/xmake.lua new file mode 100644 index 000000000..759cf69ad --- /dev/null +++ b/tests/projects/pascal/static/xmake.lua @@ -0,0 +1,9 @@ +add_rules("mode.debug", "mode.release") +target("foo") + set_kind("static") + add_files("src/foo.pas") + +target("test") + set_kind("binary") + add_deps("foo") + add_files("src/main.pas") diff --git a/xmake/modules/core/tools/fpc.lua b/xmake/modules/core/tools/fpc.lua index de5b349c6..378c4175a 100644 --- a/xmake/modules/core/tools/fpc.lua +++ b/xmake/modules/core/tools/fpc.lua @@ -25,6 +25,7 @@ import("core.project.project") -- init it function init(self) + self:set("pcarflags", "-Xt") end -- make the optimize flag |
