| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 | 2 |
| 3 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 3 # Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE.md file. | 5 # BSD-style license that can be found in the LICENSE.md file. |
| 6 | 6 |
| 7 # This file compiles the github mock data files in to a single Dart file with a | 7 # This file compiles the github mock data files in to a single Dart file with a |
| 8 # hash-map of the raw file data and generates a snapshot for running the mock | 8 # hash-map of the raw file data and generates a snapshot for running the mock |
| 9 # server with this data. | 9 # server with this data. |
| 10 | 10 |
| 11 set -ue | 11 set -ue |
| 12 | 12 |
| 13 DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | 13 DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
| 14 FLETCH_DIR="$(cd "$DIR/../.." && pwd)" | 14 DARTINO_DIR="$(cd "$DIR/../.." && pwd)" |
| 15 DATA_DIR="$DIR/lib/src/github_mock_data" | 15 DATA_DIR="$DIR/lib/src/github_mock_data" |
| 16 DATA_FILE="$DIR/lib/src/github_mock.data" | 16 DATA_FILE="$DIR/lib/src/github_mock.data" |
| 17 IDL_FILE="$DIR/lib/src/github_mock.idl" | 17 IDL_FILE="$DIR/lib/src/github_mock.idl" |
| 18 MOCK_FILE="$DIR/bin/github_mock_service.dart" | 18 MOCK_FILE="$DIR/bin/github_mock_service.dart" |
| 19 SNAPSHOT_FILE="$DIR/github_mock_service.snapshot" | 19 SNAPSHOT_FILE="$DIR/github_mock_service.snapshot" |
| 20 PKG_FILE="$DIR/.packages" | 20 PKG_FILE="$DIR/.packages" |
| 21 | 21 |
| 22 DART="$FLETCH_DIR/out/ReleaseIA32/dart" | 22 DART="$DARTINO_DIR/out/ReleaseIA32/dart" |
| 23 FLETCH="$FLETCH_DIR/out/ReleaseIA32/fletch" | 23 DARTINO="$DARTINO_DIR/out/ReleaseIA32/dartino" |
| 24 SERVICEC="$FLETCH x-servicec" | 24 SERVICEC="$DARTINO x-servicec" |
| 25 | 25 |
| 26 SERVICE_GEN_DIR="$DIR/generated/service" | 26 SERVICE_GEN_DIR="$DIR/generated/service" |
| 27 | 27 |
| 28 cd $FLETCH_DIR | 28 cd $DARTINO_DIR |
| 29 ninja -C out/ReleaseIA32 | 29 ninja -C out/ReleaseIA32 |
| 30 | 30 |
| 31 if [[ $# -eq 0 ]] || [[ "$1" == "data" ]]; then | 31 if [[ $# -eq 0 ]] || [[ "$1" == "data" ]]; then |
| 32 cd $DATA_DIR | 32 cd $DATA_DIR |
| 33 echo "const Map<String, List<int>> resources = const <String, List<int>> {"\ | 33 echo "const Map<String, List<int>> resources = const <String, List<int>> {"\ |
| 34 > $DATA_FILE | 34 > $DATA_FILE |
| 35 for f in `find . -type f -name *\\\\.data`; do | 35 for f in `find . -type f -name *\\\\.data`; do |
| 36 key=`echo $f | cut -b 3- | cut -d . -f 1` | 36 key=`echo $f | cut -b 3- | cut -d . -f 1` |
| 37 echo "'$key': const <int>[" >> $DATA_FILE | 37 echo "'$key': const <int>[" >> $DATA_FILE |
| 38 od -A n -t d1 $f |\ | 38 od -A n -t d1 $f |\ |
| 39 sed 's/\([^ ]\) /\1,/g' |\ | 39 sed 's/\([^ ]\) /\1,/g' |\ |
| 40 sed 's/\([^ ]\)$/\1,/' >> $DATA_FILE | 40 sed 's/\([^ ]\)$/\1,/' >> $DATA_FILE |
| 41 echo "]," >> $DATA_FILE | 41 echo "]," >> $DATA_FILE |
| 42 done | 42 done |
| 43 echo "};" >> $DATA_FILE | 43 echo "};" >> $DATA_FILE |
| 44 fi | 44 fi |
| 45 | 45 |
| 46 if [[ $# -eq 0 ]] || [[ "$1" == "service" ]]; then | 46 if [[ $# -eq 0 ]] || [[ "$1" == "service" ]]; then |
| 47 # TODO(zerny): This must output service files *in the existing directory*. | 47 # TODO(zerny): This must output service files *in the existing directory*. |
| 48 # Find another way of supporting multiple services! | 48 # Find another way of supporting multiple services! |
| 49 mkdir -p "$SERVICE_GEN_DIR" | 49 mkdir -p "$SERVICE_GEN_DIR" |
| 50 $SERVICEC file "$IDL_FILE" out "$SERVICE_GEN_DIR" | 50 $SERVICEC file "$IDL_FILE" out "$SERVICE_GEN_DIR" |
| 51 fi | 51 fi |
| 52 | 52 |
| 53 if [[ $# -eq 0 ]] || [[ "$1" == "snapshot" ]]; then | 53 if [[ $# -eq 0 ]] || [[ "$1" == "snapshot" ]]; then |
| 54 cd $FLETCH_DIR | 54 cd $DARTINO_DIR |
| 55 $DART -c --packages=.packages \ | 55 $DART -c --packages=.packages \ |
| 56 -Dsnapshot="$SNAPSHOT_FILE" \ | 56 -Dsnapshot="$SNAPSHOT_FILE" \ |
| 57 -Dpackages="$PKG_FILE" \ | 57 -Dpackages="$PKG_FILE" \ |
| 58 tests/fletchc/run.dart "$MOCK_FILE" | 58 tests/dartino_compiler/run.dart "$MOCK_FILE" |
| 59 fi | 59 fi |
| OLD | NEW |