summaryrefslogtreecommitdiff
path: root/docs/builder/rtems-docs-build-branches
blob: 7424238353eaa602b550480ab3b7c4696cecdeb8 (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
#! /bin/sh
#
# RTEMS Documentation Project
#
# Copyright 2017 Chris Johns <chrisj@rtems.org>
# All rights reserved
#
# Public domain
#

#
# Exit on error.
#
set -e

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

#
# 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

#
# Git repository.
#
repo=rtems-docs.git

#
# Update path to include the user installed tools
#
PATH=$PATH:/usr/local/bin

#
# 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 Documentation Build: " `date`

log rm -f rtems-docs-latest.tar.xz rtems-docs-latest-tags
rm -f rtems-docs-latest.tar.xz rtems-docs-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}
rm -rf ${output}

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
   prefix=${output}/${b}
   log rm -rf ${prefix}
   rm -rf ${prefix}
   log mkdir -p ${prefix}
   mkdir -p ${prefix}
   log ./waf distclean
   ./waf distclean >> ${log_file} 2>&1
   log ./waf configure --pdf --singlehtml --prefix=${prefix}
   ./waf configure --pdf --singlehtml --prefix=${prefix} >> ${log_file} 2>&1
   log ./waf build install
   ./waf build install >> ${log_file} 2>&1
   echo ${hash} > ${hash_cache}/${b}
   echo "${b} ${hash}" >> ${tags}
   builds=$(expr ${builds} + 1)
  fi
 done
 cd ..

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

exit 0