Skip to content

Commit ac1e1e8

Browse files
committed
build: add --shared-perfetto flag
Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 2743045 commit ac1e1e8

10 files changed

Lines changed: 96 additions & 25 deletions

File tree

‎.github/workflows/test-shared.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
- deps/nghttp2/**
3030
- deps/ngtcp2/**
3131
- deps/openssl/*/**
32+
- deps/perfetto/**
3233
- deps/simdjson/**
3334
- deps/sqlite/**
3435
- deps/uv/**
@@ -82,6 +83,7 @@ on:
8283
- deps/nghttp2/**
8384
- deps/ngtcp2/**
8485
- deps/openssl/*/**
86+
- deps/perfetto/**
8587
- deps/simdjson/**
8688
- deps/sqlite/**
8789
- deps/uv/**

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1)
13121312
$(RM) -r $(TARNAME)/deps/ngtcp2
13131313
find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} +
13141314
find $(TARNAME)/deps/openssl -mindepth 1 -maxdepth 1 -type d -exec $(RM) -r {} +
1315+
$(RM) -r $(TARNAME)/deps/perfetto
13151316
$(RM) -r $(TARNAME)/deps/simdjson
13161317
$(RM) -r $(TARNAME)/deps/sqlite
13171318
$(RM) -r $(TARNAME)/deps/uv

‎configure.py‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,29 @@
502502
dest='shared_openssl_libpath',
503503
help='a directory to search for the shared OpenSSL DLLs')
504504

505+
shared_optgroup.add_argument('--shared-perfetto',
506+
action='store_true',
507+
dest='shared_perfetto',
508+
default=None,
509+
help='link to a shared perfetto SDK instead of the one in deps/perfetto '
510+
'(requires --with-perfetto)')
511+
512+
shared_optgroup.add_argument('--shared-perfetto-includes',
513+
action='store',
514+
dest='shared_perfetto_includes',
515+
help='directory containing perfetto header files')
516+
517+
shared_optgroup.add_argument('--shared-perfetto-libname',
518+
action='store',
519+
dest='shared_perfetto_libname',
520+
default='perfetto',
521+
help='alternative lib name to link to [default: %(default)s]')
522+
523+
shared_optgroup.add_argument('--shared-perfetto-libpath',
524+
action='store',
525+
dest='shared_perfetto_libpath',
526+
help='a directory to search for the shared perfetto DLL')
527+
505528
shared_optgroup.add_argument('--shared-uvwasi',
506529
action='store_true',
507530
dest='shared_uvwasi',
@@ -2318,6 +2341,15 @@ def configure_lief(o):
23182341

23192342
configure_library('lief', o, pkgname='LIEF')
23202343

2344+
def configure_perfetto(o):
2345+
if not options.with_perfetto:
2346+
if options.shared_perfetto:
2347+
error('--shared-perfetto requires --with-perfetto')
2348+
o['variables']['node_shared_perfetto'] = b(False)
2349+
return
2350+
2351+
configure_library('perfetto', o)
2352+
23212353
def configure_sqlite(o):
23222354
o['variables']['node_use_sqlite'] = b(not options.without_sqlite)
23232355
if options.without_sqlite:
@@ -2827,6 +2859,7 @@ def make_bin_override():
28272859
configure_library('nghttp3', output, pkgname='libnghttp3')
28282860
configure_library('ngtcp2', output, pkgname='libngtcp2')
28292861
configure_lief(output);
2862+
configure_perfetto(output);
28302863
configure_sqlite(output);
28312864
configure_ffi(output);
28322865
configure_library('temporal_capi', output)

‎deps/perfetto/perfetto.gyp‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
'variables': {
3+
'node_shared_perfetto%': 'false',
34
'perfetto_sdk_sources': [
45
'sdk/perfetto.cc',
56
'sdk/perfetto.h',
@@ -8,15 +9,23 @@
89
'targets': [
910
{
1011
'target_name': 'perfetto_sdk',
11-
'type': 'static_library',
1212
'toolsets': ['host', 'target'],
13-
'include_dirs': [ 'sdk' ],
14-
'direct_dependent_settings': {
15-
# Use like `#include "perfetto.h"`
16-
'include_dirs': [ 'sdk' ],
17-
},
18-
'sources': [
19-
'<@(perfetto_sdk_sources)',
13+
'conditions': [
14+
['node_shared_perfetto=="true"', {
15+
# The SDK comes from the system, `include_dirs` and `libraries` are
16+
# provided by the configure script.
17+
'type': 'none',
18+
}, {
19+
'type': 'static_library',
20+
'include_dirs': [ 'sdk' ],
21+
'direct_dependent_settings': {
22+
# Use like `#include "perfetto.h"`
23+
'include_dirs': [ 'sdk' ],
24+
},
25+
'sources': [
26+
'<@(perfetto_sdk_sources)',
27+
],
28+
}],
2029
],
2130
},
2231
]

‎node.gyp‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
'node_shared_nbytes%': 'false',
2727
'node_shared_nghttp2%': 'false',
2828
'node_shared_openssl%': 'false',
29+
'node_shared_perfetto%': 'false',
2930
'node_shared_sqlite%': 'false',
3031
'node_shared_ffi%': 'false',
3132
'node_shared_temporal_capi%': 'false',
@@ -936,8 +937,12 @@
936937
'sources': [
937938
'<@(node_tracing_perfetto_sources)',
938939
],
939-
'dependencies': [
940-
'deps/perfetto/perfetto.gyp:perfetto_sdk',
940+
'conditions': [
941+
['node_shared_perfetto=="false"', {
942+
'dependencies': [
943+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
944+
],
945+
}],
941946
],
942947
}, {
943948
'sources': [
@@ -1395,7 +1400,7 @@
13951400
}, {
13961401
'sources!': [ '<@(node_cctest_quic_sources)' ],
13971402
}],
1398-
[ 'v8_use_perfetto==1', {
1403+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
13991404
'dependencies': [
14001405
'deps/perfetto/perfetto.gyp:perfetto_sdk',
14011406
],
@@ -1725,7 +1730,7 @@
17251730
'NODE_USE_NODE_CODE_CACHE=1',
17261731
],
17271732
}],
1728-
[ 'v8_use_perfetto==1', {
1733+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
17291734
'dependencies': [
17301735
'deps/perfetto/perfetto.gyp:perfetto_sdk',
17311736
],

‎shell.nix‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
withSQLite
3030
withFFI
3131
withSSL
32+
withPerfetto
3233
withTemporal
3334
;
3435
}
@@ -52,6 +53,7 @@ let
5253
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
5354
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
5455

56+
useSharedPerfetto = builtins.hasAttr "perfetto" sharedLibDeps;
5557
useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps;
5658
needsRustCompiler = withTemporal && !useSharedTemporal;
5759

@@ -63,6 +65,7 @@ let
6365
];
6466
buildInputs =
6567
pkgs.lib.optional useSharedICU icu
68+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto
6669
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
6770

6871
# Put here only the configure flags that affect the V8 build
@@ -75,6 +78,7 @@ let
7578
)
7679
"--v8-${if withTemporal then "enable" else "disable"}-temporal-support"
7780
]
81+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto"
7882
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
7983
++ pkgs.lib.optional withPerfetto "--with-perfetto";
8084
in

‎test/parallel/test-trace-events-category-used.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let procEnabledOutput = '';
2929
procEnabled.stdout.on('data', (data) => procEnabledOutput += data);
3030
procEnabled.stderr.pipe(process.stderr);
3131
procEnabled.once('close', common.mustCall(() => {
32-
assert.strictEqual(procEnabledOutput, 'true\n');
32+
assert.strictEqual(procEnabledOutput, `${!process.config.variables.v8_use_perfetto}\n`);
3333
}));
3434

3535
const procDisabled = cp.spawn(

‎tools/nix/sharedLibDeps.nix‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
withSQLite ? true,
66
withSSL ? true,
77
withFFI ? true,
8+
withPerfetto ? false,
89
withTemporal ? false,
910
}:
1011
{
@@ -50,6 +51,13 @@
5051
// (pkgs.lib.optionalAttrs withSSL ({
5152
inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl;
5253
}))
54+
// (pkgs.lib.optionalAttrs withPerfetto {
55+
perfetto =
56+
(pkgs.callPackage (builtins.fetchurl {
57+
url = "https://github.com/NixOS/nixpkgs/raw/34ee2404466d25c6255a3ea1f710c80a9420d284/pkgs/by-name/pe/perfetto/package.nix";
58+
sha256 = "0wc4p96kwxpqr8g2a6lmlfjsffrm3dc824m7hiy0q21r2papc0ik";
59+
}) { }).sdk;
60+
})
5361
// (pkgs.lib.optionalAttrs withTemporal {
5462
inherit (pkgs) temporal_capi;
5563
})

‎tools/nix/v8.nix‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ let
4444
../../tools/v8_gypfiles/toolchain.gypi
4545
../../tools/v8_gypfiles/v8.gyp
4646
]
47-
++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [
48-
../../deps/perfetto
49-
]
47+
++ lib.optional (
48+
builtins.elem "--with-perfetto" configureFlags
49+
&& !(builtins.elem "--shared-perfetto" configureFlags)
50+
) ../../deps/perfetto
5051
++ lib.optionals (icu != null) [
5152
../../tools/icu/icu_versions.json
5253
../../tools/icu/icu-system.gyp

‎tools/v8_gypfiles/v8.gyp‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
'<(V8_ROOT)/src/init/setup-isolate-full.cc',
295295
],
296296
'conditions': [
297-
['v8_use_perfetto==1', {
297+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
298298
'dependencies': [
299299
'<(perfetto_gyp_file):perfetto_sdk',
300300
],
@@ -320,7 +320,7 @@
320320
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?sources = ")',
321321
],
322322
'conditions': [
323-
['v8_use_perfetto==1', {
323+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
324324
'dependencies': [
325325
'<(perfetto_gyp_file):perfetto_sdk',
326326
],
@@ -492,7 +492,7 @@
492492
},
493493
],
494494
'conditions': [
495-
['v8_use_perfetto==1', {
495+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
496496
'dependencies': [
497497
'<(perfetto_gyp_file):perfetto_sdk',
498498
],
@@ -986,7 +986,7 @@
986986
'abseil.gyp:abseil',
987987
],
988988
'conditions': [
989-
['v8_use_perfetto==1', {
989+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
990990
'dependencies': [
991991
'<(perfetto_gyp_file):perfetto_sdk',
992992
],
@@ -1125,8 +1125,12 @@
11251125
'sources': [
11261126
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_use_perfetto.*?sources \\+= ")',
11271127
],
1128-
'dependencies': [
1129-
'<(perfetto_gyp_file):perfetto_sdk',
1128+
'conditions': [
1129+
['node_shared_perfetto=="false"', {
1130+
'dependencies': [
1131+
'<(perfetto_gyp_file):perfetto_sdk',
1132+
],
1133+
}],
11301134
],
11311135
}],
11321136
['v8_enable_snapshot_compression==1', {
@@ -1745,8 +1749,12 @@
17451749
'sources': [
17461750
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_libplatform.*?v8_use_perfetto.*?sources \\+= ")',
17471751
],
1748-
'dependencies': [
1749-
'<(perfetto_gyp_file):perfetto_sdk',
1752+
'conditions': [
1753+
['node_shared_perfetto=="false"', {
1754+
'dependencies': [
1755+
'<(perfetto_gyp_file):perfetto_sdk',
1756+
],
1757+
}],
17501758
],
17511759
}],
17521760
['v8_enable_system_instrumentation==1 and is_win', {
@@ -1856,7 +1864,7 @@
18561864
},
18571865
},
18581866
'conditions': [
1859-
['v8_use_perfetto==1', {
1867+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
18601868
'dependencies': [
18611869
'<(perfetto_gyp_file):perfetto_sdk',
18621870
],

0 commit comments

Comments
 (0)