5
5
from script_config import ScriptConfig , BuildConfig
6
6
7
7
8
- def parse_config () -> ScriptConfig :
9
- config = ScriptConfig .parse (allow_ldk_argument = False , parse_configuration = True )
10
- return config
11
-
12
-
13
8
def run (config : ScriptConfig ):
14
9
if len (config .LIBLDK_BUILD_CONFIGURATIONS ) != 1 :
15
10
print ('Individual libldk build must have exactly 1 build configuration.' )
@@ -34,8 +29,20 @@ def run(config: ScriptConfig):
34
29
print ('Configuration:' , config .RUST_CONFIGURATION )
35
30
print ('LLVM Target Triple Suffix:' , llvm_target_triple_suffix )
36
31
37
- individual_architecture_binary_directory = os .path .join (build_products_directory , config .RUST_CONFIGURATION , human_readable_platform , 'raw' )
38
- lipo_binary_directory = os .path .join (build_products_directory , config .RUST_CONFIGURATION , human_readable_platform , 'lipo' )
32
+ individual_architecture_binary_directory = os .path .join (
33
+ build_products_directory ,
34
+ config .RUST_CONFIGURATION ,
35
+ human_readable_platform ,
36
+ 'raw'
37
+ )
38
+ lipo_binary_directory = os .path .join (
39
+ build_products_directory ,
40
+ config .RUST_CONFIGURATION ,
41
+ human_readable_platform ,
42
+ 'lipo'
43
+ )
44
+ if config .LIPO_BINARY_OUTPUT_DIRECTORY :
45
+ lipo_binary_directory = config .LIPO_BINARY_OUTPUT_DIRECTORY
39
46
lipo_binary_output_path = os .path .join (lipo_binary_directory , 'libldk.a' )
40
47
41
48
print (individual_architecture_binary_directory )
@@ -50,7 +57,10 @@ def run(config: ScriptConfig):
50
57
lipo_executables_input : [str ] = []
51
58
52
59
for current_architecture in architectures :
53
- current_architecture_binary_directory = os .path .join (individual_architecture_binary_directory , current_architecture )
60
+ current_architecture_binary_directory = os .path .join (
61
+ individual_architecture_binary_directory ,
62
+ current_architecture
63
+ )
54
64
print (f'\n Current architecture:' , current_architecture )
55
65
56
66
rust_architecture = current_architecture
@@ -64,7 +74,13 @@ def run(config: ScriptConfig):
64
74
print ('Rust architecture:' , rust_architecture )
65
75
print ('Rust target OS:' , rust_target_os )
66
76
67
- cargo_raw_binary_origin = os .path .join (config .LDK_C_BINDINGS_DIRECTORY , 'target' , f'{ rust_architecture } -apple-{ rust_target_os } ' , config .RUST_CONFIGURATION , 'libldk.a' )
77
+ cargo_raw_binary_origin = os .path .join (
78
+ config .LDK_C_BINDINGS_DIRECTORY ,
79
+ 'target' ,
80
+ f'{ rust_architecture } -apple-{ rust_target_os } ' ,
81
+ config .RUST_CONFIGURATION ,
82
+ 'libldk.a'
83
+ )
68
84
print ('Raw binary origin:' , cargo_raw_binary_origin )
69
85
print ('Raw binary target:' , current_architecture_binary_directory )
70
86
@@ -74,7 +90,12 @@ def run(config: ScriptConfig):
74
90
subprocess .check_call (['cargo' , 'clean' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
75
91
76
92
# cargo build -Z build-std=panic_abort,std --features "std" --target "${RUST_ARCH}-apple-${RUST_TARGET_OS}" $RUST_CONFIGURATION_FLAG
77
- subprocess .check_call (['cargo' , 'build' , '-Z' , 'build-std=panic_abort,std' , '--features' , 'std' , '--target' , f'{ rust_architecture } -apple-{ rust_target_os } ' , config .RUST_CONFIGURATION_FLAG ], env = child_environment , cwd = config .LDK_C_BINDINGS_DIRECTORY )
93
+ 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 ],
96
+ env = child_environment ,
97
+ cwd = config .LDK_C_BINDINGS_DIRECTORY
98
+ )
78
99
79
100
# copy the generated binary to a monitored directory
80
101
subprocess .check_call (['cp' , cargo_raw_binary_origin , current_architecture_binary_directory ])
@@ -83,11 +104,17 @@ def run(config: ScriptConfig):
83
104
subprocess .check_call (['rustup' , 'override' , 'unset' ], cwd = config .LDK_C_BINDINGS_DIRECTORY )
84
105
85
106
# xcrun --sdk $PLATFORM_NAME lipo -create "${EXECUTABLES[@]}" -output "${LIPO_BINARY_DIR}/${TARGET_NAME}.a"
86
- subprocess .check_call (['xcrun' , '--sdk' , platform , 'lipo' , '-create' , * lipo_executables_input , '-output' , lipo_binary_output_path ])
107
+ subprocess .check_call (
108
+ ['xcrun' , '--sdk' , platform , 'lipo' , '-create' , * lipo_executables_input , '-output' , lipo_binary_output_path ]
109
+ )
87
110
88
111
89
112
if __name__ == '__main__' :
90
- script_config = parse_config ()
113
+ script_config = ScriptConfig .parse (
114
+ allow_ldk_argument = False ,
115
+ parse_configuration = True ,
116
+ parse_lipo_output_directory = True
117
+ )
91
118
92
119
platform = os .getenv ('PLATFORM' )
93
120
llvm_target_triple_suffix = os .getenv ('LLVM_TARGET_TRIPLE_SUFFIX' )
0 commit comments