summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
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
commit92978c6f56ab66e17e19776d2e35832fa8be6e97 (patch)
tree8156c9043b20682df56ee30f673ac84a2c042eeb /xmake/modules
parent274244bf3530a77ab3c93309e5ea5bb5d29907ae (diff)
parentb86e3b25723812bdf0c20bc1d3d4075d47b57523 (diff)
Merge branch 'master' of https://github.com/xmake-io/xmake into modnamefix
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/core/tools/armar.lua25
-rw-r--r--xmake/modules/core/tools/cxx.lua24
-rw-r--r--xmake/modules/core/tools/gxx.lua2
-rw-r--r--xmake/modules/core/tools/nvcc.lua5
-rw-r--r--xmake/modules/detect/tools/find_cxx.lua61
-rw-r--r--xmake/modules/net/proxy.lua3
-rw-r--r--xmake/modules/private/action/require/fetch.lua3
-rw-r--r--xmake/modules/private/xrepo/action/env.lua21
-rw-r--r--xmake/modules/private/xrepo/action/fetch.lua4
9 files changed, 139 insertions, 9 deletions
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