homebrew-core/Formula/spidermonkey.rb

97 lines
3.8 KiB
Ruby

class Spidermonkey < Formula
desc "JavaScript-C Engine"
homepage "https://spidermonkey.dev"
url "https://archive.mozilla.org/pub/firefox/releases/91.13.0esr/source/firefox-91.13.0esr.source.tar.xz"
version "91.13.0"
sha256 "53be2bcde0b5ee3ec106bd8ba06b8ae95e7d489c484e881dfbe5360e4c920762"
license "MPL-2.0"
revision 2
head "https://hg.mozilla.org/mozilla-central", using: :hg
# Spidermonkey versions use the same versions as Firefox, so we simply check
# Firefox ESR release versions.
livecheck do
url "https://www.mozilla.org/en-US/firefox/releases/"
regex(/data-esr-versions=["']?v?(\d+(?:\.\d+)+)["' >]/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "c86a0a00d17e639dc2894142194cc99406384626e92e9afa26c8dda8fdfc28d0"
sha256 cellar: :any, arm64_monterey: "d9ce5112d08c944ca6ae6aeb078c6b4a94349caa530a57940b9f0000f113c6eb"
sha256 cellar: :any, arm64_big_sur: "260e78da8f7d60e493d57a5e4a200fb602c372230f0645f6808353ce7b684fa1"
sha256 cellar: :any, ventura: "85ad09528a9fac9379ef345bfc60dd2520e1c4394da309b65dba10129b45886b"
sha256 cellar: :any, monterey: "7218b680d85eca3628fddbbfe74d215fd2b3df40f765debed343bfff348ca976"
sha256 cellar: :any, big_sur: "3795db1e0e26f3e560a596e0d35b0798910ffc455a98710913185d46a4d561f1"
sha256 cellar: :any_skip_relocation, x86_64_linux: "26a8b4df8ca062d71245432c37642a31fca065339462595f14ffd09bb2b68757"
end
depends_on "autoconf@2.13" => :build
depends_on "pkg-config" => :build
depends_on "python@3.9" => :build
depends_on "rust" => :build
depends_on "icu4c"
depends_on "nspr"
depends_on "readline"
uses_from_macos "llvm" => :build # for llvm-objdump
uses_from_macos "m4" => :build
uses_from_macos "zlib"
conflicts_with "narwhal", because: "both install a js binary"
# From python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
fails_with :gcc do
version "6"
cause "Only GCC 7.1 or newer is supported"
end
def install
# Avoid installing into HOMEBREW_PREFIX.
# https://github.com/Homebrew/homebrew-core/pull/98809
ENV["SETUPTOOLS_USE_DISTUTILS"] = "stdlib"
# Remove the broken *(for anyone but FF) install_name
# _LOADER_PATH := @executable_path
inreplace "config/rules.mk",
"-install_name $(_LOADER_PATH)/$(SHARED_LIBRARY) ",
"-install_name #{lib}/$(SHARED_LIBRARY) "
inreplace "old-configure", "-Wl,-executable_path,${DIST}/bin", ""
cd "js/src"
system "autoconf213"
mkdir "brew-build" do
system "../configure", "--prefix=#{prefix}",
"--enable-optimize",
"--enable-readline",
"--enable-release",
"--enable-shared-js",
"--disable-bootstrap",
"--disable-jemalloc",
"--with-intl-api",
"--with-system-icu",
"--with-system-nspr",
"--with-system-zlib"
system "make"
system "make", "install"
end
(lib/"libjs_static.ajs").unlink
# Add an unversioned `js` to be used by dependents like `jsawk` & `plowshare`
ln_s bin/"js#{version.major}", bin/"js"
# Avoid writing nspr's versioned Cellar path in js*-config
inreplace bin/"js#{version.major}-config",
Formula["nspr"].prefix.realpath,
Formula["nspr"].opt_prefix
end
test do
path = testpath/"test.js"
path.write "print('hello');"
assert_equal "hello", shell_output("#{bin}/js#{version.major} #{path}").strip
assert_equal "hello", shell_output("#{bin}/js #{path}").strip
end
end