OLD | NEW |
| (Empty) |
1 #!/bin/bash -e | |
2 shopt -s nullglob | |
3 | |
4 cd $(dirname "$0") | |
5 | |
6 # Script which takes all the asciidoc git-*.txt files in this directory, renders | |
7 # them to html + manpage format using git 1.9's doc toolchain, then puts | |
8 # them in depot_tools to be committed. | |
9 | |
10 ensure_in_path() { | |
11 local CMD=$1 | |
12 local PTH=$(which "$CMD") | |
13 if [[ ! $PTH ]] | |
14 then | |
15 echo Must have "$CMD" on your PATH! | |
16 exit 1 | |
17 else | |
18 echo Using \'$PTH\' for ${CMD}. | |
19 fi | |
20 } | |
21 | |
22 ensure_in_path xmlto | |
23 ensure_in_path asciidoc | |
24 | |
25 DFLT_CATALOG_PATH="/usr/local/etc/xml/catalog" | |
26 if [[ ! $XML_CATALOG_FILES && -f "$DFLT_CATALOG_PATH" ]] | |
27 then | |
28 # Default if you install doctools with homebrew on mac | |
29 export XML_CATALOG_FILES="$DFLT_CATALOG_PATH" | |
30 echo Using \'$DFLT_CATALOG_PATH\' for \$XML_CATALOG_FILES. | |
31 fi | |
32 | |
33 # We pull git to get its documentation toolchain | |
34 BRANCH=v1.9.0 | |
35 GITHASH=5f95c9f850b19b368c43ae399cc831b17a26a5ac | |
36 if [[ ! -d git || $(git -C git rev-parse HEAD) != $GITHASH ]] | |
37 then | |
38 echo Cloning git | |
39 rm -rf git | |
40 git clone --single-branch --branch $BRANCH --depth 1 \ | |
41 https://kernel.googlesource.com/pub/scm/git/git.git 2> /dev/null | |
42 | |
43 # Replace the 'source' and 'package' strings. | |
44 ed git/Documentation/asciidoc.conf <<EOF | |
45 H | |
46 81 | |
47 s/Git/depot_tools | |
48 +2 | |
49 s/Git Manual/Chromium depot_tools Manual | |
50 wq | |
51 EOF | |
52 fi | |
53 echo Git up to date at $GITHASH \($BRANCH\) | |
54 | |
55 HTML_TARGETS=() | |
56 MAN_TARGETS=() | |
57 for x in *.txt | |
58 do | |
59 TO="git/Documentation/$x" | |
60 if [[ ! -f "$TO" ]] || ! cmp --silent "$x" "$TO" | |
61 then | |
62 echo \'$x\' differs | |
63 cp $x "$TO" | |
64 fi | |
65 # Exclude files beginning with _ from the target list. This is useful to have | |
66 # includable snippet files. | |
67 if [[ ${x:0:1} != _ ]] | |
68 then | |
69 HTML_TARGETS+=("${x%%.txt}.html") | |
70 MAN_TARGETS+=("${x%%.txt}.1") | |
71 fi | |
72 done | |
73 | |
74 VER="v$(git rev-parse --short HEAD)" | |
75 if [[ ! -f git/version ]] || ! cmp --silent git/version <(echo "$VER") | |
76 then | |
77 echo Version changed, cleaning. | |
78 echo "$VER" > git/version | |
79 (cd git/Documentation && make clean) | |
80 fi | |
81 | |
82 # This export is so that asciidoc sys snippets which invoke git run relative to | |
83 # depot_tools instead of the git clone. | |
84 ( | |
85 export GIT_DIR="$(git rev-parse --git-dir)" && | |
86 cd git/Documentation && | |
87 make -j"$[${#MAN_TARGETS} + ${#HTML_TARGETS}]" "${MAN_TARGETS[@]}" "${HTML_TAR
GETS[@]}" | |
88 ) | |
89 | |
90 mkdir htmlout 2> /dev/null || true | |
91 for x in "${HTML_TARGETS[@]}" | |
92 do | |
93 echo Copying htmlout/$x | |
94 cp "git/Documentation/$x" htmlout | |
95 done | |
96 | |
97 for x in "${MAN_TARGETS[@]}" | |
98 do | |
99 echo Copying ../man1/$x | |
100 cp "git/Documentation/$x" ../man1 | |
101 done | |
OLD | NEW |