diff options
| author | ruki <[email protected]> | 2025-01-24 22:45:58 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-01-24 22:45:58 +0800 |
| commit | 1f59ab2428339916eafc2bdc1350641cc1c4f6d3 (patch) | |
| tree | 27c03e7f47ba77018516d91e0d63421b1fdf4f7d | |
| parent | dbaf52568f4bb1152ad7123917a98b52f60adaa6 (diff) | |
support static libs
| -rw-r--r-- | xmake/modules/core/tools/ar6x.lua | 27 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cl6x.lua | 29 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_ar6x.lua | 36 | ||||
| -rw-r--r-- | xmake/toolchains/ti-c6000/xmake.lua | 2 |
4 files changed, 80 insertions, 14 deletions
diff --git a/xmake/modules/core/tools/ar6x.lua b/xmake/modules/core/tools/ar6x.lua new file mode 100644 index 000000000..455b7dd1e --- /dev/null +++ b/xmake/modules/core/tools/ar6x.lua @@ -0,0 +1,27 @@ +--!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 ar6x.lua +-- + +inherit("ar") + +-- init it +function init(self) + self:set("arflags", "-r") +end + diff --git a/xmake/modules/core/tools/cl6x.lua b/xmake/modules/core/tools/cl6x.lua index 0485d2b9c..c2d272bb7 100644 --- a/xmake/modules/core/tools/cl6x.lua +++ b/xmake/modules/core/tools/cl6x.lua @@ -80,6 +80,35 @@ function nf_sysincludedir(self, dir) return nf_includedir(self, dir) 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 rpathdir flag +function nf_rpathdir(self, dir, opt) + opt = opt or {} + local extra = opt.extra + if extra and extra.installonly then + return + end + dir = path.translate(dir) + return {"-rpath=" .. dir} +end + -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) local argv = table.join("-z", "--output_file=" .. targetfile, objectfiles, flags) diff --git a/xmake/modules/detect/tools/find_ar6x.lua b/xmake/modules/detect/tools/find_ar6x.lua index 9df72e8e6..823a1f220 100644 --- a/xmake/modules/detect/tools/find_ar6x.lua +++ b/xmake/modules/detect/tools/find_ar6x.lua @@ -20,9 +20,24 @@ -- imports import("lib.detect.find_program") -import("lib.detect.find_programver") --- find ar6x +-- check +function _check(program) + + -- make a stub object file + local libraryfile = os.tmpfile() .. ".a" + local objectfile = os.tmpfile() .. ".o" + io.writefile(objectfile, "") + + -- archive it + os.execv(program, {"-r", libraryfile, objectfile}) + + -- remove files + os.rm(objectfile) + os.rm(libraryfile) +end + +-- find ar -- -- @param opt the argument options, e.g. {version = true} -- @@ -30,19 +45,14 @@ import("lib.detect.find_programver") -- -- @code -- --- local ar6x = find_ar6x() --- local ar6x, version = find_ar6x({program = "ar6x", version = true}) +-- local ar = find_ar6x() +-- local ar, version = find_ar6x({program = "xcrun -sdk macosx g++", version = true}) -- -- @endcode -- function main(opt) - opt = opt or {} - opt.check = "--help" - opt.command = "--help" - local program = find_program(opt.program or "ar6x", opt) - local version = nil - if program and opt.version then - version = find_programver(program, opt) - end - return program, version + opt = opt or {} + opt.check = opt.check or _check + return find_program(opt.program or "ar6x", opt) end + diff --git a/xmake/toolchains/ti-c6000/xmake.lua b/xmake/toolchains/ti-c6000/xmake.lua index 717b7029f..4fb587d23 100644 --- a/xmake/toolchains/ti-c6000/xmake.lua +++ b/xmake/toolchains/ti-c6000/xmake.lua @@ -29,7 +29,7 @@ toolchain("ti-c6000") set_toolset("sh", "cl6x") set_toolset("ar", "ar6x") set_toolset("strip", "strip6x") - set_toolset("as", "asm6x") + set_toolset("as", "cl6x") on_check(function (toolchain) return import("lib.detect.find_tool")("cl6x") |
