-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdobuild
executable file
·159 lines (140 loc) · 3.87 KB
/
dobuild
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
#!/bin/bash
SHORTNAME="bidimailui"
TARGET="tbird" # We used to support multiple targets, but no longer
UUID="{54e72d7b-ed31-4736-854f-f517358f21ee}"
PREPROCESSOR_PARAMS=" -DUUID=$UUID -DSHORTNAME=$SHORTNAME"
PREPROCESSOR_PARAMS+=" -DMOZ_THUNDERBIRD"
function die {
local error_message="$1"
echo -e >&2 "$error_message"
exit 1
}
function usage {
echo "Usage: $(basename) [OPTIONS...] [PREPROCESSOR DEFINITIONS...]"
echo "Build script for the $SHORTNAME extension."
echo ""
echo "Options:"
echo " -v | --version VERSION The version to build"
echo " -b | --build-type TYPE Specify the build type: beta, release-candidate, or release"
echo " -s | --subversion SUBVER Specify the subversion number for beta or rc builds (default: 1)"
echo " -h | --help This message"
echo ""
exit
}
declare -a POSITIONAL
while (( $# > 0 )); do
option="$1"
shift
case $option in
-h | --help)
usage
;;
-v | --ver | --version)
VERSION="$1"
shift
;;
-b | --build-type)
BUILD_TYPE="$1"
shift
;;
--beta)
BUILD_TYPE=beta
;;
--release)
BUILD_TYPE=release
;;
--release-candidate|--rc)
BUILD_TYPE=rc
;;
--sub-version-number|--sub-version|--sver|--sub|--sv|-s)
SUB_VERSION="$1"
shift
;;
-*)
die "Unsupported option \"$option\""
;;
*)
POSITIONAL+=("$option")
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [[ -z "$VERSION" ]]; then
if [[ -n "${BIDIMAILUI_VERSION}" ]]; then
VERSION="${BIDIMAILUI_VERSION}"
elif [[ -r ".version" ]]; then
VERSION="$(cat .version)"
fi
[[ -n "$VERSION" ]] || die "No version specified"
fi
SUB_VERSION="${SUB_VERSION:-1}"
case "$(echo $BUILD_TYPE | tr [A-Z] [a-z])" in
release )
;;
beta | b | "" )
VERSION="${VERSION}b${SUB_VERSION}"
PREPROCESSOR_PARAMS+=" -DIS_BETA_BUILD"
;;
rc | release-candidate | release_candidate)
VERSION="${VERSION}rc${SUB_VERSION}"
;;
*)
die "Invalid build type $BUILD_TYPE"
;;
esac
PREPROCESSOR_PARAMS+=" -DVERSION=$VERSION"
# all positional arguments after the target app are #define 'd in the XUL preprocessor,
# with a DEBUG_ prefix; so if you want to, say, have debugging code specific
# to the function myFancyFunc(), write it like so:
#
# #ifdef DEBUG_myFancyFunc
# debugging code etc. etc.
# #endif
#
# then invoke
#
# dobuild myFancyFunc
#
# to have your debugging code enabled
if [ $# -ne 0 ]; then
PREPROCESSOR_PARAMS+=" -DDEBUG"
for def in "$@"; do
PREPROCESSOR_PARAMS="$PREPROCESSOR_PARAMS -DDEBUG_$def"
done
else
PREPROCESSOR_PARAMS+=" --no-line-comments"
fi
BUILDDIR="build/$TARGET"
XPINAME="${SHORTNAME}_${VERSION}_${TARGET}.xpi"
LINKNAME="${SHORTNAME}_${TARGET}.xpi"
BUILDTOOLSDIR="buildtools"
export PERL5LIB="`pwd`/$BUILDTOOLSDIR"
# TODO: split builddir by /'s and try to create everything along the path
[[ -d build ]] || mkdir build
if [[ ! -d "$BUILDDIR" ]]; then
mkdir -p "$BUILDDIR"
else
rm -rf "$BUILDDIR"/*
fi
$BUILDTOOLSDIR/preprocessor.pl $PREPROCESSOR_PARAMS jar.mn > $BUILDDIR/jar.mn
# Our invocation of make-jars.pl doesn't literally make JAR files, it only preprocesses and copies.
$BUILDTOOLSDIR/make-jars.pl -q -f flat -z zip -p "$BUILDTOOLSDIR/preprocessor.pl $PREPROCESSOR_PARAMS" -s . -d . < $BUILDDIR/jar.mn || exit
$BUILDTOOLSDIR/preprocessor.pl $PREPROCESSOR_PARAMS src/manifest.json > $BUILDDIR/manifest.json
rm -f installed-chrome.txt
mkdir -p $BUILDDIR/defaults/preferences
cp src/defaults/preferences/${SHORTNAME}.js $BUILDDIR/defaults/preferences
mv ${SHORTNAME} $BUILDDIR/chrome
cp src/background.js $BUILDDIR/background.js
mkdir -p $BUILDDIR/api/WindowListener
cp src/api/WindowListener/schema.json $BUILDDIR/api/WindowListener
cp src/api/WindowListener/implementation.js $BUILDDIR/api/WindowListener
cp LICENSE $BUILDDIR
cd $BUILDDIR
zip --quiet -r $XPINAME \
chrome \
defaults/ \
api \
background.js \
LICENSE \
manifest.json || exit
ln $XPINAME $LINKNAME