summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-02-26 22:21:20 +0800
committerGitHub <[email protected]>2022-02-26 22:21:20 +0800
commitf527dbaf01ee10efb14cf0b12aca00b25debc011 (patch)
treeb53b1712537657ed8f3dc24107bf429445b7b50a
parent8432a23fd3d50e4b59c2e89f2a1b780a9942f8b5 (diff)
parent90107baef97e8c87f8bbc39a0d33a81def87f30d (diff)
Merge pull request #2101 from xq114/master
improve xmake update integrate and cuda has_flags
-rw-r--r--xmake/actions/update/main.lua7
-rw-r--r--xmake/modules/detect/tools/nvcc/has_flags.lua9
2 files changed, 13 insertions, 3 deletions
diff --git a/xmake/actions/update/main.lua b/xmake/actions/update/main.lua
index b96dfe02b..a49697058 100644
--- a/xmake/actions/update/main.lua
+++ b/xmake/actions/update/main.lua
@@ -294,8 +294,8 @@ function _initialize_shell()
local outdata, errdata = try {function () return os.iorunv(psshell.program, {"-c", "Write-Output $PROFILE.CurrentUserAllHosts"}) end}
if outdata then
target = outdata:trim()
- command = "if (Test-Path -Path \"%s\" -PathType Leaf) {\n . \"%s\"\n}"
profile = path.join(os.programdir(), "scripts", "profile-win.ps1")
+ command = format("if (Test-Path -Path \"%s\" -PathType Leaf) {\n . \"%s\"\n}", profile, profile)
else
raise("failed to get profile location from powershell!")
end
@@ -306,8 +306,9 @@ function _initialize_shell()
elseif shell:endswith("zsh") then target = "~/.zshrc"
elseif shell:endswith("ksh") then target = "~/.kshrc"
end
- command = "[[ -s \"%s\" ]] && source \"%s\""
profile = path.join(os.programdir(), "scripts", "profile-unix.sh")
+ command = format("export XMAKE_ROOTDIR=\"%s\"\nexport PATH=\"$XMAKE_ROOTDIR:$PATH\"\n", path.directory(os.programfile()))
+ command = command .. format("[[ -s \"%s\" ]] && source \"%s\"", profile, profile)
end
-- trace
@@ -324,7 +325,7 @@ function _initialize_shell()
file = file .. "\n"
end
end
- file = file .. "# >>> xmake >>>\n" .. format(command, profile, profile) .. "\n# <<< xmake <<<"
+ file = file .. "# >>> xmake >>>\n" .. command .. "\n# <<< xmake <<<"
io.writefile(target, file)
return true
end,
diff --git a/xmake/modules/detect/tools/nvcc/has_flags.lua b/xmake/modules/detect/tools/nvcc/has_flags.lua
index c30c87363..d96ffdfe8 100644
--- a/xmake/modules/detect/tools/nvcc/has_flags.lua
+++ b/xmake/modules/detect/tools/nvcc/has_flags.lua
@@ -122,6 +122,15 @@ function _check_try_running(flags, opt, islinker)
end
end
+ -- add architecture flags if cross compiling
+ if not is_arch(os.arch()) then
+ if is_arch(".+64.*") then
+ table.insert(args, 1, "-m64")
+ else
+ table.insert(args, 1, "-m32")
+ end
+ end
+
-- check flags
return _try_running(opt.program, table.join(flags, args), opt)
end