Skip to content

Commit 63f691a

Browse files
committed
build: add temporal_capi gyp
1 parent 6a7b965 commit 63f691a

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

configure.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,8 @@ def host_arch_win():
14401440
return matchup.get(arch, 'x64')
14411441

14421442
def set_configuration_variable(configs, name, release=None, debug=None):
1443-
configs['Release'][name] = release
1444-
configs['Debug'][name] = debug
1443+
configs['Release']['variables'][name] = release
1444+
configs['Debug']['variables'][name] = debug
14451445

14461446
def configure_arm(o):
14471447
if options.arm_float_abi:
@@ -1772,6 +1772,11 @@ def configure_library(lib, output, pkgname=None):
17721772
output['libraries'] += pkg_libs.split()
17731773

17741774

1775+
def configure_rust(o, configs):
1776+
set_configuration_variable(configs, 'cargo_build_mode', release='release', debug='debug')
1777+
set_configuration_variable(configs, 'cargo_build_flags', release=['--release'], debug=[])
1778+
1779+
17751780
def configure_v8(o, configs):
17761781
set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0)
17771782

@@ -2325,6 +2330,7 @@ def make_bin_override():
23252330
'libraries': [],
23262331
'defines': [],
23272332
'cflags': [],
2333+
'conditions': [],
23282334
}
23292335
configurations = {
23302336
'Release': { 'variables': {} },
@@ -2365,6 +2371,7 @@ def make_bin_override():
23652371
configure_static(output)
23662372
configure_inspector(output)
23672373
configure_section_file(output)
2374+
configure_rust(output, configurations)
23682375

23692376
# remove builtins that have been disabled
23702377
if options.without_amaro:
@@ -2387,6 +2394,17 @@ def make_bin_override():
23872394
variables = output['variables']
23882395
del output['variables']
23892396

2397+
# move configurations[*]['variables'] to conditions variables
2398+
config_release_vars = configurations['Release']['variables']
2399+
del configurations['Release']['variables']
2400+
config_debug_vars = configurations['Debug']['variables']
2401+
del configurations['Debug']['variables']
2402+
output['conditions'].append(['build_type=="Release"', {
2403+
'variables': config_release_vars,
2404+
}, {
2405+
'variables': config_debug_vars,
2406+
}])
2407+
23902408
# make_global_settings should be a root level element too
23912409
if 'make_global_settings' in output:
23922410
make_global_settings = output['make_global_settings']
@@ -2406,8 +2424,9 @@ def make_bin_override():
24062424

24072425
print_verbose(output)
24082426

2427+
# Dump as JSON to allow js2c.cc read it as a simple json file.
24092428
write('config.gypi', do_not_edit +
2410-
pprint.pformat(output, indent=2, width=128) + '\n')
2429+
json.dumps(output, indent=2) + '\n')
24112430

24122431
write('config.status', '#!/bin/sh\nset -x\nexec ./configure ' +
24132432
' '.join([shlex.quote(arg) for arg in original_argv]) + '\n')
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+
}

0 commit comments

Comments
 (0)