build: Fix build on AOSP

Fix an issue where some 'cp' commands do not create directories
recursively.

Bug: 27552463
Change-Id: Ib1c70bf0c7acdfcbc5a664246c941cd5e656354b
diff --git a/patch-android-src b/patch-android-src
index 011c007..2b515ce 100755
--- a/patch-android-src
+++ b/patch-android-src
@@ -30,6 +30,7 @@
 src_file="$2"
 src_file_with_prefix="$2"
 dst_file="$3"
+dst_dir="$(dirname "$dst_file")"
 
 # Sanity checking
 
@@ -79,6 +80,11 @@
 set -e
 
 # Copy the src file and then apply the patch to it.
+mkdir -p "$dst_dir"
 cp "$src_file_with_prefix" "$dst_file"
+if ! [[ -f "$dst_file" ]]; then
+  echo "File "$dst_file" does not exist; patching will fail" >&2
+  exit 1
+fi
 patch -p0 "$dst_file" "$patch_file_src"
 echo "Successfully applied patch $patch_file_src into copy of file $dst_file"