summaryrefslogtreecommitdiff
path: root/doxygen/builder/rtems-doxygen-build-branches
blob: c060c0de166ef22968999d389d0569daf614cb6c (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#! /bin/sh
#
# RTEMS Kernel Project
#
# Copyright 2017-2019 Chris Johns <chrisj@rtems.org>
# All rights reserved
#
# Public domain
#

#
# Exit on error.
#
set -e

#
# Executables
#
git=/usr/local/bin/git
doxygen=/usr/local/bin/doxygen

#
# Top directory
#
top=$PWD

#
# Directory of builds.
#
output=${top}/output

#
# The build tags files.
#
tags=${output}/.tags

#
# Branches to build and install as current
#
branches="master 4.11"

#
# Branch hash cache
#
hash_cache=${top}/git-hash-cache

#
# Lastest builds
#
latest=${top}/latest

#
# Git repository.
#
repo=rtems.git

#
# Logging.
#
log() {
 echo $* >> ${log_file}
}
log_file=${top}/build.log
for f in 9 8 7 6 5 4 3 2 1
do
 t=`expr $f + 1`
 rm -f ${top}/build-${t}.log
 if [ -f ${top}/build-${f}.log ]; then
  mv ${top}/build-${f}.log ${top}/build-${t}.log
 fi
done
if [ -f ${top}/build.log ]; then
 mv ${top}/build.log ${top}/build-1.log
fi
rm -rf ${log_file}

# Create or clone the repository and then check if a commit has been added on
# each branch we are interesed in and if there is a commit build the doco and
# install.

log "RTEMS Kernel Doxygen Build: " `date`

log rm -f rtems-doxygen-latest.tar.xz rtems-doxygen-latest-tags
rm -f rtems-doxygen-latest.tar.xz rtems-doxygen-latest-tags

if [ ! -d ${hash_cache} ]; then
 mkdir ${hash_cache}
fi

#
# If there is no repo create it.
#
if [ ! -d ${repo} ]; then
 log git clone git://git.rtems.org/${repo} ${repo}
 ${git} clone git://git.rtems.org/${repo} ${repo} >> ${log_file} 2>&1
fi

#
# If output exists we have an existing build so clean it first.
#
builds=0
log rm -rf ${output} ${latest}
rm -rf ${output} ${latest}
log mkdir ${latest}
mkdir ${latest}

log cd ${repo}
cd ${repo}
 #
 # Fetch any updates and reset the repo to be safe.
 #
 log git fetch
 ${git} fetch >> ${log_file} 2>&1
 log git reset --hard
 ${git} reset --hard >> ${log_file} 2>&1
 for b in ${branches}
 do
  log git co ${b}
  ${git} co ${b} >> ${log_file} 2>&1
  log git pull
  ${git} pull >> ${log_file} 2>&1
  hash=`${git} log -n 1 --pretty=format:"%H"`
  build=yes
  if [ -f ${hash_cache}/${b} ]; then
   if [ ${hash} = `cat ${hash_cache}/${b}` ]; then
    build=no
   fi
  fi
  log "Building ${b} : ${build}"
  if [ ${build} = yes ]; then
   cwd=$PWD
   prefix=${output}/${b}
   log rm -rf ${prefix}
   rm -rf ${prefix}
   log mkdir -p ${prefix}
   mkdir -p ${prefix}
   # Pre-5 building
   if [ -f ${top}/${repo}/cpukit/Doxyfile.in ]; then
    log cd ${prefix}
    cd ${prefix}
     log "Creating: Doxyfile"
     top_srcdir=$(echo ${top}/${repo}/cpukit | sed -e 's/\//\\\//g')
     perl=$(which perl | sed -e 's/\//\\\//g')
     cat ${top}/${repo}/cpukit/Doxyfile.in | \
         sed -e "s/@PACKAGE_VERSION@/${release}/g" \
             -e "s/@top_srcdir@/${top_srcdir}/g" \
             -e "s/@PERL@/${perl}/g" \
             -e "s/^INPUT[[:space:]].*=.*$/INPUT = ${top_srcdir}/g" \
             -e "s/^FULL_PATH_NAMES[[:space:]].*=.*$/FULL_PATH_NAMES = NO/g" \
             -e "s/^GENERATE_LATEX[[:space:]].*=.*$/GENERATE_LATEX = no/g" \
             -e "s/^HAVE_DOT[[:blank:]]/DOT_NUM_THREADS = 1\\
         HAVE_DOT /g"> Doxyfile
     log "Building: Doxyfile in ${prefix}"
     ${doxygen} Doxyfile >> ${log_file} 2>&1
     log cd ..
     cd ..
    log rm -rf tmp
    rm -rf tmp
    log mv ${b} tmp
    mv ${b} tmp
    log mv tmp/cpukit_doxy/html ${b}
    mv tmp/cpukit_doxy/html ${b}
    log rm -rf tmp
    rm -rf tmp
   else
    log cd ${top}/${repo}
    cd ${top}/${repo}
     log rm -rf doc
     rm -rf doc
     log "Building: Doxyfile in ${prefix}"
     ${doxygen} Doxyfile >> ${log_file} 2>&1
     log mv doc/* ${prefix}/
     mv doc/* ${prefix}/
   fi
   log cd ${cwd}
   cd ${cwd}
   echo ${hash} > ${hash_cache}/${b}
   echo "${b} ${hash}" >> ${tags}
   builds=$(expr ${builds} + 1)
  fi
 done
 log cd ${top}
 cd ${top}

if [ ${builds} -gt 0 ]; then
 cd output
  #
  # Package the builds.
  #
  tar zcf ../rtems-doxygen-latest.tar.gz .tags *
  cp .tags ../rtems-doxygen-latest-tags
  cd .
fi

exit 0