summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-03-25 22:55:28 +0800
committerruki <[email protected]>2021-03-25 22:55:28 +0800
commit704444ba3d3089970efdd7747416031f95fd36c7 (patch)
tree64fd15d5df80df42ed507642d42560a9819b575f
parent6f4cdb2998faa46527d3f54b9b70aafdf9a79820 (diff)
improve scons to support android
-rw-r--r--xmake/modules/package/tools/scons.lua32
1 files changed, 31 insertions, 1 deletions
diff --git a/xmake/modules/package/tools/scons.lua b/xmake/modules/package/tools/scons.lua
index d9468666c..eb09d74bc 100644
--- a/xmake/modules/package/tools/scons.lua
+++ b/xmake/modules/package/tools/scons.lua
@@ -20,8 +20,38 @@
-- imports
import("core.base.option")
+import("core.tool.toolchain")
import("lib.detect.find_tool")
+-- get the build environments
+function buildenvs(package, opt)
+ opt = opt or {}
+ local envs = {}
+ if package:is_plat("android") then
+ local ndk = toolchain.load("ndk", {plat = package:plat(), arch = package:arch()})
+ envs.ANDROID_NDK_ROOT = ndk:config("ndk")
+ end
+ local ACLOCAL_PATH = {}
+ local PKG_CONFIG_PATH = {}
+ for _, dep in ipairs(package:orderdeps()) do
+ local pkgconfig = path.join(dep:installdir(), "lib", "pkgconfig")
+ if os.isdir(pkgconfig) then
+ table.insert(PKG_CONFIG_PATH, pkgconfig)
+ end
+ pkgconfig = path.join(dep:installdir(), "share", "pkgconfig")
+ if os.isdir(pkgconfig) then
+ table.insert(PKG_CONFIG_PATH, pkgconfig)
+ end
+ local aclocal = path.join(dep:installdir(), "share", "aclocal")
+ if os.isdir(aclocal) then
+ table.insert(ACLOCAL_PATH, aclocal)
+ end
+ end
+ envs.ACLOCAL_PATH = path.joinenv(ACLOCAL_PATH)
+ envs.PKG_CONFIG_PATH = path.joinenv(PKG_CONFIG_PATH)
+ return envs
+end
+
-- build package
function build(package, configs, opt)
opt = opt or {}
@@ -32,5 +62,5 @@ function build(package, configs, opt)
if configs then
table.join2(argv, configs)
end
- os.vrunv(scons.program, argv, {envs = opt.envs})
+ os.vrunv(scons.program, argv, {envs = opt.envs or buildenvs(package, opt)})
end