summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-01-26 13:28:13 +0800
committerruki <[email protected]>2025-01-26 13:28:13 +0800
commit2dff9f8387dde9bdaa59ef7c693927d54fbd27ab (patch)
treed9390514bddb2077e16a40ce562c76416b8c78d5
parent9472fb3d2c57ecadf66efec734372bb7d46a4443 (diff)
add ilinkarm
-rw-r--r--xmake/modules/core/tools/ilinkarm.lua76
1 files changed, 76 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/ilinkarm.lua b/xmake/modules/core/tools/ilinkarm.lua
new file mode 100644
index 000000000..3c5a4a813
--- /dev/null
+++ b/xmake/modules/core/tools/ilinkarm.lua
@@ -0,0 +1,76 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file ilinkarm.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.base.global")
+import("core.project.policy")
+import("core.language.language")
+import("utils.progress")
+
+-- make the strip flag
+function nf_strip(self, level)
+ local maps = {
+ debug = "--strip"
+ , all = "--strip"
+ }
+ return maps[level]
+end
+
+-- make the link flag
+function nf_link(self, lib)
+ if not lib:endswith(".a") and not lib:endswith(".so") then
+ lib = "lib" .. lib .. ".a"
+ end
+ return "-l" .. lib
+end
+
+-- make the syslink flag
+function nf_syslink(self, lib)
+ return nf_link(self, lib)
+end
+
+-- make the linkdir flag
+function nf_linkdir(self, dir)
+ return {"-i" .. path.translate(dir)}
+end
+
+-- make the link arguments list
+function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+ local argv = table.join("-o", targetfile, objectfiles, flags)
+ return self:program(), argv
+end
+
+-- link the target file
+--
+-- maybe we need to use os.vrunv() to show link output when enable verbose information
+-- @see https://github.com/xmake-io/xmake/discussions/2916
+--
+function link(self, objectfiles, targetkind, targetfile, flags, opt)
+ opt = opt or {}
+ os.mkdir(path.directory(targetfile))
+ local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags)
+ if option.get("verbose") then
+ os.execv(program, argv, {envs = self:runenvs(), shell = opt.shell})
+ else
+ os.vrunv(program, argv, {envs = self:runenvs(), shell = opt.shell})
+ end
+end
+