From b5b7aeaf1b70da92a831e666def967bbb49e39ed Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 11 Apr 2018 14:19:49 -0700 Subject: [PATCH 1/2] Create a script to do local builds of core Blockly. --- .gitignore | 2 ++ local_build/local_build.sh | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 local_build/local_build.sh diff --git a/.gitignore b/.gitignore index 0dce6535c..642605678 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ npm-debug.log tests/compile/main_compressed.js tests/compile/*compiler*.jar +local_build/*compiler*.jar +local_build/local_blockly_compressed.js diff --git a/local_build/local_build.sh b/local_build/local_build.sh new file mode 100755 index 000000000..44d02af23 --- /dev/null +++ b/local_build/local_build.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Locally build and compress the core Blockly files into a single JavaScript +# file. +# +# Copyright 2018 Google Inc. +# https://developers.google.com/blockly/ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Usage: local_build.sh. +# +# This script generates only local_blockly_compressed.js. You may modify it as +# needed to build other files. +# +# The compressed file is a concatenation of all of Blockly's core files, run +# through a local copy of Google's Closure Compiler with simple optimizations +# turned on. + +# Future work: +# - Trim down Google's Apache licenses, to match the output of build.py. +# - Generate other compressed files generated by build.py normally. + +# Find the Closure Compiler. +if [ -f "$(npm root)/google-closure-compiler/compiler.jar" ]; then + # Travis test. + COMPILER="$(npm root)/google-closure-compiler/compiler.jar" +elif [ -f *compiler*.jar ]; then + # Manual test. + COMPILER="*compiler*.jar" +else + echo "ERROR: Closure Compiler not found." + echo "Download from this URL, and place jar file in current directory." + echo "https://dl.google.com/closure-compiler/compiler-latest.zip" + exit 1 +fi + +rm local_blockly_compressed.js 2> /dev/null +echo Compiling Blockly core... +java -jar closure-compiler.jar \ + --js='../core/**.js' \ + --js='../../closure-library/closure/goog/**.js' \ + --js='../../closure-library/third_party/closure/goog/**.js' \ + --generate_exports \ + --warning_level='DEFAULT' \ + --compilation_level SIMPLE_OPTIMIZATIONS \ + --dependency_mode=STRICT \ + --entry_point=Blockly \ + --js_output_file local_blockly_compressed.js + +if [ -s local_blockly_compressed.js ]; then + echo Compilation OK. +else + echo Compilation FAIL. + exit 1 +fi From 42cb962cefd0285c3c73c48b6920df8ff6ad78c1 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 11 Apr 2018 15:26:05 -0700 Subject: [PATCH 2/2] Apply review feedback. --- local_build/local_build.sh | 12 +++++++----- tests/compile/compile.sh | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/local_build/local_build.sh b/local_build/local_build.sh index 44d02af23..c5122036c 100755 --- a/local_build/local_build.sh +++ b/local_build/local_build.sh @@ -30,14 +30,15 @@ # Future work: # - Trim down Google's Apache licenses, to match the output of build.py. # - Generate other compressed files generated by build.py normally. +# - Add a good error message if multiple versions of the closure compiler were +# found. # Find the Closure Compiler. if [ -f "$(npm root)/google-closure-compiler/compiler.jar" ]; then - # Travis test. COMPILER="$(npm root)/google-closure-compiler/compiler.jar" -elif [ -f *compiler*.jar ]; then - # Manual test. - COMPILER="*compiler*.jar" +elif [ -f closure-compiler*.jar ]; then + COMPILER="closure-compiler*.jar" + # TODO: Check whether multiple files were found. else echo "ERROR: Closure Compiler not found." echo "Download from this URL, and place jar file in current directory." @@ -45,9 +46,10 @@ else exit 1 fi +echo Using $COMPILER as the compiler. rm local_blockly_compressed.js 2> /dev/null echo Compiling Blockly core... -java -jar closure-compiler.jar \ +java -jar $COMPILER \ --js='../core/**.js' \ --js='../../closure-library/closure/goog/**.js' \ --js='../../closure-library/third_party/closure/goog/**.js' \ diff --git a/tests/compile/compile.sh b/tests/compile/compile.sh index b5e73ec04..9ddd44f35 100755 --- a/tests/compile/compile.sh +++ b/tests/compile/compile.sh @@ -1,17 +1,17 @@ # Find the Closure Compiler. if [ -f "$(npm root)/google-closure-compiler/compiler.jar" ]; then - # Travis test. COMPILER="$(npm root)/google-closure-compiler/compiler.jar" elif [ -f *compiler*.jar ]; then - # Manual test. COMPILER="*compiler*.jar" + # TODO: Check whether multiple files were found. else - echo "ERROR: Closure Compiler not found." + echo "ERROR: Closure Compiler not found." echo "Download from this URL, and place jar file in current directory." echo "https://dl.google.com/closure-compiler/compiler-latest.zip" exit 1 fi +echo Using $COMPILER as the compiler. rm main_compressed.js 2> /dev/null echo Compiling Blockly... java -jar $COMPILER --js='main.js' \