summaryrefslogtreecommitdiffstats
path: root/camera/docs/metadata-generate
blob: 59aaff28123298cb6ee5a8d0ec380f91a596aa19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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=$(cd "$(dirname "$0")"; pwd)

function relpath() {
    python -c "import os.path; print os.path.relpath('$1', '$PWD')"
}

function gen_file() {
    local in=$thisdir/$1
    local out=$thisdir/$2

    python $thisdir/metadata_parser_xml.py $thisdir/metadata_properties.xml $in $out

    local succ=$?

    if [[ $succ -eq 0 ]]
    then
        echo "OK: Generated $(relpath "$out")"
    else
        echo "FAIL: Errors while generating $(relpath "$out")" >& 2
    fi

    return $succ
}

$thisdir/metadata-check-dependencies || exit 1
$thisdir/metadata-validate $thisdir/metadata_properties.xml || exit 1
$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