commit:     75c8059bb0bc595deff3cadcc1195e1ffdf0f385
Author:     Marek Szuba <marecki <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 20 17:17:14 2021 +0000
Commit:     Marek Szuba <marecki <AT> gentoo <DOT> org>
CommitDate: Tue Apr 20 17:48:40 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=75c8059b

net-libs/nodejs: support dev-libs/icu-69.1

The version of V8 bundled with all versions of NodeJS currently in the
tree calls ListFormatter::createInstance() in a way that is both marked
as internal in icu-68 and absent from icu-69. Apply a fix originally
developed from Chromium which switches to a style marked as stable since
icu-67, meaning it works with both versions of dev-libs/icu currently in
the tree (confirmed by building 12.22.1 against both, with USE=icu of
course).

Closes: https://bugs.gentoo.org/781287
Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>

 .../nodejs/files/nodejs-12.22.1-v8_icu69.patch     | 85 ++++++++++++++++++++++
 .../nodejs/files/nodejs-14.16.1-v8_icu69.patch     | 84 +++++++++++++++++++++
 net-libs/nodejs/nodejs-12.22.1.ebuild              |  1 +
 net-libs/nodejs/nodejs-14.16.1.ebuild              |  1 +
 net-libs/nodejs/nodejs-15.14.0.ebuild              |  1 +
 5 files changed, 172 insertions(+)

diff --git a/net-libs/nodejs/files/nodejs-12.22.1-v8_icu69.patch 
b/net-libs/nodejs/files/nodejs-12.22.1-v8_icu69.patch
new file mode 100644
index 00000000000..bd6d5c64b02
--- /dev/null
+++ b/net-libs/nodejs/files/nodejs-12.22.1-v8_icu69.patch
@@ -0,0 +1,85 @@
+Port of the Chromium commit 035c305ce7761f51328b45f1bd83e26aef267c9d to 
node-v12.
+Original commit message follows.
+
+Author:     Frank Tang <[email protected]>
+AuthorDate: 2020-10-15 22:44:27 -0700
+Commit:     Commit Bot <[email protected]>
+CommitDate: 2020-10-20 02:08:13 +0000
+[Intl] call new ListFormatter::createInstance
+The one we currently using is now marked as internal and to be removed
+for 68. Migrating to the style which already avaiable in ICU 67-1.
+
+--- a/deps/v8/src/objects/js-list-format.cc
++++ b/deps/v8/src/objects/js-list-format.cc
+@@ -29,46 +29,27 @@
+ namespace internal {
+ 
+ namespace {
+-const char* kStandard = "standard";
+-const char* kOr = "or";
+-const char* kUnit = "unit";
+-const char* kStandardShort = "standard-short";
+-const char* kOrShort = "or-short";
+-const char* kUnitShort = "unit-short";
+-const char* kStandardNarrow = "standard-narrow";
+-const char* kOrNarrow = "or-narrow";
+-const char* kUnitNarrow = "unit-narrow";
+ 
+-const char* GetIcuStyleString(JSListFormat::Style style,
+-                              JSListFormat::Type type) {
++UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
++  switch (style) {
++    case JSListFormat::Style::LONG:
++      return ULISTFMT_WIDTH_WIDE;
++    case JSListFormat::Style::SHORT:
++      return ULISTFMT_WIDTH_SHORT;
++    case JSListFormat::Style::NARROW:
++      return ULISTFMT_WIDTH_NARROW;
++  }
++  UNREACHABLE();
++}
++
++UListFormatterType GetIcuType(JSListFormat::Type type) {
+   switch (type) {
+     case JSListFormat::Type::CONJUNCTION:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kStandard;
+-        case JSListFormat::Style::SHORT:
+-          return kStandardShort;
+-        case JSListFormat::Style::NARROW:
+-          return kStandardNarrow;
+-      }
++      return ULISTFMT_TYPE_AND;
+     case JSListFormat::Type::DISJUNCTION:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kOr;
+-        case JSListFormat::Style::SHORT:
+-          return kOrShort;
+-        case JSListFormat::Style::NARROW:
+-          return kOrNarrow;
+-      }
++      return ULISTFMT_TYPE_OR;
+     case JSListFormat::Type::UNIT:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kUnit;
+-        case JSListFormat::Style::SHORT:
+-          return kUnitShort;
+-        case JSListFormat::Style::NARROW:
+-          return kUnitNarrow;
+-      }
++      return ULISTFMT_TYPE_UNITS;
+   }
+   UNREACHABLE();
+ }
+@@ -170,7 +151,7 @@
+   icu::Locale icu_locale = r.icu_locale;
+   UErrorCode status = U_ZERO_ERROR;
+   icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
+-      icu_locale, GetIcuStyleString(style_enum, type_enum), status);
++      icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
+   if (U_FAILURE(status)) {
+     delete formatter;
+     FATAL("Failed to create ICU list formatter, are ICU data files missing?");

diff --git a/net-libs/nodejs/files/nodejs-14.16.1-v8_icu69.patch 
b/net-libs/nodejs/files/nodejs-14.16.1-v8_icu69.patch
new file mode 100644
index 00000000000..d1e204f0c5d
--- /dev/null
+++ b/net-libs/nodejs/files/nodejs-14.16.1-v8_icu69.patch
@@ -0,0 +1,84 @@
+Port of the Chromium commit 035c305ce7761f51328b45f1bd83e26aef267c9d to 
node-v14.
+Original commit message follows.
+
+Author:     Frank Tang <[email protected]>
+AuthorDate: 2020-10-15 22:44:27 -0700
+Commit:     Commit Bot <[email protected]>
+CommitDate: 2020-10-20 02:08:13 +0000
+[Intl] call new ListFormatter::createInstance
+The one we currently using is now marked as internal and to be removed
+for 68. Migrating to the style which already avaiable in ICU 67-1.
+
+--- a/deps/v8/src/objects/js-list-format.cc
++++ b/deps/v8/src/objects/js-list-format.cc
+@@ -29,46 +29,26 @@
+ namespace internal {
+ 
+ namespace {
+-const char* kStandard = "standard";
+-const char* kOr = "or";
+-const char* kUnit = "unit";
+-const char* kStandardShort = "standard-short";
+-const char* kOrShort = "or-short";
+-const char* kUnitShort = "unit-short";
+-const char* kStandardNarrow = "standard-narrow";
+-const char* kOrNarrow = "or-narrow";
+-const char* kUnitNarrow = "unit-narrow";
++UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
++  switch (style) {
++    case JSListFormat::Style::LONG:
++      return ULISTFMT_WIDTH_WIDE;
++    case JSListFormat::Style::SHORT:
++      return ULISTFMT_WIDTH_SHORT;
++    case JSListFormat::Style::NARROW:
++      return ULISTFMT_WIDTH_NARROW;
++  }
++  UNREACHABLE();
++}
+ 
+-const char* GetIcuStyleString(JSListFormat::Style style,
+-                              JSListFormat::Type type) {
++UListFormatterType GetIcuType(JSListFormat::Type type) {
+   switch (type) {
+     case JSListFormat::Type::CONJUNCTION:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kStandard;
+-        case JSListFormat::Style::SHORT:
+-          return kStandardShort;
+-        case JSListFormat::Style::NARROW:
+-          return kStandardNarrow;
+-      }
++      return ULISTFMT_TYPE_AND;
+     case JSListFormat::Type::DISJUNCTION:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kOr;
+-        case JSListFormat::Style::SHORT:
+-          return kOrShort;
+-        case JSListFormat::Style::NARROW:
+-          return kOrNarrow;
+-      }
++      return ULISTFMT_TYPE_OR;
+     case JSListFormat::Type::UNIT:
+-      switch (style) {
+-        case JSListFormat::Style::LONG:
+-          return kUnit;
+-        case JSListFormat::Style::SHORT:
+-          return kUnitShort;
+-        case JSListFormat::Style::NARROW:
+-          return kUnitNarrow;
+-      }
++      return ULISTFMT_TYPE_UNITS;
+   }
+   UNREACHABLE();
+ }
+@@ -143,7 +123,7 @@
+   icu::Locale icu_locale = r.icu_locale;
+   UErrorCode status = U_ZERO_ERROR;
+   icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
+-      icu_locale, GetIcuStyleString(style_enum, type_enum), status);
++      icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
+   if (U_FAILURE(status) || formatter == nullptr) {
+     delete formatter;
+     THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),

diff --git a/net-libs/nodejs/nodejs-12.22.1.ebuild 
b/net-libs/nodejs/nodejs-12.22.1.ebuild
index 09249518e7e..4d8fd536264 100644
--- a/net-libs/nodejs/nodejs-12.22.1.ebuild
+++ b/net-libs/nodejs/nodejs-12.22.1.ebuild
@@ -47,6 +47,7 @@ DEPEND="
 PATCHES=(
        "${FILESDIR}"/${PN}-10.3.0-global-npm-config.patch
        "${FILESDIR}"/${PN}-12.20.1-fix_ppc64_crashes.patch
+       "${FILESDIR}"/${PN}-12.22.1-v8_icu69.patch
        "${FILESDIR}"/${PN}-99999999-llhttp.patch
 )
 RESTRICT="test"

diff --git a/net-libs/nodejs/nodejs-14.16.1.ebuild 
b/net-libs/nodejs/nodejs-14.16.1.ebuild
index b9e5858aaa6..c7c510655c8 100644
--- a/net-libs/nodejs/nodejs-14.16.1.ebuild
+++ b/net-libs/nodejs/nodejs-14.16.1.ebuild
@@ -43,6 +43,7 @@ DEPEND="${RDEPEND}"
 PATCHES=(
        "${FILESDIR}"/${PN}-10.3.0-global-npm-config.patch
        "${FILESDIR}"/${PN}-14.15.0-fix_ppc64_crashes.patch
+       "${FILESDIR}"/${PN}-14.16.1-v8_icu69.patch
 )
 
 S="${WORKDIR}/node-v${PV}"

diff --git a/net-libs/nodejs/nodejs-15.14.0.ebuild 
b/net-libs/nodejs/nodejs-15.14.0.ebuild
index 3b317ab08c9..9ef4cb031dd 100644
--- a/net-libs/nodejs/nodejs-15.14.0.ebuild
+++ b/net-libs/nodejs/nodejs-15.14.0.ebuild
@@ -41,6 +41,7 @@ BDEPEND="${PYTHON_DEPS}
 DEPEND="${RDEPEND}"
 
 PATCHES=(
+       "${FILESDIR}"/${PN}-14.16.1-v8_icu69.patch
        "${FILESDIR}"/${PN}-15.2.0-global-npm-config.patch
 )
 

Reply via email to