diff options
| author | ruki <[email protected]> | 2024-03-13 23:25:02 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-13 23:25:02 +0800 |
| commit | 487a1047fab0914b755ea7a87859203a971ce3f2 (patch) | |
| tree | 6dd017e3213318750b23faaeb0cd8536daad8b61 | |
| parent | 5439a4a60f142cc5c238903972409c51341e6be7 (diff) | |
add objcopy
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_objcopy.lua | 46 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_ranlib.lua | 8 | ||||
| -rw-r--r-- | xmake/toolchains/clang/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/toolchains/gcc/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/toolchains/llvm/xmake.lua | 3 |
6 files changed, 54 insertions, 9 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 057153ca7..be4e82810 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -388,6 +388,8 @@ function _instance:_description(toolkind) ar = "the static library archiver", mrc = "the windows resource compiler", strip = "the symbols stripper", + ranlib = "the archive index generator", + objcopy = "the GNU objcopy utility", dsymutil = "the symbols generator", mm = "the objc compiler", mxx = "the objc++ compiler", diff --git a/xmake/modules/detect/tools/find_objcopy.lua b/xmake/modules/detect/tools/find_objcopy.lua new file mode 100644 index 000000000..8c29fca09 --- /dev/null +++ b/xmake/modules/detect/tools/find_objcopy.lua @@ -0,0 +1,46 @@ +--!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_objcopy.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find objcopy +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local objcopy = find_objcopy() +-- local objcopy, version = find_objcopy({program = "xcrun -sdk macosx objcopy", version = true}) +-- +-- @endcode +-- +function main(opt) + opt = opt or {} + local program = find_program(opt.program or "objcopy", opt) + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + return program, version +end diff --git a/xmake/modules/detect/tools/find_ranlib.lua b/xmake/modules/detect/tools/find_ranlib.lua index d5db80986..278eedee6 100644 --- a/xmake/modules/detect/tools/find_ranlib.lua +++ b/xmake/modules/detect/tools/find_ranlib.lua @@ -36,19 +36,11 @@ import("lib.detect.find_programver") -- @endcode -- function main(opt) - - -- init options opt = opt or {} - - -- find program local program = find_program(opt.program or "ranlib", opt) - - -- find program version local version = nil if program and opt and opt.version then version = find_programver(program, opt) end - - -- ok? return program, version end diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua index 0a792ca40..cc8da1d26 100644 --- a/xmake/toolchains/clang/xmake.lua +++ b/xmake/toolchains/clang/xmake.lua @@ -36,6 +36,8 @@ toolchain("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) diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua index 9b01a80f5..9afc56c65 100644 --- a/xmake/toolchains/gcc/xmake.lua +++ b/xmake/toolchains/gcc/xmake.lua @@ -36,6 +36,8 @@ toolchain("gcc" .. suffix) set_toolset("sh", "g++" .. suffix, "gcc" .. suffix) set_toolset("ar", "ar") set_toolset("strip", "strip") + set_toolset("objcopy", "objcopy") + set_toolset("ranlib", "ranlib") set_toolset("mm", "gcc" .. suffix) set_toolset("mxx", "gcc" .. suffix, "g++" .. suffix) set_toolset("as", "gcc" .. suffix) diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index 5c6ab2586..71baf9fe6 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -33,8 +33,9 @@ toolchain("llvm") set_toolset("ld", "clang++", "clang") set_toolset("sh", "clang++", "clang") set_toolset("ar", "llvm-ar") - set_toolset("ranlib", "llvm-ranlib") set_toolset("strip", "llvm-strip") + set_toolset("ranlib", "llvm-ranlib") + set_toolset("objcopy","llvm-objcopy") set_toolset("mrc", "llvm-rc") on_check("check") |
