Skip to content

Commit a040aae

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

9 files changed

Lines changed: 91 additions & 24 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/**
@@ -83,6 +84,7 @@ on:
8384
- deps/nghttp2/**
8485
- deps/ngtcp2/**
8586
- deps/openssl/*/**
87+
- deps/perfetto/**
8688
- deps/simdjson/**
8789
- deps/sqlite/**
8890
- 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
@@ -524,6 +524,29 @@
524524
dest='shared_openssl_libpath',
525525
help='a directory to search for the shared OpenSSL DLLs')
526526

527+
shared_optgroup.add_argument('--shared-perfetto',
528+
action='store_true',
529+
dest='shared_perfetto',
530+
default=None,
531+
help='link to a shared perfetto SDK instead of the one in deps/perfetto '
532+
'(requires --with-perfetto)')
533+
534+
shared_optgroup.add_argument('--shared-perfetto-includes',
535+
action='store',
536+
dest='shared_perfetto_includes',
537+
help='directory containing perfetto header files')
538+
539+
shared_optgroup.add_argument('--shared-perfetto-libname',
540+
action='store',
541+
dest='shared_perfetto_libname',
542+
default='perfetto',
543+
help='alternative lib name to link to [default: %(default)s]')
544+
545+
shared_optgroup.add_argument('--shared-perfetto-libpath',
546+
action='store',
547+
dest='shared_perfetto_libpath',
548+
help='a directory to search for the shared perfetto DLL')
549+
527550
shared_optgroup.add_argument('--shared-uvwasi',
528551
action='store_true',
529552
dest='shared_uvwasi',
@@ -2340,6 +2363,15 @@ def configure_lief(o):
23402363

23412364
configure_library('lief', o, pkgname='LIEF')
23422365

2366+
def configure_perfetto(o):
2367+
if not options.with_perfetto:
2368+
if options.shared_perfetto:
2369+
error('--shared-perfetto requires --with-perfetto')
2370+
o['variables']['node_shared_perfetto'] = b(False)
2371+
return
2372+
2373+
configure_library('perfetto', o)
2374+
23432375
def configure_sqlite(o):
23442376
o['variables']['node_use_sqlite'] = b(not options.without_sqlite)
23452377
if options.without_sqlite:
@@ -2914,6 +2946,7 @@ def make_bin_override():
29142946
configure_library('nghttp3', output, pkgname='libnghttp3')
29152947
configure_library('ngtcp2', output, pkgname='libngtcp2')
29162948
configure_lief(output);
2949+
configure_perfetto(output);
29172950
configure_sqlite(output);
29182951
configure_ffi(output);
29192952
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
@@ -27,6 +27,7 @@
2727
'node_shared_nbytes%': 'false',
2828
'node_shared_nghttp2%': 'false',
2929
'node_shared_openssl%': 'false',
30+
'node_shared_perfetto%': 'false',
3031
'node_shared_sqlite%': 'false',
3132
'node_shared_ffi%': 'false',
3233
'node_shared_temporal_capi%': 'false',
@@ -939,8 +940,12 @@
939940
'sources': [
940941
'<@(node_tracing_perfetto_sources)',
941942
],
942-
'dependencies': [
943-
'deps/perfetto/perfetto.gyp:perfetto_sdk',
943+
'conditions': [
944+
['node_shared_perfetto=="false"', {
945+
'dependencies': [
946+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
947+
],
948+
}],
944949
],
945950
}, {
946951
'sources': [
@@ -1398,7 +1403,7 @@
13981403
}, {
13991404
'sources!': [ '<@(node_cctest_quic_sources)' ],
14001405
}],
1401-
[ 'v8_use_perfetto==1', {
1406+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
14021407
'dependencies': [
14031408
'deps/perfetto/perfetto.gyp:perfetto_sdk',
14041409
],
@@ -1728,7 +1733,7 @@
17281733
'NODE_USE_NODE_CODE_CACHE=1',
17291734
],
17301735
}],
1731-
[ 'v8_use_perfetto==1', {
1736+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
17321737
'dependencies': [
17331738
'deps/perfetto/perfetto.gyp:perfetto_sdk',
17341739
],

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

@@ -64,6 +66,7 @@ let
6466
buildInputs =
6567
pkgs.lib.optional useSharedICU icu
6668
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil
69+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto
6770
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
6871

6972
# Put here only the configure flags that affect the V8 build
@@ -77,6 +80,7 @@ let
7780
"--v8-${if withTemporal then "enable" else "disable"}-temporal-support"
7881
]
7982
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil"
83+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto"
8084
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
8185
++ pkgs.lib.optional withPerfetto "--with-perfetto";
8286
in

tools/nix/sharedLibDeps.nix

Lines changed: 4 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
{
@@ -51,6 +52,9 @@
5152
// (pkgs.lib.optionalAttrs withSSL ({
5253
inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl;
5354
}))
55+
// (pkgs.lib.optionalAttrs withPerfetto {
56+
perfetto = pkgs.perfetto.sdk;
57+
})
5458
// (pkgs.lib.optionalAttrs withTemporal {
5559
inherit (pkgs) temporal_capi;
5660
})

tools/nix/v8.nix

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

tools/v8_gypfiles/v8.gyp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
'<(V8_ROOT)/src/init/setup-isolate-full.cc',
294294
],
295295
'conditions': [
296-
['v8_use_perfetto==1', {
296+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
297297
'dependencies': [
298298
'<(perfetto_gyp_file):perfetto_sdk',
299299
],
@@ -321,7 +321,7 @@
321321
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?sources = ")',
322322
],
323323
'conditions': [
324-
['v8_use_perfetto==1', {
324+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
325325
'dependencies': [
326326
'<(perfetto_gyp_file):perfetto_sdk',
327327
],
@@ -496,7 +496,7 @@
496496
},
497497
],
498498
'conditions': [
499-
['v8_use_perfetto==1', {
499+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
500500
'dependencies': [
501501
'<(perfetto_gyp_file):perfetto_sdk',
502502
],
@@ -994,7 +994,7 @@
994994
'v8_pch',
995995
],
996996
'conditions': [
997-
['v8_use_perfetto==1', {
997+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
998998
'dependencies': [
999999
'<(perfetto_gyp_file):perfetto_sdk',
10001000
],
@@ -1135,8 +1135,12 @@
11351135
'sources': [
11361136
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_use_perfetto.*?sources \\+= ")',
11371137
],
1138-
'dependencies': [
1139-
'<(perfetto_gyp_file):perfetto_sdk',
1138+
'conditions': [
1139+
['node_shared_perfetto=="false"', {
1140+
'dependencies': [
1141+
'<(perfetto_gyp_file):perfetto_sdk',
1142+
],
1143+
}],
11401144
],
11411145
}],
11421146
['v8_enable_snapshot_compression==1', {
@@ -1761,8 +1765,12 @@
17611765
'sources': [
17621766
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_libplatform.*?v8_use_perfetto.*?sources \\+= ")',
17631767
],
1764-
'dependencies': [
1765-
'<(perfetto_gyp_file):perfetto_sdk',
1768+
'conditions': [
1769+
['node_shared_perfetto=="false"', {
1770+
'dependencies': [
1771+
'<(perfetto_gyp_file):perfetto_sdk',
1772+
],
1773+
}],
17661774
],
17671775
}],
17681776
['v8_enable_system_instrumentation==1 and is_win', {
@@ -1878,7 +1886,7 @@
18781886
},
18791887
},
18801888
'conditions': [
1881-
['v8_use_perfetto==1', {
1889+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
18821890
'dependencies': [
18831891
'<(perfetto_gyp_file):perfetto_sdk',
18841892
],

0 commit comments

Comments
 (0)