Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installer: install ICU header files #12217

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
30 changes: 30 additions & 0 deletions test/addons/icu-binding/binding.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <node.h>
#include <unicode/timezone.h>
#include <unicode/utypes.h>
#include <unicode/uversion.h>

namespace {

inline void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context) {
auto isolate = context->GetIsolate();
{
auto key = v8::String::NewFromUtf8(isolate, "icuVersion");
auto value = v8::String::NewFromUtf8(isolate, U_ICU_VERSION);
exports->Set(context, key, value).FromJust();
}
{
UErrorCode tzdata_status = U_ZERO_ERROR;
const char* tzdata_version = TimeZone::getTZDataVersion(tzdata_status);
if (U_SUCCESS(tzdata_status) && tzdata_version != nullptr) {
auto key = v8::String::NewFromUtf8(isolate, "tzdataVersion");
auto value = v8::String::NewFromUtf8(isolate, tzdata_version);
exports->Set(context, key, value).FromJust();
}
}
}

} // anonymous namespace

NODE_MODULE_CONTEXT_AWARE(binding, Initialize)
17 changes: 17 additions & 0 deletions test/addons/icu-binding/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
'targets': [
{
'target_name': 'binding',
'defines': [ 'V8_DEPRECATION_WARNINGS=1' ],
'conditions': [
['v8_enable_i18n_support==1', {
'sources': ['binding.cc'],
'include_dirs': [
'../../../deps/icu-small/source/common',
'../../../deps/icu-small/source/i18n',
],
}]
]
},
]
}
11 changes: 11 additions & 0 deletions test/addons/icu-binding/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const common = require('../../common');
if (!common.hasIntl) {
common.skip('missing intl');
process.exit(0);
}
const assert = require('assert');
const binding = require(`./build/${common.buildType}/binding`);
assert.strictEqual(binding.icuVersion, process.versions.icu);
assert.strictEqual(binding.tzdataVersion, process.versions.tz);
9 changes: 9 additions & 0 deletions tools/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ def headers(action):
'deps/zlib/zlib.h',
], 'include/node/')

# |icu_path| is set in small-icu and full-icu configurations
# but not when --with-intl= is set to none or system-icu.
icu_path = variables.get('icu_path')
if icu_path:
target_path = 'include/node/unicode/'
# Note: merges both directories into one.
subdir_files(icu_path + '/source/common/unicode', target_path, action)
subdir_files(icu_path + '/source/i18n/unicode', target_path, action)

def run(args):
global node_prefix, install_path, target_defaults, variables

Expand Down