summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-08-13 17:17:40 (GMT)
committerTobias Markmann <tm@ayena.de>2013-08-13 17:40:43 (GMT)
commit437e70ff9d254b11a30a4926010a91543d7f282c (patch)
tree123ef9476d89ad32643356ea11c52d212d2d03ad /BuildTools
parent3eefe28a2f6cc1e33d9d2b0bad7f9c6f2146352f (diff)
downloadswift-contrib-437e70ff9d254b11a30a4926010a91543d7f282c.zip
swift-contrib-437e70ff9d254b11a30a4926010a91543d7f282c.tar.bz2
Adding basic support for Android and Unbound (No IPv6 yet).
Change-Id: I1d74324515b20e0dc3d0ef4aa2f556fea7b4bee3 License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.s
Diffstat (limited to 'BuildTools')
-rw-r--r--BuildTools/SCons/SConscript.boot18
-rw-r--r--BuildTools/SCons/SConstruct12
-rw-r--r--BuildTools/SCons/Tools/Test.py21
3 files changed, 42 insertions, 9 deletions
diff --git a/BuildTools/SCons/SConscript.boot b/BuildTools/SCons/SConscript.boot
index 9ac3cca..8429737 100644
--- a/BuildTools/SCons/SConscript.boot
+++ b/BuildTools/SCons/SConscript.boot
@@ -19,7 +19,9 @@ vars.Add(BoolVariable("debug", "Compile with debug information", "yes"))
vars.Add(BoolVariable("allow_warnings", "Allow compilation warnings during compilation", "yes"))
vars.Add(BoolVariable("assertions", "Compile with assertions", "yes"))
vars.Add(BoolVariable("max_jobs", "Build with maximum number of parallel jobs", "no"))
-vars.Add(EnumVariable("target", "Choose a target platform for compilation", "native", ["native", "iphone-simulator", "iphone-device", "xcode"]))
+vars.Add(EnumVariable("target", "Choose a target platform for compilation", "native", ["native", "iphone-simulator", "iphone-device", "xcode", "android"]))
+vars.Add('android_toolchain', "Path to Android toolchain")
+vars.Add('android_sdk_bin', "Path to Android SDK's tools directory")
vars.Add(BoolVariable("swift_mobile", "Build mobile Swift", "no"))
vars.Add(BoolVariable("swiften_dll", "Build Swiften as dynamically linked library", "no"))
if os.name != "nt" :
@@ -68,6 +70,7 @@ vars.Add(BoolVariable("build_examples", "Build example programs", "yes"))
vars.Add(BoolVariable("enable_variants", "Build in a separate dir under build/, depending on compile flags", "no"))
vars.Add(BoolVariable("experimental", "Build experimental features", "yes"))
vars.Add(BoolVariable("set_iterator_debug_level", "Set _ITERATOR_DEBUG_LEVEL=0", "yes"))
+vars.Add(BoolVariable("unbound", "Build bundled ldns and unbound. Use them for DNS lookup.", "no"))
################################################################################
# Set up default build & configure environment
@@ -284,7 +287,7 @@ if env["PLATFORM"] == "win32" :
env["LINKCOM"] = [env["LINKCOM"], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1']
env["SHLINKCOM"] = [env["SHLINKCOM"], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2']
-if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphone-simulator", "xcode"] :
+if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphone-simulator", "xcode", "android"] :
env["PLATFORM_FLAGS"]["FRAMEWORKS"] += ["IOKit", "AppKit", "SystemConfiguration", "Security", "SecurityInterface"]
# Testing
@@ -351,6 +354,17 @@ if target in ["iphone-device", "iphone-simulator", "xcode"] :
# Bit of a hack, because BOOST doesn't know the endianness for ARM
env.Append(CPPDEFINES = ["_LITTLE_ENDIAN"])
+################################################################################
+# Android
+################################################################################
+if target in ["android"] :
+ env["ENV"]["PATH"] = env["android_toolchain"] + "/bin:" + env["ENV"]["PATH"]
+ env["CC"] = "arm-linux-androideabi-gcc"
+ env["CXX"] = "arm-linux-androideabi-g++"
+ env["RANLIB"] = "arm-linux-androideabi-ranlib"
+ env.Append(CPPDEFINES = ["ANDROID"])
+ env.Append(CPPDEFINES = ["_REENTRANT", "_GLIBCXX__PTHREADS"])
+
# CCache
if env.get("ccache", False) :
env["ENV"]["HOME"] = os.environ["HOME"]
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 75baf21..8f4d440 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -333,6 +333,14 @@ if not env.get("HAVE_ICU", False) and not env.get("HAVE_LIBIDN", False) :
env["HAVE_LIBIDN"] = 1
env["LIBIDN_BUNDLED"] = 1
+# Unbound
+if env["unbound"] :
+ env["LDNS_BUNDLED"] = 1
+ env["UNBOUND_BUNDLED"] = 1
+else :
+ env["LDNS_FLAGS"] = {}
+ env["UNBOUND_FLAGS"] = {}
+
# LibMiniUPnPc
if env["experimental"] :
libminiupnpc_flags = {"CPPPATH": ["/usr/include/miniupnpc/"]}
@@ -427,7 +435,7 @@ if env["qt"] :
# OpenSSL
openssl_env = conf_env.Clone()
-if env.get("openssl_force_bundled", False) or env["target"] in ("iphone-device", "iphone-simulator", "xcode") :
+if env.get("openssl_force_bundled", False) or env["target"] in ("iphone-device", "iphone-simulator", "xcode", "android") :
env["OPENSSL_BUNDLED"] = True
env["HAVE_OPENSSL"] = True
else :
@@ -480,7 +488,7 @@ if hunspell_conf.CheckCXXHeader("hunspell/hunspell.hxx") and hunspell_conf.Check
hunspell_conf.Finish()
# Bonjour
-if env["PLATFORM"] == "darwin" :
+if env["PLATFORM"] == "darwin" and env["target"] == "native" :
env["HAVE_BONJOUR"] = 1
elif env.get("bonjour", False) :
bonjour_env = conf_env.Clone()
diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py
index c52f448..ee16ec4 100644
--- a/BuildTools/SCons/Tools/Test.py
+++ b/BuildTools/SCons/Tools/Test.py
@@ -19,13 +19,24 @@ def generate(env) :
for i in ["HOME", "USERPROFILE", "APPDATA"]:
if os.environ.get(i, "") :
test_env["ENV"][i] = os.environ[i]
- if test_env["PLATFORM"] == "darwin" :
- test_env["ENV"]["DYLD_FALLBACK_LIBRARY_PATH"] = ":".join(map(lambda x : str(x), test_env.get("LIBPATH", [])))
- elif test_env["PLATFORM"] == "win32" :
- test_env["ENV"]["PATH"] = ";".join(map(lambda x : str(x), test_env.get("LIBRUNPATH", []))) + ";" + test_env["ENV"]["PATH"]
+ if env["target"] == "android" :
+ test_env["ENV"]["PATH"] = env["android_sdk_bin"] + ";" + test_env["ENV"]["PATH"]
+ else :
+ if test_env["PLATFORM"] == "darwin" :
+ test_env["ENV"]["DYLD_FALLBACK_LIBRARY_PATH"] = ":".join(map(lambda x : str(x), test_env.get("LIBPATH", [])))
+ elif test_env["PLATFORM"] == "win32" :
+ test_env["ENV"]["PATH"] = ";".join(map(lambda x : str(x), test_env.get("LIBRUNPATH", []))) + ";" + test_env["ENV"]["PATH"]
+
# Run the test
- test_env.Command("**dummy**", target,
+ if env["target"] == "android":
+ exec_name = os.path.basename(cmd)
+ test_env.Command("**dummy**", target, SCons.Action.Action(
+ ["adb shell mount -o rw,remount /system",
+ "adb push " + cmd + " /system/usr/bin/" + exec_name,
+ "adb shell SWIFT_CLIENTTEST_JID=\"" + os.getenv("SWIFT_CLIENTTEST_JID") + "\" SWIFT_CLIENTTEST_PASS=\"" + os.getenv("SWIFT_CLIENTTEST_PASS") + "\" " + env.get("TEST_RUNNER", "") + "/system/usr/bin/" + exec_name], cmdstr = "$TESTCOMSTR"))
+ else :
+ test_env.Command("**dummy**", target,
SCons.Action.Action(ignore_prefix + env.get("TEST_RUNNER", "") + cmd + " " + params, cmdstr = "$TESTCOMSTR"))
def registerScriptTests(env, scripts, name, type) :