forked from Ultraschall/ultraschall-manual
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·112 lines (100 loc) · 3.65 KB
/
build.sh
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
#!/bin/bash
################################################################################
#
# Copyright (c) The Ultraschall Project (http://ultraschall.fm)
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
################################################################################
ULTRASCHALL_BUILD_FAILED=0
ULTRASCHALL_BUILD_DIRECTORY="./build"
ULTRASCHALL_SCRIPTS_DIRECTORY="./scripts"
ULTRASCHALL_DOCS_DIRECTORY="./docs"
ULTRASCHALL_BUILD_OUTPUT="html"
ULTRASCHALL_BUILD_TARGET="ultraschall-manual.$ULTRASCHALL_BUILD_OUTPUT"
ULTRASCHALL_BUILD_BOOTSTRAP=0
ULTRASCHALL_BUILD_CLEAN=0
for arg in "$@"
do
case $arg in
-b|--bootstrap)
ULTRASCHALL_BUILD_BOOTSTRAP=1
shift # past argument
;;
-c|--clean)
ULTRASCHALL_BUILD_CLEAN=1
shift # past argument
;;
-h|--help)
echo "Usage: build.sh [Options]"
echo ""
echo "Options:"
echo " -b|--bootstrap Reinitialize build targets"
echo " -c|--clean Delete intermediate build targets"
echo " -h|--help Print this help screen"
echo " -o|--output Select output format (default = $ULTRASCHALL_BUILD_OUTPUT)"
echo ""
exit 0
shift # past argument
;;
*) # unknown option
echo "Unknown option $arg"
exit 1
shift # past argument
;;
esac
done
echo "**********************************************************************"
echo "* *"
echo "* ULTRASCHALL MANUAL *"
echo "* *"
echo "**********************************************************************"
echo ""
if [ ! -x "$(command -v pandoc)" ]; then
echo "ERROR: The build script requires the pandoc command."
ULTRASCHALL_BUILD_FAILED=1
fi
if [ $ULTRASCHALL_BUILD_FAILED -eq 0 ]; then
if [ $ULTRASCHALL_BUILD_CLEAN -ne 0 ]; then
echo "Cleaning Ultraschall manual files..."
rm -rf $ULTRASCHALL_BUILD_DIRECTORY
echo "Done."
fi
fi
if [ $ULTRASCHALL_BUILD_FAILED -eq 0 ]; then
if [ ! -d $ULTRASCHALL_BUILD_DIRECTORY ]; then
mkdir -p $ULTRASCHALL_BUILD_DIRECTORY
fi
fi
if [ $ULTRASCHALL_BUILD_FAILED -eq 0 ]; then
echo "Building Ultraschall manual files..."
pandoc --from=markdown --to=$ULTRASCHALL_BUILD_OUTPUT --standalone --self-contained --quiet \
--css=$ULTRASCHALL_SCRIPTS_DIRECTORY/ultraschall.css \
--output=$ULTRASCHALL_BUILD_TARGET \
$ULTRASCHALL_DOCS_DIRECTORY/outline.md
if [ $? -ne 0 ]; then
ULTRASCHALL_BUILD_FAILED=1
fi
echo "Done."
fi
if [ $ULTRASCHALL_BUILD_FAILED -ne 0 ]; then
echo "Failed to build $ULTRASCHALL_BUILD_TARGET."
fi