Camera: Add a script to generate files from XML

Change-Id: I638017934ddfcfe8ab8f9f56bebb587dae35f17f
diff --git a/camera/docs/metadata-generate b/camera/docs/metadata-generate
new file mode 100755
index 0000000..bf3e3ee
--- /dev/null
+++ b/camera/docs/metadata-generate
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Generate all files we have templates for:
+#   docs.html
+#   ../src/camera_metadata_tag_info.c
+#   ../src/camera_metadata_tags.h
+#
+
+thisdir=$(dirname $(readlink -f $0))
+
+function gen_file() {
+    local in=$thisdir/$1
+    local out=$thisdir/$2
+
+    $thisdir/metadata_parser_xml.py $thisdir/metadata_properties.xml $in > $out
+    return $?
+}
+
+$thisdir/metadata-parser-sanity-check || exit 1
+gen_file html.mako docs.html || exit 1
+gen_file camera_metadata_tag_info.mako ../src/camera_metadata_tag_info.c || exit 1
+gen_file camera_metadata_tags.mako ../include/system/camera_metadata_tags.h || exit 1
+
+echo "Successfully generated all metadata source files"
+
+exit 0