tridactyl/scripts/build.sh

89 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/sh
2017-11-20 18:13:26 +00:00
set -e
2018-03-04 14:15:26 +01:00
CLEANSLATE="node_modules/cleanslate/docs/files/cleanslate.css"
TRIDACTYL_LOGO="src/static/logo/Tridactyl_64px.png"
2018-05-16 01:52:03 +10:00
isWindowsMinGW() {
2019-03-24 17:29:42 +01:00
is_mingw="False"
2018-05-28 13:06:45 +10:00
if [ "$(uname | cut -c 1-5)" = "MINGW" ] \
|| [ "$(uname | cut -c 1-4)" = "MSYS" ]; then
is_mingw="True"
fi
2019-03-24 17:29:42 +01:00
printf "%s" "${is_mingw}"
}
if [ "$(isWindowsMinGW)" = "True" ]; then
WIN_PYTHON="py -3"
2019-05-31 16:48:53 +01:00
YARN_BIN_DIR="$(cygpath "$(yarn bin)")"
2019-05-31 18:44:40 +01:00
PATH=$YARN_BIN_DIR:$PATH
else
2019-05-31 16:48:53 +01:00
PATH="$(yarn bin):$PATH"
fi
export PATH
mkdir -p build
mkdir -p build/static
mkdir -p generated/static
mkdir -p generated/static/clippy
if [ "$(isWindowsMinGW)" = "True" ]; then
2018-05-16 04:39:32 +10:00
$WIN_PYTHON scripts/excmds_macros.py
else
2018-05-16 04:39:32 +10:00
scripts/excmds_macros.py
fi
# .bracketexpr.generated.ts is needed for metadata generation
2019-05-31 16:48:53 +01:00
"$(yarn bin)/nearleyc" src/grammars/bracketexpr.ne > \
src/grammars/.bracketexpr.generated.ts
# It's important to generate the metadata before the documentation because
# missing imports might break documentation generation on clean builds
2019-05-31 16:48:53 +01:00
"$(yarn bin)/tsc" compiler/gen_metadata.ts -m commonjs --target es2017 \
&& node compiler/gen_metadata.js \
--out src/.metadata.generated.ts \
--themeDir src/static/themes \
src/excmds.ts src/lib/config.ts
scripts/newtab.md.sh
scripts/make_tutorial.sh
scripts/make_docs.sh
if [ "$1" != "--no-native" ]; then
if [ "$(isWindowsMinGW)" = "True" ]; then
powershell \
-NoProfile \
-InputFormat None \
-ExecutionPolicy Bypass \
native/win_install.ps1 -DebugDirBase native
else
native/install.sh local
fi
fi
2019-05-27 12:36:36 +01:00
(webpack --display errors-only --bail\
&& scripts/git_version.sh)
scripts/bodgecss.sh
scripts/authors.sh
if [ -e "$CLEANSLATE" ] ; then
2018-05-20 13:17:28 +01:00
cp -v "$CLEANSLATE" build/static/css/cleanslate.css
else
2019-05-31 16:48:53 +01:00
echo "Couldn't find cleanslate.css. Try running 'yarn install'"
fi
if [ -e "$TRIDACTYL_LOGO" ] ; then
# sed and base64 take different arguments on Mac
case "$(uname)" in
Darwin*) sed -i "" "s@REPLACE_ME_WITH_BASE64_TRIDACTYL_LOGO@$(base64 "$TRIDACTYL_LOGO")@" build/static/themes/default/default.css;;
*BSD) sed -in "s@REPLACE_ME_WITH_BASE64_TRIDACTYL_LOGO@$(base64 "$TRIDACTYL_LOGO" | tr -d '\r\n')@" build/static/themes/default/default.css;;
*) sed "s@REPLACE_ME_WITH_BASE64_TRIDACTYL_LOGO@$(base64 --wrap 0 "$TRIDACTYL_LOGO")@" -i build/static/themes/default/default.css;;
esac
else
echo "Couldn't find Tridactyl logo ($TRIDACTYL_LOGO)"
fi