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