@@ -5,19 +5,11 @@ use std::process::Command;
55
66use anyhow:: { ensure, Context , Result } ;
77
8- static TEST_PROTOS : & [ & str ] = & [
9- "test_messages_proto2.proto" ,
10- "test_messages_proto3.proto" ,
11- "unittest.proto" ,
12- "unittest_import.proto" ,
13- "unittest_import_public.proto" ,
14- ] ;
15-
168fn main ( ) -> Result < ( ) > {
179 let out_dir =
1810 & PathBuf :: from ( env:: var ( "OUT_DIR" ) . expect ( "OUT_DIR environment variable not set" ) ) ;
1911
20- let src_dir = PathBuf :: from ( "../third_party/protobuf" ) . canonicalize ( ) ?;
12+ let src_dir = std :: path :: absolute ( PathBuf :: from ( "../third_party/protobuf" ) ) ?;
2113 if !src_dir. join ( "cmake" ) . exists ( ) {
2214 anyhow:: bail!(
2315 "protobuf sources are not checked out; Try `git submodule update --init --recursive`"
@@ -41,20 +33,17 @@ fn main() -> Result<()> {
4133 let prefix_dir = & tempdir. path ( ) . join ( "prefix" ) ;
4234 fs:: create_dir ( prefix_dir) . expect ( "failed to create prefix directory" ) ;
4335 install_conformance_test_runner ( & src_dir, build_dir, prefix_dir) ?;
44- install_protos ( & src_dir, prefix_dir) ?;
4536 fs:: rename ( prefix_dir, protobuf_dir) . context ( "failed to move protobuf dir" ) ?;
4637 }
4738
48- let include_dir = & protobuf_dir. join ( "include" ) ;
49-
50- let conformance_include_dir = include_dir. join ( "conformance" ) ;
39+ let conformance_proto_dir = src_dir. join ( "conformance" ) ;
5140 prost_build:: compile_protos (
52- & [ conformance_include_dir . join ( "conformance.proto" ) ] ,
53- & [ conformance_include_dir ] ,
41+ & [ conformance_proto_dir . join ( "conformance.proto" ) ] ,
42+ & [ conformance_proto_dir ] ,
5443 )
5544 . unwrap ( ) ;
5645
57- let test_includes = & include_dir . join ( "google" ) . join ( "protobuf ") ;
46+ let proto_dir = src_dir . join ( "src " ) ;
5847
5948 // Generate BTreeMap fields for all messages. This forces encoded output to be consistent, so
6049 // that encode/decode roundtrips can use encoded output for comparison. Otherwise trying to
@@ -64,11 +53,11 @@ fn main() -> Result<()> {
6453 . btree_map ( [ "." ] )
6554 . compile_protos (
6655 & [
67- test_includes . join ( "test_messages_proto2.proto" ) ,
68- test_includes . join ( "test_messages_proto3.proto" ) ,
69- test_includes . join ( "unittest.proto" ) ,
56+ proto_dir . join ( "google/protobuf/ test_messages_proto2.proto" ) ,
57+ proto_dir . join ( "google/protobuf/ test_messages_proto3.proto" ) ,
58+ proto_dir . join ( "google/protobuf/ unittest.proto" ) ,
7059 ] ,
71- & [ include_dir ] ,
60+ & [ proto_dir ] ,
7261 )
7362 . unwrap ( ) ;
7463
@@ -161,34 +150,3 @@ fn install_conformance_test_runner(
161150
162151 Ok ( ( ) )
163152}
164-
165- fn install_protos ( src_dir : & Path , prefix_dir : & Path ) -> Result < ( ) > {
166- let include_dir = prefix_dir. join ( "include" ) ;
167-
168- // Move test protos to the prefix directory.
169- let test_include_dir = & include_dir. join ( "google" ) . join ( "protobuf" ) ;
170- fs:: create_dir_all ( test_include_dir) . expect ( "failed to create test include directory" ) ;
171- for proto in TEST_PROTOS {
172- fs:: copy (
173- src_dir
174- . join ( "src" )
175- . join ( "google" )
176- . join ( "protobuf" )
177- . join ( proto) ,
178- test_include_dir. join ( proto) ,
179- )
180- . with_context ( || format ! ( "failed to move {}" , proto) ) ?;
181- }
182-
183- // Move conformance.proto to the install directory.
184- let conformance_include_dir = & include_dir. join ( "conformance" ) ;
185- fs:: create_dir ( conformance_include_dir)
186- . expect ( "failed to create conformance include directory" ) ;
187- fs:: copy (
188- src_dir. join ( "conformance" ) . join ( "conformance.proto" ) ,
189- conformance_include_dir. join ( "conformance.proto" ) ,
190- )
191- . expect ( "failed to move conformance.proto" ) ;
192-
193- Ok ( ( ) )
194- }
0 commit comments