Skip to content

Commit 804c425

Browse files
committed
build: add temporal_capi gyp
1 parent 18c483b commit 804c425

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
@@ -1469,8 +1469,8 @@ def host_arch_win():
14691469
return matchup.get(arch, 'x64')
14701470

14711471
def set_configuration_variable(configs, name, release=None, debug=None):
1472-
configs['Release'][name] = release
1473-
configs['Debug'][name] = debug
1472+
configs['Release']['variables'][name] = release
1473+
configs['Debug']['variables'][name] = debug
14741474

14751475
def configure_arm(o):
14761476
if options.arm_float_abi:
@@ -1551,6 +1551,7 @@ def configure_node(o):
15511551
o['variables']['control_flow_guard'] = b(options.enable_cfg)
15521552
o['variables']['node_use_amaro'] = b(not options.without_amaro)
15531553
o['variables']['debug_node'] = b(options.debug_node)
1554+
o['variables']['build_type%'] = 'Debug' if options.debug else 'Release'
15541555
o['default_configuration'] = 'Debug' if options.debug else 'Release'
15551556
if options.error_on_warn and options.suppress_all_error_on_warn:
15561557
raise Exception('--error_on_warn is incompatible with --suppress_all_error_on_warn.')
@@ -1801,6 +1802,11 @@ def configure_library(lib, output, pkgname=None):
18011802
output['libraries'] += pkg_libs.split()
18021803

18031804

1805+
def configure_rust(o, configs):
1806+
set_configuration_variable(configs, 'cargo_build_mode', release='release', debug='debug')
1807+
set_configuration_variable(configs, 'cargo_build_flags', release=['--release'], debug=[])
1808+
1809+
18041810
def configure_v8(o, configs):
18051811
set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
18061812

@@ -2355,6 +2361,7 @@ def make_bin_override():
23552361
'libraries': [],
23562362
'defines': [],
23572363
'cflags': [],
2364+
'conditions': [],
23582365
}
23592366
configurations = {
23602367
'Release': { 'variables': {} },
@@ -2396,6 +2403,7 @@ def make_bin_override():
23962403
configure_static(output)
23972404
configure_inspector(output)
23982405
configure_section_file(output)
2406+
configure_rust(output, configurations)
23992407

24002408
# remove builtins that have been disabled
24012409
if options.without_amaro:
@@ -2418,6 +2426,17 @@ def make_bin_override():
24182426
variables = output['variables']
24192427
del output['variables']
24202428

2429+
# move configurations[*]['variables'] to conditions variables
2430+
config_release_vars = configurations['Release']['variables']
2431+
del configurations['Release']['variables']
2432+
config_debug_vars = configurations['Debug']['variables']
2433+
del configurations['Debug']['variables']
2434+
output['conditions'].append(['build_type=="Release"', {
2435+
'variables': config_release_vars,
2436+
}, {
2437+
'variables': config_debug_vars,
2438+
}])
2439+
24212440
# make_global_settings should be a root level element too
24222441
if 'make_global_settings' in output:
24232442
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)