Last active
November 28, 2016 12:57
-
-
Save pstjvn/d15c6ba2c8a2b875b575 to your computer and use it in GitHub Desktop.
Sample script to bootstrap closure based development environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APPSDIR=apps/ | |
SRCDIR=src/ | |
LIBDIR=library/ | |
GCCDIR=compiler/ | |
SOYDIR=templates/ | |
GSSDIR=stylesheets/ | |
PSTJLIBDIR=pstj/ | |
SMJSLIBDIR=smjs/ | |
EXTERNSDIR=externs/ | |
[email protected]:google/closure-library.git | |
[email protected]:google/closure-compiler.git | |
[email protected]:google/closure-templates.git | |
[email protected]:google/closure-stylesheets.git | |
[email protected]:pstjvn/pstj-closure.git | |
[email protected]:pstjvn/smjslib.git | |
[email protected]:pstjvn/gcc-externs.git | |
function checks { | |
if type -p java; then | |
local javaversion=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') | |
if [[ "$javaversion" < "1.8" ]]; then | |
echo "Cannot find java 1.8" | |
exit 1 | |
fi | |
else | |
echo "Cannot find java" | |
exit 1 | |
fi | |
if type -p mvn; then | |
local mvnversion=$(mvn -version 2>&1 | awk -F ' ' '/Apache Maven/ {print $3}') | |
if [[ "$mvnversion" < "3" ]]; then | |
echo "Cannot find maven 3" | |
exit 1 | |
fi | |
else | |
echo "Cannot find mvn / maven" | |
exit 1 | |
fi | |
} | |
function alib { | |
if [[ ! -d $1 ]]; then | |
git clone $2 $1 | |
else | |
cd $1 | |
git pull | |
cd ../ | |
fi | |
} | |
function closurelibrary { | |
alib $LIBDIR $LIBREPO | |
} | |
function pstjlibrary { | |
alib $PSTJLIBDIR $PSTJLIBREPO | |
cd $PSTJLIBDIR | |
cd nodejs | |
npm install | |
cd ../../ | |
} | |
function smjslibrary { | |
alib $SMJSLIBDIR $SMJSLIBREPO | |
} | |
function externslibrary { | |
alib $EXTERNSDIR $EXTERNSREPO | |
} | |
function enterapps { | |
if [[ ! -d $APPSDIR ]]; then mkdir $APPSDIR; fi | |
cd $APPSDIR | |
} | |
function exitapps { | |
cd ../ | |
} | |
function libs { | |
closurelibrary | |
enterapps | |
pstjlibrary | |
smjslibrary | |
externslibrary | |
exitapps | |
} | |
function closurecompiler { | |
local lastversion= | |
if [[ ! -d $GCCDIR ]]; then | |
mkdir $GCCDIR | |
fi | |
cd $GCCDIR | |
if [[ -e '.lastversion' ]]; then | |
lastversion=`cat .lastversion` | |
fi | |
local currentversion=`git ls-remote $GCCREPO HEAD | awk '{print $1;}'` | |
if [[ $lastversion != $currentversion ]]; then | |
git clone $GCCREPO $SRCDIR | |
cd $SRCDIR | |
mvn clean | |
mvn package -Dmaven.test.skip=true | |
cp target/closure-compiler-1.0-SNAPSHOT.jar ../compiler.jar | |
cp target/closure-compiler-linter*.jar ../linter.jar | |
cd ../ | |
rm -rf $SRCDIR | |
echo $currentversion > .lastversion | |
fi | |
cd ../ | |
} | |
function soycompiler { | |
local lastversion= | |
if [[ ! -d $SOYDIR ]]; then | |
mkdir $SOYDIR | |
fi | |
cd $SOYDIR | |
if [[ -e '.lastversion' ]]; then | |
lastversion=`cat .lastversion` | |
fi | |
local currentversion=`git ls-remote $SOYREPO HEAD | awk '{print $1;}'` | |
if [[ $lastversion != $currentversion ]]; then | |
git clone $SOYREPO $SRCDIR | |
cd $SRCDIR | |
mvn clean | |
mvn package -Dmaven.test.skip=true | |
cp target/*SoyToJsSrcCompiler.jar ../SoyToJsSrcCompiler.jar | |
cp target/*SoyMsgExtractor.jar ../SoyMsgExtractor.jar | |
cp target/soyutils_usegoog.js ../ | |
cd ../ | |
rm -rf $SRCDIR | |
python ../library/closure/bin/build/depswriter.py \ | |
--path_with_depspath="soyutils_usegoog.js ../../../templates/soyutils_usegoog.js" \ | |
--output_file=deps.js ; | |
echo $currentversion > .lastversion | |
fi | |
cd ../ | |
} | |
function gsscompiler { | |
local lastversion= | |
if [[ ! -d $GSSDIR ]]; then | |
mkdir $GSSDIR | |
fi | |
cd $GSSDIR | |
if [[ -e '.lastversion' ]]; then | |
lastversion=`cat .lastversion` | |
fi | |
local currentversion=`git ls-remote $GSSREPO HEAD | awk '{print $1;}'` | |
if [[ $lastversion != $currentversion ]]; then | |
git clone $GSSREPO $SRCDIR | |
cd $SRCDIR | |
mvn clean | |
mvn compile assembly:single | |
cp target/closure-stylesheets*.jar ../closure-stylesheets.jar | |
cd ../ | |
rm -rf $SRCDIR | |
echo $currentversion > .lastversion | |
fi | |
cd ../ | |
} | |
function compilers { | |
closurecompiler | |
soycompiler | |
gsscompiler | |
} | |
function clang { | |
if [[ ! -e clang/bin/clang-format ]]; then | |
rm -rf clang* | |
wget "http://llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz" | |
tar xf clang+llvm-3.* | |
mv clang+llvm-3.* clang | |
rm clang+llvm-3.* | |
fi | |
} | |
checks | |
libs | |
compilers | |
clang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment