summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-25 22:58:48 +0800
committerruki <[email protected]>2021-03-25 22:58:48 +0800
commit5b414ecebb74389487c946b9c4687ec08d2c1aa9 (patch)
treeb9c703779e7053a9875049b903a5b5b168fae2cf
parent704444ba3d3089970efdd7747416031f95fd36c7 (diff)
improve tools/scons
-rw-r--r--xmake/modules/package/tools/scons.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/xmake/modules/package/tools/scons.lua b/xmake/modules/package/tools/scons.lua
index eb09d74bc..386645bba 100644
--- a/xmake/modules/package/tools/scons.lua
+++ b/xmake/modules/package/tools/scons.lua
@@ -23,6 +23,36 @@ import("core.base.option")
import("core.tool.toolchain")
import("lib.detect.find_tool")
+-- get configs
+function _get_configs(package, configs)
+ local configs = configs or {}
+ table.insert(configs, "target=" .. (package:is_debug() and "debug" or "release"))
+ table.insert(configs, "use_mingw=" .. (package:is_plat("mingw", "cygwin", "msys") and "yes" or "no"))
+ if package:is_plat("android") then
+ local scons_android_arch = "armv7"
+ if package:is_arch("arm64-v8a") then
+ scons_android_arch = "arm64v8"
+ end
+ table.insert(configs, "platform=android")
+ table.insert(configs, "android_arch=" .. scons_android_arch)
+ elseif package:is_plat("iphoneos") then
+ table.insert(configs, "platform=ios")
+ table.insert(configs, "ios_arch=" .. package:arch())
+ elseif package:is_plat("macosx") then
+ table.insert(configs, "platform=osx")
+ elseif package:is_plat("windows", "mingw", "cygwin", "msys") then
+ table.insert(configs, "platform=windows")
+ elseif package:is_plat("linux") then
+ table.insert(configs, "platform=linux")
+ elseif package:is_plat("bsd") then
+ table.insert(configs, "platform=freebsd")
+ end
+ if package:is_plat("x86_64", "x86", "i386", "x64") then
+ table.insert("bits=" .. (package:is_arch("x86", "i386") and "32" or "64"))
+ end
+ return configs
+end
+
-- get the build environments
function buildenvs(package, opt)
opt = opt or {}
@@ -59,6 +89,7 @@ function build(package, configs, opt)
local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2))
local scons = assert(find_tool("scons"), "scons not found!")
local argv = {"-C", buildir, "-j", njob}
+ configs = _get_configs(package, configs)
if configs then
table.join2(argv, configs)
end