Add facility to cross compile for Mac OS X on Linux (elastic/elasticsearch#717)

Adding a build system that makes it possible for an Ubuntu 16.04 build
server configured according to the instructions in
https://github.com/elastic/prelert-legacy/wiki/Plugin-Development-Setup-for-Mac-OS-X-cross-compiled-on-Linux
to build a Mac OS X version of the product.

Original commit: elastic/x-pack-elasticsearch@c6f39c0395
This commit is contained in:
David Roberts 2017-01-13 17:42:11 +00:00 committed by GitHub
parent c9a8d9d283
commit bc03dba9a2
2 changed files with 29 additions and 14 deletions

View File

@ -20,6 +20,18 @@ if (envMlAwsSecretKey != null) {
project.ext.mlAwsSecretKey = PRELERT_AWS_SECRET_ACCESS_KEY project.ext.mlAwsSecretKey = PRELERT_AWS_SECRET_ACCESS_KEY
} }
String cppCrossCompile = System.env.CPP_CROSS_COMPILE
if (cppCrossCompile != null) {
project.ext.cppCrossCompile = cppCrossCompile
} else if (project.hasProperty("CPP_CROSS_COMPILE")) {
project.ext.cppCrossCompile = CPP_CROSS_COMPILE
} else {
project.ext.cppCrossCompile = ''
}
if (project.ext.cppCrossCompile != '' && project.ext.cppCrossCompile != 'macosx') {
throw new GradleException("CPP_CROSS_COMPILE property must be empty or 'macosx'")
}
project.ext.isWindows = OperatingSystem.current().isWindows() project.ext.isWindows = OperatingSystem.current().isWindows()
project.ext.isLinux = OperatingSystem.current().isLinux() project.ext.isLinux = OperatingSystem.current().isLinux()
project.ext.isMacOsX = OperatingSystem.current().isMacOsX() project.ext.isMacOsX = OperatingSystem.current().isMacOsX()
@ -41,7 +53,8 @@ if (['true', 'false', 'auto'].contains(cppEnabledStr) == false) {
project.ext.cppEnabled = cppEnabledStr == 'true' project.ext.cppEnabled = cppEnabledStr == 'true'
if (cppEnabledStr == 'auto') { if (cppEnabledStr == 'auto') {
// Disable the C++ build if the 3rd party tools/libraries aren't available // Disable the C++ build if the 3rd party tools/libraries aren't available
String[] cmdArray = [ project.ext.bash, '-c', 'source cpp/set_env.sh && cpp/3rd_party/3rd_party.sh --check' ] String[] cmdArray = [ project.ext.bash, '-c',
'export CPP_CROSS_COMPILE=' + project.ext.cppCrossCompile + ' && source cpp/set_env.sh && cpp/3rd_party/3rd_party.sh --check' ]
Process checkProcess = Runtime.getRuntime().exec(cmdArray, null, rootDir) Process checkProcess = Runtime.getRuntime().exec(cmdArray, null, rootDir)
StringBuffer checkOutput = new StringBuffer() StringBuffer checkOutput = new StringBuffer()
checkProcess.consumeProcessOutputStream(checkOutput) checkProcess.consumeProcessOutputStream(checkOutput)

View File

@ -32,6 +32,8 @@ check.dependsOn noBootstrapTest
noBootstrapTest.mustRunAfter test noBootstrapTest.mustRunAfter test
integTest { integTest {
// Cannot run integration tests when cross compiling
enabled project.cppCrossCompile == ''
cluster { cluster {
//setting 'useNativeProcess', 'true' //setting 'useNativeProcess', 'true'
distribution = 'zip' distribution = 'zip'