diff options
| author | ruki <[email protected]> | 2017-06-06 18:41:05 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-06 18:41:05 +0800 |
| commit | 2309c5ec03eb09842814bcf03fffa8fa93999acf (patch) | |
| tree | d0e796ee7eff59a38eae6979b069a574eb51fe40 | |
| parent | b62c9a1a532058db12fb73cdfeb0e174c8cbf2f2 (diff) | |
add find_library and remove some old codes
36 files changed, 356 insertions, 99 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index e1c894add..76ff5ff93 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -108,13 +108,6 @@ function _instance:archs() return self._INFO.archs end --- get the platform tooldirs -function _instance:tooldirs() - - -- get it - return self._INFO.tooldirs -end - -- the directories of platform function platform._directories() @@ -147,7 +140,6 @@ function platform._interpreter() , "platform.set_hosts" , "platform.set_archs" , "platform.set_menu" - , "platform.set_tooldirs" , "platform.set_installdir" } , script = @@ -163,6 +155,11 @@ function platform._interpreter() -- platform.set_xxx "platform.set_environment" } + , dictionary = + { + -- platform.set_xxx + "platform.set_formats" + } } -- save interpreter @@ -302,11 +299,6 @@ function platform.archs(plat) return platform.get("archs", plat) end --- get the tool directories -function platform.tooldirs(plat) - return platform.get("tooldirs", plat) -end - -- get the format of the given target kind for platform function platform.format(targetkind) diff --git a/xmake/core/sandbox/modules/import/core/tool/tool.lua b/xmake/core/sandbox/modules/import/core/tool/tool.lua index a97e8b9e0..9fbc68ced 100644 --- a/xmake/core/sandbox/modules/import/core/tool/tool.lua +++ b/xmake/core/sandbox/modules/import/core/tool/tool.lua @@ -42,7 +42,7 @@ end function sandbox_core_tool.check(shellname, dirs, check) -- check it - return tool.check(shellname, dirs or platform.tooldirs(), check) + return tool.check(shellname, dirs, check) end -- return module diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua index a9d13de62..ae61faa40 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua @@ -80,6 +80,11 @@ function sandbox_lib_detect_find_file.main(name, pathes) result = file break end + + -- found? + if result then + break + end end -- ok? diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua index e48f75ebe..732a24019 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_library.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_library.lua @@ -26,13 +26,99 @@ local sandbox_lib_detect_find_library = sandbox_lib_detect_find_library or {} -- load modules -local raise = require("sandbox/modules/raise") +local os = require("base/os") +local path = require("base/path") +local utils = require("base/utils") +local table = require("base/table") +local target = require("project/target") +local config = require("project/config") +local raise = require("sandbox/modules/raise") +local import = require("sandbox/modules/import") +local find_file = import("lib.detect.find_file", {anonymous = true}) +local find_pkg_config = import("detect.tool.find_pkg_config", {anonymous = true}) --- find file -function sandbox_lib_detect_find_library.main(...) - - -- TODO - print("find file") +-- get link name from the file name +function sandbox_lib_detect_find_library._link(filename) + + -- get link + local link, count = filename:gsub(target.filename("([%w_]+)", "static"):gsub("%.", "%%.") .. "$", "%1") + if count == 0 then + link, count = filename:gsub(target.filename("([%w_]+)", "shared"):gsub("%.", "%%.") .. "$", "%1") + end + + -- ok? + if count > 0 then + return link + end +end + +-- find library +-- +-- @param names the library names +-- @param pathes the library pathes +-- @param kinds the library kinds, .e.g {"static", "shared"} +-- +-- @return {kind = "static", link = "crypto", linkdir = "/usr/local/lib", filename = "libcrypto.a"} +-- +-- @code +-- +-- local library = find_library("crypto") +-- local library = find_library({"crypto", "cryp*"}, {"/usr/lib", "/usr/local/lib"}) +-- +-- @endcode +-- +function sandbox_lib_detect_find_library.main(names, paths, kinds) + + -- init pathes + pathes = table.wrap(pathes) + + -- init kinds + kinds = kinds or {"static", "shared"} + + -- get current platform + local plat = config.get("plat") or os.host() + + -- get current architecture + local arch = config.get("arch") or os.arch() + + -- attempt to add search pathes from pkg-config + local pkg_config = find_pkg_config() + if pkg_config then + for _, name in ipairs(table.wrap(names)) do + + -- attempt to get -L/xxx/dir + local ok, libs_only_L = os.iorunv(pkg_config, {"--libs-only-L", name}) + if not ok and not name:startswith("lib") then + ok, libs_only_L = os.iorunv(pkg_config, {"--libs-only-L", "lib" .. name}) + end + + -- add linkdir to pathes + if libs_only_L then + local linkdir = (libs_only_L:match("%-L(.+)") or ""):trim() + if os.isdir(linkdir) then + table.insert(pathes, linkdir) + break + end + end + end + end + + -- add default search pathes on pc host + if plat == "macosx" or (plat == "linux" and arch == os.arch()) then + table.insert(pathes, "/usr/local/lib") + table.insert(pathes, "/usr/lib") + end + + -- find library file from the given pathes + for _, name in ipairs(table.wrap(names)) do + for _, kind in ipairs(table.wrap(kinds)) do + local filepath = find_file(target.filename(name, kind), pathes) + if filepath then + local filename = path.filename(filepath) + return {kind = kind, filename = filename, linkdir = path.directory(filepath), link = sandbox_lib_detect_find_library._link(filename)} + end + end + end end -- return module diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua index 8748bd08a..2b94b33fc 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua @@ -79,6 +79,11 @@ function sandbox_lib_detect_find_path.main(name, pathes) result = p break end + + -- found? + if result then + break + end end -- ok? diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua index 2ac078152..a14b67648 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -151,6 +151,11 @@ function sandbox_lib_detect_find_program.main(name, pathes, check) return utils.ifelse(result, result, nil) end + -- add default search pathes + if os.host() ~= "windows" then + pathes = table.join(table.wrap(pathes), "/usr/local/lib", "/usr/lib") + end + -- find executable program result = sandbox_lib_detect_find_program._find(name, pathes, check) diff --git a/xmake/modules/detect/tool/find_7z.lua b/xmake/modules/detect/tool/find_7z.lua index f6a39c325..58a4ea24e 100644 --- a/xmake/modules/detect/tool/find_7z.lua +++ b/xmake/modules/detect/tool/find_7z.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("7z", { "/usr/bin", "/usr/local/bin"}, "--help") + local program = find_program("7z", {}, "--help") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_ccache.lua b/xmake/modules/detect/tool/find_ccache.lua index e3a5a8313..faf45da53 100644 --- a/xmake/modules/detect/tool/find_ccache.lua +++ b/xmake/modules/detect/tool/find_ccache.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("ccache", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("ccache") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_curl.lua b/xmake/modules/detect/tool/find_curl.lua index bf23d6bdf..3b49247ef 100644 --- a/xmake/modules/detect/tool/find_curl.lua +++ b/xmake/modules/detect/tool/find_curl.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("curl", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("curl") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_doxygen.lua b/xmake/modules/detect/tool/find_doxygen.lua new file mode 100644 index 000000000..3b3a6bee4 --- /dev/null +++ b/xmake/modules/detect/tool/find_doxygen.lua @@ -0,0 +1,55 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_doxygen.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find doxygen +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local doxygen = find_doxygen() +-- local doxygen, version = find_doxygen({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- find program + local program = find_program("doxygen", { "/usr/bin", "/usr/local/bin"}) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_gdb.lua b/xmake/modules/detect/tool/find_gdb.lua index 37b84e647..ff206288c 100644 --- a/xmake/modules/detect/tool/find_gdb.lua +++ b/xmake/modules/detect/tool/find_gdb.lua @@ -46,7 +46,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "gdb", { "/usr/bin", "/usr/local/bin"}) + local program = find_program(opt.program or "gdb") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_git.lua b/xmake/modules/detect/tool/find_git.lua index 666d79d25..12f08978d 100644 --- a/xmake/modules/detect/tool/find_git.lua +++ b/xmake/modules/detect/tool/find_git.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("git", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("git") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_gzip.lua b/xmake/modules/detect/tool/find_gzip.lua index 744c1878a..d1b286bba 100644 --- a/xmake/modules/detect/tool/find_gzip.lua +++ b/xmake/modules/detect/tool/find_gzip.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("gzip", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("gzip") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_lipo.lua b/xmake/modules/detect/tool/find_lipo.lua new file mode 100644 index 000000000..621bb80d5 --- /dev/null +++ b/xmake/modules/detect/tool/find_lipo.lua @@ -0,0 +1,45 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_lipo.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find lipo +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local lipo = find_lipo() +-- +-- @endcode +-- +function main(opt) + + -- find program + return find_program("lipo", {}, function (program) os.run("%s -info %s", program, os.programfile()) end) +end diff --git a/xmake/modules/detect/tool/find_lldb.lua b/xmake/modules/detect/tool/find_lldb.lua index 32d4ff735..3c15c2fb1 100644 --- a/xmake/modules/detect/tool/find_lldb.lua +++ b/xmake/modules/detect/tool/find_lldb.lua @@ -46,7 +46,7 @@ function main(opt) opt = opt or {} -- find program - local program = find_program(opt.program or "lldb", { "/usr/bin", "/usr/local/bin"}) + local program = find_program(opt.program or "lldb") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_pkg_config.lua b/xmake/modules/detect/tool/find_pkg_config.lua new file mode 100644 index 000000000..8bbad9f3f --- /dev/null +++ b/xmake/modules/detect/tool/find_pkg_config.lua @@ -0,0 +1,55 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_pkg_config.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find pkg_config +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local pkg_config = find_pkg_config() +-- local pkg_config, version = find_pkg_config({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- find program + local program = find_program("pkg-config") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program) + end + + -- ok? + return program, version +end diff --git a/xmake/modules/detect/tool/find_sudo.lua b/xmake/modules/detect/tool/find_sudo.lua index 968746020..3d0082b17 100644 --- a/xmake/modules/detect/tool/find_sudo.lua +++ b/xmake/modules/detect/tool/find_sudo.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("sudo", { "/usr/bin", "/usr/local/bin"}, "-h") + local program = find_program("sudo", {}, "-h") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_tar.lua b/xmake/modules/detect/tool/find_tar.lua index 24a3743ec..e091d3204 100644 --- a/xmake/modules/detect/tool/find_tar.lua +++ b/xmake/modules/detect/tool/find_tar.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("tar", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("tar") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_unzip.lua b/xmake/modules/detect/tool/find_unzip.lua index c0a6a88a0..19c30f517 100644 --- a/xmake/modules/detect/tool/find_unzip.lua +++ b/xmake/modules/detect/tool/find_unzip.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("unzip", { "/usr/bin", "/usr/local/bin"}, "-v") + local program = find_program("unzip", {}, "-v") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_wget.lua b/xmake/modules/detect/tool/find_wget.lua index ff22f31d4..59a9c7d63 100644 --- a/xmake/modules/detect/tool/find_wget.lua +++ b/xmake/modules/detect/tool/find_wget.lua @@ -42,7 +42,7 @@ import("lib.detect.find_programver") function main(opt) -- find program - local program = find_program("wget", { "/usr/bin", "/usr/local/bin"}) + local program = find_program("wget") -- find program version local version = nil diff --git a/xmake/modules/detect/tool/find_zip.lua b/xmake/modules/detect/tool/find_zip.lua new file mode 100644 index 000000000..b424d6e99 --- /dev/null +++ b/xmake/modules/detect/tool/find_zip.lua @@ -0,0 +1,55 @@ +--!The Make-like Build Utility based on Lua +-- +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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 - 2017, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_zip.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find zip +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local zip = find_zip() +-- local zip, version = find_zip({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- find program + local program = find_program("zip", {}, "-v") + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, "-v") + end + + -- ok? + return program, version +end diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua index a9b00b554..0e0d88131 100644 --- a/xmake/platforms/android/load.lua +++ b/xmake/platforms/android/load.lua @@ -28,13 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".so"} - _g.formats.symbol = {"", ".sym"} - -- init flags local arch = config.get("arch") if arch:startswith("arm64") then diff --git a/xmake/platforms/android/xmake.lua b/xmake/platforms/android/xmake.lua index 35f503fc2..fcd2857f4 100644 --- a/xmake/platforms/android/xmake.lua +++ b/xmake/platforms/android/xmake.lua @@ -34,8 +34,8 @@ platform("android") -- set archs set_archs("armv5te", "armv6", "armv7-a", "armv8-a", "arm64-v8a") - -- set tooldirs - set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".so"}, symbol = {"", ".sym"}} -- on check on_check("check") diff --git a/xmake/platforms/iphoneos/load.lua b/xmake/platforms/iphoneos/load.lua index 16cee2652..f6c67c88f 100644 --- a/xmake/platforms/iphoneos/load.lua +++ b/xmake/platforms/iphoneos/load.lua @@ -28,13 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".dylib"} - _g.formats.symbol = {"", ".sym"} - -- init architecture local arch = config.get("arch") local simulator = (arch == "i386" or arch == "x86_64") diff --git a/xmake/platforms/iphoneos/xmake.lua b/xmake/platforms/iphoneos/xmake.lua index 7acd75368..abe3395f3 100644 --- a/xmake/platforms/iphoneos/xmake.lua +++ b/xmake/platforms/iphoneos/xmake.lua @@ -34,8 +34,8 @@ platform("iphoneos") -- set archs set_archs("armv7", "armv7s", "arm64", "i386", "x86_64") - -- set tooldirs - set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".dylib"}, symbol = {"", ".sym"}} -- on check on_check("check") diff --git a/xmake/platforms/linux/load.lua b/xmake/platforms/linux/load.lua index 58b543114..003b31909 100644 --- a/xmake/platforms/linux/load.lua +++ b/xmake/platforms/linux/load.lua @@ -28,13 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".so"} - _g.formats.symbol = {"", ".sym"} - -- cross toolchains? if config.get("cross") or config.get("toolchains") or config.get("sdk") then diff --git a/xmake/platforms/linux/xmake.lua b/xmake/platforms/linux/xmake.lua index 85756709e..753e24742 100644 --- a/xmake/platforms/linux/xmake.lua +++ b/xmake/platforms/linux/xmake.lua @@ -34,8 +34,8 @@ platform("linux") -- set archs set_archs("i386", "x86_64") - -- set tooldirs - set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".so"}, symbol = {"", ".sym"}} -- set installdir set_installdir("/usr/local") diff --git a/xmake/platforms/macosx/load.lua b/xmake/platforms/macosx/load.lua index ce6566daf..2b57222f9 100644 --- a/xmake/platforms/macosx/load.lua +++ b/xmake/platforms/macosx/load.lua @@ -28,13 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".dylib"} - _g.formats.symbol = {"", ".sym"} - -- init flags for architecture local arch = config.get("arch") local target_minver = config.get("target_minver") diff --git a/xmake/platforms/macosx/xmake.lua b/xmake/platforms/macosx/xmake.lua index b7185eea4..7fbf6cd43 100644 --- a/xmake/platforms/macosx/xmake.lua +++ b/xmake/platforms/macosx/xmake.lua @@ -34,8 +34,8 @@ platform("macosx") -- set archs set_archs("i386", "x86_64") - -- set tooldirs - set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".dylib"}, symbol = {"", ".sym"}} -- set installdir set_installdir("/usr/local") diff --git a/xmake/platforms/mingw/load.lua b/xmake/platforms/mingw/load.lua index d455fc564..0199573d9 100644 --- a/xmake/platforms/mingw/load.lua +++ b/xmake/platforms/mingw/load.lua @@ -28,14 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".so"} - _g.formats.binary = {"", ".exe"} - _g.formats.symbol = {"", ".pdb"} - -- init flags for architecture local archflags = nil local arch = config.get("arch") diff --git a/xmake/platforms/mingw/xmake.lua b/xmake/platforms/mingw/xmake.lua index 075fc1d9d..5151bc7e6 100644 --- a/xmake/platforms/mingw/xmake.lua +++ b/xmake/platforms/mingw/xmake.lua @@ -34,6 +34,9 @@ platform("mingw") -- set archs set_archs("i386", "x86_64") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".so"}, binary = {"", ".exe"},symbol = {"", ".pdb"}} + -- on check on_check("check") diff --git a/xmake/platforms/watchos/load.lua b/xmake/platforms/watchos/load.lua index 7abdf2441..3d366f477 100644 --- a/xmake/platforms/watchos/load.lua +++ b/xmake/platforms/watchos/load.lua @@ -28,13 +28,6 @@ import("core.project.config") -- load it function main() - -- init the file formats - _g.formats = {} - _g.formats.static = {"lib", ".a"} - _g.formats.object = {"", ".o"} - _g.formats.shared = {"lib", ".dylib"} - _g.formats.symbol = {"", ".sym"} - -- init architecture local arch = config.get("arch") local simulator = arch == "i386" diff --git a/xmake/platforms/watchos/xmake.lua b/xmake/platforms/watchos/xmake.lua index 9758cab38..b48f95cee 100644 --- a/xmake/platforms/watchos/xmake.lua +++ b/xmake/platforms/watchos/xmake.lua @@ -34,8 +34,8 @@ platform("watchos") -- set archs set_archs("armv7k", "i386") - -- set tooldirs - set_tooldirs("/usr/bin", "/usr/local/bin", "/opt/bin", "/opt/local/bin") + -- set formats + set_formats {static = {"lib", ".a"}, object = {"", ".o"}, shared = {"lib", ".dylib"}, symbol = {"", ".sym"}} -- on check on_check("check") diff --git a/xmake/plugins/app2ipa/main.lua b/xmake/plugins/app2ipa/main.lua index 0cac7feab..7fba742dc 100644 --- a/xmake/plugins/app2ipa/main.lua +++ b/xmake/plugins/app2ipa/main.lua @@ -24,15 +24,13 @@ -- imports import("core.base.option") -import("core.tool.tool") +import("detect.tool.find_zip") -- main function main() - -- check the zip - local zip = tool.check("zip", nil, function (shellname) - os.run("%s -v", shellname) - end) + -- find zip + local zip = find_zip() assert(zip, "zip not found!") -- get the .app file path diff --git a/xmake/plugins/doxygen/main.lua b/xmake/plugins/doxygen/main.lua index 1788486c8..7129c7306 100644 --- a/xmake/plugins/doxygen/main.lua +++ b/xmake/plugins/doxygen/main.lua @@ -24,17 +24,15 @@ -- imports import("core.base.option") -import("core.tool.tool") import("core.project.config") import("core.project.project") +import("detect.tool.find_doxygen") -- main function main() - -- check the doxygen - local doxygen = tool.check("doxygen", nil, function (shellname) - os.run("%s -v", shellname) - end) + -- find doxygen + local doxygen = find_doxygen() assert(doxygen, "doxygen not found!") -- generate doxyfile first diff --git a/xmake/plugins/lua/scripts/lipo.lua b/xmake/plugins/lua/scripts/lipo.lua index 9cd9c4c96..8b87eb9e0 100644 --- a/xmake/plugins/lua/scripts/lipo.lua +++ b/xmake/plugins/lua/scripts/lipo.lua @@ -23,7 +23,7 @@ -- -- imports -import("core.tool.tool") +import("detect.tool.find_lipo") -- main -- @@ -39,10 +39,8 @@ function main(...) end args = args[1] - -- check the lipo - local lipo = tool.check("xcrun lipo", nil, function (shellname) - os.run("xcrun -find lipo") - end) + -- find the lipo + local lipo = find_lipo() assert(lipo, "lipo not found!") -- run it |
