Skip to content

Commit

Permalink
Standardize build distribution internals on os/architecture (#105842) (
Browse files Browse the repository at this point in the history
…#105846)

The build handles platform specific code which may be for arm or x86.
Yet there are multiple ways to describe 64bit x86, and the build
converts between the two in several places. This commit consolidates on
the x64 nomenclature in most places, except where necessary (eg ML still
uses x86_64).

relates #105715
  • Loading branch information
rjernst committed Feb 28, 2024
1 parent eae8d7e commit e9ca585
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
24 changes: 14 additions & 10 deletions distribution/archives/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.nio.file.Path

apply plugin: 'elasticsearch.internal-distribution-archive-setup'

CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String platform, String architecture, boolean isTestDistro) {
CopySpec archiveFiles(String distributionType, String os, String architecture, boolean isTestDistro) {
return copySpec {
into("elasticsearch-${version}") {
into('lib') {
Expand All @@ -29,9 +29,9 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
into('bin') {
with binFiles(distributionType, isTestDistro)
}
into("darwin".equals(platform) ? 'jdk.app' : 'jdk') {
into("darwin".equals(os) ? 'jdk.app' : 'jdk') {
if (isTestDistro == false) {
with jdkFiles(project, platform, architecture)
with jdkFiles(project, os, architecture)
}
}
into('') {
Expand All @@ -56,7 +56,11 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla

with noticeFile(isTestDistro)
into('modules') {
with modulesFiles
if (isTestDistro) {
with integTestModulesFiles
} else {
with modulesFiles(os, architecture)
}
}
}
}
Expand All @@ -65,42 +69,42 @@ CopySpec archiveFiles(CopySpec modulesFiles, String distributionType, String pla
distribution_archives {
integTestZip {
content {
archiveFiles(integTestModulesFiles, 'zip', null, 'x64', true)
archiveFiles('zip', null, null, true)
}
}

windowsZip {
archiveClassifier = 'windows-x86_64'
content {
archiveFiles(modulesFiles('windows-x86_64'), 'zip', 'windows', 'x64', false)
archiveFiles('zip', 'windows', 'x64', false)
}
}

darwinTar {
archiveClassifier = 'darwin-x86_64'
content {
archiveFiles(modulesFiles('darwin-x86_64'), 'tar', 'darwin', 'x64', false)
archiveFiles('tar', 'darwin', 'x64', false)
}
}

darwinAarch64Tar {
archiveClassifier = 'darwin-aarch64'
content {
archiveFiles(modulesFiles('darwin-aarch64'), 'tar', 'darwin', 'aarch64', false)
archiveFiles('tar', 'darwin', 'aarch64', false)
}
}

linuxAarch64Tar {
archiveClassifier = 'linux-aarch64'
content {
archiveFiles(modulesFiles('linux-aarch64'), 'tar', 'linux', 'aarch64', false)
archiveFiles('tar', 'linux', 'aarch64', false)
}
}

linuxTar {
archiveClassifier = 'linux-x86_64'
content {
archiveFiles(modulesFiles('linux-x86_64'), 'tar', 'linux', 'x64', false)
archiveFiles('tar', 'linux', 'x64', false)
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions distribution/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}

modulesFiles = { platform ->
modulesFiles = { os, architecture ->
copySpec {
eachFile {
if (it.relativePath.segments[-2] == 'bin' || ((platform == 'darwin-x86_64' || platform == 'darwin-aarch64') && it.relativePath.segments[-2] == 'MacOS')) {
if (it.relativePath.segments[-2] == 'bin' || (os == 'darwin' && it.relativePath.segments[-2] == 'MacOS')) {
// bin files, wherever they are within modules (eg platform specific) should be executable
// and MacOS is an alternative to bin on macOS
it.mode = 0755
Expand All @@ -344,7 +344,12 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}
List excludePlatforms = ['linux-x86_64', 'linux-aarch64', 'windows-x86_64', 'darwin-x86_64', 'darwin-aarch64']
if (platform != null) {
if (os != null) {
String platform = os + '-' + architecture
if (architecture == 'x64') {
// ML platform dir uses the x86_64 nomenclature
platform = os + '-x86_64'
}
excludePlatforms.remove(excludePlatforms.indexOf(platform))
} else {
excludePlatforms = []
Expand Down Expand Up @@ -430,15 +435,15 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}

jdkFiles = { Project project, String platform, String architecture ->
jdkFiles = { Project project, String os, String architecture ->
return copySpec {
from project.jdks."bundled_${platform}_${architecture}"
from project.jdks."bundled_${os}_${architecture}"
exclude "demo/**"
/*
* The Contents/MacOS directory interferes with notarization, and is unused by our distribution, so we exclude
* it from the build.
*/
if ("darwin".equals(platform)) {
if ("darwin".equals(os)) {
exclude "Contents/MacOS"
}
eachFile { FileCopyDetails details ->
Expand Down
2 changes: 1 addition & 1 deletion distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def commonPackageConfig(String type, String architecture) {
with libFiles
}
into('modules') {
with modulesFiles('linux-' + ((architecture == 'x64') ? 'x86_64' : architecture))
with modulesFiles('linux', architecture)
}
into('jdk') {
with jdkFiles(project, 'linux', architecture)
Expand Down

0 comments on commit e9ca585

Please sign in to comment.