@@ -17,9 +17,9 @@ if [ "$1" == "watch" ]; then
1717 done
1818fi
1919
20- UNPACKED =
20+ UNPACKED_ONLY =
2121if [ " $1 " == ' -u' ]; then
22- UNPACKED =1
22+ UNPACKED_ONLY =1
2323 shift
2424fi
2525
@@ -95,70 +95,75 @@ NSCL="$SRC/nscl"
9595
9696rm -rf " $BUILD " " $XPI "
9797cp -pR " $SRC " " $BUILD "
98-
99- # include nscl dependencies
100- " $NSCL /include.sh" " $BUILD "
101-
10298cp -p LICENSE " $BUILD " /
10399
104100BUILD_CMD=" web-ext"
105101BUILD_OPTS=" build --overwrite-dest"
102+
103+ # save Chromium build settings from Mozilla signing overwrite
106104CHROMIUM_BUILD_CMD=" $BUILD_CMD "
107105CHROMIUM_BUILD_OPTS=" $BUILD_OPTS "
108106
109- if [[ $VER == * rc * ]]; then
110- if [[ " $1 " =~ ^sign(ed) ? $ ]]; then
107+ if [[ " $1 " =~ ^sign(ed) ? $ ]]; then
108+ if [[ $VER == * rc * ]]; then
111109 BUILD_CMD=" $BASE /../../we-sign"
112110 BUILD_OPTS=" "
113- fi
114- else
115- if [[ " $1 " == " sign" ]]; then
111+ else
116112 echo >&2 " WARNING: won't auto-sign a release version, please manually upload to AMO."
117113 fi
118114fi
119115
120116if [ " $1 " != " debug" ]; then
121117 DBG=" "
122- pushd " $SRC "
123- for file in ** /* .js nscl/** /* .js; do
118+ for file in " $BUILD " /** /* .js " $BUILD " /nscl/** /* .js; do
124119 if grep -P ' \/\/\s(REL|DEV)_ONLY' " $file " > /dev/null; then
125- sed -re ' s/\s*\/\/\s*(\S.*)\s*\/\/\s*REL_ONLY.*/\1/' -e ' s/.*\/\/\s*DEV_ONLY.*//' " $file " > " $BUILD / $file "
120+ sed -i -r -e ' s/\s*\/\/\s*(\S.*)\s*\/\/\s*REL_ONLY.*/\1/' -e ' s/.*\/\/\s*DEV_ONLY.*//' " $file "
126121 fi
127122 done
128- popd
129123else
130124 DBG=" -dbg"
131125fi
132126
133- if ! [ " $UNPACKED " ]; then
127+ UNPACKED_BASE=" $BASE /unpacked"
128+ mkdir -p " $UNPACKED_BASE "
129+
130+ if ! [ " $UNPACKED_ONLY " ]; then
134131 echo " Creating $XPI .xpi..."
135132 mkdir -p " $XPI_DIR "
136133fi
137134
138- if which cygpath; then
139- WEBEXT_IN=" $( cygpath -w " $BUILD " ) "
140- WEBEXT_OUT=" $( cygpath -w " $XPI_DIR " ) "
141- else
142- WEBEXT_IN=" $BUILD "
143- WEBEXT_OUT=" $XPI_DIR "
144- fi
145-
135+ CYGPATH=$( which cypath)
146136COMMON_BUILD_OPTS=" --ignore-files='test/**' 'embargoed/**' content/experiments.js"
147137
148138fix_manifest () {
149139 node manifest.js " $1 " " $MANIFEST_IN " " $MANIFEST_OUT "
150140}
151141
152142build () {
153- if [ " $1 " ]; then
154- UNPACKED_DIR=" $BASE /$1 "
155- rm -rf " $UNPACKED_DIR "
156- cp -rp " $WEBEXT_IN " " $UNPACKED_DIR " && echo >&2 " Copied $WEBEXT_IN to $UNPACKED_DIR "
143+ UNPACKED_DIR=" $UNPACKED_BASE /${1:- out} "
144+ rm -rf " $UNPACKED_DIR "
145+ cp -rp " $BUILD " " $UNPACKED_DIR " && echo >&2 " Copied $BUILD to $UNPACKED_DIR "
146+ # include only the actually used nscl dependencies
147+ rm -rf " $UNPACKED_DIR /nscl"
148+ " $BUILD /nscl/include.sh" " $UNPACKED_DIR "
149+
150+ if [ " $UNPACKED_ONLY " ]; then
151+ return
157152 fi
158- [ " $UNPACKED " ] || \
159- ( " $BUILD_CMD " $BUILD_OPTS --source-dir=" $WEBEXT_IN " \
160- --artifacts-dir=" $WEBEXT_OUT " $COMMON_BUILD_OPTS | \
161- grep ' ready: .*\.zip' | sed -re ' s/.* ready: //' )
153+
154+ if [ " $CYGPATH " ]; then
155+ WEBEXT_IN=" $( cygpath -w " $UNPACKED_DIR " ) "
156+ WEBEXT_OUT=" $( cygpath -w " $XPI_DIR " ) "
157+ else
158+ WEBEXT_IN=" $UNPACKED_DIR "
159+ WEBEXT_OUT=" $XPI_DIR "
160+ fi
161+
162+ " $BUILD_CMD " $BUILD_OPTS \
163+ --source-dir=" $WEBEXT_IN " \
164+ --artifacts-dir=" $WEBEXT_OUT " \
165+ $COMMON_BUILD_OPTS | \
166+ grep ' ready: .*\.zip' | sed -re ' s/.* ready: //'
162167}
163168
164169fix_manifest mv2firefox
@@ -178,7 +183,7 @@ elif [ -f "$XPI.zip" ]; then
178183fi
179184if [ -f " $XPI .xpi" ]; then
180185 ln -fs " $XPI .xpi" " $BASE /latest.xpi"
181- elif ! [ " $UNPACKED " ]; then
186+ elif ! [ " $UNPACKED_ONLY " ]; then
182187 echo >&2 " ERROR: Could not create $XPI$DBG .xpi!"
183188 exit 3
184189fi
@@ -196,7 +201,7 @@ fix_manifest mv3chrome
196201ZIP=$( build chromium)
197202[ -f " $ZIP " ] && mv " $ZIP " " $XPI$DBG -chrome.zip"
198203
199- if [ " $SIGNED " ] && ! [ " $UNPACKED " ]; then
204+ if [ " $SIGNED " ] && ! [ " $UNPACKED_ONLY " ]; then
200205 " $0 " tag quiet
201206 nscl
202207 ../../we-publish " $XPI .xpi"
0 commit comments