From 6864d328a02a72340635bdf14964254601fb9dfd Mon Sep 17 00:00:00 2001 From: calvinit <541298948@qq.com> Date: Thu, 17 Oct 2024 14:17:26 +0800 Subject: [PATCH] openjdk@8 1.8.0-432 --- Formula/o/openjdk@8.rb | 77 ++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/Formula/o/openjdk@8.rb b/Formula/o/openjdk@8.rb index bb067873392c9..6b031a2f88541 100644 --- a/Formula/o/openjdk@8.rb +++ b/Formula/o/openjdk@8.rb @@ -1,9 +1,9 @@ class OpenjdkAT8 < Formula desc "Development kit for the Java programming language" homepage "https://openjdk.java.net/" - url "https://github.com/openjdk/jdk8u/archive/refs/tags/jdk8u422-ga.tar.gz" - version "1.8.0-422" - sha256 "3931898b4336f0e583a5e97df7e5c339d859d53afaff6dafe20124107e836ebe" + url "https://github.com/openjdk/jdk8u/archive/refs/tags/jdk8u432-ga.tar.gz" + version "1.8.0-432" + sha256 "6ac8ee2b6932e4632ea2c33fe2320d6ceaca50a67521fac02a67027e40437460" license "GPL-2.0-only" livecheck do @@ -33,6 +33,16 @@ class OpenjdkAT8 < Formula uses_from_macos "unzip" uses_from_macos "zip" + # Note: Since the JNF (JavaNativeFoundation.framework) in macOS Sonoma or newer lacks the necessary headers to compile `openjdk@8`, + # we'll use our pre-built JNF later on. + on_sonoma :or_newer do + depends_on xcode: :build + resource "JavaNativeFoundation" do + url "https://github.com/apple/openjdk/archive/refs/tags/iTunesOpenJDK-1014.0.2.12.1.tar.gz" + sha256 "e8556a73ea36c75953078dfc1bafc9960e64593bc01e733bc772d2e6b519fd4a" + end + end + on_monterey :or_newer do depends_on "gawk" => :build end @@ -62,7 +72,7 @@ class OpenjdkAT8 < Formula end end - # Fix `clang++ -std=gnu++11` compile failure issue on MacOS. + # Fix `clang++ -std=gnu++11` compile failure issue on macOS. patch :p0 do url "https://raw.githubusercontent.com/macports/macports-ports/04ad4a17332e391cd359271965d4c6dac87a7eb2/java/openjdk8/files/0001-8181503-Can-t-compile-hotspot-with-c-11.patch" sha256 "a02e0ea7c70390796e46b8b6565f986fedc17a08aa039ee3306438a39a60538a" @@ -123,25 +133,48 @@ def install --with-toolchain-type=clang --with-zlib=system ] + on_sonoma :or_newer do + resource("JavaNativeFoundation").stage do + cd "apple/JavaNativeFoundation" do + xcodebuild "-arch", Hardware::CPU.arch, + "OTHER_CFLAGS=-Wno-strict-prototypes", + "-project", "JavaNativeFoundation.xcodeproj" + + my_sdk_path = buildpath/"PrebuiltSDKs/MacOSX.sdk" + my_framework_path = my_sdk_path/"System/Library/Frameworks" + my_framework_path.install "build/Release/JavaNativeFoundation.framework" + + sys_sdk_path = Pathname.new(`xcrun --show-sdk-path`.chomp) + + Dir.glob(sys_sdk_path/"System/Library/Frameworks/*.framework").each do |framework| + framework_name = File.basename(framework) + next if framework_name == "JavaNativeFoundation.framework" + my_framework_path.install_symlink framework => "#{framework_name}" + end + + sys_lib_path = sys_sdk_path/"System/Library" + my_lib_path = my_sdk_path/"System/Library" + Dir.foreach(sys_lib_path) do |entry| + next if entry == '.' || entry == '..' || entry == 'Frameworks' + my_lib_path.install_symlink sys_lib_path/entry => entry + end + + sys_sys_path = sys_sdk_path/"System" + my_sys_path = my_sdk_path/"System" + Dir.foreach(sys_sys_path) do |entry| + next if entry == '.' || entry == '..' || entry == 'Library' + my_sys_path.install_symlink sys_sys_path/entry => entry + end + + Dir.foreach(sys_sdk_path) do |entry| + next if entry == '.' || entry == '..' || entry == 'System' + my_sdk_path.install_symlink sys_sdk_path/entry => entry + end - # Work around SDK issues with JavaVM framework. - if MacOS.version <= :catalina - sdk_path = MacOS::CLT.sdk_path(MacOS.version) - ENV["SDKPATH"] = ENV["SDKROOT"] = sdk_path - javavm_framework_path = sdk_path/"System/Library/Frameworks/JavaVM.framework/Frameworks" - args += %W[ - --with-extra-cflags=-F#{javavm_framework_path} - --with-extra-cxxflags=-F#{javavm_framework_path} - ] - ldflags << "-F#{javavm_framework_path}" - # Fix "'JavaNativeFoundation/JavaNativeFoundation.h' file not found" issue on MacOS Sonoma. - elsif MacOS.version == :sonoma - javavm_framework_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks" - args += %W[ - --with-extra-cflags=-F#{javavm_framework_path} - --with-extra-cxxflags=-F#{javavm_framework_path} - ] - ldflags << "-F#{javavm_framework_path}" + ENV["SDKPATH"] = ENV["SDKROOT"] = ENV["HOMEBREW_SDKROOT"] = my_sdk_path + ENV["DYLD_FALLBACK_FRAMEWORK_PATH"] = my_framework_path + end + end end else args += %W[