Imported Upstream version 1.7.1
[platform/upstream/ninja.git] / src / gen_doxygen_mainpage.sh
1 #!/bin/sh
2
3 # Copyright 2011 Google Inc. All Rights Reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 set -o errexit
18 set -o nounset
19
20 STATUS=0
21
22 # Print each of its arguments on stderr (one per line) prefixed by the
23 # basename of this script.
24 stderr()
25 {
26   local me=$(basename "$0")
27   local i
28   for i
29   do
30     echo >&2 "$me: $i"
31   done
32 }
33
34 # Print each of its arguments on stderr (one per line) prefixed by the
35 # basename of this script and 'error'.
36 error()
37 {
38   local i
39   for i
40   do
41     stderr "error: $i"
42   done
43   STATUS=1
44 }
45
46 generate_header()
47 {
48   cat <<EOF
49 /**
50  * \\mainpage
51 EOF
52 }
53
54 generate_footer()
55 {
56   cat <<EOF
57  */
58 EOF
59 }
60
61 include_file()
62 {
63   local file="$1"
64   if ! [ -r "$file" ]
65   then
66     error "'$file' is not readable."
67     return
68   fi
69   cat <<EOF
70  * \\section $file
71  * \\verbatim
72 EOF
73   cat < "$file"
74   cat <<EOF
75  \\endverbatim
76 EOF
77 }
78
79 if [ $# -eq 0 ]
80 then
81   echo >&2 "usage: $0 inputs..."
82   exit 1
83 fi
84
85 generate_header
86 for i in "$@"
87 do
88   include_file "$i"
89 done
90 generate_footer
91
92 exit $STATUS