homebrew-core/Formula/openj9.rb

197 lines
6.4 KiB
Ruby

class Openj9 < Formula
desc "High performance, scalable, Java virtual machine"
homepage "https://www.eclipse.org/openj9/"
url "https://github.com/eclipse-openj9/openj9.git",
tag: "openj9-0.35.0",
revision: "e04a7f6c1c365a6b375deb5f641c72309b170b95"
license any_of: [
"EPL-2.0",
"Apache-2.0",
{ "GPL-2.0-only" => { with: "Classpath-exception-2.0" } },
{ "GPL-2.0-only" => { with: "OpenJDK-assembly-exception-1.0" } },
]
livecheck do
url :stable
regex(/^openj9-(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "9570aad125859a5ab095905d6cdc64e2f537dddc8762419d9bea87230c045cba"
sha256 cellar: :any, arm64_big_sur: "a45ff6f91ee86d0fcc2bfbd3ce83f4aea20715aa01df3e01680f163b74e36c24"
sha256 cellar: :any, ventura: "2763ff46d605b2a7173fc85ee04413f111f800343779644d698a86f54988274d"
sha256 cellar: :any, monterey: "a1ec2be6a1104b63db5dd1da2c71da3a746478cfca5a6037eb6744426dd22a89"
sha256 cellar: :any, big_sur: "432828659e46fed219dcd4ce9e89a16555c054f85077b001f67b18dcbddcd145"
sha256 cellar: :any, catalina: "89d89fc29751a74527f9d4a465a9a36adccb19a5935ef0e70e0ddea864f0058c"
end
keg_only :shadowed_by_macos
depends_on "autoconf" => :build
depends_on "bash" => :build
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "pkg-config" => :build
depends_on "fontconfig"
depends_on "giflib"
depends_on "harfbuzz"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "little-cms2"
uses_from_macos "cups"
uses_from_macos "libffi"
uses_from_macos "unzip"
uses_from_macos "zip"
uses_from_macos "zlib"
on_linux do
keg_only "it conflicts with openjdk"
depends_on "alsa-lib"
depends_on "libx11"
depends_on "libxext"
depends_on "libxrandr"
depends_on "libxrender"
depends_on "libxt"
depends_on "libxtst"
depends_on "numactl"
end
on_intel do
depends_on "nasm" => :build
end
# From https://github.com/eclipse-openj9/openj9/blob/openj9-#{version}/doc/build-instructions/
# We use JDK 17 to bootstrap on Apple Silicon since there is no JDK 16 prebuilt.
resource "boot-jdk" do
on_macos do
on_arm do
url "https://github.com/AdoptOpenJDK/semeru17-binaries/releases/download/jdk-17.0.4.1%2B1_openj9-0.33.1/ibm-semeru-open-jdk_aarch64_mac_17.0.4.1_1_openj9-0.33.1.tar.gz"
sha256 "50e4c324e7ffcf18c2e3ea7b1bfa870672203dab3fe61520c09fb2bdbe81f2c0"
end
on_intel do
url "https://github.com/AdoptOpenJDK/semeru16-binaries/releases/download/jdk-16.0.2%2B7_openj9-0.27.0/ibm-semeru-open-jdk_x64_mac_16.0.2_7_openj9-0.27.0.tar.gz"
sha256 "89e807261145243a358a2a626f64340944c03622f34eaa35429053e2085d7aef"
end
end
on_linux do
url "https://github.com/AdoptOpenJDK/semeru16-binaries/releases/download/jdk-16.0.2%2B7_openj9-0.27.0/ibm-semeru-open-jdk_x64_linux_16.0.2_7_openj9-0.27.0.tar.gz"
sha256 "1349eb9a1d9af491a1984d66a80126730357c4a5c4fcbe7112a2c832f6c0886e"
end
end
resource "omr" do
url "https://github.com/eclipse-openj9/openj9-omr.git",
tag: "openj9-0.35.0",
revision: "85a21674fdf30403b75c3000a4dc10605ca52ba2"
end
resource "openj9-openjdk-jdk" do
url "https://github.com/ibmruntimes/openj9-openjdk-jdk17.git",
tag: "openj9-0.35.0",
revision: "32d2c409a3325231f58eed81de0f0f1a229b43d6"
end
def install
openj9_files = buildpath.children
(buildpath/"openj9").install openj9_files
resource("openj9-openjdk-jdk").stage buildpath
resource("omr").stage buildpath/"omr"
boot_jdk = buildpath/"boot-jdk"
resource("boot-jdk").stage boot_jdk
boot_jdk /= "Contents/Home" if OS.mac?
java_options = ENV.delete("_JAVA_OPTIONS")
config_args = %W[
--disable-warnings-as-errors-omr
--disable-warnings-as-errors-openj9
--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-giflib=system
--with-harfbuzz=system
--with-lcms=system
--with-libjpeg=system
--with-libpng=system
--with-zlib=system
--enable-ddr=no
--enable-full-docs=no
]
config_args += if OS.mac?
%W[
--enable-dtrace
--with-sysroot=#{MacOS.sdk_path}
]
else
# Override hardcoded /usr/include directory when checking for numa headers
inreplace "closed/autoconf/custom-hook.m4", "/usr/include/numa", Formula["numactl"].opt_include/"numa"
%W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{Formula["cups"].opt_prefix}
--with-fontconfig=#{Formula["fontconfig"].opt_prefix}
]
end
# Ref: https://github.com/eclipse-openj9/openj9/issues/13767
# TODO: Remove once compressed refs mode is supported on Apple Silicon
config_args << "--with-noncompressedrefs" if OS.mac? && Hardware::CPU.arm?
ENV["CMAKE_CONFIG_TYPE"] = "Release"
system "bash", "./configure", *config_args
system "make", "all", "-j"
jdk = libexec
if OS.mac?
libexec.install Dir["build/*/images/jdk-bundle/*"].first => "openj9.jdk"
jdk /= "openj9.jdk/Contents/Home"
rm jdk/"lib/src.zip"
rm_rf Dir.glob(jdk/"**/*.dSYM")
else
libexec.install Dir["build/linux-x86_64-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}/openj9.jdk /Library/Java/JavaVirtualMachines/openj9.jdk
EOS
end
end
test do
(testpath/"HelloWorld.java").write <<~EOS
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
system bin/"javac", "HelloWorld.java"
assert_match "Hello, world!", shell_output("#{bin}/java HelloWorld")
end
end