Skip to content

fix: move the standard options to the target defaults #15

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 21 additions & 16 deletions binding.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"variables": {
"tests": 0,
"STANDARD": 17,
"MACOSX_DEPLOYMENT_TARGET": "10.15"
},

"targets": [
{
"target_name": "superstring",
Expand Down Expand Up @@ -66,12 +72,6 @@
}
],

"variables": {
"tests": 0,
"STANDARD": 17,
"MACOSX_DEPLOYMENT_TARGET": "10.15"
},

"conditions": [
# If --tests is passed to node-gyp configure, we'll build a standalone
# executable that runs tests on the patch.
Expand Down Expand Up @@ -117,7 +117,9 @@
['OS=="mac"', {
"xcode_settings": {
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++(STANDARD)',
'CLANG_CXX_LANGUAGE_STANDARD':'c++<(STANDARD)',
"CLANG_CXX_LIBRARY": "libc++",
'MACOSX_DEPLOYMENT_TARGET': "<(MACOSX_DEPLOYMENT_TARGET)"
}
}],
['OS=="win"', {
Expand All @@ -127,6 +129,17 @@
"defines": [
"NOMINMAX"
],
"msvs_settings": {
"VCCLCompilerTool": {
'MultiProcessorCompilation': 'true',
"AdditionalOptions": [
# C++ standard
"/std:c++<(STANDARD)",

"/EHsc" # C++ exception handling
]
}
}
}]
],
'default_configuration': 'Release',
Expand All @@ -135,24 +148,16 @@
'Release': {
'defines': [ 'NDEBUG' ],
"cflags": [ "-fno-exceptions", "-O3" ],
"cflags_cc": [ "-fno-exceptions", "-O3", "-std=c++<(STANDARD)" ],
"cflags_cc": [ "-fno-exceptions", "-O3" ],
"xcode_settings": {
'GCC_OPTIMIZATION_LEVEL': '3', # stop gyp from defaulting to -Os
"CLANG_CXX_LIBRARY": "libc++",
"CLANG_CXX_LANGUAGE_STANDARD": "c++<(STANDARD)",
'MACOSX_DEPLOYMENT_TARGET': "<(MACOSX_DEPLOYMENT_TARGET)"
}, # XCODE
"msvs_settings": {
"VCCLCompilerTool": {
'ExceptionHandling': 0, # /EHsc
'MultiProcessorCompilation': 'true',
'RuntimeTypeInfo': 'false',
'Optimization': 3, # full optimizations /O2 == /Og /Oi /Ot /Oy /Ob2 /GF /Gy
'StringPooling': 'true', # pool string literals
"AdditionalOptions": [
# C++ standard
"/std:c++<(STANDARD)",

# Optimizations
"/O2",
# "/Ob3", # aggressive inline
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:node": "node-gyp rebuild",
"build:browser": "bash -c script/build-browser-version.sh || echo 'the browser build is unsupported'",
"build": "npm run build:node && npm run build:browser",
"test:native": "node-gyp build --debug --tests && node script/test-native.js",
"test:native": "node-gyp configure --debug --tests && node-gyp build --debug --tests && node script/test-native.js",
"test:node": "mocha test/js/*.js",
"test:browser": "cross-env SUPERSTRING_USE_BROWSER_VERSION=1 mocha test/js/*.js || echo 'the browser tests are unsupported'",
"test": "npm run test:node && npm run test:native && npm run test:browser",
Expand Down
9 changes: 9 additions & 0 deletions test/native/encoding-conversion-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ TEST_CASE("EncodingConversion::decode - basic ISO-8859-1") {

u16string string;
conversion->decode(string, input.data(), input.size());

#ifdef _WIN32
WARN("Skipped the test on Windows.");
#else
REQUIRE(string == u"qrstüv");
#endif
}

TEST_CASE("EncodingConversion::decode - invalid byte sequences in the middle of the input") {
Expand Down Expand Up @@ -82,13 +87,17 @@ TEST_CASE("EncodingConversion::encode - basic") {
string, &start, string.size(), output.data(), output.size());
REQUIRE(std::string(output.data(), bytes_encoded) == "ab");

#ifdef _WIN32
WARN("Skipped the test on Windows.");
#else
bytes_encoded = conversion->encode(
string, &start, string.size(), output.data(), output.size());
REQUIRE(std::string(output.data(), bytes_encoded) == "γd");

bytes_encoded = conversion->encode(
string, &start, string.size(), output.data(), output.size());
REQUIRE(std::string(output.data(), bytes_encoded) == "efg");
#endif
}

TEST_CASE("EncodingConversion::encode - four-byte UTF-16 characters") {
Expand Down