diff options
| author | star9029 <[email protected]> | 2025-05-08 23:49:54 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2025-05-08 23:49:54 +0800 |
| commit | 9c61177d07db0b9740833d334b80d08aac1c6e2c (patch) | |
| tree | a25d24526222616335b6cef7eb2cafc15368386c | |
| parent | f8f940759860e118e222a735b71e29a01dcc9491 (diff) | |
Add llvm-dlltool support
| -rw-r--r-- | xmake/modules/detect/tools/find_llvm_dlltool.lua | 50 | ||||
| -rw-r--r-- | xmake/modules/package/tools/meson.lua | 8 | ||||
| -rw-r--r-- | xmake/toolchains/clang-cl/load.lua | 7 | ||||
| -rw-r--r-- | xmake/toolchains/clang/xmake.lua | 25 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/xmake.lua | 27 | ||||
| -rw-r--r-- | xmake/toolchains/zig/xmake.lua | 3 |
6 files changed, 90 insertions, 30 deletions
diff --git a/xmake/modules/detect/tools/find_llvm_dlltool.lua b/xmake/modules/detect/tools/find_llvm_dlltool.lua new file mode 100644 index 000000000..2933844a9 --- /dev/null +++ b/xmake/modules/detect/tools/find_llvm_dlltool.lua @@ -0,0 +1,50 @@ +--!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 find_llvm_dlltool.lua +-- + +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find llvm-dlltool +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local dlltool = find_llvm_dlltool() +-- +-- @endcode +-- +function main(opt) + opt = opt or {} + -- return with non-zero code + opt.norun = true + + -- find program + local program = find_program(opt.program or "llvm-dlltool", opt) + + -- find program version + local version = nil + if program and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index d03745b41..2e75e0459 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -256,7 +256,7 @@ function _get_configs_file(package, opt) if ranlib then file:print("ranlib=['%s']", executable_path(ranlib)) end - if package:is_plat("mingw") then + if package:is_plat("mingw", "msys", "windows") then local mrc = package:build_getenv("mrc") if mrc then file:print("windres=['%s']", executable_path(mrc)) @@ -469,6 +469,12 @@ end -- get the build environments function buildenvs(package, opt) local envs = {} + if not is_host("windows") and package:is_plat("windows") then + local msvc = package:toolchain("msvc") or package:toolchain("clang") or package:toolchain("clang-cl") + assert(msvc:check(), "msvc envs not found!") -- we need to check vs envs if it has been not checked yet + envs = os.joinenvs(msvc:runenvs()) + end + opt = opt or {} if package:is_plat(os.host()) then local cflags = table.join(table.wrap(package:config("cxflags")), package:config("cflags")) diff --git a/xmake/toolchains/clang-cl/load.lua b/xmake/toolchains/clang-cl/load.lua index f8848064f..b4d2037d6 100644 --- a/xmake/toolchains/clang-cl/load.lua +++ b/xmake/toolchains/clang-cl/load.lua @@ -52,9 +52,10 @@ end function main(toolchain) -- set toolset - toolchain:set("toolset", "cc", "clang-cl") - toolchain:set("toolset", "cxx", "clang-cl") - toolchain:set("toolset", "mrc", "rc.exe") + toolchain:set("toolset", "cc", "clang-cl") + toolchain:set("toolset", "cxx", "clang-cl") + toolchain:set("toolset", "mrc", "rc.exe") + toolchain:set("toolset", "dlltool", "llvm-dlltool") if toolchain:is_arch("x64") then toolchain:set("toolset", "as", "ml64.exe") else diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua index 829413278..a95200f2d 100644 --- a/xmake/toolchains/clang/xmake.lua +++ b/xmake/toolchains/clang/xmake.lua @@ -30,18 +30,19 @@ toolchain("clang" .. suffix) set_description("A C language family frontend for LLVM" .. (version and (" (" .. version .. ")") or "")) set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") - set_toolset("cc", "clang" .. suffix) - set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix) - set_toolset("ld", "clang++" .. suffix, "clang" .. suffix) - set_toolset("sh", "clang++" .. suffix, "clang" .. suffix) - set_toolset("ar", "ar", "llvm-ar") - set_toolset("strip", "strip", "llvm-strip") - set_toolset("ranlib", "ranlib", "llvm-ranlib") - set_toolset("objcopy", "objcopy", "llvm-objcopy") - set_toolset("mm", "clang" .. suffix) - set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix) - set_toolset("as", "clang" .. suffix) - set_toolset("mrc", "llvm-rc") + set_toolset("cc", "clang" .. suffix) + set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix) + set_toolset("ld", "clang++" .. suffix, "clang" .. suffix) + set_toolset("sh", "clang++" .. suffix, "clang" .. suffix) + set_toolset("ar", "ar", "llvm-ar" .. suffix) + set_toolset("strip", "strip", "llvm-strip" .. suffix) + set_toolset("ranlib", "ranlib", "llvm-ranlib" .. suffix) + set_toolset("objcopy", "objcopy", "llvm-objcopy" .. suffix) + set_toolset("mm", "clang" .. suffix) + set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix) + set_toolset("as", "clang" .. suffix) + set_toolset("mrc", "llvm-rc" .. suffix) + set_toolset("dlltool", "llvm-dlltool" .. suffix) on_check(function (toolchain) if toolchain:is_plat("windows") then diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index 226eebeb7..57638e4f6 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -24,19 +24,20 @@ toolchain("llvm") set_description("A collection of modular and reusable compiler and toolchain technologies") set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") - set_toolset("cc", "clang") - set_toolset("cxx", "clang", "clang++") - set_toolset("mxx", "clang", "clang++") - set_toolset("mm", "clang") - set_toolset("cpp", "clang -E") - set_toolset("as", "clang") - set_toolset("ld", "clang++", "clang") - set_toolset("sh", "clang++", "clang") - set_toolset("ar", "llvm-ar") - set_toolset("strip", "llvm-strip") - set_toolset("ranlib", "llvm-ranlib") - set_toolset("objcopy","llvm-objcopy") - set_toolset("mrc", "llvm-rc") + set_toolset("cc", "clang") + set_toolset("cxx", "clang", "clang++") + set_toolset("mxx", "clang", "clang++") + set_toolset("mm", "clang") + set_toolset("cpp", "clang -E") + set_toolset("as", "clang") + set_toolset("ld", "clang++", "clang") + set_toolset("sh", "clang++", "clang") + set_toolset("ar", "llvm-ar") + set_toolset("strip", "llvm-strip") + set_toolset("ranlib", "llvm-ranlib") + set_toolset("objcopy", "llvm-objcopy") + set_toolset("mrc", "llvm-rc") + set_toolset("dlltool", "llvm-dlltool") on_check("check") diff --git a/xmake/toolchains/zig/xmake.lua b/xmake/toolchains/zig/xmake.lua index b88449fb8..c7b6777a7 100644 --- a/xmake/toolchains/zig/xmake.lua +++ b/xmake/toolchains/zig/xmake.lua @@ -30,7 +30,7 @@ toolchain("zig") -- @see https://github.com/xmake-io/xmake/issues/5610 function _setup_zigcc_wrapper(zig) local script_suffix = is_host("windows") and ".cmd" or "" - for _, tool in ipairs({"cc", "c++", "ar", "ranlib", "objcopy"}) do + for _, tool in ipairs({"cc", "c++", "ar", "ranlib", "objcopy", "dlltool"}) do local wrapper_path = path.join(os.tmpdir(), "zigcc", tool) .. script_suffix if not os.isfile(wrapper_path) then if is_host("windows") then @@ -90,6 +90,7 @@ toolchain("zig") toolchain:set("toolset", "ranlib", toolchain:config("toolset_ranlib")) toolchain:set("toolset", "objcopy", toolchain:config("toolset_objcopy")) toolchain:set("toolset", "as", toolchain:config("toolset_cc")) + toolchain:set("toolset", "dlltool", toolchain:config("toolset_dlltool")) end toolchain:set("toolset", "zc", zig) toolchain:set("toolset", "zcar", zig) |
