Skip to content

Instantly share code, notes, and snippets.

@pstjvn
Last active November 28, 2016 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pstjvn/6896ceeecfa165001c030afbb32913c2 to your computer and use it in GitHub Desktop.
Save pstjvn/6896ceeecfa165001c030afbb32913c2 to your computer and use it in GitHub Desktop.
Provides closure compatible environment but instead of compiling from source uses pre-built binaries
#!/bin/bash
# Allows the usage of prebuilt binaries to be used.
APPSDIR=apps/
SRCDIR=src/
LIBDIR=library/
GCCDIR=compiler/
SOYDIR=templates/
GSSDIR=stylesheets/
PSTJLIBDIR=pstj/
SMJSLIBDIR=smjs/
EXTERNSDIR=externs/
LIBREPO=git@github.com:google/closure-library.git
GCCREPO=git@github.com:google/closure-compiler.git
SOYREPO=git@github.com:google/closure-templates.git
GSSREPO=git@github.com:google/closure-stylesheets.git
PSTJLIBREPO=git@github.com:pstjvn/pstj-closure.git
SMJSLIBREPO=git@github.com:pstjvn/smjslib.git
EXTERNSREPO=git@github.com:pstjvn/gcc-externs.git
GCC_BINARY_LINK=http://dl.google.com/closure-compiler/compiler-latest.tar.gz
GSS_BINARY_LINK=https://github.com/google/closure-stylesheets/releases/download/v1.4.0/closure-stylesheets.jar
SOY_BINARY_LINK=http://dl.google.com/closure-templates/closure-templates-for-javascript-latest.zip
MSG_EXTRACTOR_LINK=https://dl.google.com/closure-templates/closure-templates-msg-extractor-latest.zip
CLANG_BINARY_LINK=http://llvm.org/releases/3.9.0/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz
#### Helper functions
function closurecompiler {
if [[ ! -d $GCCDIR ]]; then
mkdir $GCCDIR
fi
cd $GCCDIR
rm -rf closure-*
wget $GCC_BINARY_LINK
tar xf compiler-latest.tar.gz
rm compiler-latest.tar.gz
ln -sf closure-compiler* compiler.jar
cd ../
}
function soycompiler {
if [[ ! -d $SOYDIR ]]; then
mkdir $SOYDIR
fi
cd $SOYDIR
wget $SOY_BINARY_LINK
wget $MSG_EXTRACTOR_LINK
unzip -o closure-templates-for-javascript-latest.zip
unzip -o closure-templates-msg-extractor-latest.zip
rm closure-templates-for-javascript-latest.zip
rm closure-templates-msg-extractor-latest.zip
python ../library/closure/bin/build/depswriter.py \
--path_with_depspath="./soyutils_usegoog.js ../../../templates/soyutils_usegoog.js" \
--output_file=deps.js
cd ../
}
function gsscompiler {
if [[ ! -d $GSSDIR ]]; then
mkdir $GSSDIR
fi
cd $GSSDIR
rm -rf closure-stylesheets.jar
wget $GSS_BINARY_LINK
cd ../
}
function compilers {
closurecompiler
soycompiler
gsscompiler
}
### Library helpers - download / update any library code.
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 clang {
if [[ ! -e clang/bin/clang-format ]]; then
rm -rf clang*
wget $CLANG_BINARY_LINK
tar xf clang+llvm-3.*
rm clang+llvm-3.*.xz
mv clang+llvm-3.* clang
fi
}
### Main entry point
compilers
libs
# clang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment