metadata-generate revision 5804a48bb15d245fb06f72cf6d64369f151fcc28
1#!/bin/bash
2
3#
4# Copyright (C) 2012 The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#      http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19#
20# Generate all files we have templates for:
21#   docs.html
22#   ../src/camera_metadata_tag_info.c
23#   ../src/camera_metadata_tags.h
24#
25
26thisdir=$(dirname $(readlink -f $0))
27
28function relpath() {
29    python -c "import os.path; print os.path.relpath('$1', '$PWD')"
30}
31
32function gen_file() {
33    local in=$thisdir/$1
34    local out=$thisdir/$2
35
36    python $thisdir/metadata_parser_xml.py $thisdir/metadata_properties.xml $in > $out
37
38    local succ=$?
39
40    if [[ $succ -eq 0 ]]
41    then
42        echo "OK: Generated $(relpath "$out")"
43    else
44        echo "FAIL: Errors while generating $(relpath "$out")" >& 2
45    fi
46
47    return $succ
48}
49
50$thisdir/metadata-check-dependencies || exit 1
51$thisdir/metadata-parser-sanity-check || exit 1
52gen_file html.mako docs.html || exit 1
53gen_file camera_metadata_tag_info.mako ../src/camera_metadata_tag_info.c || exit 1
54gen_file camera_metadata_tags.mako ../include/system/camera_metadata_tags.h || exit 1
55
56echo "Successfully generated all metadata source files"
57
58exit 0
59