blob: 89d94297c85001b43e10dc0ecb99f8d43b7e13a4 [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001#!/bin/bash
2#
3# Copyright 2015 Google Inc. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16set -e
17
Austin Schuh272c6132020-11-14 16:37:52 -080018commandline="'$*'"
19
20if [[ $commandline == *"--cpp-std c++0x"* ]]; then
21 TEST_CPP_FLAGS="--cpp-std c++0x"
22else
23 # --cpp-std is defined by flatc default settings.
24 TEST_CPP_FLAGS=
25fi
26
27TEST_CPP_FLAGS="--gen-compare --cpp-ptr-type flatbuffers::unique_ptr $TEST_CPP_FLAGS"
28TEST_CS_FLAGS="--cs-gen-json-serializer"
29TEST_JS_TS_FLAGS="--gen-name-strings"
30TEST_BASE_FLAGS="--reflect-names --gen-mutable --gen-object-api"
31TEST_RUST_FLAGS="$TEST_BASE_FLAGS --gen-name-strings"
32TEST_NOINCL_FLAGS="$TEST_BASE_FLAGS --no-includes --no-fb-import"
33
34../flatc --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --js --ts --php --grpc \
35$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS -I include_test monster_test.fbs monsterdata_test.json
36../flatc --rust $TEST_RUST_FLAGS -I include_test monster_test.fbs monsterdata_test.json
37
38../flatc --python $TEST_BASE_FLAGS -I include_test monster_test.fbs monsterdata_test.json
39
40../flatc --cpp --java --kotlin --csharp --dart --go --binary --lobster --lua --js --ts --php --python --rust \
41$TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs
42
43../flatc --cpp --java --kotlin --csharp --js --ts --php $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS $TEST_JS_TS_FLAGS -o union_vector ./union_vector/union_vector.fbs
44../flatc --rust -I include_test -o include_test include_test/include_test1.fbs
45../flatc --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs
Austin Schuhe89fa2d2019-08-14 20:24:23 -070046../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs
Austin Schuh272c6132020-11-14 16:37:52 -080047../flatc --cpp --bfbs-comments --bfbs-builtins --bfbs-gen-embed $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS -I include_test monster_test.fbs
Austin Schuhe89fa2d2019-08-14 20:24:23 -070048../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test arrays_test.fbs
49../flatc --jsonschema --schema -I include_test monster_test.fbs
Austin Schuh272c6132020-11-14 16:37:52 -080050../flatc --cpp --java --kotlin --csharp --python $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS monster_extra.fbs monsterdata_extra.json
51../flatc --cpp --java --csharp --jsonschema $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS --scoped-enums arrays_test.fbs
52../flatc --python $TEST_BASE_FLAGS arrays_test.fbs
53../flatc --dart monster_extra.fbs
54
55# Generate optional scalar code for tests.
56../flatc --csharp --java --kotlin --rust --lobster --ts --js optional_scalars.fbs
57../flatc $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS --cpp optional_scalars.fbs
58
59# Generate the schema evolution tests
60../flatc --cpp --scoped-enums $TEST_CPP_FLAGS -o evolution_test ./evolution_test/evolution_v*.fbs
61
62working_dir=`pwd`
63cd FlatBuffers.Test.Swift/Tests/FlatBuffers.Test.SwiftTests
64$working_dir/../flatc --swift --grpc $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS -I ../../../include_test ../../../monster_test.fbs
65$working_dir/../flatc --swift $TEST_BASE_FLAGS $TEST_CPP_FLAGS $TEST_CS_FLAGS ../../../union_vector/union_vector.fbs
66$working_dir/../flatc --swift ../../../optional_scalars.fbs
67cd $working_dir
68
69cd FlatBuffers.GRPC.Swift/Sources/Model
70$working_dir/../flatc --swift --grpc greeter.fbs
71cd $working_dir
72
73# Tests if the --filename-suffix and --filename-ext works and produces the same
74# outputs.
75../flatc --cpp --filename-suffix _suffix --filename-ext hpp $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS -I include_test monster_test.fbs
76if [ -f "monster_test_suffix.hpp" ]; then
77 if ! cmp -s "monster_test_suffix.hpp" "monster_test_generated.h"; then
78 echo "[Error] Filename suffix option did not produce identical results"
79 fi
80 rm "monster_test_suffix.hpp"
81else
82 echo "[Error] Filename suffix option did not produce a file"
83fi
84
85# Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher.
86TEST_CPP17_FLAGS="--cpp --cpp-std c++17 -o ./cpp17/generated_cpp17 $TEST_NOINCL_FLAGS"
87../flatc $TEST_CPP17_FLAGS -I include_test monster_test.fbs
88../flatc $TEST_CPP17_FLAGS optional_scalars.fbs
89
Austin Schuhe89fa2d2019-08-14 20:24:23 -070090cd ../samples
Austin Schuh272c6132020-11-14 16:37:52 -080091../flatc --cpp --rust --lobster $TEST_BASE_FLAGS $TEST_CPP_FLAGS monster.fbs
Austin Schuhe89fa2d2019-08-14 20:24:23 -070092../flatc -b --schema --bfbs-comments --bfbs-builtins monster.fbs
93cd ../reflection
Austin Schuh272c6132020-11-14 16:37:52 -080094./generate_code.sh --cpp-std c++0x