From e5e039973e1768801122ed00c8c7f11abdea22ad Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Thu, 1 Dec 2016 12:16:06 +0000 Subject: [PATCH] Changes build to only grab cpp zip if it was built Original commit: elastic/x-pack-elasticsearch@24fc48fe867f7f5e8469649889985313afce83e8 --- build.gradle | 25 +++++++++++++++++++++++++ elasticsearch/build.gradle | 13 ++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8fb55ffdd9e..c53a953c43a 100644 --- a/build.gradle +++ b/build.gradle @@ -13,6 +13,9 @@ boolean isWindows = OperatingSystem.current().isWindows() boolean isLinux = OperatingSystem.current().isLinux() boolean isMacOsX = OperatingSystem.current().isMacOsX() +project.ext.bash = isWindows ? "C:\\Program Files\\Git\\bin\\bash" : "/bin/bash" + +// norelease: replace with something else when we become part of x-plugins project.ext.nasDirectory = isWindows ? "\\\\prelert-nas\\builds\\6.5.0\\" : (isMacOsX ? "/Volumes/builds/6.5.0/" : "/export/builds/6.5.0/") // norelease: replace with something else when we become part of x-plugins @@ -20,6 +23,28 @@ project.ext.nasExtension = '_' + (System.getenv()['GIT_COMMIT'] ?: 'xxxxxxxxxxxx (isWindows ? "_windows-x86_64.zip" : (isMacOsX ? "_darwin-x86_64.zip" : (isLinux ? "_linux-x86_64.zip" : "_sunos-x86_64.zip"))) +// 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', 'source cpp/set_env.sh && 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 + } +} + configurations.all { // check for updates every build resolutionStrategy.cacheChangingModulesFor 0, 'seconds' diff --git a/elasticsearch/build.gradle b/elasticsearch/build.gradle index 29108c625aa..2b8ef8fac9e 100644 --- a/elasticsearch/build.gradle +++ b/elasticsearch/build.gradle @@ -40,7 +40,18 @@ integTest { integTest.mustRunAfter noBootstrapTest bundlePlugin { - from { zipTree(project(':cpp').buildZip.outputs.files.singleFile) } + if (project.cppEnabled) { + from { zipTree(project(':cpp').buildZip.outputs.files.singleFile) } + } else { + from("${rootDir}/cppdistribution") { + into '.' + // Don't copy Windows import libraries + exclude "**/*.lib" + // Don't copy the test support library + exclude "**/libPreTest.*" + includeEmptyDirs = false + } + } } bundlePlugin.dependsOn(':cpp:buildZip')