@@ -64,16 +64,19 @@ fn bindgen_headers() -> Result<()> {
64
64
/// (This is in contrast to zcash which generates in `depend/zcash/src/rust/gen/`)
65
65
fn gen_cxxbridge ( ) -> Result < ( ) > {
66
66
let out_path = env:: var ( "OUT_DIR" ) . map_err ( Error :: Env ) ?;
67
- let out_path = PathBuf :: from ( out_path) . join ( "include" ) ;
67
+ let out_path = PathBuf :: from ( out_path) . join ( "gen" ) ;
68
+ let src_out_path = PathBuf :: from ( & out_path) . join ( "src" ) ;
69
+ let header_out_path = PathBuf :: from ( & out_path) . join ( "include" ) . join ( "rust" ) ;
68
70
69
71
// These must match `CXXBRIDGE_RS` in depend/zcash/src/Makefile.am
70
72
let filenames = [ "blake2b" , "ed25519" , "equihash" , "streams" , "bridge" ] ;
71
73
72
74
// The output folder must exist
73
- fs:: create_dir_all ( out_path. join ( "rust" ) ) . unwrap ( ) ;
75
+ fs:: create_dir_all ( & src_out_path) . unwrap ( ) ;
76
+ fs:: create_dir_all ( & header_out_path) . unwrap ( ) ;
74
77
75
78
// Generate the generic header file
76
- fs:: write ( out_path . join ( "rust/ cxx.h" ) , cxx_gen:: HEADER ) . unwrap ( ) ;
79
+ fs:: write ( header_out_path . join ( "cxx.h" ) , cxx_gen:: HEADER ) . unwrap ( ) ;
77
80
78
81
// Generate the source and header for each bridge file
79
82
for filename in filenames {
@@ -100,9 +103,13 @@ fn gen_cxxbridge() -> Result<()> {
100
103
)
101
104
} ) ;
102
105
103
- fs:: write ( out_path. join ( format ! ( "rust/{}.h" , filename) ) , output. header ) . unwrap ( ) ;
104
106
fs:: write (
105
- out_path. join ( format ! ( "rust/{}.c" , filename) ) ,
107
+ header_out_path. join ( format ! ( "{}.h" , filename) ) ,
108
+ output. header ,
109
+ )
110
+ . unwrap ( ) ;
111
+ fs:: write (
112
+ src_out_path. join ( format ! ( "{}.c" , filename) ) ,
106
113
output. implementation ,
107
114
)
108
115
. unwrap ( ) ;
@@ -114,8 +121,8 @@ fn main() -> Result<()> {
114
121
bindgen_headers ( ) ?;
115
122
gen_cxxbridge ( ) ?;
116
123
117
- let include_path = env:: var ( "OUT_DIR" ) . map_err ( Error :: Env ) ?;
118
- let include_path = PathBuf :: from ( include_path ) . join ( "include " ) ;
124
+ let gen_path = env:: var ( "OUT_DIR" ) . map_err ( Error :: Env ) ?;
125
+ let gen_path = PathBuf :: from ( gen_path ) . join ( "gen " ) ;
119
126
120
127
let target = env:: var ( "TARGET" ) . expect ( "TARGET was not set" ) ;
121
128
let mut base_config = cc:: Build :: new ( ) ;
@@ -126,7 +133,7 @@ fn main() -> Result<()> {
126
133
. include ( "depend/zcash/src/" )
127
134
. include ( "depend/zcash/src/rust/include/" )
128
135
. include ( "depend/zcash/src/secp256k1/include/" )
129
- . include ( & include_path )
136
+ . include ( & gen_path . join ( "include" ) )
130
137
. flag_if_supported ( "-Wno-implicit-fallthrough" )
131
138
. flag_if_supported ( "-Wno-catch-value" )
132
139
. flag_if_supported ( "-Wno-reorder" )
@@ -155,6 +162,7 @@ fn main() -> Result<()> {
155
162
. file ( "depend/zcash/src/uint256.cpp" )
156
163
. file ( "depend/zcash/src/pubkey.cpp" )
157
164
. file ( "depend/zcash/src/hash.cpp" )
165
+ . file ( "depend/zcash/src/streams_rust.cpp" )
158
166
. file ( "depend/zcash/src/primitives/transaction.cpp" )
159
167
. file ( "depend/zcash/src/crypto/ripemd160.cpp" )
160
168
. file ( "depend/zcash/src/crypto/sha1.cpp" )
@@ -165,7 +173,11 @@ fn main() -> Result<()> {
165
173
. file ( "depend/zcash/src/script/script.cpp" )
166
174
. file ( "depend/zcash/src/script/script_error.cpp" )
167
175
. file ( "depend/zcash/src/support/cleanse.cpp" )
168
- . file ( include_path. join ( "rust/blake2b.c" ) )
176
+ // A subset of the files generated by gen_cxxbridge
177
+ // which are required by zcash_script.
178
+ . file ( gen_path. join ( "src/blake2b.c" ) )
179
+ . file ( gen_path. join ( "src/bridge.c" ) )
180
+ . file ( gen_path. join ( "src/streams.c" ) )
169
181
. compile ( "libzcash_script.a" ) ;
170
182
171
183
Ok ( ( ) )
0 commit comments