Skip to content

Commit 0b1ca0a

Browse files
committed
build: fix how we handle x86_64 library paths
1 parent 53b811a commit 0b1ca0a

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

BuildLogic/src/main/kotlin/build-logic.java-common-conventions.gradle.kts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,24 @@ tasks.withType(JavaCompile::class).forEach {
4343
}
4444

4545

46+
// FIXME: cannot share definition with 'buildSrc' so we duplicated the impl here
4647
fun javaLibraryPaths(): List<String> {
4748
val osName = System.getProperty("os.name")
4849
val osArch = System.getProperty("os.arch")
4950
val isLinux = osName.lowercase(Locale.getDefault()).contains("linux")
5051

5152
return listOf(
52-
if (osName.lowercase(Locale.getDefault()).contains("linux")) {
53-
"""$rootDir/.build/$osArch-unknown-linux-gnu/debug/"""
53+
if (isLinux) {
54+
if (osArch.equals("x86_64") || osArch.equals("amd64")) {
55+
"$rootDir/.build/x86_64-unknown-linux-gnu/debug/"
56+
} else {
57+
"$rootDir/.build/$osArch-unknown-linux-gnu/debug/"
58+
}
5459
} else {
5560
if (osArch.equals("aarch64")) {
56-
"""$rootDir/.build/arm64-apple-macosx/debug/"""
61+
"$rootDir/.build/arm64-apple-macosx/debug/"
5762
} else {
58-
"""$rootDir/.build/$osArch-apple-macosx/debug/"""
63+
"$rootDir/.build/$osArch-apple-macosx/debug/"
5964
}
6065
},
6166
if (isLinux) {

buildSrc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
buildSrc are shared "build library code" that is available to all sub-projects of the primary build.

buildSrc/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
14+
115
repositories {
216
mavenCentral()
317
}

buildSrc/src/main/groovy/org/swift/swiftkit/gradle/BuildUtils.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@
1515
package org.swift.swiftkit.gradle
1616

1717
final class BuildUtils {
18+
19+
/// Find library paths for 'java.library.path' when running or testing projects inside this build.
1820
static def javaLibraryPaths(File rootDir) {
1921
def osName = System.getProperty("os.name")
2022
def osArch = System.getProperty("os.arch")
2123
def isLinux = osName.toLowerCase(Locale.getDefault()).contains("linux")
2224

2325
return [
24-
osName.toLowerCase(Locale.getDefault()).contains("linux") ?
25-
"${rootDir}/.build/${osArch}-unknown-linux-gnu/debug/" :
26-
osArch == "aarch64" ?
26+
isLinux ?
27+
/* Linux */(osArch == "amd64" || osArch == "amd64" ?
28+
"${rootDir}/.build/x86_64-unknown-linux-gnu/debug/" :
29+
"${rootDir}/.build/${osArch}-unknown-linux-gnu/debug/") :
30+
/* macOS */(osArch == "aarch64" ?
2731
"${rootDir}/.build/arm64-apple-macosx/debug/" :
28-
"${rootDir}/.build/${osArch}-apple-macosx/debug/",
32+
"${rootDir}/.build/${osArch}-apple-macosx/debug/"),
2933
isLinux ?
3034
"/usr/lib/swift/linux" :
3135
// assume macOS

0 commit comments

Comments
 (0)