summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-04-24 00:34:33 +0800
committerruki <[email protected]>2019-04-23 21:27:19 +0800
commita4b4fff7cb09c6a8359bad4ee204559eb0e41c35 (patch)
treead4d4ae5a9eaff5a765a7c83040e84b6d757dc07
parent6a430c2260ea9ba01cfd164bfe265157b15c235f (diff)
improve autoconf tools
-rw-r--r--xmake/core/package/package.lua20
-rw-r--r--xmake/core/project/config.lua2
-rw-r--r--xmake/modules/package/tools/autoconf.lua24
-rw-r--r--xmake/platforms/android/load.lua2
4 files changed, 45 insertions, 3 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 690197179..3e60043af 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -113,6 +113,26 @@ function _instance:repo()
return self._REPO
end
+-- the current platform is belong to the given platforms?
+function _instance:is_plat(...)
+ local plat = self:plat()
+ for _, v in ipairs(table.join(...)) do
+ if v and plat == v then
+ return true
+ end
+ end
+end
+
+-- the current architecture is belong to the given architectures?
+function _instance:is_arch(...)
+ local arch = self:arch()
+ for _, v in ipairs(table.join(...)) do
+ if v and arch:find("^" .. v:gsub("%-", "%%-") .. "$") then
+ return true
+ end
+ end
+end
+
-- get the package alias
function _instance:alias()
local requireinfo = self:requireinfo()
diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua
index 14db64d6a..75c8d94c7 100644
--- a/xmake/core/project/config.lua
+++ b/xmake/core/project/config.lua
@@ -244,7 +244,7 @@ function config.is_plat(...)
return config.is_value("plat", ...)
end
--- the current platform is belong to the given architectures?
+-- the current architecture is belong to the given architectures?
function config.is_arch(...)
return config.is_value("arch", ...)
end
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 8104fc822..d44adea5e 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -22,6 +22,28 @@
function _get_configs(package, configs)
local configs = configs or {}
table.insert(configs, "--prefix=" .. package:installdir())
+ if package:is_plat("iphoneos") then
+ local hosts = { arm64 = "aarch64-apple-darwin",
+ arm64e = "aarch64-apple-darwin",
+ armv7 = "armv7-apple-darwin",
+ armv7s = "armv7s-apple-darwin",
+ i386 = "i386-apple-darwin",
+ x86_64 = "x86_64-apple-darwin"}
+ table.insert(configs, "--host=" .. (hosts[package:arch()] or "aarch64-apple-darwin"))
+ elseif package:is_plat("android") then
+ -- @see https://developer.android.com/ndk/guides/other_build_systems#autoconf
+ local triples =
+ {
+ ["armv5te"] = "arm-linux-androideabi"
+ , ["armv7-a"] = "armv7a-linux-androideabi"
+ , ["arm64-v8a"] = "aarch64-linux-android"
+ , i386 = "i686-linux-android"
+ , x86_64 = "x86_64-linux-android"
+ , mips = "mips-linux-android"
+ , mips64 = "mips64-linux-android"
+ }
+ table.insert(configs, "--host=" .. (triples[package:arch()] or "armv7a-linux-androideabi"))
+ end
return configs
end
@@ -47,7 +69,7 @@ function _enter_envs(package)
envs.PKG_CONFIG_PATH = os.getenv("PKG_CONFIG_PATH")
-- set new environments
- if package:plat() == os.host() then
+ if package:is_plat(os.host()) then
os.addenvp("CFLAGS", package:config("cflags"), ' ')
os.addenvp("CFLAGS", package:config("cxflags"), ' ')
os.addenvp("CXXFLAGS", package:config("cxflags"), ' ')
diff --git a/xmake/platforms/android/load.lua b/xmake/platforms/android/load.lua
index 94212458c..c4fcd1342 100644
--- a/xmake/platforms/android/load.lua
+++ b/xmake/platforms/android/load.lua
@@ -122,7 +122,7 @@ function main(platform)
local triples =
{
["armv5te"] = "arm-linux-androideabi"
- , ["armv7-a"] = "arm-linux-androideabi"
+ , ["armv7-a"] = "armv7a-linux-androideabi"
, ["arm64-v8a"] = "aarch64-linux-android"
, i386 = "i686-linux-android"
, x86_64 = "x86_64-linux-android"