@@ -20,13 +20,194 @@ use crate::{
20
20
} ;
21
21
use std:: path:: PathBuf ;
22
22
23
+ const AWS_LC_RS_UNNEEDED_SRC : [ & str ; 177 ] = [
24
+ "crypto/asn1/a_bitstr.c" ,
25
+ "crypto/asn1/a_bool.c" ,
26
+ "crypto/asn1/a_d2i_fp.c" ,
27
+ "crypto/asn1/a_dup.c" ,
28
+ "crypto/asn1/a_gentm.c" ,
29
+ "crypto/asn1/a_i2d_fp.c" ,
30
+ "crypto/asn1/a_int.c" ,
31
+ "crypto/asn1/a_mbstr.c" ,
32
+ "crypto/asn1/a_object.c" ,
33
+ "crypto/asn1/a_octet.c" ,
34
+ "crypto/asn1/a_strex.c" ,
35
+ "crypto/asn1/a_strnid.c" ,
36
+ "crypto/asn1/a_time.c" ,
37
+ "crypto/asn1/a_type.c" ,
38
+ "crypto/asn1/a_utctm.c" ,
39
+ "crypto/asn1/a_utf8.c" ,
40
+ "crypto/asn1/asn1_lib.c" ,
41
+ "crypto/asn1/asn1_par.c" ,
42
+ "crypto/asn1/asn_pack.c" ,
43
+ "crypto/asn1/f_int.c" ,
44
+ "crypto/asn1/f_string.c" ,
45
+ "crypto/asn1/posix_time.c" ,
46
+ "crypto/asn1/tasn_dec.c" ,
47
+ "crypto/asn1/tasn_enc.c" ,
48
+ "crypto/asn1/tasn_fre.c" ,
49
+ "crypto/asn1/tasn_new.c" ,
50
+ "crypto/asn1/tasn_typ.c" ,
51
+ "crypto/asn1/tasn_utl.c" ,
52
+ "crypto/base64/base64.c" ,
53
+ "crypto/bio/bio.c" ,
54
+ "crypto/bio/bio_mem.c" ,
55
+ "crypto/bio/connect.c" ,
56
+ "crypto/bio/errno.c" ,
57
+ "crypto/bio/fd.c" ,
58
+ "crypto/bio/file.c" ,
59
+ "crypto/bio/hexdump.c" ,
60
+ "crypto/bio/pair.c" ,
61
+ "crypto/bio/printf.c" ,
62
+ "crypto/bio/socket.c" ,
63
+ "crypto/bio/socket_helper.c" ,
64
+ "crypto/blake2/blake2.c" ,
65
+ "crypto/buf/buf.c" ,
66
+ "crypto/bytestring/ber.c" ,
67
+ "crypto/bytestring/unicode.c" ,
68
+ "crypto/cipher_extra/cipher_extra.c" ,
69
+ "crypto/cipher_extra/derive_key.c" ,
70
+ "crypto/cipher_extra/e_aes_cbc_hmac_sha1.c" ,
71
+ "crypto/cipher_extra/e_aes_cbc_hmac_sha256.c" ,
72
+ "crypto/cipher_extra/e_aesctrhmac.c" ,
73
+ "crypto/cipher_extra/e_des.c" ,
74
+ "crypto/cipher_extra/e_null.c" ,
75
+ "crypto/cipher_extra/e_rc2.c" ,
76
+ "crypto/cipher_extra/e_rc4.c" ,
77
+ "crypto/cipher_extra/e_tls.c" ,
78
+ "crypto/cipher_extra/tls_cbc.c" ,
79
+ "crypto/conf/conf.c" ,
80
+ "crypto/decrepit/bio/base64_bio.c" ,
81
+ "crypto/decrepit/blowfish/blowfish.c" ,
82
+ "crypto/decrepit/cast/cast.c" ,
83
+ "crypto/decrepit/cast/cast_tables.c" ,
84
+ "crypto/decrepit/dh/dh_decrepit.c" ,
85
+ "crypto/decrepit/evp/evp_do_all.c" ,
86
+ "crypto/decrepit/obj/obj_decrepit.c" ,
87
+ "crypto/decrepit/rsa/rsa_decrepit.c" ,
88
+ "crypto/decrepit/x509/x509_decrepit.c" ,
89
+ "crypto/des/des.c" ,
90
+ "crypto/ec_extra/ec_derive.c" ,
91
+ "crypto/ec_extra/hash_to_curve.c" ,
92
+ "crypto/ecdh_extra/ecdh_extra.c" ,
93
+ "crypto/evp_extra/print.c" ,
94
+ "crypto/evp_extra/scrypt.c" ,
95
+ "crypto/evp_extra/sign.c" ,
96
+ "crypto/hpke/hpke.c" ,
97
+ "crypto/hrss/hrss.c" ,
98
+ "crypto/obj/obj_xref.c" ,
99
+ "crypto/ocsp/ocsp_asn.c" ,
100
+ "crypto/ocsp/ocsp_client.c" ,
101
+ "crypto/ocsp/ocsp_extension.c" ,
102
+ "crypto/ocsp/ocsp_http.c" ,
103
+ "crypto/ocsp/ocsp_lib.c" ,
104
+ "crypto/ocsp/ocsp_print.c" ,
105
+ "crypto/ocsp/ocsp_server.c" ,
106
+ "crypto/ocsp/ocsp_verify.c" ,
107
+ "crypto/pem/pem_all.c" ,
108
+ "crypto/pem/pem_info.c" ,
109
+ "crypto/pem/pem_lib.c" ,
110
+ "crypto/pem/pem_oth.c" ,
111
+ "crypto/pem/pem_pk8.c" ,
112
+ "crypto/pem/pem_pkey.c" ,
113
+ "crypto/pem/pem_x509.c" ,
114
+ "crypto/pem/pem_xaux.c" ,
115
+ "crypto/pkcs7/bio/cipher.c" ,
116
+ "crypto/pkcs7/bio/md.c" ,
117
+ "crypto/pkcs7/pkcs7.c" ,
118
+ "crypto/pkcs7/pkcs7_asn1.c" ,
119
+ "crypto/pkcs7/pkcs7_x509.c" ,
120
+ "crypto/pkcs8/p5_pbev2.c" ,
121
+ "crypto/pkcs8/pkcs8.c" ,
122
+ "crypto/pkcs8/pkcs8_x509.c" ,
123
+ "crypto/pool/pool.c" ,
124
+ "crypto/rc4/rc4.c" ,
125
+ "crypto/rsa_extra/rsa_print.c" ,
126
+ "crypto/siphash/siphash.c" ,
127
+ "crypto/spake25519/spake25519.c" ,
128
+ "crypto/trust_token/pmbtoken.c" ,
129
+ "crypto/trust_token/trust_token.c" ,
130
+ "crypto/trust_token/voprf.c" ,
131
+ "crypto/x509/a_digest.c" ,
132
+ "crypto/x509/a_sign.c" ,
133
+ "crypto/x509/a_verify.c" ,
134
+ "crypto/x509/algorithm.c" ,
135
+ "crypto/x509/asn1_gen.c" ,
136
+ "crypto/x509/by_dir.c" ,
137
+ "crypto/x509/by_file.c" ,
138
+ "crypto/x509/i2d_pr.c" ,
139
+ "crypto/x509/name_print.c" ,
140
+ "crypto/x509/policy.c" ,
141
+ "crypto/x509/rsa_pss.c" ,
142
+ "crypto/x509/t_crl.c" ,
143
+ "crypto/x509/t_req.c" ,
144
+ "crypto/x509/t_x509.c" ,
145
+ "crypto/x509/t_x509a.c" ,
146
+ "crypto/x509/v3_akey.c" ,
147
+ "crypto/x509/v3_akeya.c" ,
148
+ "crypto/x509/v3_alt.c" ,
149
+ "crypto/x509/v3_bcons.c" ,
150
+ "crypto/x509/v3_bitst.c" ,
151
+ "crypto/x509/v3_conf.c" ,
152
+ "crypto/x509/v3_cpols.c" ,
153
+ "crypto/x509/v3_crld.c" ,
154
+ "crypto/x509/v3_enum.c" ,
155
+ "crypto/x509/v3_extku.c" ,
156
+ "crypto/x509/v3_genn.c" ,
157
+ "crypto/x509/v3_ia5.c" ,
158
+ "crypto/x509/v3_info.c" ,
159
+ "crypto/x509/v3_int.c" ,
160
+ "crypto/x509/v3_lib.c" ,
161
+ "crypto/x509/v3_ncons.c" ,
162
+ "crypto/x509/v3_ocsp.c" ,
163
+ "crypto/x509/v3_pcons.c" ,
164
+ "crypto/x509/v3_pmaps.c" ,
165
+ "crypto/x509/v3_prn.c" ,
166
+ "crypto/x509/v3_purp.c" ,
167
+ "crypto/x509/v3_skey.c" ,
168
+ "crypto/x509/v3_utl.c" ,
169
+ "crypto/x509/x509.c" ,
170
+ "crypto/x509/x509_att.c" ,
171
+ "crypto/x509/x509_cmp.c" ,
172
+ "crypto/x509/x509_d2.c" ,
173
+ "crypto/x509/x509_def.c" ,
174
+ "crypto/x509/x509_ext.c" ,
175
+ "crypto/x509/x509_lu.c" ,
176
+ "crypto/x509/x509_obj.c" ,
177
+ "crypto/x509/x509_req.c" ,
178
+ "crypto/x509/x509_set.c" ,
179
+ "crypto/x509/x509_trs.c" ,
180
+ "crypto/x509/x509_txt.c" ,
181
+ "crypto/x509/x509_v3.c" ,
182
+ "crypto/x509/x509_vfy.c" ,
183
+ "crypto/x509/x509_vpm.c" ,
184
+ "crypto/x509/x509cset.c" ,
185
+ "crypto/x509/x509name.c" ,
186
+ "crypto/x509/x509rset.c" ,
187
+ "crypto/x509/x509spki.c" ,
188
+ "crypto/x509/x_algor.c" ,
189
+ "crypto/x509/x_all.c" ,
190
+ "crypto/x509/x_attrib.c" ,
191
+ "crypto/x509/x_crl.c" ,
192
+ "crypto/x509/x_exten.c" ,
193
+ "crypto/x509/x_name.c" ,
194
+ "crypto/x509/x_pubkey.c" ,
195
+ "crypto/x509/x_req.c" ,
196
+ "crypto/x509/x_sig.c" ,
197
+ "crypto/x509/x_spki.c" ,
198
+ "crypto/x509/x_val.c" ,
199
+ "crypto/x509/x_x509.c" ,
200
+ "crypto/x509/x_x509a.c" ,
201
+ ] ;
202
+
23
203
pub ( crate ) struct CcBuilder {
24
204
manifest_dir : PathBuf ,
25
205
out_dir : PathBuf ,
26
206
build_prefix : Option < String > ,
27
207
output_lib_type : OutputLibType ,
28
208
}
29
209
210
+ use std:: collections:: HashSet ;
30
211
use std:: { env, fs} ;
31
212
32
213
pub ( crate ) struct Library {
@@ -230,8 +411,21 @@ impl CcBuilder {
230
411
fn add_all_files ( & self , lib : & Library , cc_build : & mut cc:: Build ) {
231
412
use core:: str:: FromStr ;
232
413
cc_build. file ( PathBuf :: from_str ( "rust_wrapper.c" ) . unwrap ( ) ) ;
233
-
414
+ let aws_lc_rs_unneeded_files = HashSet :: from ( AWS_LC_RS_UNNEEDED_SRC ) ;
415
+ let feature_aws_lc_rs = cfg ! ( feature = "aws-lc-rs" ) ;
416
+ if feature_aws_lc_rs {
417
+ emit_warning (
418
+ format ! (
419
+ "Feature aws-lc-rs enabled. Ignoring source file: {:?}" ,
420
+ AWS_LC_RS_UNNEEDED_SRC
421
+ )
422
+ . as_str ( ) ,
423
+ ) ;
424
+ }
234
425
for source in lib. sources {
426
+ if feature_aws_lc_rs && aws_lc_rs_unneeded_files. contains ( source) {
427
+ continue ;
428
+ }
235
429
let source_path = self . manifest_dir . join ( "aws-lc" ) . join ( source) ;
236
430
let is_asm = std:: path:: Path :: new ( source)
237
431
. extension ( )
0 commit comments