- add sources.
[platform/framework/web/crosswalk.git] / src / chrome_frame / cfinstall / build.sh
1 #!/bin/sh
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 OPTIMIZATION_LEVEL="ADVANCED_OPTIMIZATIONS"
7 EXTRA_FLAGS=""
8
9 while getopts l:d o
10 do case "$o" in
11     l)    EXTRA_FLAGS="$EXTRA_FLAGS -f --define=google.cf.installer.Prompt.\
12 DEFAULT_IMPLEMENTATION_URL='${OPTARG}cf-xd-install-impl.js'";;
13     d)    OPTIMIZATION_LEVEL="SIMPLE_OPTIMIZATIONS"
14           EXTRA_FLAGS="$EXTRA_FLAGS -f --formatting=PRETTY_PRINT";;
15     [?])  echo >&2 "Usage: $0 [-l //host.com/path/to/scripts/dir/] [-p] [-d]"
16           echo >&2 "       -l <URL>   The path under which the generated"
17           echo >&2 "                  scripts will be deployed."
18           echo >&2 "       -d         Disable obfuscating optimizations."
19           exit 1;;
20   esac
21 done
22
23 DEPS_DIR=deps
24 OUT_DIR=out
25 SRC_DIR=src
26 CLOSURE_LIBRARY_DIR=$DEPS_DIR/closure_library
27 CLOSURE_BUILDER=$CLOSURE_LIBRARY_DIR/closure/bin/build/closurebuilder.py
28 CLOSURE_COMPILER_ZIP=$DEPS_DIR/compiler-latest.zip
29 CLOSURE_COMPILER_JAR_ZIP_RELATIVE=compiler.jar
30 CLOSURE_COMPILER_JAR=$DEPS_DIR/$CLOSURE_COMPILER_JAR_ZIP_RELATIVE
31
32 # TODO(palmer): Convert the svn checkout to HTTPS with the broken SVN
33 # clients are finally gone. As of 24 July 2012, that should be pretty soon.
34 mkdir -p $DEPS_DIR &&
35 mkdir -p $OUT_DIR &&
36 { [[ -e $CLOSURE_LIBRARY_DIR ]] || \
37   svn checkout http://closure-library.googlecode.com/svn/trunk/ \
38     $CLOSURE_LIBRARY_DIR; } && \
39 { [[ -e $CLOSURE_COMPILER_JAR ]] ||
40   { wget https://closure-compiler.googlecode.com/files/compiler-latest.zip \
41       -O $CLOSURE_COMPILER_ZIP && \
42     unzip -d $DEPS_DIR $CLOSURE_COMPILER_ZIP \
43       $CLOSURE_COMPILER_JAR_ZIP_RELATIVE >/dev/null; }; } &&
44 $CLOSURE_BUILDER \
45   --root=$CLOSURE_LIBRARY_DIR --root=src/common/ \
46   --root=src/implementation/ \
47   --namespace="google.cf.installer.CrossDomainInstall" \
48   --output_mode=compiled --compiler_jar=$CLOSURE_COMPILER_JAR \
49   $EXTRA_FLAGS \
50   -f "--compilation_level=$OPTIMIZATION_LEVEL" \
51   -f "--output_wrapper='(function (scope){ %output% })(window)'" \
52   -f "--externs=src/common/cf-interactiondelegate-externs.js" \
53   --output_file=out/cf-xd-install-impl.js && \
54 $CLOSURE_BUILDER \
55   --root=src/miniclosure/ --root=src/common/ \
56   --root=src/stub/ \
57   --namespace="google.cf.installer.CFInstall" \
58   --output_mode=compiled --compiler_jar=$CLOSURE_COMPILER_JAR \
59   $EXTRA_FLAGS \
60   -f "--compilation_level=$OPTIMIZATION_LEVEL" \
61   -f "--output_wrapper='(function (scope){ %output% })(window)'" \
62   -f "--externs=src/stub/cf-activex-externs.js" \
63   -f "--externs=src/common/cf-interactiondelegate-externs.js" \
64   --output_file=out/CFInstall.min.js