Skip to content

Commit 0242613

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

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/**
@@ -84,6 +85,7 @@ on:
8485
- deps/nghttp2/**
8586
- deps/ngtcp2/**
8687
- deps/openssl/*/**
88+
- deps/perfetto/**
8789
- deps/simdjson/**
8890
- deps/sqlite/**
8991
- deps/uv/**

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,7 @@ ifeq ($(SKIP_SHARED_DEPS), 1)
13181318
$(RM) -r $(TARNAME)/deps/ngtcp2
13191319
find $(TARNAME)/deps/openssl -maxdepth 1 -type f ! -name 'nodejs-openssl.cnf' -exec $(RM) {} +
13201320
find $(TARNAME)/deps/openssl -mindepth 1 -maxdepth 1 -type d -exec $(RM) -r {} +
1321+
$(RM) -r $(TARNAME)/deps/perfetto
13211322
$(RM) -r $(TARNAME)/deps/simdjson
13221323
$(RM) -r $(TARNAME)/deps/sqlite
13231324
$(RM) -r $(TARNAME)/deps/uv

‎configure.py‎

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

549+
shared_optgroup.add_argument('--shared-perfetto',
550+
action='store_true',
551+
dest='shared_perfetto',
552+
default=None,
553+
help='link to a shared perfetto SDK instead of the one in deps/perfetto '
554+
'(requires --with-perfetto)')
555+
556+
shared_optgroup.add_argument('--shared-perfetto-includes',
557+
action='store',
558+
dest='shared_perfetto_includes',
559+
help='directory containing perfetto header files')
560+
561+
shared_optgroup.add_argument('--shared-perfetto-libname',
562+
action='store',
563+
dest='shared_perfetto_libname',
564+
default='perfetto',
565+
help='alternative lib name to link to [default: %(default)s]')
566+
567+
shared_optgroup.add_argument('--shared-perfetto-libpath',
568+
action='store',
569+
dest='shared_perfetto_libpath',
570+
help='a directory to search for the shared perfetto DLL')
571+
549572
shared_optgroup.add_argument('--shared-uvwasi',
550573
action='store_true',
551574
dest='shared_uvwasi',
@@ -2362,6 +2385,15 @@ def configure_lief(o):
23622385

23632386
configure_library('lief', o, pkgname='LIEF')
23642387

2388+
def configure_perfetto(o):
2389+
if not options.with_perfetto:
2390+
if options.shared_perfetto:
2391+
error('--shared-perfetto requires --with-perfetto')
2392+
o['variables']['node_shared_perfetto'] = b(False)
2393+
return
2394+
2395+
configure_library('perfetto', o)
2396+
23652397
def configure_sqlite(o):
23662398
o['variables']['node_use_sqlite'] = b(not options.without_sqlite)
23672399
if options.without_sqlite:
@@ -2937,6 +2969,7 @@ def make_bin_override():
29372969
configure_library('nghttp3', output, pkgname='libnghttp3')
29382970
configure_library('ngtcp2', output, pkgname='libngtcp2')
29392971
configure_lief(output);
2972+
configure_perfetto(output);
29402973
configure_sqlite(output);
29412974
configure_ffi(output);
29422975
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
@@ -28,6 +28,7 @@
2828
'node_shared_nbytes%': 'false',
2929
'node_shared_nghttp2%': 'false',
3030
'node_shared_openssl%': 'false',
31+
'node_shared_perfetto%': 'false',
3132
'node_shared_sqlite%': 'false',
3233
'node_shared_ffi%': 'false',
3334
'node_shared_temporal_capi%': 'false',
@@ -942,8 +943,12 @@
942943
'sources': [
943944
'<@(node_tracing_perfetto_sources)',
944945
],
945-
'dependencies': [
946-
'deps/perfetto/perfetto.gyp:perfetto_sdk',
946+
'conditions': [
947+
['node_shared_perfetto=="false"', {
948+
'dependencies': [
949+
'deps/perfetto/perfetto.gyp:perfetto_sdk',
950+
],
951+
}],
947952
],
948953
}, {
949954
'sources': [
@@ -1401,7 +1406,7 @@
14011406
}, {
14021407
'sources!': [ '<@(node_cctest_quic_sources)' ],
14031408
}],
1404-
[ 'v8_use_perfetto==1', {
1409+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
14051410
'dependencies': [
14061411
'deps/perfetto/perfetto.gyp:perfetto_sdk',
14071412
],
@@ -1731,7 +1736,7 @@
17311736
'NODE_USE_NODE_CODE_CACHE=1',
17321737
],
17331738
}],
1734-
[ 'v8_use_perfetto==1', {
1739+
[ 'v8_use_perfetto==1 and node_shared_perfetto=="false"', {
17351740
'dependencies': [
17361741
'deps/perfetto/perfetto.gyp:perfetto_sdk',
17371742
],

‎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

@@ -65,6 +67,7 @@ let
6567
pkgs.lib.optional useSharedICU icu
6668
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) sharedLibDeps.abseil
6769
++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) sharedLibDeps.highway
70+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) sharedLibDeps.perfetto
6871
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
6972

7073
# Put here only the configure flags that affect the V8 build
@@ -79,6 +82,7 @@ let
7982
]
8083
++ pkgs.lib.optional (builtins.hasAttr "abseil" sharedLibDeps) "--shared-abseil"
8184
++ pkgs.lib.optional (builtins.hasAttr "highway" sharedLibDeps) "--shared-highway"
85+
++ pkgs.lib.optional (withPerfetto && useSharedPerfetto) "--shared-perfetto"
8286
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
8387
++ pkgs.lib.optional withPerfetto "--with-perfetto";
8488
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
{
@@ -46,6 +47,9 @@
4647
// (pkgs.lib.optionalAttrs withSSL ({
4748
inherit (import ./openssl-matrix.nix { inherit pkgs; }) openssl;
4849
}))
50+
// (pkgs.lib.optionalAttrs withPerfetto {
51+
perfetto = pkgs.perfetto.sdk;
52+
})
4953
// (pkgs.lib.optionalAttrs withTemporal {
5054
inherit (pkgs) temporal_capi;
5155
})

‎tools/nix/v8.nix‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ let
4747
]
4848
++ lib.optional (!useSharedAbseil) ../../tools/v8_gypfiles/abseil.gyp
4949
++ lib.optional (!useSharedHighway) ../../tools/v8_gypfiles/highway.gyp
50-
++ lib.optionals (builtins.elem "--with-perfetto" configureFlags) [
51-
../../deps/perfetto
52-
]
50+
++ lib.optional (
51+
builtins.elem "--with-perfetto" configureFlags
52+
&& !(builtins.elem "--shared-perfetto" configureFlags)
53+
) ../../deps/perfetto
5354
++ lib.optionals (icu != null) [
5455
../../tools/icu/icu_versions.json
5556
../../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
],
@@ -996,7 +996,7 @@
996996
'v8_pch',
997997
],
998998
'conditions': [
999-
['v8_use_perfetto==1', {
999+
['v8_use_perfetto==1 and node_shared_perfetto=="false"', {
10001000
'dependencies': [
10011001
'<(perfetto_gyp_file):perfetto_sdk',
10021002
],
@@ -1137,8 +1137,12 @@
11371137
'sources': [
11381138
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_use_perfetto.*?sources \\+= ")',
11391139
],
1140-
'dependencies': [
1141-
'<(perfetto_gyp_file):perfetto_sdk',
1140+
'conditions': [
1141+
['node_shared_perfetto=="false"', {
1142+
'dependencies': [
1143+
'<(perfetto_gyp_file):perfetto_sdk',
1144+
],
1145+
}],
11421146
],
11431147
}],
11441148
['v8_enable_snapshot_compression==1', {
@@ -1763,8 +1767,12 @@
17631767
'sources': [
17641768
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_libplatform.*?v8_use_perfetto.*?sources \\+= ")',
17651769
],
1766-
'dependencies': [
1767-
'<(perfetto_gyp_file):perfetto_sdk',
1770+
'conditions': [
1771+
['node_shared_perfetto=="false"', {
1772+
'dependencies': [
1773+
'<(perfetto_gyp_file):perfetto_sdk',
1774+
],
1775+
}],
17681776
],
17691777
}],
17701778
['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)