Remove C++ from build files (elastic/elasticsearch#739)
NB: The actual C++ code will be deleted in a separate commit to avoid swamping this commit. If you want to have the Java build pick up locally built C++ then: export CPP_LOCAL_DISTS=$CPP_SRC_HOME/build/distributions Otherwise, C++ artifacts will be downloaded from S3. Original commit: elastic/x-pack-elasticsearch@246672e81d
This commit is contained in:
parent
9af2c2cbeb
commit
f24e8c6d54
49
build.gradle
49
build.gradle
|
@ -1,4 +1,4 @@
|
||||||
description = 'Builds the Ml Engine native binaries and Java classes'
|
description = 'Builds the Machine Learning Java classes and UI'
|
||||||
|
|
||||||
import org.gradle.internal.os.OperatingSystem
|
import org.gradle.internal.os.OperatingSystem
|
||||||
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||||
|
@ -20,53 +20,25 @@ 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
|
String envCppLocalDists = System.env.CPP_LOCAL_DISTS
|
||||||
if (cppCrossCompile != null) {
|
if (envCppLocalDists != null) {
|
||||||
project.ext.cppCrossCompile = cppCrossCompile
|
project.ext.cppLocalDists = envCppLocalDists
|
||||||
} else if (project.hasProperty("CPP_CROSS_COMPILE")) {
|
} else if (project.hasProperty("CPP_LOCAL_DISTS")) {
|
||||||
project.ext.cppCrossCompile = CPP_CROSS_COMPILE
|
project.ext.cppLocalDists = CPP_LOCAL_DISTS
|
||||||
} else {
|
} else {
|
||||||
project.ext.cppCrossCompile = ''
|
project.ext.cppLocalDists = ''
|
||||||
}
|
|
||||||
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()
|
||||||
|
|
||||||
project.ext.bash = project.isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash"
|
|
||||||
|
|
||||||
String uploadEnabledStr = properties.get('upload', 'false')
|
String uploadEnabledStr = properties.get('upload', 'false')
|
||||||
if (['true', 'false'].contains(uploadEnabledStr) == false) {
|
if (['true', 'false'].contains(uploadEnabledStr) == false) {
|
||||||
throw new GradleException("upload must be true or false, got ${uploadEnabledStr}")
|
throw new GradleException("upload must be true or false, got ${uploadEnabledStr}")
|
||||||
}
|
}
|
||||||
project.ext.uploadEnabled = uploadEnabledStr == 'true'
|
project.ext.uploadEnabled = uploadEnabledStr == 'true'
|
||||||
|
|
||||||
// C++ build can be explicitly enabled or disabled, or if neither is chosen
|
|
||||||
// it will be enabled if the necessary 3rd party dependencies are present
|
|
||||||
String cppEnabledStr = properties.get('xpack.cpp.build', 'auto')
|
|
||||||
if (['true', 'false', 'auto'].contains(cppEnabledStr) == false) {
|
|
||||||
throw new GradleException("xpack.cpp.build must be true or false, got ${cppEnabledStr}")
|
|
||||||
}
|
|
||||||
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',
|
|
||||||
'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 {
|
allprojects {
|
||||||
group = 'org.elasticsearch.ml'
|
group = 'org.elasticsearch.ml'
|
||||||
version = VersionProperties.elasticsearch
|
version = VersionProperties.elasticsearch
|
||||||
|
@ -123,7 +95,7 @@ task assemble(dependsOn: bundlePack) {
|
||||||
description = 'Assembles the outputs of this project.'
|
description = 'Assembles the outputs of this project.'
|
||||||
}
|
}
|
||||||
|
|
||||||
task test(dependsOn: [':elasticsearch:test', ':cpp:test', ':kibana:test']) {
|
task test(dependsOn: [':elasticsearch:test', ':kibana:test']) {
|
||||||
group = 'Build'
|
group = 'Build'
|
||||||
description = 'Assembles and tests this project.'
|
description = 'Assembles and tests this project.'
|
||||||
}
|
}
|
||||||
|
@ -139,14 +111,14 @@ task clean(type: Delete) {
|
||||||
delete 'build'
|
delete 'build'
|
||||||
}
|
}
|
||||||
|
|
||||||
task uploadPackToS3(type: UploadS3Task, dependsOn: [build]) {
|
task uploadPackToS3(type: UploadS3Task, dependsOn: build) {
|
||||||
enabled project.uploadEnabled
|
enabled project.uploadEnabled
|
||||||
description = 'upload pack zip to S3 Bucket'
|
description = 'upload pack zip to S3 Bucket'
|
||||||
bucket 'prelert-artifacts'
|
bucket 'prelert-artifacts'
|
||||||
upload bundlePack.outputs.files.singleFile, "maven/${project.group}/${packArtifactName}/${project.version}/${bundlePack.outputs.files.singleFile.name}"
|
upload bundlePack.outputs.files.singleFile, "maven/${project.group}/${packArtifactName}/${project.version}/${bundlePack.outputs.files.singleFile.name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
task deploy(dependsOn: [uploadPackToS3, ':cpp:upload']) {
|
task deploy(dependsOn: uploadPackToS3) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +171,6 @@ allprojects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// intellij configuration
|
|
||||||
allprojects {
|
allprojects {
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ apply plugin: 'elasticsearch.esplugin'
|
||||||
|
|
||||||
esplugin {
|
esplugin {
|
||||||
name 'ml'
|
name 'ml'
|
||||||
description 'Ml Plugin'
|
description 'Machine Learning Plugin'
|
||||||
classname 'org.elasticsearch.xpack.ml.MlPlugin'
|
classname 'org.elasticsearch.xpack.ml.MlPlugin'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,6 @@ 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'
|
||||||
|
@ -43,8 +41,8 @@ integTest {
|
||||||
integTest.mustRunAfter noBootstrapTest
|
integTest.mustRunAfter noBootstrapTest
|
||||||
|
|
||||||
task downloadCppDist(type: DownloadS3Task) {
|
task downloadCppDist(type: DownloadS3Task) {
|
||||||
enabled project.cppEnabled == false
|
enabled project.cppLocalDists == ''
|
||||||
description = 'download cpp zips from S3 Bucket'
|
description = 'Download C++ zips from S3 Bucket'
|
||||||
bucket 'prelert-artifacts'
|
bucket 'prelert-artifacts'
|
||||||
destDir file("${buildDir}/cppDist")
|
destDir file("${buildDir}/cppDist")
|
||||||
flatten true
|
flatten true
|
||||||
|
@ -57,12 +55,17 @@ task downloadCppDist(type: DownloadS3Task) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bundlePlugin {
|
bundlePlugin {
|
||||||
if (project.cppEnabled) {
|
if (project.cppLocalDists) {
|
||||||
from { zipTree(project(':cpp').buildZip.outputs.files.singleFile) }
|
String localZipFile = 'ml-cpp-' +
|
||||||
dependsOn ':cpp:buildZip'
|
(project.isWindows ? "windows-x86_64" : (project.isMacOsX ? "darwin-x86_64" :
|
||||||
|
(project.isLinux ? "linux-x86_64" : "sunos-x86_64"))) +
|
||||||
|
"-${project.version}.zip"
|
||||||
|
from { zipTree(cppLocalDists + '/' + localZipFile) }
|
||||||
} else {
|
} else {
|
||||||
for (outputFile in downloadCppDist.outputs.files) {
|
for (outputFile in downloadCppDist.outputs.files) {
|
||||||
from(zipTree(outputFile))
|
from(zipTree(outputFile)) {
|
||||||
|
duplicatesStrategy 'exclude'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependsOn 'downloadCppDist'
|
dependsOn 'downloadCppDist'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
rootProject.name = 'ml'
|
rootProject.name = 'ml'
|
||||||
include ':cpp'
|
|
||||||
include ':elasticsearch'
|
include ':elasticsearch'
|
||||||
include ':docs'
|
include ':docs'
|
||||||
include ':kibana'
|
include ':kibana'
|
||||||
|
|
Loading…
Reference in New Issue