Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

node: add support for statically linking icu4c #44147

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions Library/Formula/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ class Node < Formula
option "with-debug", "Build with debugger hooks"
option "without-npm", "npm will not be installed"
option "without-completion", "npm bash completion will not be installed"
option "with-full-icu", "Build with full-icu (all locales) instead of small-icu (English only)"

deprecated_option "enable-debug" => "with-debug"
deprecated_option "with-icu4c" => "with-full-icu"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should keep this or not:

  • argument for keeping this: no side effect for someone who has previously build node --with-icu4c and is relying on non English locales (through he could add other locales at runtime to a small-icu build as mentioned above)
  • argument against keeping this: someone who needs only the English local and has previously build node --with-icu4c would have an unnecessary big node installation and would have to build it from source instead of downloading a smaller bottle


depends_on :python => :build if MacOS.version <= :snow_leopard
depends_on "pkg-config" => :build
depends_on "openssl" => :optional

# https://github.com/nodejs/node-v0.x-archive/issues/7919
# https://github.com/Homebrew/homebrew/issues/36681
depends_on "icu4c" => :optional

fails_with :llvm do
build 2326
end
Expand All @@ -34,11 +32,24 @@ class Node < Formula
sha256 "c8b602de5d51f956aa8f9c34d89be38b2df3b7c25ff6588030eb8224b070db27"
end

resource "icu4c" do
url "https://ssl.icu-project.org/files/icu4c/55.1/icu4c-55_1-src.tgz"
mirror "https://fossies.org/linux/misc/icu4c-55_1-src.tgz"
version "55.1"
sha256 "e16b22cbefdd354bec114541f7849a12f8fc2015320ca5282ee4fd787571457b"
end

def install
args = %W[--prefix=#{prefix} --without-npm]
args << "--debug" if build.with? "debug"
args << "--with-intl=system-icu" if build.with? "icu4c"
args << "--shared-openssl" if build.with? "openssl"
if build.with? "full-icu"
args << "--with-intl=full-icu"
else
args << "--with-intl=small-icu"
end

resource("icu4c").stage buildpath/"deps/icu"

system "./configure", *args
system "make", "install"
Expand Down Expand Up @@ -105,18 +116,6 @@ def caveats
EOS
end

if build.with? "icu4c"
s += <<-EOS.undent

Please note `icu4c` is built with a newer deployment target than Node and
this may cause issues in certain usage. Node itself is built against the
outdated `libstdc++` target, which is the root cause. For more information see:
https://github.com/nodejs/node-v0.x-archive/issues/7919

If this is an issue for you, do `brew install node --without-icu4c`.
EOS
end

s
end

Expand All @@ -127,6 +126,9 @@ def caveats
output = `#{bin}/node #{path}`.strip
assert_equal "hello", output
assert_equal 0, $?.exitstatus
output = `#{bin}/node -e "console.log(new Date('2015-09-15').toLocaleDateString('en'))"`.strip
assert_match /9\/1[45]\/2015/u, output # depends on system timezone
assert_equal 0, $?.exitstatus

if build.with? "npm"
# make sure npm can find node
Expand Down