-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
/
Copy pathopenjdk.rb
184 lines (162 loc) · 5.99 KB
/
openjdk.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
class Openjdk < Formula
desc "Development kit for the Java programming language"
homepage "https://openjdk.java.net/"
url "https://github.com/openjdk/jdk23u/archive/refs/tags/jdk-23.0.2-ga.tar.gz"
sha256 "0812e2e4d51ab1d752c1d532150297a56bd47557db67f8e2b298199e7f65db1c"
license "GPL-2.0-only" => { with: "Classpath-exception-2.0" }
livecheck do
url :stable
regex(/^jdk[._-]v?(\d+(?:\.\d+)*)-ga$/i)
end
bottle do
sha256 cellar: :any, arm64_sequoia: "1285eadf2b5998cda49e4470ee3875e855b0be199765401ad77dc38aea573f49"
sha256 cellar: :any, arm64_sonoma: "1cccc8bb39130612a61ff9d18a208ec232b86a21d646748a7af3f3f693eab804"
sha256 cellar: :any, arm64_ventura: "bb9bc5a4c4128b4c61a99d419026811f7f5fcf3ac243b1e393449aa680715d36"
sha256 cellar: :any, sonoma: "e0999137182b5abc4e0738330f4d9cb2f45b4d9642deffed420c0e7be4f337e8"
sha256 cellar: :any, ventura: "f5effdfcbab956c20d0f65bdc504ac27723d81d9fe940abadf81764782881650"
sha256 x86_64_linux: "a7bd3a62568d49149d566ed5cf98ec8a5cd2ab130019918ce42c8eaeb268b45b"
end
keg_only :shadowed_by_macos
depends_on "autoconf" => :build
depends_on "pkgconf" => :build
depends_on xcode: :build # for metal
depends_on "freetype"
depends_on "giflib"
depends_on "harfbuzz"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "little-cms2"
depends_on macos: :catalina
uses_from_macos "cups"
uses_from_macos "unzip"
uses_from_macos "zip"
uses_from_macos "zlib"
on_linux do
depends_on "alsa-lib"
depends_on "fontconfig"
depends_on "libx11"
depends_on "libxext"
depends_on "libxi"
depends_on "libxrandr"
depends_on "libxrender"
depends_on "libxt"
depends_on "libxtst"
end
# From https://jdk.java.net/archive/
resource "boot-jdk" do
on_macos do
on_arm do
url "https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/openjdk-23.0.1_macos-aarch64_bin.tar.gz"
sha256 "cd626e636fdd7e68467a9ca27d71107a27bd500c33ab40a91b57317c0c0f949f"
end
on_intel do
url "https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/openjdk-23.0.1_macos-x64_bin.tar.gz"
sha256 "3661d387ea2f1248364bc384a1e36197b3633f63dde7fd1f61b296e89eb0f768"
end
end
on_linux do
on_arm do
url "https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/openjdk-23.0.1_linux-aarch64_bin.tar.gz"
sha256 "94586630f70f1e87d90c252a6a2a202655399d1358c9b226834179e8bcf800e9"
end
on_intel do
url "https://download.java.net/java/GA/jdk23.0.1/c28985cbf10d4e648e4004050f8781aa/11/GPL/openjdk-23.0.1_linux-x64_bin.tar.gz"
sha256 "dc9b6adc1550afd95e30e131c1c38044925cb656923f92f6dbf0fbd8c1405629"
end
end
end
# Fix build with `--with-harfbuzz=system`.
# https://github.com/openjdk/jdk/pull/19739
patch do
url "https://github.com/openjdk/jdk/commit/ba5a4670b8ad86fefb41a939752754bf36aac9dc.patch?full_index=1"
sha256 "ff6c66f3fa81bef3fb18e88196c520cfa867aa5d57ebf26574635723b4d06d16"
end
def install
boot_jdk = buildpath/"boot-jdk"
resource("boot-jdk").stage boot_jdk
boot_jdk /= "Contents/Home" if OS.mac?
java_options = ENV.delete("_JAVA_OPTIONS")
args = %W[
--disable-warnings-as-errors
--with-boot-jdk-jvmargs=#{java_options}
--with-boot-jdk=#{boot_jdk}
--with-debug-level=release
--with-jvm-variants=server
--with-native-debug-symbols=none
--with-vendor-bug-url=#{tap.issues_url}
--with-vendor-name=#{tap.user}
--with-vendor-url=#{tap.issues_url}
--with-vendor-version-string=#{tap.user}
--with-vendor-vm-bug-url=#{tap.issues_url}
--with-version-build=#{revision}
--without-version-opt
--without-version-pre
--with-freetype=system
--with-giflib=system
--with-harfbuzz=system
--with-lcms=system
--with-libjpeg=system
--with-libpng=system
--with-zlib=system
]
ldflags = %W[
-Wl,-rpath,#{loader_path.gsub("$", "\\$$")}
-Wl,-rpath,#{loader_path.gsub("$", "\\$$")}/server
]
args += if OS.mac?
ldflags << "-headerpad_max_install_names"
# Allow unbundling `freetype` on macOS
inreplace "make/autoconf/lib-freetype.m4", '= "xmacosx"', '= ""'
%W[
--enable-dtrace
--with-freetype-include=#{Formula["freetype"].opt_include}
--with-freetype-lib=#{Formula["freetype"].opt_lib}
--with-sysroot=#{MacOS.sdk_path}
]
else
%W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{HOMEBREW_PREFIX}
--with-fontconfig=#{HOMEBREW_PREFIX}
--with-stdc++lib=dynamic
]
end
args << "--with-extra-ldflags=#{ldflags.join(" ")}"
if DevelopmentTools.clang_build_version == 1600
args << "--with-extra-cflags=-mllvm -enable-constraint-elimination=0"
end
system "bash", "configure", *args
ENV["MAKEFLAGS"] = "JOBS=#{ENV.make_jobs}"
system "make", "images"
jdk = libexec
if OS.mac?
libexec.install Dir["build/*/images/jdk-bundle/*"].first => "openjdk.jdk"
jdk /= "openjdk.jdk/Contents/Home"
else
libexec.install Dir["build/linux-*-server-release/images/jdk/*"]
end
bin.install_symlink Dir[jdk/"bin/*"]
include.install_symlink Dir[jdk/"include/*.h"]
include.install_symlink Dir[jdk/"include"/OS.kernel_name.downcase/"*.h"]
man1.install_symlink Dir[jdk/"man/man1/*"]
end
def caveats
on_macos do
<<~EOS
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn #{opt_libexec}/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
EOS
end
end
test do
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
JAVA
system bin/"javac", "HelloWorld.java"
assert_match "Hello, world!", shell_output("#{bin}/java HelloWorld")
end
end