@@ -64,7 +64,7 @@ mod common {
64
64
65
65
use std:: env;
66
66
use std:: io:: { Error , ErrorKind , Result } ;
67
- use std:: path:: { Path , PathBuf } ;
67
+ use std:: path:: PathBuf ;
68
68
69
69
#[ cfg( any( feature = "prefix" , feature = "operations" ) ) ]
70
70
pub fn get_external_mbedtls ( ) -> Option < Result < ( String , String ) > > {
@@ -133,41 +133,6 @@ mod common {
133
133
) )
134
134
}
135
135
136
- pub fn configure_mbed_crypto ( ) -> Result < ( ) > {
137
- let mbedtls_dir = String :: from ( "./vendor" ) ;
138
- let mbedtls_config = mbedtls_dir + "/scripts/config.py" ;
139
-
140
- println ! ( "cargo:rerun-if-changed=src/c/shim.c" ) ;
141
- println ! ( "cargo:rerun-if-changed=src/c/shim.h" ) ;
142
-
143
- let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
144
-
145
- // Check for Mbed TLS sources
146
- if !Path :: new ( & mbedtls_config) . exists ( ) {
147
- return Err ( Error :: new (
148
- ErrorKind :: Other ,
149
- "MbedTLS config.py is missing. Have you run 'git submodule update --init'?" ,
150
- ) ) ;
151
- }
152
-
153
- // Configure the MbedTLS build for making Mbed Crypto
154
- if !:: std:: process:: Command :: new ( mbedtls_config)
155
- . arg ( "--write" )
156
- . arg ( & ( out_dir + "/" + CONFIG_FILE ) )
157
- . arg ( "crypto" )
158
- . status ( )
159
- . map_err ( |_| Error :: new ( ErrorKind :: Other , "configuring mbedtls failed" ) ) ?
160
- . success ( )
161
- {
162
- return Err ( Error :: new (
163
- ErrorKind :: Other ,
164
- "config.py returned an error status" ,
165
- ) ) ;
166
- }
167
-
168
- Ok ( ( ) )
169
- }
170
-
171
136
#[ cfg( feature = "prefix" ) ]
172
137
// Cargo provides the crate version from Cargo.toml in the environment.
173
138
const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
@@ -282,10 +247,8 @@ mod interface {
282
247
pub fn script_interface ( ) -> Result < ( ) > {
283
248
let include_dir = common:: get_external_mbedtls_include_only ( ) ?;
284
249
285
- // TODO: Does interface need the vendored mbedtls?
286
- common:: configure_mbed_crypto ( ) ?;
287
- common:: generate_mbed_crypto_bindings ( include_dir. clone ( ) , false ) ?;
288
- let _ = common:: compile_shim_library ( include_dir, true , false ) ?;
250
+ common:: generate_mbed_crypto_bindings ( include_dir. clone ( ) , true ) ?;
251
+ let _ = common:: compile_shim_library ( include_dir, true , true ) ?;
289
252
Ok ( ( ) )
290
253
}
291
254
}
@@ -297,12 +260,47 @@ mod operations {
297
260
use super :: common:: prefix;
298
261
use cmake:: Config ;
299
262
use std:: env;
300
- use std:: io:: Result ;
301
263
#[ cfg( feature = "prefix" ) ]
302
264
use std:: io:: Write ;
303
- use std:: path:: PathBuf ;
265
+ use std:: io:: { Error , ErrorKind , Result } ;
266
+ use std:: path:: { Path , PathBuf } ;
304
267
use walkdir:: WalkDir ;
305
268
269
+ pub fn configure_mbed_crypto ( ) -> Result < ( ) > {
270
+ let mbedtls_dir = String :: from ( "./vendor" ) ;
271
+ let mbedtls_config = mbedtls_dir + "/scripts/config.py" ;
272
+
273
+ println ! ( "cargo:rerun-if-changed=src/c/shim.c" ) ;
274
+ println ! ( "cargo:rerun-if-changed=src/c/shim.h" ) ;
275
+
276
+ let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
277
+
278
+ // Check for Mbed TLS sources
279
+ if !Path :: new ( & mbedtls_config) . exists ( ) {
280
+ return Err ( Error :: new (
281
+ ErrorKind :: Other ,
282
+ "MbedTLS config.py is missing. Have you run 'git submodule update --init'?" ,
283
+ ) ) ;
284
+ }
285
+
286
+ // Configure the MbedTLS build for making Mbed Crypto
287
+ if !:: std:: process:: Command :: new ( mbedtls_config)
288
+ . arg ( "--write" )
289
+ . arg ( & ( out_dir + "/" + common:: CONFIG_FILE ) )
290
+ . arg ( "crypto" )
291
+ . status ( )
292
+ . map_err ( |_| Error :: new ( ErrorKind :: Other , "configuring mbedtls failed" ) ) ?
293
+ . success ( )
294
+ {
295
+ return Err ( Error :: new (
296
+ ErrorKind :: Other ,
297
+ "config.py returned an error status" ,
298
+ ) ) ;
299
+ }
300
+
301
+ Ok ( ( ) )
302
+ }
303
+
306
304
fn compile_mbed_crypto ( ) -> Result < PathBuf > {
307
305
let mbedtls_dir = String :: from ( "./vendor" ) ;
308
306
let out_dir = env:: var ( "OUT_DIR" ) . unwrap ( ) ;
@@ -360,7 +358,7 @@ mod operations {
360
358
}
361
359
None => {
362
360
println ! ( "Did not find external MBEDTLS, building MbedTLS!" ) ;
363
- common :: configure_mbed_crypto ( ) ?;
361
+ configure_mbed_crypto ( ) ?;
364
362
let mut mbed_lib_dir = compile_mbed_crypto ( ) ?;
365
363
let mut mbed_include_dir = mbed_lib_dir. clone ( ) ;
366
364
mbed_lib_dir. push ( "lib" ) ;
@@ -407,7 +405,7 @@ mod operations {
407
405
}
408
406
None => {
409
407
println ! ( "Did not find environment variables, building MbedTLS!" ) ;
410
- common :: configure_mbed_crypto ( ) ?;
408
+ configure_mbed_crypto ( ) ?;
411
409
let mut mbed_lib_dir = compile_mbed_crypto ( ) ?;
412
410
let mut mbed_include_dir = mbed_lib_dir. clone ( ) ;
413
411
mbed_lib_dir. push ( "lib" ) ;
0 commit comments