Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | #!/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. |
| 16 | set -e |
| 17 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 18 | commandline="'$*'" |
| 19 | |
| 20 | if [[ $commandline == *"--cpp-std c++0x"* ]]; then |
| 21 | TEST_CPP_FLAGS="--cpp-std c++0x" |
| 22 | else |
| 23 | # --cpp-std is defined by flatc default settings. |
| 24 | TEST_CPP_FLAGS= |
| 25 | fi |
| 26 | |
| 27 | TEST_CPP_FLAGS="--gen-compare --cpp-ptr-type flatbuffers::unique_ptr $TEST_CPP_FLAGS" |
| 28 | TEST_CS_FLAGS="--cs-gen-json-serializer" |
| 29 | TEST_JS_TS_FLAGS="--gen-name-strings" |
| 30 | TEST_BASE_FLAGS="--reflect-names --gen-mutable --gen-object-api" |
| 31 | TEST_RUST_FLAGS="$TEST_BASE_FLAGS --gen-name-strings" |
| 32 | TEST_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 Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 46 | ../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 47 | ../flatc --cpp --bfbs-comments --bfbs-builtins --bfbs-gen-embed $TEST_NOINCL_FLAGS $TEST_CPP_FLAGS -I include_test monster_test.fbs |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 48 | ../flatc -b --schema --bfbs-comments --bfbs-builtins -I include_test arrays_test.fbs |
| 49 | ../flatc --jsonschema --schema -I include_test monster_test.fbs |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 50 | ../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 | |
| 62 | working_dir=`pwd` |
| 63 | cd 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 |
| 67 | cd $working_dir |
| 68 | |
| 69 | cd FlatBuffers.GRPC.Swift/Sources/Model |
| 70 | $working_dir/../flatc --swift --grpc greeter.fbs |
| 71 | cd $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 |
| 76 | if [ -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" |
| 81 | else |
| 82 | echo "[Error] Filename suffix option did not produce a file" |
| 83 | fi |
| 84 | |
| 85 | # Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher. |
| 86 | TEST_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 Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 90 | cd ../samples |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 91 | ../flatc --cpp --rust --lobster $TEST_BASE_FLAGS $TEST_CPP_FLAGS monster.fbs |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 92 | ../flatc -b --schema --bfbs-comments --bfbs-builtins monster.fbs |
| 93 | cd ../reflection |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 94 | ./generate_code.sh --cpp-std c++0x |