summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2019-08-20 09:31:50 (GMT)
committerTobias Markmann <tobias.markmann@isode.com>2019-08-20 10:26:29 (GMT)
commitc62b7b6ce35a77d0a8236ef48155187fe5c30d12 (patch)
treee8afb68d84be1d36604b3f14a26b24796a583a72 /3rdParty/Expat/SConscript
parentd4105dbe815ba4109e0165cae696bd87d91c8bfe (diff)
downloadswift-c62b7b6ce35a77d0a8236ef48155187fe5c30d12.zip
swift-c62b7b6ce35a77d0a8236ef48155187fe5c30d12.tar.bz2
Fix building 3rdParty/Expat on non-Windows
Test-Information: Tested successfully on macOS 10.14.6 and Debian 9. Change-Id: I341589b6e92e9d16b53ea247d0b91ac1a0639f66
Diffstat (limited to '3rdParty/Expat/SConscript')
-rw-r--r--3rdParty/Expat/SConscript55
1 files changed, 55 insertions, 0 deletions
diff --git a/3rdParty/Expat/SConscript b/3rdParty/Expat/SConscript
index c2ccd4a..9a0cecd 100644
--- a/3rdParty/Expat/SConscript
+++ b/3rdParty/Expat/SConscript
@@ -8,6 +8,12 @@ if env.get("EXPAT_BUNDLED", False) :
"LIBPATH": [Dir(".")],
}
+ def checkBuilds(context, message, source):
+ context.Message(message)
+ result = context.TryLink(source, '.cpp')
+ context.Result(result)
+ return result
+
if env["SCONS_STAGE"] == "build" :
myenv = env.Clone()
myenv.Append(CPPDEFINES = ["XML_STATIC", "HAVE_EXPAT_CONFIG_H"])
@@ -22,6 +28,55 @@ if env.get("EXPAT_BUNDLED", False) :
myenv.Append(CPPDEFINES = ["HAVE_MEMMOVE"])
conf.Finish()
+ if env["PLATFORM"] != "win32" :
+ conf = Configure(conf_env, custom_tests = { "CheckBuilds" : checkBuilds})
+ if conf.CheckBuilds('Checking for C function getrandom()... ',
+ """
+ #include <stdlib.h> /* for NULL */
+ #include <sys/random.h>
+ int main() {
+ return getrandom(NULL, 0U, 0U);
+ }
+ """):
+ myenv.Append(CPPDEFINES = ["HAVE_GETRANDOM"])
+ elif conf.CheckBuilds('Checking for syscall SYS_getrandom... ',
+ """
+ #include <stdlib.h> /* for NULL */
+ #include <unistd.h> /* for syscall */
+ #include <sys/syscall.h> /* for SYS_getrandom */
+ int main() {
+ syscall(SYS_getrandom, NULL, 0, 0);
+ return 0;
+ }
+ """):
+ myenv.Append(CPPDEFINES = ["HAVE_SYSCALL_GETRANDOM"])
+ elif conf.CheckBuilds('Checking for arc4random_buf... ',
+ """
+ #include <stdlib.h> /* for arc4random_buf on BSD, for NULL */
+ #if defined(HAVE_LIBBSD)
+ # include <bsd/stdlib.h>
+ #endif
+ int main() {
+ arc4random_buf(NULL, 0U);
+ return 0;
+ }
+ """):
+ myenv.Append(CPPDEFINES = ["HAVE_ARC4RANDOM_BUF"])
+ elif conf.CheckBuilds('Checking for arc4random... ',
+ """
+ #if defined(HAVE_LIBBSD)
+ # include <bsd/stdlib.h>
+ #else
+ # include <stdlib.h>
+ #endif
+ int main() {
+ arc4random();
+ return 0;
+ }
+ """):
+ myenv.Append(CPPDEFINES = ["HAVE_ARC4RANDOM"])
+ conf.Finish()
+
env["EXPAT_OBJECTS"] = myenv.SwiftenObject([
"src/xmltok.c",
"src/xmlparse.c",