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
}
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.isLinux = OperatingSystem.current().isLinux()
project.ext.isMacOsX = OperatingSystem.current().isMacOsX()
@ -40,18 +52,19 @@ if (['true', 'false', 'auto'].contains(cppEnabledStr) == false) {
}
project.ext.cppEnabled = cppEnabledStr == 'true'
if (cppEnabledStr == 'auto') {
// 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' ]
Process checkProcess = Runtime.getRuntime().exec(cmdArray, null, rootDir)
StringBuffer checkOutput = new StringBuffer()
checkProcess.consumeProcessOutputStream(checkOutput)
if (checkProcess.waitFor() == 0) {
project.ext.cppEnabled = true
} else {
println 'C++ dependencies not available - disabling C++ build'
println checkOutput
project.ext.cppEnabled = false
}
// Disable the C++ build if the 3rd party tools/libraries aren't available
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)
StringBuffer checkOutput = new StringBuffer()
checkProcess.consumeProcessOutputStream(checkOutput)
if (checkProcess.waitFor() == 0) {
project.ext.cppEnabled = true
} else {
println 'C++ dependencies not available - disabling C++ build'
println checkOutput
project.ext.cppEnabled = false
}
}
allprojects {

View File

@ -32,6 +32,8 @@ check.dependsOn noBootstrapTest
noBootstrapTest.mustRunAfter test
integTest {
// Cannot run integration tests when cross compiling
enabled project.cppCrossCompile == ''
cluster {
//setting 'useNativeProcess', 'true'
distribution = 'zip'
@ -47,8 +49,8 @@ task downloadCppDist(type: DownloadS3Task) {
destDir file("${buildDir}/cppDist")
flatten true
download "maven/${project.group}/ml-cpp/${project.version}/ml-cpp-windows-x86_64-${project.version}.zip"
download "maven/${project.group}/ml-cpp/${project.version}/ml-cpp-linux-x86_64-${project.version}.zip"
download "maven/${project.group}/ml-cpp/${project.version}/ml-cpp-darwin-x86_64-${project.version}.zip"
download "maven/${project.group}/ml-cpp/${project.version}/ml-cpp-linux-x86_64-${project.version}.zip"
download "maven/${project.group}/ml-cpp/${project.version}/ml-cpp-darwin-x86_64-${project.version}.zip"
outputs.file(file("${buildDir}/cppDist/ml-cpp-windows-x86_64-${project.version}.zip"))
outputs.file(file("${buildDir}/cppDist/ml-cpp-darwin-x86_64-${project.version}.zip"))
outputs.file(file("${buildDir}/cppDist/ml-cpp-linux-x86_64-${project.version}.zip"))