4
4
5
5
from script_config import ScriptConfig , BuildConfig
6
6
7
+ RUSTUP_PATH = os .getenv ('HOME' ) + '/.cargo/bin/rustup'
8
+ CARGO_PATH = os .getenv ('HOME' ) + '/.cargo/bin/cargo'
9
+
7
10
8
11
def run (config : ScriptConfig ):
9
12
if len (config .LIBLDK_BUILD_CONFIGURATIONS ) != 1 :
@@ -12,15 +15,14 @@ def run(config: ScriptConfig):
12
15
13
16
ldkBuildConfig = config .LIBLDK_BUILD_CONFIGURATIONS [0 ]
14
17
platform = ldkBuildConfig .platform
18
+ human_readable_platform = ldkBuildConfig .human_readable_platform
15
19
llvm_target_triple_suffix = ldkBuildConfig .llvm_target_triple_suffix
16
20
architectures = ldkBuildConfig .architectures
17
21
18
22
build_products_directory = os .path .realpath (os .path .join (os .path .dirname (__file__ ), '../../bindings/bin' ))
19
23
20
- human_readable_platform = platform
21
24
rust_target_os = 'ios'
22
25
if platform == 'macosx' and llvm_target_triple_suffix == '-macabi' :
23
- human_readable_platform = 'catalyst'
24
26
rust_target_os = 'ios-macabi'
25
27
elif platform == 'macosx' :
26
28
rust_target_os = 'darwin'
@@ -51,8 +53,9 @@ def run(config: ScriptConfig):
51
53
52
54
child_environment = dict (os .environ )
53
55
child_environment ['RUSTFLAGS' ] = '--cfg=c_bindings'
56
+ child_environment ['PATH' ] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
54
57
55
- subprocess .check_call (['rustup' , 'override' , 'set' , 'nightly' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
58
+ subprocess .check_call ([RUSTUP_PATH , 'override' , 'set' , 'nightly' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
56
59
57
60
lipo_executables_input : [str ] = []
58
61
@@ -87,12 +90,14 @@ def run(config: ScriptConfig):
87
90
# create the directory if it doesn't exist
88
91
os .makedirs (current_architecture_binary_directory , exist_ok = True )
89
92
90
- subprocess .check_call (['cargo' , 'clean' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
93
+ subprocess .check_call ([CARGO_PATH , 'clean' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
91
94
92
95
# cargo build -Z build-std=panic_abort,std --features "std" --target "${RUST_ARCH}-apple-${RUST_TARGET_OS}" $RUST_CONFIGURATION_FLAG
96
+ build_arguments = [CARGO_PATH , 'build' , '-Z' , 'build-std=panic_abort,std' , '--features' , 'std' , '--target' , f'{ rust_architecture } -apple-{ rust_target_os } ' ]
97
+ if config .RUST_CONFIGURATION_FLAG :
98
+ build_arguments .append (config .RUST_CONFIGURATION_FLAG )
93
99
subprocess .check_call (
94
- ['cargo' , 'build' , '-Z' , 'build-std=panic_abort,std' , '--features' , 'std' , '--target' ,
95
- f'{ rust_architecture } -apple-{ rust_target_os } ' , config .RUST_CONFIGURATION_FLAG ],
100
+ build_arguments ,
96
101
env = child_environment ,
97
102
cwd = config .LDK_C_BINDINGS_DIRECTORY
98
103
)
@@ -101,7 +106,7 @@ def run(config: ScriptConfig):
101
106
subprocess .check_call (['cp' , cargo_raw_binary_origin , current_architecture_binary_directory ])
102
107
lipo_executables_input .append (os .path .join (current_architecture_binary_directory , 'libldk.a' ))
103
108
104
- subprocess .check_call (['rustup' , 'override' , 'unset' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
109
+ subprocess .check_call ([RUSTUP_PATH , 'override' , 'unset' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
105
110
106
111
# xcrun --sdk $PLATFORM_NAME lipo -create "${EXECUTABLES[@]}" -output "${LIPO_BINARY_DIR}/${TARGET_NAME}.a"
107
112
subprocess .check_call (
@@ -116,7 +121,7 @@ def run(config: ScriptConfig):
116
121
parse_lipo_output_directory = True
117
122
)
118
123
119
- platform = os .getenv ('PLATFORM ' )
124
+ platform = os .getenv ('PLATFORM_NAME ' )
120
125
llvm_target_triple_suffix = os .getenv ('LLVM_TARGET_TRIPLE_SUFFIX' )
121
126
architectures = os .getenv ('ARCHS' ).split (' ' )
122
127
0 commit comments