summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/scons.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-03 00:39:53 +0800
committerruki <[email protected]>2023-03-03 00:39:53 +0800
commitd469035fc49b6565a2ba7366d148d7f239bc352e (patch)
treeff7d2086d851091d29f0477a4e90cdeccd284061 /xmake/modules/package/tools/scons.lua
parentd451f16665a8230ec8c730cb67911f1e8a767fdb (diff)
improve tools.scons
Diffstat (limited to 'xmake/modules/package/tools/scons.lua')
-rw-r--r--xmake/modules/package/tools/scons.lua52
1 files changed, 32 insertions, 20 deletions
diff --git a/xmake/modules/package/tools/scons.lua b/xmake/modules/package/tools/scons.lua
index 16055609a..65b73dfec 100644
--- a/xmake/modules/package/tools/scons.lua
+++ b/xmake/modules/package/tools/scons.lua
@@ -20,34 +20,46 @@
-- imports
import("core.base.option")
+import("core.base.hashset")
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"
+ local items = hashset.new()
+ for _, item in ipairs(configs) do
+ local name = item:split("=")[1]
+ items:insert(name)
+ end
+ if not items:has("target") then
+ table.insert(configs, "target=" .. (package:is_debug() and "debug" or "release"))
+ end
+ if not items:has("use_mingw") then
+ table.insert(configs, "use_mingw=" .. (package:is_plat("mingw", "cygwin", "msys") and "yes" or "no"))
+ end
+ if not items:has("platform") then
+ 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
- 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
+ if not items:has("bits") and package:is_plat("x86_64", "x86", "i386", "x64") then
table.insert("bits=" .. (package:is_arch("x86", "i386") and "32" or "64"))
end
return configs