Skip to content

Commit 1f59ab2

Browse files
committed
support static libs
1 parent dbaf525 commit 1f59ab2

File tree

4 files changed

+80
-14
lines changed

4 files changed

+80
-14
lines changed

xmake/modules/core/tools/ar6x.lua

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--!A cross-platform build utility based on Lua
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
--
15+
-- Copyright (C) 2015-present, TBOOX Open Source Group.
16+
--
17+
-- @author ruki
18+
-- @file ar6x.lua
19+
--
20+
21+
inherit("ar")
22+
23+
-- init it
24+
function init(self)
25+
self:set("arflags", "-r")
26+
end
27+

xmake/modules/core/tools/cl6x.lua

+29
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,35 @@ function nf_sysincludedir(self, dir)
8080
return nf_includedir(self, dir)
8181
end
8282

83+
-- make the link flag
84+
function nf_link(self, lib)
85+
if not lib:endswith(".a") and not lib:endswith(".so") then
86+
lib = "lib" .. lib .. ".a"
87+
end
88+
return "-l" .. lib
89+
end
90+
91+
-- make the syslink flag
92+
function nf_syslink(self, lib)
93+
return nf_link(self, lib)
94+
end
95+
96+
-- make the linkdir flag
97+
function nf_linkdir(self, dir)
98+
return {"-i" .. path.translate(dir)}
99+
end
100+
101+
-- make the rpathdir flag
102+
function nf_rpathdir(self, dir, opt)
103+
opt = opt or {}
104+
local extra = opt.extra
105+
if extra and extra.installonly then
106+
return
107+
end
108+
dir = path.translate(dir)
109+
return {"-rpath=" .. dir}
110+
end
111+
83112
-- make the link arguments list
84113
function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
85114
local argv = table.join("-z", "--output_file=" .. targetfile, objectfiles, flags)

xmake/modules/detect/tools/find_ar6x.lua

+23-13
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,39 @@
2020

2121
-- imports
2222
import("lib.detect.find_program")
23-
import("lib.detect.find_programver")
2423

25-
-- find ar6x
24+
-- check
25+
function _check(program)
26+
27+
-- make a stub object file
28+
local libraryfile = os.tmpfile() .. ".a"
29+
local objectfile = os.tmpfile() .. ".o"
30+
io.writefile(objectfile, "")
31+
32+
-- archive it
33+
os.execv(program, {"-r", libraryfile, objectfile})
34+
35+
-- remove files
36+
os.rm(objectfile)
37+
os.rm(libraryfile)
38+
end
39+
40+
-- find ar
2641
--
2742
-- @param opt the argument options, e.g. {version = true}
2843
--
2944
-- @return program, version
3045
--
3146
-- @code
3247
--
33-
-- local ar6x = find_ar6x()
34-
-- local ar6x, version = find_ar6x({program = "ar6x", version = true})
48+
-- local ar = find_ar6x()
49+
-- local ar, version = find_ar6x({program = "xcrun -sdk macosx g++", version = true})
3550
--
3651
-- @endcode
3752
--
3853
function main(opt)
39-
opt = opt or {}
40-
opt.check = "--help"
41-
opt.command = "--help"
42-
local program = find_program(opt.program or "ar6x", opt)
43-
local version = nil
44-
if program and opt.version then
45-
version = find_programver(program, opt)
46-
end
47-
return program, version
54+
opt = opt or {}
55+
opt.check = opt.check or _check
56+
return find_program(opt.program or "ar6x", opt)
4857
end
58+

xmake/toolchains/ti-c6000/xmake.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ toolchain("ti-c6000")
2929
set_toolset("sh", "cl6x")
3030
set_toolset("ar", "ar6x")
3131
set_toolset("strip", "strip6x")
32-
set_toolset("as", "asm6x")
32+
set_toolset("as", "cl6x")
3333

3434
on_check(function (toolchain)
3535
return import("lib.detect.find_tool")("cl6x")

0 commit comments

Comments
 (0)