Use --copy-out to generate .bp file.

* The original include command now works without
  local patch or post_update.sh.

Bug: 171659849
Test: make
Test: tools/external_updater/updater.sh update --refresh --keep-date rust/crates/protobuf
Change-Id: I973c7ac3dfa4f8233f8522b1ada678a9ef144f73
diff --git a/Android.bp b/Android.bp
index ad518d0..fcbc354 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,15 +1,23 @@
-// This file is generated by cargo2android.py --run --dependencies --features=bytes --device.
+// This file is generated by cargo2android.py --run --dependencies --features=bytes --device --copy-out.
+
+genrule {
+    name: "copy_protobuf_build_out",
+    srcs: ["out/*"],
+    cmd: "cp $(in) $(genDir)",
+    out: ["version.rs"],
+}
 
 rust_library {
     name: "libprotobuf",
     // has rustc warnings
     host_supported: true,
     crate_name: "protobuf",
-    srcs: ["src/lib.rs"],
-    edition: "2018",
-    features: [
-        "bytes",
+    srcs: [
+        "src/lib.rs",
+        ":copy_protobuf_build_out",
     ],
+    edition: "2018",
+    features: ["bytes"],
     rustlibs: [
         "libbytes",
     ],
diff --git a/post_update.sh b/post_update.sh
deleted file mode 100755
index ba60c59..0000000
--- a/post_update.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-# $1 Path to the new version.
-# $2 Path to the old version.
-
-set -x
-set -e
-
-# out/version.rs should be copied after cargo build.
-# Change src/lib.rs to include files from ../out/
-SRCFILE=src/lib.rs
-OLDSTR='include!(concat!(env!("OUT_DIR"), "/version.rs"));'
-NEWSTR='include!("../out/version.rs");  // ANDROID'
-sed -i -e "s:$OLDSTR:$NEWSTR:" $SRCFILE
-# Make sure that sed replaced $OLDSTR with $NEWSTR
-grep "$NEWSTR" $SRCFILE > /dev/null
diff --git a/src/lib.rs b/src/lib.rs
index 4a346c8..8233e07 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -95,4 +95,4 @@
 #[cfg(never)]
 #[doc(hidden)]
 pub const VERSION_IDENT: &str = "";
-include!("../out/version.rs");  // ANDROID
+include!(concat!(env!("OUT_DIR"), "/version.rs"));