Skip to content

Commit 2e17846

Browse files
committed
build: add --shared-ncrypto configure flag
1 parent 518ff3f commit 2e17846

File tree

6 files changed

+105
-8
lines changed

6 files changed

+105
-8
lines changed

.github/workflows/test-shared.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ on:
2525
- deps/llhttp/**
2626
- deps/merve/**
2727
- deps/nbytes/**
28+
- deps/ncrypto/**
2829
- deps/nghttp2/**
2930
- deps/ngtcp2/**
3031
- deps/openssl/*/**
@@ -75,6 +76,7 @@ on:
7576
- deps/llhttp/**
7677
- deps/merve/**
7778
- deps/nbytes/**
79+
- deps/ncrypto/**
7880
- deps/nghttp2/**
7981
- deps/ngtcp2/**
8082
- deps/openssl/*/**

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1)
12431243
$(RM) -r $(TARNAME)/deps/llhttp
12441244
$(RM) -r $(TARNAME)/deps/merve
12451245
$(RM) -r $(TARNAME)/deps/nbytes
1246+
$(RM) -r $(TARNAME)/deps/ncrypto
12461247
$(RM) -r $(TARNAME)/deps/nghttp2
12471248
$(RM) -r $(TARNAME)/deps/ngtcp2
12481249
find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} +

configure.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,28 @@
399399
dest='shared_nbytes_libpath',
400400
help='a directory to search for the shared nbytes DLL')
401401

402+
shared_optgroup.add_argument('--shared-ncrypto',
403+
action='store_true',
404+
dest='shared_ncrypto',
405+
default=None,
406+
help='link to a shared ncrypto DLL instead of static linking')
407+
408+
shared_optgroup.add_argument('--shared-ncrypto-includes',
409+
action='store',
410+
dest='shared_ncrypto_includes',
411+
help='directory containing ncrypto header files')
412+
413+
shared_optgroup.add_argument('--shared-ncrypto-libname',
414+
action='store',
415+
dest='shared_ncrypto_libname',
416+
default='ncrypto',
417+
help='alternative lib name to link to [default: %(default)s]')
418+
419+
shared_optgroup.add_argument('--shared-ncrypto-libpath',
420+
action='store',
421+
dest='shared_ncrypto_libpath',
422+
help='a directory to search for the shared ncrypto DLL')
423+
402424
shared_optgroup.add_argument('--shared-nghttp2',
403425
action='store_true',
404426
dest='shared_nghttp2',
@@ -2609,6 +2631,7 @@ def make_bin_override():
26092631
configure_library('hdr_histogram', output)
26102632
configure_library('merve', output)
26112633
configure_library('nbytes', output)
2634+
configure_library('ncrypto', output)
26122635
configure_library('nghttp2', output, pkgname='libnghttp2')
26132636
configure_library('nghttp3', output, pkgname='libnghttp3')
26142637
configure_library('ngtcp2', output, pkgname='libngtcp2')

node.gyp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'node_shared_lief%': 'false',
2222
'node_shared_merve%': 'false',
2323
'node_shared_nbytes%': 'false',
24+
'node_shared_ncrypto%': 'false',
2425
'node_shared_nghttp2%': 'false',
2526
'node_shared_openssl%': 'false',
2627
'node_shared_sqlite%': 'false',
@@ -995,7 +996,12 @@
995996
'Ws2_32',
996997
],
997998
}],
998-
[ 'node_use_openssl=="true"', {
999+
[ 'node_use_openssl=="true" and node_shared_ncrypto=="true"', {
1000+
'sources': [
1001+
'<@(node_crypto_sources)',
1002+
],
1003+
}],
1004+
[ 'node_use_openssl=="true" and node_shared_ncrypto=="false"', {
9991005
'sources': [
10001006
'<@(node_crypto_sources)',
10011007
],
@@ -1308,11 +1314,13 @@
13081314
'defines': [
13091315
'HAVE_OPENSSL=1',
13101316
],
1317+
}, {
1318+
'sources!': [ '<@(node_cctest_openssl_sources)' ],
1319+
}],
1320+
[ 'node_use_openssl=="true" and node_shared_ncrypto=="false"', {
13111321
'dependencies': [
13121322
'deps/ncrypto/ncrypto.gyp:ncrypto',
13131323
],
1314-
}, {
1315-
'sources!': [ '<@(node_cctest_openssl_sources)' ],
13161324
}],
13171325
[ 'node_use_quic=="true"', {
13181326
'defines': [
@@ -1598,13 +1606,15 @@
15981606
],
15991607
}],
16001608
[ 'node_use_openssl=="true"', {
1601-
'dependencies': [
1602-
'deps/ncrypto/ncrypto.gyp:ncrypto',
1603-
],
16041609
'defines': [
16051610
'HAVE_OPENSSL=1',
16061611
],
16071612
}],
1613+
[ 'node_use_openssl=="true" and node_shared_ncrypto=="false"', {
1614+
'dependencies': [
1615+
'deps/ncrypto/ncrypto.gyp:ncrypto',
1616+
],
1617+
}],
16081618
[ 'node_use_node_code_cache=="true"', {
16091619
'defines': [
16101620
'NODE_USE_NODE_CODE_CACHE=1',

tools/nix/ncrypto.nix

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
lib,
3+
cmake,
4+
fetchFromGitHub,
5+
fetchpatch2,
6+
gtest,
7+
openssl,
8+
nix-update-script,
9+
stdenv,
10+
testers,
11+
validatePkgConfig,
12+
static ? stdenv.hostPlatform.isStatic,
13+
}:
14+
15+
stdenv.mkDerivation (finalAttrs: {
16+
pname = "ncrypto";
17+
version = "1.0.2-unstable";
18+
19+
src = fetchFromGitHub {
20+
owner = "nodejs";
21+
repo = "ncrypto";
22+
# tag = "v${finalAttrs.version}";
23+
rev = "7e4a1bdeed104dd389b2744982712d24e49c3383";
24+
hash = "sha256-Tq5BclGO38ZhT7v5vBaj3WeCkSUBIUx5QCDTUm9+aqo=";
25+
};
26+
27+
nativeBuildInputs = [
28+
cmake
29+
validatePkgConfig
30+
];
31+
buildInputs = [ openssl ];
32+
33+
doCheck = true;
34+
checkInputs = [ gtest ];
35+
cmakeFlags = [
36+
(lib.cmakeBool "BUILD_SHARED_LIBS" (!static))
37+
(lib.cmakeBool "NCRYPTO_SHARED_LIBS" true)
38+
(lib.cmakeBool "NCRYPTO_TESTING" finalAttrs.finalPackage.doCheck)
39+
];
40+
41+
passthru = {
42+
updateScript = nix-update-script { };
43+
44+
tests.pkg-config = testers.hasPkgConfigModules {
45+
package = finalAttrs.finalPackage;
46+
checkVersion = true;
47+
};
48+
};
49+
50+
meta = {
51+
description = "Library of byte handling functions extracted from Node.js core";
52+
homepage = "https://github.com/nodejs/ncrypto";
53+
changelog = "https://github.com/nodejs/ncrypto/releases/tag/v${finalAttrs.version}";
54+
license = lib.licenses.mit;
55+
maintainers = with lib.maintainers; [ aduh95 ];
56+
platforms = lib.platforms.all;
57+
pkgConfigModules = [ "ncrypto" ];
58+
};
59+
})

tools/nix/sharedLibDeps.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@
6565
}${opensslSrc}" { })
6666
openssl_3_6
6767
;
68-
in
69-
{
7068
openssl = openssl_3_6.overrideAttrs (old: {
7169
inherit version;
7270
src = pkgs.fetchurl {
@@ -84,6 +82,10 @@
8482
"dev"
8583
];
8684
});
85+
in
86+
{
87+
inherit openssl;
88+
ncrypto = pkgs.callPackage ./ncrypto.nix { inherit openssl; };
8789
}
8890
))
8991
// (pkgs.lib.optionalAttrs withTemporal {

0 commit comments

Comments
 (0)