Import protobuf-codegen-2.14.0
* Add OWNERS, Android.bp, and README.android.
* Hard code version number in src/lib.rs for now.
It could be in a smarter update_package.sh to get the
new version number from Cargo.tom. But until then,
the difference in lib.rs will be caught and fixed manually.
* Rename protoc_gen_rust to protoc-gen-rust for aprotoc plugin.
Bug: 143953733
Test: make
Change-Id: I9b3c3b9f2e7ad0eb203c26534f2b6ba5fac46eef
diff --git a/src/bin/protobuf-bin-gen-rust-do-not-use.rs b/src/bin/protobuf-bin-gen-rust-do-not-use.rs
new file mode 100644
index 0000000..fc66d27
--- /dev/null
+++ b/src/bin/protobuf-bin-gen-rust-do-not-use.rs
@@ -0,0 +1,37 @@
+extern crate protobuf;
+extern crate protobuf_codegen;
+
+use std::fs::*;
+use std::io::Read;
+use std::path::Path;
+
+use protobuf::descriptor::*;
+use protobuf::parse_from_reader;
+use protobuf_codegen::*;
+
+fn write_file(bin: &str) {
+ let mut is = File::open(&Path::new(bin)).unwrap();
+ let fds = parse_from_reader::<FileDescriptorSet>(&mut is as &mut dyn Read).unwrap();
+
+ let file_names: Vec<String> = fds
+ .get_file()
+ .iter()
+ .map(|f| f.get_name().to_string())
+ .collect();
+ gen_and_write(
+ fds.get_file(),
+ &file_names,
+ Path::new("."),
+ &Default::default(),
+ )
+ .expect("gen_and_write");
+}
+
+fn main() {
+ let args: Vec<String> = std::env::args().collect();
+ if args.len() != 2 {
+ panic!("must have exactly one argument");
+ }
+ let ref pb_bin = args[1];
+ write_file(&pb_bin);
+}