Skip to content

Commit 9c61177

Browse files
committed
Add llvm-dlltool support
1 parent f8f9407 commit 9c61177

File tree

6 files changed

+90
-30
lines changed

6 files changed

+90
-30
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 find_llvm_dlltool.lua
19+
--
20+
21+
import("lib.detect.find_program")
22+
import("lib.detect.find_programver")
23+
24+
-- find llvm-dlltool
25+
--
26+
-- @param opt the argument options, e.g. {version = true}
27+
--
28+
-- @return program, version
29+
--
30+
-- @code
31+
--
32+
-- local dlltool = find_llvm_dlltool()
33+
--
34+
-- @endcode
35+
--
36+
function main(opt)
37+
opt = opt or {}
38+
-- return with non-zero code
39+
opt.norun = true
40+
41+
-- find program
42+
local program = find_program(opt.program or "llvm-dlltool", opt)
43+
44+
-- find program version
45+
local version = nil
46+
if program and opt.version then
47+
version = find_programver(program, opt)
48+
end
49+
return program, version
50+
end

xmake/modules/package/tools/meson.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function _get_configs_file(package, opt)
256256
if ranlib then
257257
file:print("ranlib=['%s']", executable_path(ranlib))
258258
end
259-
if package:is_plat("mingw") then
259+
if package:is_plat("mingw", "msys", "windows") then
260260
local mrc = package:build_getenv("mrc")
261261
if mrc then
262262
file:print("windres=['%s']", executable_path(mrc))
@@ -469,6 +469,12 @@ end
469469
-- get the build environments
470470
function buildenvs(package, opt)
471471
local envs = {}
472+
if not is_host("windows") and package:is_plat("windows") then
473+
local msvc = package:toolchain("msvc") or package:toolchain("clang") or package:toolchain("clang-cl")
474+
assert(msvc:check(), "msvc envs not found!") -- we need to check vs envs if it has been not checked yet
475+
envs = os.joinenvs(msvc:runenvs())
476+
end
477+
472478
opt = opt or {}
473479
if package:is_plat(os.host()) then
474480
local cflags = table.join(table.wrap(package:config("cxflags")), package:config("cflags"))

xmake/toolchains/clang-cl/load.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ end
5252
function main(toolchain)
5353

5454
-- set toolset
55-
toolchain:set("toolset", "cc", "clang-cl")
56-
toolchain:set("toolset", "cxx", "clang-cl")
57-
toolchain:set("toolset", "mrc", "rc.exe")
55+
toolchain:set("toolset", "cc", "clang-cl")
56+
toolchain:set("toolset", "cxx", "clang-cl")
57+
toolchain:set("toolset", "mrc", "rc.exe")
58+
toolchain:set("toolset", "dlltool", "llvm-dlltool")
5859
if toolchain:is_arch("x64") then
5960
toolchain:set("toolset", "as", "ml64.exe")
6061
else

xmake/toolchains/clang/xmake.lua

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@ toolchain("clang" .. suffix)
3030
set_description("A C language family frontend for LLVM" .. (version and (" (" .. version .. ")") or ""))
3131
set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared")
3232

33-
set_toolset("cc", "clang" .. suffix)
34-
set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix)
35-
set_toolset("ld", "clang++" .. suffix, "clang" .. suffix)
36-
set_toolset("sh", "clang++" .. suffix, "clang" .. suffix)
37-
set_toolset("ar", "ar", "llvm-ar")
38-
set_toolset("strip", "strip", "llvm-strip")
39-
set_toolset("ranlib", "ranlib", "llvm-ranlib")
40-
set_toolset("objcopy", "objcopy", "llvm-objcopy")
41-
set_toolset("mm", "clang" .. suffix)
42-
set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix)
43-
set_toolset("as", "clang" .. suffix)
44-
set_toolset("mrc", "llvm-rc")
33+
set_toolset("cc", "clang" .. suffix)
34+
set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix)
35+
set_toolset("ld", "clang++" .. suffix, "clang" .. suffix)
36+
set_toolset("sh", "clang++" .. suffix, "clang" .. suffix)
37+
set_toolset("ar", "ar", "llvm-ar" .. suffix)
38+
set_toolset("strip", "strip", "llvm-strip" .. suffix)
39+
set_toolset("ranlib", "ranlib", "llvm-ranlib" .. suffix)
40+
set_toolset("objcopy", "objcopy", "llvm-objcopy" .. suffix)
41+
set_toolset("mm", "clang" .. suffix)
42+
set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix)
43+
set_toolset("as", "clang" .. suffix)
44+
set_toolset("mrc", "llvm-rc" .. suffix)
45+
set_toolset("dlltool", "llvm-dlltool" .. suffix)
4546

4647
on_check(function (toolchain)
4748
if toolchain:is_plat("windows") then

xmake/toolchains/llvm/xmake.lua

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,20 @@ toolchain("llvm")
2424
set_description("A collection of modular and reusable compiler and toolchain technologies")
2525
set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared")
2626

27-
set_toolset("cc", "clang")
28-
set_toolset("cxx", "clang", "clang++")
29-
set_toolset("mxx", "clang", "clang++")
30-
set_toolset("mm", "clang")
31-
set_toolset("cpp", "clang -E")
32-
set_toolset("as", "clang")
33-
set_toolset("ld", "clang++", "clang")
34-
set_toolset("sh", "clang++", "clang")
35-
set_toolset("ar", "llvm-ar")
36-
set_toolset("strip", "llvm-strip")
37-
set_toolset("ranlib", "llvm-ranlib")
38-
set_toolset("objcopy","llvm-objcopy")
39-
set_toolset("mrc", "llvm-rc")
27+
set_toolset("cc", "clang")
28+
set_toolset("cxx", "clang", "clang++")
29+
set_toolset("mxx", "clang", "clang++")
30+
set_toolset("mm", "clang")
31+
set_toolset("cpp", "clang -E")
32+
set_toolset("as", "clang")
33+
set_toolset("ld", "clang++", "clang")
34+
set_toolset("sh", "clang++", "clang")
35+
set_toolset("ar", "llvm-ar")
36+
set_toolset("strip", "llvm-strip")
37+
set_toolset("ranlib", "llvm-ranlib")
38+
set_toolset("objcopy", "llvm-objcopy")
39+
set_toolset("mrc", "llvm-rc")
40+
set_toolset("dlltool", "llvm-dlltool")
4041

4142
on_check("check")
4243

xmake/toolchains/zig/xmake.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ toolchain("zig")
3030
-- @see https://github.com/xmake-io/xmake/issues/5610
3131
function _setup_zigcc_wrapper(zig)
3232
local script_suffix = is_host("windows") and ".cmd" or ""
33-
for _, tool in ipairs({"cc", "c++", "ar", "ranlib", "objcopy"}) do
33+
for _, tool in ipairs({"cc", "c++", "ar", "ranlib", "objcopy", "dlltool"}) do
3434
local wrapper_path = path.join(os.tmpdir(), "zigcc", tool) .. script_suffix
3535
if not os.isfile(wrapper_path) then
3636
if is_host("windows") then
@@ -90,6 +90,7 @@ toolchain("zig")
9090
toolchain:set("toolset", "ranlib", toolchain:config("toolset_ranlib"))
9191
toolchain:set("toolset", "objcopy", toolchain:config("toolset_objcopy"))
9292
toolchain:set("toolset", "as", toolchain:config("toolset_cc"))
93+
toolchain:set("toolset", "dlltool", toolchain:config("toolset_dlltool"))
9394
end
9495
toolchain:set("toolset", "zc", zig)
9596
toolchain:set("toolset", "zcar", zig)

0 commit comments

Comments
 (0)