| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | #!/bin/bash
 | 
					
						
							| 
									
										
										
										
											2015-11-05 08:20:13 -08:00
										 |  |  | set -ex | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | echo ============================================================================= | 
					
						
							| 
									
										
										
										
											2016-01-25 22:47:42 -08:00
										 |  |  | echo "DART DEV COMPILER (DDC) BUILD" | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | echo ============================================================================= | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # go to project dir | 
					
						
							|  |  |  | SCRIPT_DIR=$(dirname $0) | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | REPO_ROOT_DIR=`cd ${SCRIPT_DIR}/../..; pwd` | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | source $SCRIPT_DIR/env_dart.sh | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | cd $REPO_ROOT_DIR | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | # Variables | 
					
						
							| 
									
										
										
										
											2016-04-01 09:20:50 -07:00
										 |  |  | DDC_TOTAL_WARNING_CAP="100" | 
					
						
							| 
									
										
										
										
											2016-02-19 11:49:31 -08:00
										 |  |  | DDC_TOTAL_ERROR_CAP="0" | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | DDC_DIR=`pwd`/tmp/dev_compiler | 
					
						
							| 
									
										
										
										
											2016-04-01 09:20:50 -07:00
										 |  |  | DDC_VERSION="0.1.24" | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Get DDC | 
					
						
							|  |  |  | mkdir -p tmp | 
					
						
							|  |  |  | rm -rf tmp/dev_compiler | 
					
						
							|  |  |  | git clone https://github.com/dart-lang/dev_compiler.git tmp/dev_compiler | 
					
						
							|  |  |  | (cd $DDC_DIR && \
 | 
					
						
							|  |  |  |   git checkout tags/$DDC_VERSION && \
 | 
					
						
							|  |  |  |   $PUB get) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Convert TypeScript to Dart | 
					
						
							| 
									
										
										
										
											2016-02-16 20:42:48 -08:00
										 |  |  | ./node_modules/.bin/gulp build.js.cjs | 
					
						
							| 
									
										
										
										
											2015-06-03 17:22:30 -07:00
										 |  |  | ./node_modules/.bin/gulp build/packages.dart | 
					
						
							|  |  |  | ./node_modules/.bin/gulp build/pubspec.dart | 
					
						
							| 
									
										
										
										
											2016-01-25 22:47:42 -08:00
										 |  |  | node ./scripts/ci/dart_ddc/pubspec_for_ddc.js \
 | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  |     --pubspec-file=dist/dart/playground/pubspec.yaml | 
					
						
							|  |  |  | cd dist/dart/playground | 
					
						
							|  |  |  | $PUB build --mode=debug | 
					
						
							|  |  |  | cd build/web | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # TODO: temporarily remove references to dart.js as ddc doesn't do it | 
					
						
							|  |  |  | # automatically yet (https://github.com/dart-lang/dev_compiler/issues/437) | 
					
						
							|  |  |  | echo `pwd` | 
					
						
							|  |  |  | for htmlFile in `find ./src -name '*.html'`; do | 
					
						
							|  |  |  |   tmpFile=$REPO_ROOT_DIR/tmp/scriptless_html.tmp | 
					
						
							|  |  |  |   cat $htmlFile | grep -vE '<script.*dart\.js' >$tmpFile | 
					
						
							|  |  |  |   mv $tmpFile $htmlFile | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ############################################################################## | 
					
						
							|  |  |  | # Analyze code | 
					
						
							|  |  |  | ############################################################################## | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | LOG_FILE="analyzer.log" | 
					
						
							|  |  |  | set +e | 
					
						
							|  |  |  | $DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
 | 
					
						
							| 
									
										
										
										
											2016-01-25 17:57:29 -08:00
										 |  |  |   --dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o out \
 | 
					
						
							|  |  |  |   src/animate/index.dart \
 | 
					
						
							|  |  |  |   src/async/index.dart \
 | 
					
						
							|  |  |  |   src/gestures/index.dart \
 | 
					
						
							|  |  |  |   src/hash_routing/index.dart \
 | 
					
						
							|  |  |  |   src/hello_world/index.dart \
 | 
					
						
							|  |  |  |   src/key_events/index.dart \
 | 
					
						
							|  |  |  |   src/model_driven_forms/index.dart \
 | 
					
						
							|  |  |  |   src/observable_models/index.dart \
 | 
					
						
							|  |  |  |   src/order_management/index.dart \
 | 
					
						
							|  |  |  |   src/person_management/index.dart \
 | 
					
						
							|  |  |  |   src/relative_assets/index.dart \
 | 
					
						
							|  |  |  |   src/routing/index.dart \
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:45:12 -07:00
										 |  |  |   src/alt_routing/index.dart \
 | 
					
						
							| 
									
										
										
										
											2016-01-25 17:57:29 -08:00
										 |  |  |   src/sourcemap/index.dart \
 | 
					
						
							|  |  |  |   src/svg/index.dart \
 | 
					
						
							|  |  |  |   src/template_driven_forms/index.dart \
 | 
					
						
							|  |  |  |   src/todo/index.dart \
 | 
					
						
							|  |  |  |   src/zippy_component/index.dart \
 | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  |   >$LOG_FILE | 
					
						
							|  |  |  | EXIT_CODE=`echo $?` | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Analyzer exits with 1 when there are warnings and something crazy | 
					
						
							|  |  |  | # like 255 when it crashes. We don't want to fail the build if its | 
					
						
							|  |  |  | # only warnings (until our code is warning-free). | 
					
						
							|  |  |  | if [[ "$EXIT_CODE" -ne "0" && "$EXIT_CODE" -ne "1" ]] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |   echo "DDC compiler crashed with exit code $EXIT_CODE" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cat $LOG_FILE | 
					
						
							| 
									
										
										
										
											2016-02-19 11:49:31 -08:00
										 |  |  | EXIT_CODE=0 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # TODO remove  `grep -v template.dart` after Tobias new compiler lands. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 14:13:44 -08:00
										 |  |  | WARNING_COUNT=$(cat $LOG_FILE | grep -E '^warning.*' | wc -l | sed -e 's/^[[:space:]]*//' || true) | 
					
						
							| 
									
										
										
										
											2016-02-19 11:49:31 -08:00
										 |  |  | ERROR_COUNT=$(cat $LOG_FILE | grep -E '^severe.*' | wc -l | sed -e 's/^[[:space:]]*//' || true) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ "$ERROR_COUNT" -gt "$DDC_TOTAL_ERROR_CAP" ]] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |   echo "Found severe errors in angular2 package" | 
					
						
							|  |  |  |   EXIT_CODE=1 | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-25 17:57:29 -08:00
										 |  |  | if [[ "$WARNING_COUNT" -gt "$DDC_TOTAL_WARNING_CAP" ]] | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | then | 
					
						
							|  |  |  |   echo "Too many warnings: $WARNING_COUNT" | 
					
						
							| 
									
										
										
										
											2016-02-19 11:49:31 -08:00
										 |  |  |   EXIT_CODE=1 | 
					
						
							| 
									
										
										
										
											2016-01-12 09:25:01 -08:00
										 |  |  | else | 
					
						
							|  |  |  |   echo "Warning count ok" | 
					
						
							|  |  |  | fi | 
					
						
							| 
									
										
										
										
											2016-01-21 18:13:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ############################################################################## | 
					
						
							|  |  |  | # Run e2e tests | 
					
						
							|  |  |  | ############################################################################## | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DIST_DIR="${REPO_ROOT_DIR}/dist/js/ddc" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Build the apps (again) | 
					
						
							|  |  |  | # TODO: ddc does not yet support compiling multiple html files. Ideally we | 
					
						
							|  |  |  | # could build everything during analysis above. | 
					
						
							|  |  |  | # See: https://github.com/dart-lang/dev_compiler/issues/430 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ln -s `pwd`/packages src/hello_world/packages | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set +e | 
					
						
							|  |  |  | OUT_DIR="${DIST_DIR}/playground/src/hello_world" | 
					
						
							|  |  |  | mkdir -p $OUT_DIR | 
					
						
							|  |  |  | $DART_SDK/bin/dart $DDC_DIR/bin/dartdevc.dart \
 | 
					
						
							|  |  |  |   --force-compile \
 | 
					
						
							|  |  |  |   --dart-sdk=$DART_SDK_LIB_SEARCH_PATH -o $OUT_DIR \
 | 
					
						
							|  |  |  |   src/hello_world/index.html | 
					
						
							|  |  |  | EXIT_CODE=`echo $?` | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ "$EXIT_CODE" -ne "0" && "$EXIT_CODE" -ne "1" ]] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |   echo "DDC compiler crashed with exit code $EXIT_CODE" | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Run e2e tests | 
					
						
							|  |  |  | cd $REPO_ROOT_DIR | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ./node_modules/.bin/webdriver-manager update | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function killServer () { | 
					
						
							|  |  |  |   kill $serverPid | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ./node_modules/.bin/gulp serve.js.ddc& | 
					
						
							|  |  |  | serverPid=$! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-16 20:42:48 -08:00
										 |  |  | echo CHROM_BIN=$CHROME_BIN | 
					
						
							|  |  |  | echo CHROM_BIN_VERSION=`$CHROME_BIN --version` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  | trap killServer EXIT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # wait for server to come up | 
					
						
							|  |  |  | sleep 10 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function runSpec { | 
					
						
							|  |  |  |   SPEC=$1 | 
					
						
							|  |  |  |   ./node_modules/.bin/protractor protractor-ddc.conf.js \
 | 
					
						
							| 
									
										
										
										
											2016-02-16 20:42:48 -08:00
										 |  |  |       --browsers=${E2E_BROWSERS:-ChromeDesktop} \
 | 
					
						
							| 
									
										
										
										
											2016-01-29 18:22:28 -08:00
										 |  |  |       --spec=$SPEC | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # TODO: add more e2e tests | 
					
						
							|  |  |  | runSpec hello_world/hello_world_spec.js | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-21 18:13:58 -08:00
										 |  |  | echo 'Dart DDC build finished' | 
					
						
							| 
									
										
										
										
											2016-02-19 11:49:31 -08:00
										 |  |  | exit $EXIT_CODE |