Skip to content

Commit d9650e3

Browse files
big-r81daeho-ro
authored andcommitted
spidermonkey@128 (new formula)
Adding SpiderMonkey v128 as additional version
1 parent 1854fca commit d9650e3

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

Formula/s/[email protected]

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
class SpidermonkeyAT128 < Formula
2+
desc "JavaScript-C Engine"
3+
homepage "https://spidermonkey.dev"
4+
url "https://archive.mozilla.org/pub/firefox/releases/128.14.0esr/source/firefox-128.14.0esr.source.tar.xz"
5+
version "128.14.0"
6+
sha256 "93b9ef6229f41cb22ff109b95bbf61a78395a0fe4b870192eeca22947cb09a53"
7+
license "MPL-2.0"
8+
9+
# Spidermonkey versions use the same versions as Firefox, so we simply check
10+
# Firefox ESR release versions.
11+
livecheck do
12+
url "https://www.mozilla.org/en-US/firefox/releases/"
13+
regex(%r{href=.*?/v?(128(?:\.\d+)+)/releasenotes}i)
14+
end
15+
16+
keg_only :versioned_formula
17+
18+
depends_on "cbindgen" => :build
19+
depends_on "pkgconf" => :build
20+
depends_on "[email protected]" => :build
21+
depends_on "rust" => :build
22+
depends_on "icu4c@77"
23+
depends_on "nspr"
24+
depends_on "readline"
25+
26+
uses_from_macos "llvm" => :build # for llvm-objdump
27+
uses_from_macos "m4" => :build
28+
uses_from_macos "zlib"
29+
30+
# From python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
31+
fails_with :gcc do
32+
version "7"
33+
cause "Only GCC 8.1 or newer is supported"
34+
end
35+
36+
# Apply patch used by `gjs` to bypass build error.
37+
# ERROR: *** The pkg-config script could not be found. Make sure it is
38+
# *** in your path, or set the PKG_CONFIG environment variable
39+
# *** to the full path to pkg-config.
40+
# Ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1783570
41+
# Ref: https://discourse.gnome.org/t/gnome-45-to-depend-on-spidermonkey-115/16653
42+
patch do
43+
on_macos do
44+
url "https://github.com/ptomato/mozjs/commit/c82346c4e19a73ed4c7f65a6b274fc2138815ae9.patch?full_index=1"
45+
sha256 "0f1cd5f80b4ae46e614efa74a409133e8a69fff38220314f881383ba0adb0f87"
46+
end
47+
end
48+
49+
def install
50+
# Workaround for ICU 76+
51+
# Issue ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1927380
52+
inreplace "js/moz.configure", '"icu-i18n >= 73.1"', '"icu-i18n >= 73.1 icu-uc"'
53+
54+
if OS.mac?
55+
inreplace "build/moz.configure/toolchain.configure" do |s|
56+
# Help the build script detect ld64 as it expects logs from LD_PRINT_OPTIONS=1 with -Wl,-version
57+
# Issue ref: https://bugzilla.mozilla.org/show_bug.cgi?id=1844694
58+
s.sub! '"-Wl,--version"', '"-Wl,-ld_classic,-v"' if DevelopmentTools.clang_build_version >= 1500
59+
# Allow using brew libraries on macOS (not officially supported)
60+
s.sub!(/^(\s*def no_system_lib_in_sysroot\(.*\n\s*if )bootstrapped and value:/, "\\1False:")
61+
# Work around upstream only allowing build on limited macOS SDK (14.4 as of Spidermonkey 128)
62+
s.sub!(/^(\s*def mac_sdk_min_version\(.*\n\s*return )"\d+(\.\d+)*"$/, "\\1\"#{MacOS.version}\"")
63+
end
64+
end
65+
66+
mkdir "brew-build" do
67+
args = %W[
68+
--prefix=#{prefix}
69+
--enable-hardening
70+
--enable-optimize
71+
--enable-readline
72+
--enable-release
73+
--enable-rust-simd
74+
--enable-shared-js
75+
--disable-bootstrap
76+
--disable-debug
77+
--disable-jemalloc
78+
--with-intl-api
79+
--with-system-icu
80+
--with-system-nspr
81+
--with-system-zlib
82+
]
83+
84+
system "../js/src/configure", *args
85+
ENV.deparallelize { system "make" }
86+
system "make", "install"
87+
end
88+
89+
rm(lib/"libjs_static.ajs")
90+
91+
# Add an unversioned `js` to be used by dependents like `jsawk` & `plowshare`
92+
bin.install_symlink "js#{version.major}" => "js"
93+
94+
# Avoid writing nspr's versioned Cellar path in js*-config
95+
inreplace bin/"js#{version.major}-config",
96+
Formula["nspr"].prefix.realpath,
97+
Formula["nspr"].opt_prefix
98+
end
99+
100+
test do
101+
path = testpath/"test.js"
102+
path.write "print('hello');"
103+
assert_equal "hello", shell_output("#{bin}/js#{version.major} #{path}").strip
104+
assert_equal "hello", shell_output("#{bin}/js #{path}").strip
105+
end
106+
end

0 commit comments

Comments
 (0)