blob: 40326790dfcdb8fa6558724661bf3218c2f772ea [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001#!/bin/bash
James Kuszmaul8e62b022022-03-22 09:33:25 -07002set -euo
Austin Schuhe89fa2d2019-08-14 20:24:23 -07003#
4# Copyright 2018 Dan Field. All rights reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# Note: This script runs on Mac and Linux. It requires `Node.js` to be installed
19# and `flatc` to be built (using `cmake` in the root directory).
20
21sampledir=$(cd $(dirname $BASH_SOURCE) && pwd)
22rootdir=$(cd $sampledir/.. && pwd)
23currentdir=$(pwd)
24
25if [[ "$sampledir" != "$currentdir" ]]; then
26 echo Error: This script must be run from inside the $sampledir directory.
27 echo You executed it from the $currentdir directory.
28 exit 1
29fi
30
Austin Schuhe89fa2d2019-08-14 20:24:23 -070031# Run `flatc`. Note: This requires you to compile using `cmake` from the
32# root `/flatbuffers` directory.
James Kuszmaul8e62b022022-03-22 09:33:25 -070033if [ -e ../flatc ]; then
34 ../flatc --dart -o ../dart/example/ monster.fbs
35elif [ -e ../Debug/flatc ]; then
36 ../Debug/flatc --dart -o ../dart/example/ monster.fbs
Austin Schuhe89fa2d2019-08-14 20:24:23 -070037else
38 echo 'flatc' could not be found. Make sure to build FlatBuffers from the \
39 $rootdir directory.
40 exit 1
41fi
42
43echo Running the Dart sample.
44
45# Execute the sample.
James Kuszmaul8e62b022022-03-22 09:33:25 -070046dart ../dart/example/example.dart
Austin Schuhe89fa2d2019-08-14 20:24:23 -070047
James Kuszmaul8e62b022022-03-22 09:33:25 -070048# Copy the source schema so it is distributed when published to pub.dev
49cp monster.fbs ../dart/example/