diff options
| author | Ângelo Andrade Cirino <[email protected]> | 2022-01-17 10:56:56 -0300 |
|---|---|---|
| committer | Ângelo Andrade Cirino <[email protected]> | 2022-01-17 10:56:56 -0300 |
| commit | 92978c6f56ab66e17e19776d2e35832fa8be6e97 (patch) | |
| tree | 8156c9043b20682df56ee30f673ac84a2c042eeb | |
| parent | 274244bf3530a77ab3c93309e5ea5bb5d29907ae (diff) | |
| parent | b86e3b25723812bdf0c20bc1d3d4075d47b57523 (diff) | |
Merge branch 'master' of https://github.com/xmake-io/xmake into modnamefix
| -rw-r--r-- | CHANGELOG.md | 6 | ||||
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rw-r--r-- | xmake/actions/global/xmake.lua | 12 | ||||
| -rw-r--r-- | xmake/core/base/tty.lua | 14 | ||||
| -rw-r--r-- | xmake/modules/core/tools/armar.lua | 25 | ||||
| -rw-r--r-- | xmake/modules/core/tools/cxx.lua | 24 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gxx.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 5 | ||||
| -rw-r--r-- | xmake/modules/detect/tools/find_cxx.lua | 61 | ||||
| -rw-r--r-- | xmake/modules/net/proxy.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/fetch.lua | 3 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 21 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/fetch.lua | 4 | ||||
| -rw-r--r-- | xmake/rules/cuda/devlink/xmake.lua | 11 | ||||
| -rw-r--r-- | xmake/rules/cuda/env/xmake.lua | 14 | ||||
| -rw-r--r-- | xmake/scripts/pac/github_mirror.lua | 12 |
16 files changed, 189 insertions, 28 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b10e4f0c..60a9f6345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ * [#1896](https://github.com/xmake-io/xmake/issues/1896): Add `python.library` rule to build pybind modules * [#1939](https://github.com/xmake-io/xmake/issues/1939): Add `remove_files`, `remove_headerfiles` and mark `del_files` as deprecated * Made on_config as the official api for rule/target +* Add riscv32/64 support +* [#1970](https://github.com/xmake-io/xmake/issues/1970): Add CMake wrapper for Xrepo C and C++ package manager. +* Add builtin github mirror pac files, `xmake g --proxy_pac=github_mirror.lua` ### Changes @@ -1190,6 +1193,9 @@ * [#1896](https://github.com/xmake-io/xmake/issues/1896): 添加 `python.library` 规则去构建 pybind 模块,并且支持 soabi * [#1939](https://github.com/xmake-io/xmake/issues/1939): 添加 `remove_files`, `remove_headerfiles` 并且标记 `del_files` 作为废弃接口 * 将 on_config 作为正式的公开接口,用于 target 和 rule +* 添加 riscv32/64 支持 +* [#1970](https://github.com/xmake-io/xmake/issues/1970): 添加 CMake wrapper 支持在 CMakelists 中去调用 xrepo 集成 C/C++ 包 +* 添加内置的 github 镜像加速 pac 代理文件, `xmake g --proxy_pac=github_mirror.lua` ### 改进 diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject 122a479e626ee3fdd7d6c1117ec7c19212a1e08 +Subproject 927fc0ed16e02f7591a8403754f351215bbf452 diff --git a/xmake/actions/global/xmake.lua b/xmake/actions/global/xmake.lua index 9765412a0..224bf06fd 100644 --- a/xmake/actions/global/xmake.lua +++ b/xmake/actions/global/xmake.lua @@ -59,7 +59,17 @@ task("global") , " if host == 'github.com' then" , " return true" , " end" - , " end"}, + , " end" + , "" + , "Builtin pac files:" + , function () + local description = {} + local pacfiles = os.files(path.join(os.programdir(), "scripts", "pac", "*.lua")) + for _, pacfile in ipairs(pacfiles) do + table.insert(description, " - " .. path.filename(pacfile)) + end + return description + end}, -- package configuration {category = "Package Configuration"}, diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index a744f12e0..4ef3bb768 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -402,12 +402,14 @@ end -- function tty.term_mode(stdtype, newmode) local oldmode = 0 - if stdtype == "stdin" then - oldmode = tty._term_mode(1, newmode) - elseif stdtype == "stdout" then - oldmode = tty._term_mode(2, newmode) - elseif stdtype == "stderr" then - oldmode = tty._term_mode(3, newmode) + if tty._term_mode then + if stdtype == "stdin" then + oldmode = tty._term_mode(1, newmode) + elseif stdtype == "stdout" then + oldmode = tty._term_mode(2, newmode) + elseif stdtype == "stderr" then + oldmode = tty._term_mode(3, newmode) + end end return oldmode end diff --git a/xmake/modules/core/tools/armar.lua b/xmake/modules/core/tools/armar.lua index 66740c11a..9449bf4b9 100644 --- a/xmake/modules/core/tools/armar.lua +++ b/xmake/modules/core/tools/armar.lua @@ -24,3 +24,28 @@ function init(self) _super.init(self) end +-- make the link arguments list +function linkargv(self, objectfiles, targetkind, targetfile, flags, opt) + opt = opt or {} + local argv = table.join(flags, targetfile, objectfiles) + if is_host("windows") and not opt.rawargs then + argv = winos.cmdargv(argv, {escape = true}) + if #argv > 0 and argv[1] and argv[1]:startswith("@") then + argv[1] = argv[1]:replace("@", "", {plain = true}) + table.insert(argv, 1, "--via") + end + end + return self:program(), argv +end + +-- link the library file +function link(self, objectfiles, targetkind, targetfile, flags) + os.mkdir(path.directory(targetfile)) + + -- @note remove the previous archived file first to force recreating a new file + os.tryrm(targetfile) + + -- link it + local program, argv = linkargv(self, objectfiles, targetkind, targetfile, flags) + os.runv(program, argv, {envs = self:runenvs()}) +end diff --git a/xmake/modules/core/tools/cxx.lua b/xmake/modules/core/tools/cxx.lua new file mode 100644 index 000000000..0e53e0134 --- /dev/null +++ b/xmake/modules/core/tools/cxx.lua @@ -0,0 +1,24 @@ +--!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 cxx.lua +-- + +-- inherit gcc +inherit("gcc") + + diff --git a/xmake/modules/core/tools/gxx.lua b/xmake/modules/core/tools/gxx.lua index be14f79e7..ec7ea3838 100644 --- a/xmake/modules/core/tools/gxx.lua +++ b/xmake/modules/core/tools/gxx.lua @@ -15,7 +15,7 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file g++.lua +-- @file gxx.lua -- -- inherit gcc diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 2aad54096..471d62532 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -352,7 +352,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) local lines = errors:split("\n", {plain = true}) local start = 0 for index, line in ipairs(lines) do - if line:find("error:", 1, true) or line:find("错误:", 1, true) then + if line:find("error:", 1, true) or line:find("错误:", 1, true) or line:match("ptxas fatal%s*:") or line:match("error %a+[0-9]+%s*:") then start = index break end @@ -363,6 +363,9 @@ function compile(self, sourcefile, objectfile, dependinfo, flags) if start == 0 then start = 1 end errors = table.concat(table.slice(lines, start, start + ((#lines - start > 16) and 16 or (#lines - start))), "\n") end + if not option.get("verbose") then + errors = errors .. "\n ${yellow}> in ${bright}" .. sourcefile + end -- raise compiling errors raise(errors) diff --git a/xmake/modules/detect/tools/find_cxx.lua b/xmake/modules/detect/tools/find_cxx.lua new file mode 100644 index 000000000..c21fe8ad4 --- /dev/null +++ b/xmake/modules/detect/tools/find_cxx.lua @@ -0,0 +1,61 @@ +--!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_cxx.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find c++ +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local cxx = find_cxx() +-- local cxx, version, hintname = find_cxx({program = "xcrun -sdk macosx c++", version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "c++", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- is clang++ or c++ + local is_clang = false + if program then + local versioninfo = os.iorunv(program, {"--version"}) + if versioninfo and versioninfo:find("clang", 1, true) then + is_clang = true + end + end + return program, version, (is_clang and "clangxx" or "cxx") +end diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua index 6aac4af4c..809b28352 100644 --- a/xmake/modules/net/proxy.lua +++ b/xmake/modules/net/proxy.lua @@ -60,6 +60,9 @@ function _proxy_pac() end if not pacfile and not path.is_absolute(pac) then pacfile = path.join(global.directory(), pac) + if not os.isfile(pacfile) and os.isfile(path.join(os.programdir(), "scripts", "pac", pac)) then + pacfile = path.join(os.programdir(), "scripts", "pac", pac) + end end end if pacfile and os.isfile(pacfile) then diff --git a/xmake/modules/private/action/require/fetch.lua b/xmake/modules/private/action/require/fetch.lua index e64b7f0b0..01a5bf5ab 100644 --- a/xmake/modules/private/action/require/fetch.lua +++ b/xmake/modules/private/action/require/fetch.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("core.base.hashset") +import("core.base.json") import("core.project.project") import("core.package.package", {alias = "core_package"}) import("core.tool.linker") @@ -86,6 +87,8 @@ function main(requires_raw) end if #flags > 0 then print(os.args(flags)) + elseif fetchmodes and fetchmodes:has("json") then + print(json.encode(fetchinfos)) else print(fetchinfos) end diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index bf5b2ec44..cedd2e339 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -431,14 +431,21 @@ end -- main entry function main() if option.get("list") then - print("%s:", _get_envsdir()) - local count = 0 - for _, envfile in ipairs(os.files(path.join(_get_envsdir(), "*.lua"))) do - local envname = path.basename(envfile) - print(" - %s", envname) - count = count + 1 + local envname = option.get("program") + if envname then + local envfile = path.join(_get_envsdir(), envname .. ".lua") + print("%s:", envfile) + io.cat(envfile) + else + print("%s:", _get_envsdir()) + local count = 0 + for _, envfile in ipairs(os.files(path.join(_get_envsdir(), "*.lua"))) do + local envname = path.basename(envfile) + print(" - %s", envname) + count = count + 1 + end + print("envs(%d) found!", count) end - print("envs(%d) found!", count) elseif option.get("add") then local envfile = assert(option.get("program"), "please set environment config file!") if os.isfile(envfile) then diff --git a/xmake/modules/private/xrepo/action/fetch.lua b/xmake/modules/private/xrepo/action/fetch.lua index 57e56c71b..d94d0d215 100644 --- a/xmake/modules/private/xrepo/action/fetch.lua +++ b/xmake/modules/private/xrepo/action/fetch.lua @@ -45,6 +45,7 @@ function menu_options() {nil, "cflags", "k", nil, "Fetch cflags of the given packages." }, {nil, "ldflags", "k", nil, "Fetch ldflags of the given packages."}, {'e', "external", "k", nil, "Show cflags as external packages with -isystem."}, + {nil, "json", "k", nil, "Output package info as json format." }, {}, {nil, "packages", "vs", nil, "The packages list.", "e.g.", @@ -139,6 +140,9 @@ function _fetch_packages(packages) if option.get("external") then table.insert(fetchmodes, "external") end + if option.get("json") then + table.insert(fetchmodes, "json") + end if #fetchmodes > 0 then table.insert(require_argv, "--fetch_modes=" .. table.concat(fetchmodes, ',')) end diff --git a/xmake/rules/cuda/devlink/xmake.lua b/xmake/rules/cuda/devlink/xmake.lua index fb1f603b0..67c7836eb 100644 --- a/xmake/rules/cuda/devlink/xmake.lua +++ b/xmake/rules/cuda/devlink/xmake.lua @@ -37,13 +37,14 @@ rule("cuda.build.devlink") import("utils.progress") -- disable devlink? - if target:values("cuda.build.devlink") == false then + local devlink = target:values("cuda.build.devlink") + if devlink == false then return end - -- only for binary/shared - local targetkind = target:kind() - if targetkind ~= "binary" and targetkind ~= "shared" then + -- only for binary/shared on non-windows platforms + -- https://github.com/xmake-io/xmake/issues/1976 + if not (devlink == true or target:is_plat("windows") or target:is_binary() or target:is_shared()) then return end @@ -54,7 +55,7 @@ rule("cuda.build.devlink") local culdflags = {"-dlink"} -- add shared flag - if targetkind == "shared" then + if target:is_shared() then table.insert(culdflags, "-shared") end diff --git a/xmake/rules/cuda/env/xmake.lua b/xmake/rules/cuda/env/xmake.lua index 96d587e41..d36482901 100644 --- a/xmake/rules/cuda/env/xmake.lua +++ b/xmake/rules/cuda/env/xmake.lua @@ -22,11 +22,8 @@ rule("cuda.env") on_load(function (target) - - -- imports import("detect.sdks.find_cuda") - -- find cuda sdk first local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK not found!") if cuda then target:data_set("cuda", cuda) @@ -34,15 +31,13 @@ rule("cuda.env") end) after_load(function (target) - - -- imports import("core.platform.platform") -- get cuda sdk local cuda = assert(target:data("cuda"), "Cuda SDK not found!") -- add arch - if is_arch("i386", "x86") then + if target:is_arch("i386", "x86") then target:add("cuflags", "-m32", {force = true}) target:add("culdflags", "-m32", {force = true}) else @@ -56,6 +51,11 @@ rule("cuda.env") target:add("culdflags", "-ccbin=" .. os.args(cu_ccbin), {force = true}) end + -- add rdc, @see https://github.com/xmake-io/xmake/issues/1975 + if target:values("cuda.rdc") ~= false then + target:add("cuflags", "-rdc=true") + end + -- add links target:add("syslinks", "cudadevrt") local cudart = false @@ -68,7 +68,7 @@ rule("cuda.env") if not cudart then target:add("syslinks", "cudart_static") end - if is_plat("linux") then + if target:is_plat("linux") then target:add("syslinks", "rt", "pthread", "dl") end target:add("linkdirs", cuda.linkdirs) diff --git a/xmake/scripts/pac/github_mirror.lua b/xmake/scripts/pac/github_mirror.lua new file mode 100644 index 000000000..026a9a50c --- /dev/null +++ b/xmake/scripts/pac/github_mirror.lua @@ -0,0 +1,12 @@ +import("net.fasturl") + +function mirror(url) + local configs = {} + local proxyurls = {"github.com.cnpmjs.org", "hub.fastgit.org"} + fasturl.add(proxyurls) + proxyurls = fasturl.sort(proxyurls) + if #proxyurls > 0 then + return url:replace("/github.com/", "/" .. proxyurls[1] .. "/", {plain = true}) + end +end + |
