Skip to content

Commit a96d077

Browse files
committed
Fix build error
1 parent 2d7c2c3 commit a96d077

File tree

5 files changed

+75
-22
lines changed

5 files changed

+75
-22
lines changed

Benchmarks/Package.swift

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
import class Foundation.FileManager
6+
import class Foundation.ProcessInfo
7+
8+
// Note: the JAVA_HOME environment variable must be set to point to where
9+
// Java is installed, e.g.,
10+
// Library/Java/JavaVirtualMachines/openjdk-21.jdk/Contents/Home.
11+
func findJavaHome() -> String {
12+
if let home = ProcessInfo.processInfo.environment["JAVA_HOME"] {
13+
return home
14+
}
15+
16+
// This is a workaround for envs (some IDEs) which have trouble with
17+
// picking up env variables during the build process
18+
let path = "\(FileManager.default.homeDirectoryForCurrentUser.path()).java_home"
19+
if let home = try? String(contentsOfFile: path, encoding: .utf8) {
20+
if let lastChar = home.last, lastChar.isNewline {
21+
return String(home.dropLast())
22+
}
23+
24+
return home
25+
}
26+
27+
fatalError("Please set the JAVA_HOME environment variable to point to where Java is installed.")
28+
}
29+
let javaHome = findJavaHome()
30+
31+
let javaIncludePath = "\(javaHome)/include"
32+
#if os(Linux)
33+
let javaPlatformIncludePath = "\(javaIncludePath)/linux"
34+
#elseif os(macOS)
35+
let javaPlatformIncludePath = "\(javaIncludePath)/darwin"
36+
#else
37+
// TODO: Handle windows as well
38+
#error("Currently only macOS and Linux platforms are supported, this may change in the future.")
39+
#endif
40+
41+
let package = Package(
42+
name: "benchmarks",
43+
platforms: [
44+
.macOS("15.03")
45+
],
46+
dependencies: [
47+
.package(path: "../"),
48+
.package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.4.0")),
49+
],
50+
targets: [
51+
.executableTarget(
52+
name: "JavaApiCallBenchmarks",
53+
dependencies: [
54+
.product(name: "JavaRuntime", package: "swift-java"),
55+
.product(name: "JavaKit", package: "swift-java"),
56+
.product(name: "JavaKitNetwork", package: "swift-java"),
57+
.product(name: "Benchmark", package: "package-benchmark"),
58+
],
59+
path: "Benchmarks/JavaApiCallBenchmarks",
60+
swiftSettings: [
61+
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
62+
.swiftLanguageMode(.v5),
63+
],
64+
plugins: [
65+
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
66+
]
67+
)
68+
]
69+
)

Package.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -374,24 +374,6 @@ let package = Package(
374374
.swiftLanguageMode(.v5),
375375
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"])
376376
]
377-
),
378-
379-
.executableTarget(
380-
name: "JavaApiCallBenchmarks",
381-
dependencies: [
382-
"JavaRuntime",
383-
"JavaKit",
384-
"JavaKitNetwork",
385-
.product(name: "Benchmark", package: "package-benchmark"),
386-
],
387-
path: "Benchmarks/JavaApiCallBenchmarks",
388-
swiftSettings: [
389-
.unsafeFlags(["-I\(javaIncludePath)", "-I\(javaPlatformIncludePath)"]),
390-
.swiftLanguageMode(.v5),
391-
],
392-
plugins: [
393-
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
394-
],
395-
),
377+
)
396378
]
397379
)

Samples/SwiftKitSampleApp/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import org.swift.swiftkit.gradle.BuildUtils
1616

1717
plugins {
1818
id("build-logic.java-application-conventions")
19-
id "me.champeau.jmh" version "0.7.2"
19+
id("me.champeau.jmh") version "0.7.2"
2020
}
2121

2222
group = "org.swift.swiftkit"
@@ -91,4 +91,4 @@ jmh {
9191
jvmArgsAppend = [
9292
"-Djava.library.path=" + BuildUtils.javaLibraryPaths(rootDir).join(":"),
9393
]
94-
}
94+
}

docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ RUN apt-get update && apt-get install -y \
1111
locales locales-all \
1212
make \
1313
libc6-dev \
14-
curl
14+
curl \
15+
libjemalloc2 \
16+
libjemalloc-dev
1517
ENV LC_ALL=en_US.UTF-8
1618
ENV LANG=en_US.UTF-8
1719
ENV LANGUAGE=en_US.UTF-8

0 commit comments

Comments
 (0)