| Igor Murashkin | eaddcd4 | 2012-11-26 12:01:11 -0800 | [diff] [blame] | 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 |  | 
 | 26 | thisdir=$(dirname $(readlink -f $0)) | 
 | 27 |  | 
| Igor Murashkin | 5804a48 | 2012-12-05 13:06:59 -0800 | [diff] [blame^] | 28 | function relpath() { | 
 | 29 |     python -c "import os.path; print os.path.relpath('$1', '$PWD')" | 
 | 30 | } | 
 | 31 |  | 
| Igor Murashkin | eaddcd4 | 2012-11-26 12:01:11 -0800 | [diff] [blame] | 32 | function gen_file() { | 
 | 33 |     local in=$thisdir/$1 | 
 | 34 |     local out=$thisdir/$2 | 
 | 35 |  | 
| Igor Murashkin | 0334aa0 | 2012-12-04 14:59:53 -0800 | [diff] [blame] | 36 |     python $thisdir/metadata_parser_xml.py $thisdir/metadata_properties.xml $in > $out | 
| Igor Murashkin | 5804a48 | 2012-12-05 13:06:59 -0800 | [diff] [blame^] | 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 | 
| Igor Murashkin | eaddcd4 | 2012-11-26 12:01:11 -0800 | [diff] [blame] | 48 | } | 
 | 49 |  | 
| Igor Murashkin | 0334aa0 | 2012-12-04 14:59:53 -0800 | [diff] [blame] | 50 | $thisdir/metadata-check-dependencies || exit 1 | 
| Igor Murashkin | eaddcd4 | 2012-11-26 12:01:11 -0800 | [diff] [blame] | 51 | $thisdir/metadata-parser-sanity-check || exit 1 | 
 | 52 | gen_file html.mako docs.html || exit 1 | 
 | 53 | gen_file camera_metadata_tag_info.mako ../src/camera_metadata_tag_info.c || exit 1 | 
 | 54 | gen_file camera_metadata_tags.mako ../include/system/camera_metadata_tags.h || exit 1 | 
 | 55 |  | 
 | 56 | echo "Successfully generated all metadata source files" | 
 | 57 |  | 
 | 58 | exit 0 |