diff options
| author | ruki <[email protected]> | 2020-04-03 22:45:32 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-04-03 14:20:20 +0800 |
| commit | cfde52218b78948f2a8648300352e9586bf11b11 (patch) | |
| tree | 4ad1458714ce9c93235a8a0724f3edca7c826d7c | |
| parent | 43c47094400aa2dc1d17628a840a58868215d6de (diff) | |
add dsymutil for macho
| -rw-r--r-- | xmake/core/sandbox/modules/os.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 21 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_dsymutil.lua | 54 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/config.lua | 6 | ||||
| -rw-r--r-- | xmake/platforms/iphoneos/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/macosx/config.lua | 6 | ||||
| -rw-r--r-- | xmake/platforms/macosx/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/platforms/watchos/config.lua | 6 | ||||
| -rw-r--r-- | xmake/platforms/watchos/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/extract.lua | 35 |
10 files changed, 104 insertions, 34 deletions
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua index 6b505b43a..c1a7c6c01 100644 --- a/xmake/core/sandbox/modules/os.lua +++ b/xmake/core/sandbox/modules/os.lua @@ -116,7 +116,7 @@ end function sandbox_os.vcp(srcpath, dstpath, opt) assert(srcpath and dstpath) if option.get("verbose") then - utils.cprint("${dim}> copy %s to %s ..", srcpath, dstpath) + utils.cprint("${dim}> copy %s to %s", srcpath, dstpath) end return sandbox_os.cp(srcpath, dstpath, opt) end @@ -125,7 +125,7 @@ end function sandbox_os.vmv(srcpath, dstpath) assert(srcpath and dstpath) if option.get("verbose") then - utils.cprint("${dim}> move %s to %s ..", srcpath, dstpath) + utils.cprint("${dim}> move %s to %s", srcpath, dstpath) end return sandbox_os.mv(srcpath, dstpath) end diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index bf613f257..5d493ece7 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -73,43 +73,32 @@ end -- make the strip flag function nf_strip(self, level) - - -- the maps local maps = { debug = "-S" , all = "-s" } - -- for macho target local plat = config.plat() if plat == "macosx" or plat == "iphoneos" then maps.all = "-Wl,-x" maps.debug = "-Wl,-S" end - - -- make it return maps[level] end -- make the symbol flag function nf_symbol(self, level) - - -- the maps local maps = { debug = "-g" , hidden = "-fvisibility=hidden -fvisibility-inlines-hidden" } - - -- make it return maps[level] end -- make the warning flag function nf_warning(self, level) - - -- the maps local maps = { none = "-w" @@ -119,15 +108,11 @@ function nf_warning(self, level) , everything = "-Wall -Wextra -Weffc++" , error = "-Werror" } - - -- make it return maps[level] end -- make the optimize flag function nf_optimize(self, level) - - -- the maps local maps = { none = "-O0" @@ -137,15 +122,11 @@ function nf_optimize(self, level) , smallest = "-Os" , aggressive = "-Ofast" } - - -- make it return maps[level] end -- make the vector extension flag function nf_vectorext(self, extension) - - -- the maps local maps = { mmx = "-mmmx" @@ -157,8 +138,6 @@ function nf_vectorext(self, extension) , avx2 = "-mavx2" , neon = "-mfpu=neon" } - - -- make it return maps[extension] end diff --git a/xmake/modules/detect/tools/find_dsymutil.lua b/xmake/modules/detect/tools/find_dsymutil.lua new file mode 100644 index 000000000..b4c25591b --- /dev/null +++ b/xmake/modules/detect/tools/find_dsymutil.lua @@ -0,0 +1,54 @@ +--!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-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_dsymutil.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find dsymutil +-- +-- @param opt the arguments, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local dsymutil = find_dsymutil() +-- local dsymutil, version = find_dsymutil({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "dsymutil", 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/platforms/iphoneos/config.lua b/xmake/platforms/iphoneos/config.lua index 60e8a7500..2a7f52aa1 100644 --- a/xmake/platforms/iphoneos/config.lua +++ b/xmake/platforms/iphoneos/config.lua @@ -45,13 +45,14 @@ function _toolchains() local ar = toolchain("the static library archiver") local ex = toolchain("the static library extractor") local strip = toolchain("the symbols stripper") + local dsymutil = toolchain("the symbols generator") local mm = toolchain("the objc compiler") local mxx = toolchain("the objc++ compiler") local as = toolchain("the assember") local sc = toolchain("the swift compiler") local sc_ld = toolchain("the swift linker") local sc_sh = toolchain("the swift shared library linker") - local toolchains = {cc = cc, cpp = cpp, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, + local toolchains = {cc = cc, cpp = cpp, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil, mm = mm, mxx = mxx, sc = sc, ["sc-ld"] = sc_ld, ["sc-sh"] = sc_sh} -- init the c compiler @@ -88,6 +89,9 @@ function _toolchains() -- init the symbols stripper strip:add({name = "strip", cross = cross}) + -- init the symbols generator + dsymutil:add({name = "dsymutil", cross = cross}) + -- init the objc compiler mm:add({name = "clang", cross = cross}) diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index d97a7ec71..eac65916a 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -31,7 +31,7 @@ platform("iphoneos") set_archs("arm64", "armv7", "armv7s", "i386", "x86_64") -- set formats - set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).sym"} + set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).dSYM"} -- on check project configuration on_config_check("config") diff --git a/xmake/platforms/macosx/config.lua b/xmake/platforms/macosx/config.lua index 7c24bea6d..b440146cc 100644 --- a/xmake/platforms/macosx/config.lua +++ b/xmake/platforms/macosx/config.lua @@ -40,6 +40,7 @@ function _toolchains() local ar = toolchain("the static library archiver") local ex = toolchain("the static library extractor") local strip = toolchain("the symbols stripper") + local dsymutil = toolchain("the symbols generator") local mm = toolchain("the objc compiler") local mxx = toolchain("the objc++ compiler") local as = toolchain("the assember") @@ -60,7 +61,7 @@ function _toolchains() local cu = toolchain("the cuda compiler") local cu_ld = toolchain("the cuda linker") local cu_ccbin = toolchain("the cuda host c++ compiler") - local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, + local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil, mm = mm, mxx = mxx, sc = sc, ["sc-ld"] = sc_ld, ["sc-sh"] = sc_sh, gc = gc, ["gc-ld"] = gc_ld, ["gc-ar"] = gc_ar, dc = dc, ["dc-ld"] = dc_ld, ["dc-sh"] = dc_sh, ["dc-ar"] = dc_ar, @@ -100,6 +101,9 @@ function _toolchains() -- init the symbols stripper strip:add({name = "strip", cross = cross}, "strip") + -- init the symbols generator + dsymutil:add({name = "dsymutil", cross = cross}, "dsymutil") + -- init the objc compiler mm:add("$(env MM)", {name = "clang", cross = cross}, "clang", "gcc") diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index 1a12f6e5a..683944607 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -31,7 +31,7 @@ platform("macosx") set_archs("i386", "x86_64") -- set formats - set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).sym"} + set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).dSYM"} -- set install directory set_installdir("/usr/local") diff --git a/xmake/platforms/watchos/config.lua b/xmake/platforms/watchos/config.lua index 7776e4128..57504cb60 100644 --- a/xmake/platforms/watchos/config.lua +++ b/xmake/platforms/watchos/config.lua @@ -44,13 +44,14 @@ function _toolchains() local ar = toolchain("the static library archiver") local ex = toolchain("the static library extractor") local strip = toolchain("the symbols stripper") + local dsymutil = toolchain("the symbols generator") local mm = toolchain("the objc compiler") local mxx = toolchain("the objc++ compiler") local as = toolchain("the assember") local sc = toolchain("the swift compiler") local sc_ld = toolchain("the swift linker") local sc_sh = toolchain("the swift shared library linker") - local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, + local toolchains = {cc = cc, cxx = cxx, as = as, ld = ld, sh = sh, ar = ar, ex = ex, strip = strip, dsymutil = dsymutil, mm = mm, mxx = mxx, sc = sc, ["sc-ld"] = sc_ld, ["sc-sh"] = sc_sh} -- init the c compiler @@ -84,6 +85,9 @@ function _toolchains() -- init the symbols stripper strip:add({name = "strip", cross = cross}) + -- init the symbols generator + dsymutil:add({name = "dsymutil", cross = cross}) + -- init the objc compiler mm:add({name = "clang", cross = cross}) diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua index 79b440a4f..3922f7d84 100644 --- a/xmake/platforms/watchos/xmake.lua +++ b/xmake/platforms/watchos/xmake.lua @@ -31,7 +31,7 @@ platform("watchos") set_archs("armv7k", "i386") -- set formats - set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).sym"} + set_formats {static = "lib$(name).a", object = "$(name).o", shared = "lib$(name).dylib", symbol = "$(name).dSYM"} -- on check project configuration on_config_check("config") diff --git a/xmake/rules/utils/symbols/extract.lua b/xmake/rules/utils/symbols/extract.lua index f53044a21..a272eada8 100644 --- a/xmake/rules/utils/symbols/extract.lua +++ b/xmake/rules/utils/symbols/extract.lua @@ -22,7 +22,6 @@ import("core.base.option") import("core.theme.theme") import("core.platform.platform") -import("lib.detect.find_tool") -- need generate symbols? function _need_symbols(target) @@ -39,19 +38,45 @@ function main(target, opt) return end - -- find strip + -- get strip local strip = platform.tool("strip") if not strip then return end + + -- get dsymutil + local dsymutil + if is_plat("macosx", "iphoneos", "watchos") then + dsymutil = platform.tool("dsymutil") + if not dsymutil then + return + end + end -- trace progress info - local targetfile = target:targetfile() + local symbolfile = target:symbolfile() local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} " if option.get("verbose") then - cprint(progress_prefix .. "${dim color.build.target}stripping.$(mode) %s", opt.progress, path.filename(targetfile)) + cprint(progress_prefix .. "${dim color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile)) + else + cprint(progress_prefix .. "${color.build.target}generating.$(mode) %s", opt.progress, path.filename(symbolfile)) + end + + -- generate symbols file + local targetfile = target:targetfile() + if dsymutil then + local dsymutil_argv = {} + local arch = get_config("arch") + if arch then + table.insert(dsymutil_argv, "-arch") + table.insert(dsymutil_argv, arch) + end + table.insert(dsymutil_argv, targetfile) + table.insert(dsymutil_argv, "-o") + table.insert(dsymutil_argv, symbolfile) + os.vrunv(dsymutil, dsymutil_argv, {dryrun = option.get("dry-run")}) else - cprint(progress_prefix .. "${color.build.target}stripping.$(mode) %s", opt.progress, path.filename(targetfile)) + os.vcp(targetfile, target:symbolfile()) end -- strip it |
