Skip to content

Commit 4703552

Browse files
committed
tools: clean up handling of shared libs in shell.nix
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent d2fa3b2 commit 4703552

1 file changed

Lines changed: 25 additions & 36 deletions

File tree

shell.nix

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,24 @@
4848
benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; },
4949
}:
5050

51+
assert pkgs.lib.assertMsg (withTemporal || !(builtins.hasAttr "temporal_capi" sharedLibDeps))
52+
"`sharedLibDeps` must not contain `temporal_capi` when `withTemporal` is false";
53+
assert pkgs.lib.assertMsg (withPerfetto || !(builtins.hasAttr "perfetto" sharedLibDeps))
54+
"`sharedLibDeps` must not contain `perfetto` when `withPerfetto` is false";
55+
5156
let
5257
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
53-
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
54-
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
58+
needsRustCompiler = withTemporal && !(builtins.hasAttr "temporal_capi" sharedLibDeps);
5559

56-
useSharedPerfetto = builtins.hasAttr "perfetto" sharedLibDeps;
57-
useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps;
58-
needsRustCompiler = withTemporal && !useSharedTemporal;
60+
sharedV8Deps = builtins.filter (depName: builtins.hasAttr depName sharedLibDeps) (
61+
[
62+
"abseil"
63+
"highway"
64+
"perfetto"
65+
"simdutf"
66+
"temporal_capi"
67+
]
68+
);
5969

6070
nativeBuildInputs =
6171
pkgs.nodejs-slim_latest.nativeBuildInputs
@@ -64,12 +74,7 @@ let
6474
pkgs.rustc
6575
];
6676
buildInputs =
67-
pkgs.lib.optional useSharedICU icu
68-
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil
69-
++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) sharedLibDeps.highway
70-
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto
71-
++ pkgs.lib.optional (builtins.hasAttr "simdutf" sharedLibDeps) sharedLibDeps.simdutf
72-
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
77+
pkgs.lib.optional useSharedICU icu ++ builtins.map (depName: sharedLibDeps.${depName}) sharedV8Deps;
7378

7479
# Put here only the configure flags that affect the V8 build
7580
configureFlags = [
@@ -81,11 +86,7 @@ let
8186
)
8287
"--v8-${if withTemporal then "enable" else "disable"}-temporal-support"
8388
]
84-
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil"
85-
++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) "--shared-highway"
86-
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto"
87-
++ pkgs.lib.optional (builtins.hasAttr "simdutf" sharedLibDeps) "--shared-simdutf"
88-
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
89+
++ builtins.map (depName: "--shared-${depName}") sharedV8Deps
8990
++ pkgs.lib.optional withPerfetto "--with-perfetto";
9091
in
9192
pkgs.mkShell {
@@ -131,26 +132,14 @@ pkgs.mkShell {
131132
++ pkgs.lib.optional (!withSSL) "--without-ssl"
132133
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
133134
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
134-
++
135-
pkgs.lib.concatMap
136-
(name: [
137-
"--shared-${name}"
138-
"--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib"
139-
"--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include"
140-
])
141-
(
142-
builtins.attrNames (
143-
if (useSeparateDerivationForV8 != false) then
144-
builtins.removeAttrs sharedLibDeps [
145-
"abseil"
146-
"highway"
147-
"simdutf"
148-
"temporal_capi"
149-
]
150-
else
151-
sharedLibDeps
152-
)
153-
)
135+
++ builtins.map (name: "--shared-${name}") (
136+
builtins.attrNames (
137+
if (useSeparateDerivationForV8 != false) then
138+
builtins.removeAttrs sharedLibDeps sharedV8Deps
139+
else
140+
sharedLibDeps
141+
)
142+
)
154143
);
155144
}
156145
// (

0 commit comments

Comments
 (0)