Skip to content

Commit 342e87f

Browse files
legendecasnodejs-github-bot
authored andcommitted
build: add temporal_capi gyp
PR-URL: #60703 Refs: #58730 Refs: #60693 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 4947af9 commit 342e87f

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed

configure.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,8 +1478,8 @@ def host_arch_win():
14781478
return matchup.get(arch, 'x64')
14791479

14801480
def set_configuration_variable(configs, name, release=None, debug=None):
1481-
configs['Release'][name] = release
1482-
configs['Debug'][name] = debug
1481+
configs['Release']['variables'][name] = release
1482+
configs['Debug']['variables'][name] = debug
14831483

14841484
def configure_arm(o):
14851485
if options.arm_float_abi:
@@ -1560,6 +1560,7 @@ def configure_node(o):
15601560
o['variables']['control_flow_guard'] = b(options.enable_cfg)
15611561
o['variables']['node_use_amaro'] = b(not options.without_amaro)
15621562
o['variables']['debug_node'] = b(options.debug_node)
1563+
o['variables']['build_type%'] = 'Debug' if options.debug else 'Release'
15631564
o['default_configuration'] = 'Debug' if options.debug else 'Release'
15641565
if options.error_on_warn and options.suppress_all_error_on_warn:
15651566
raise Exception('--error_on_warn is incompatible with --suppress_all_error_on_warn.')
@@ -1810,6 +1811,11 @@ def configure_library(lib, output, pkgname=None):
18101811
output['libraries'] += pkg_libs.split()
18111812

18121813

1814+
def configure_rust(o, configs):
1815+
set_configuration_variable(configs, 'cargo_build_mode', release='release', debug='debug')
1816+
set_configuration_variable(configs, 'cargo_build_flags', release=['--release'], debug=[])
1817+
1818+
18131819
def configure_v8(o, configs):
18141820
set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
18151821

@@ -2364,6 +2370,7 @@ def make_bin_override():
23642370
'libraries': [],
23652371
'defines': [],
23662372
'cflags': [],
2373+
'conditions': [],
23672374
}
23682375
configurations = {
23692376
'Release': { 'variables': {} },
@@ -2405,6 +2412,7 @@ def make_bin_override():
24052412
configure_static(output)
24062413
configure_inspector(output)
24072414
configure_section_file(output)
2415+
configure_rust(output, configurations)
24082416

24092417
# remove builtins that have been disabled
24102418
if options.without_amaro:
@@ -2427,6 +2435,17 @@ def make_bin_override():
24272435
variables = output['variables']
24282436
del output['variables']
24292437

2438+
# move configurations[*]['variables'] to conditions variables
2439+
config_release_vars = configurations['Release']['variables']
2440+
del configurations['Release']['variables']
2441+
config_debug_vars = configurations['Debug']['variables']
2442+
del configurations['Debug']['variables']
2443+
output['conditions'].append(['build_type=="Release"', {
2444+
'variables': config_release_vars,
2445+
}, {
2446+
'variables': config_debug_vars,
2447+
}])
2448+
24302449
# make_global_settings should be a root level element too
24312450
if 'make_global_settings' in output:
24322451
make_global_settings = output['make_global_settings']
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
'targets': [
3+
{
4+
'target_name': 'temporal_capi',
5+
'type': 'none',
6+
'hard_dependency': 1,
7+
'sources': [
8+
'src/calendar.rs',
9+
'src/error.rs',
10+
'src/lib.rs',
11+
'src/plain_date_time.rs',
12+
'src/plain_month_day.rs',
13+
'src/plain_year_month.rs',
14+
'src/time_zone.rs',
15+
'src/duration.rs',
16+
'src/instant.rs',
17+
'src/options.rs',
18+
'src/plain_date.rs',
19+
'src/plain_time.rs',
20+
'src/provider.rs',
21+
'src/zoned_date_time.rs',
22+
],
23+
'direct_dependent_settings': {
24+
'include_dirs': [
25+
'bindings/cpp',
26+
],
27+
},
28+
'link_settings': {
29+
'libraries': [
30+
'<(SHARED_INTERMEDIATE_DIR)/>(cargo_build_mode)/libtemporal_capi.a',
31+
],
32+
},
33+
'actions': [
34+
{
35+
'action_name': 'cargo_build',
36+
'inputs': [
37+
'<@(_sources)',
38+
],
39+
'outputs': [
40+
'<(SHARED_INTERMEDIATE_DIR)/>(cargo_build_mode)/libtemporal_capi.a'
41+
],
42+
'action': [
43+
'cargo',
44+
'rustc',
45+
'>@(cargo_build_flags)',
46+
'--crate-type',
47+
'staticlib',
48+
'--features',
49+
'zoneinfo64',
50+
'--target-dir',
51+
'<(SHARED_INTERMEDIATE_DIR)'
52+
],
53+
}
54+
],
55+
}
56+
]
57+
}

node.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'node_shared_cares%': 'false',
2323
'node_shared_libuv%': 'false',
2424
'node_shared_sqlite%': 'false',
25+
'node_shared_temporal_capi%': 'false',
2526
'node_shared_uvwasi%': 'false',
2627
'node_shared_nghttp2%': 'false',
2728
'node_use_openssl%': 'true',

tools/v8_gypfiles/v8.gyp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@
319319
'<(icu_gyp_path):icuuc',
320320
],
321321
}],
322+
['v8_enable_temporal_support==1 and node_shared_temporal_capi=="false"', {
323+
'dependencies': [
324+
'../../deps/temporal/temporal_capi/temporal_capi.gyp:temporal_capi',
325+
],
326+
}],
322327
],
323328
}, # v8_initializers_slow
324329
{
@@ -356,6 +361,11 @@
356361
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_initializers.*?v8_enable_webassembly.*?sources \\+= ")',
357362
],
358363
}],
364+
['v8_enable_temporal_support==1 and node_shared_temporal_capi=="false"', {
365+
'dependencies': [
366+
'../../deps/temporal/temporal_capi/temporal_capi.gyp:temporal_capi',
367+
],
368+
}],
359369
['v8_target_arch=="ia32"', {
360370
'sources': [
361371
'<(V8_ROOT)/src/builtins/ia32/builtins-ia32.cc',
@@ -1128,6 +1138,13 @@
11281138
],
11291139
}],
11301140
['v8_enable_temporal_support==1', {
1141+
'conditions': [
1142+
['node_shared_temporal_capi=="false"', {
1143+
'dependencies': [
1144+
'../../deps/temporal/temporal_capi/temporal_capi.gyp:temporal_capi',
1145+
],
1146+
}],
1147+
],
11311148
'sources': [
11321149
'<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn" "\\"v8_base_without_compiler.*?v8_enable_temporal_support.*?sources \\+= ")',
11331150
],

0 commit comments

Comments
 (0)