2015-12-10 01:06:11 +00:00
|
|
|
:: Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
::
|
|
|
|
:: Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
:: you may not use this file except in compliance with the License.
|
|
|
|
:: You may obtain a copy of the License at
|
|
|
|
::
|
|
|
|
:: http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
::
|
|
|
|
:: Unless required by applicable law or agreed to in writing, software
|
|
|
|
:: distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
:: See the License for the specific language governing permissions and
|
|
|
|
:: limitations under the License.
|
|
|
|
|
2019-12-23 20:13:48 +00:00
|
|
|
@SETLOCAL
|
|
|
|
|
2016-08-13 01:01:38 +00:00
|
|
|
set buildtype=Release
|
|
|
|
if "%1"=="-b" set buildtype=%2
|
|
|
|
|
2019-12-23 20:13:48 +00:00
|
|
|
set commandline=%*
|
|
|
|
|
|
|
|
|
|
|
|
if NOT "%commandline%"=="%commandline:--cpp-std c++0x=%" (
|
|
|
|
set TEST_CPP_FLAGS=--cpp-std c++0x
|
|
|
|
) else (
|
|
|
|
@rem --cpp-std is defined by flatc default settings.
|
|
|
|
set TEST_CPP_FLAGS=
|
|
|
|
)
|
|
|
|
|
|
|
|
set TEST_CPP_FLAGS=--gen-compare --cpp-ptr-type flatbuffers::unique_ptr %TEST_CPP_FLAGS%
|
2020-02-11 01:43:36 +00:00
|
|
|
set TEST_CS_FLAGS=--cs-gen-json-serializer
|
2021-04-12 17:41:59 +00:00
|
|
|
set TEST_TS_FLAGS=--gen-name-strings
|
2019-12-23 20:13:48 +00:00
|
|
|
set TEST_BASE_FLAGS=--reflect-names --gen-mutable --gen-object-api
|
2021-01-25 17:33:47 +00:00
|
|
|
set TEST_RUST_FLAGS=%TEST_BASE_FLAGS% --gen-name-strings
|
2021-01-19 20:51:13 +00:00
|
|
|
set TEST_NOINCL_FLAGS=%TEST_BASE_FLAGS% --no-includes
|
2019-12-23 20:13:48 +00:00
|
|
|
|
2021-01-19 20:51:13 +00:00
|
|
|
..\%buildtype%\flatc.exe --binary --cpp --java --kotlin --csharp --dart --go --lobster --lua --ts --php --grpc ^
|
2020-02-11 01:43:36 +00:00
|
|
|
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
2021-01-25 17:33:47 +00:00
|
|
|
..\%buildtype%\flatc.exe --rust %TEST_RUST_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
|
2021-01-19 20:51:13 +00:00
|
|
|
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% -I include_test monster_test.fbs monsterdata_test.json || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
|
2021-01-25 17:33:47 +00:00
|
|
|
..\%buildtype%\flatc.exe --binary --cpp --java --csharp --dart --go --lobster --lua --ts --php --python ^
|
2021-04-12 17:41:59 +00:00
|
|
|
%TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_TS_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
|
2021-01-25 17:33:47 +00:00
|
|
|
@rem For Rust we currently generate two independent schemas, with namespace_test2
|
|
|
|
@rem duplicating the types in namespace_test1
|
|
|
|
..\%buildtype%\flatc.exe --rust --gen-all %TEST_RUST_FLAGS% -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs || goto FAIL
|
|
|
|
|
2021-04-12 17:41:59 +00:00
|
|
|
..\%buildtype%\flatc.exe --cpp --java --csharp --ts --php %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% %TEST_TS_FLAGS% -o union_vector ./union_vector/union_vector.fbs || goto FAIL
|
|
|
|
..\%buildtype%\flatc.exe --ts --gen-name-strings --gen-mutable %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -I include_test monster_test.fbs
|
|
|
|
..\%buildtype%\flatc.exe %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -b -I include_test monster_test.fbs unicode_test.json
|
|
|
|
..\%buildtype%\flatc.exe --ts --gen-name-strings %TEST_BASE_FLAGS% %TEST_TS_FLAGS% -o union_vector union_vector/union_vector.fbs
|
[rust] Add use declarations to Rust-generated bindings for imported FB definitions (#5645)
* Bugfix for Rust generation of union fields named with language keywords
Looking at ParseField, it appears that in the case of unions, an extra field with a `UnionTypeFieldSuffix` is added to the type definition, however, if the name of this field is a keyword in the target language, it isn't escaped.
For example, if generating code for rust for a union field named `type`, flatc will generate a (non-keyword escaped) field named `type_type` for this hidden union field, and one (keyword escaped) called `type_` for the actual union contents.
When the union accessors are generated, they refer to this `type_type` field, but they will escape it mistakenly, generating code like this:
```
#[inline]
#[allow(non_snake_case)]
pub fn type__as_int(&self) -> Option<Int<'a>> {
if self.type__type() == Type::Int {
self.type_().map(|u| Int::init_from_table(u))
} else {
None
}
}
```
Which will fail to build because the field is called `self.type_type()`, not `self.type__type()`.
* [Rust] Add crate-relative use statements for FBS includes.
At present if a flatbuffer description includes a reference to a type in
another file, the generated Rust code needs to be hand-modified to add
the appropriate `use` statements.
This assumes that the dependencies are built into the same crate, which
I think is a reasonable assumption?
* Revert "[Rust] Add crate-relative use statements for FBS includes."
This reverts commit d554d79fecf5afd6da6fb993b30b4cd523a5889a.
* Add updated generated test files.
* Fixing Rust test harness to handle new includes.
Test binaries need to add references to generated code that's
transitively included.
This also has the knock-on in that this code (which is referenced by
include directives directly in the flatbuffer schema files) also needs
to be generated, hence the changes to generate_code.sh.
* Test harnesses expect test data to be checked in.
Put include_test2 files into the same directory as the include_test2
schema definition.
Update all code generation scripts (forgot the batch file from last
time).
Path updates in Rust test.
* Include updated generated code
* Address comments raised in PR
* Fix failing Rust tests.
* Previous merge clobbered this branch change.
* Add updated imports to benchmarks.
* Clarifying comment per PR request
* Update documentation comments per feedback
* Remove non-Rust generated files for include tests, per feedback from @rw/@aardappel
* Broken code generation batch file
* Fix typo
* Add TODO for tidying up use declaration traversal sometime in the future
* Update test files.
2020-01-19 22:47:28 +00:00
|
|
|
..\%buildtype%\flatc.exe --rust -I include_test -o include_test include_test/include_test1.fbs || goto FAIL
|
|
|
|
..\%buildtype%\flatc.exe --rust -I include_test -o include_test/sub include_test/sub/include_test2.fbs || goto FAIL
|
2018-12-13 19:59:27 +00:00
|
|
|
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test monster_test.fbs || goto FAIL
|
2020-01-24 22:55:34 +00:00
|
|
|
..\%buildtype%\flatc.exe --cpp --bfbs-comments --bfbs-builtins --bfbs-gen-embed %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% -I include_test monster_test.fbs || goto FAIL
|
2019-06-17 22:15:13 +00:00
|
|
|
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins -I include_test arrays_test.fbs || goto FAIL
|
2018-10-22 22:41:12 +00:00
|
|
|
..\%buildtype%\flatc.exe --jsonschema --schema -I include_test monster_test.fbs || goto FAIL
|
2021-04-16 15:15:59 +00:00
|
|
|
..\%buildtype%\flatc.exe --cpp --java --csharp --jsonschema --rust %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% --scoped-enums arrays_test.fbs || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% arrays_test.fbs || goto FAIL
|
|
|
|
..\%buildtype%\flatc.exe --cpp %TEST_BASE_FLAGS% --cpp-ptr-type flatbuffers::unique_ptr native_type_test.fbs || goto FAIL
|
2019-01-07 18:04:44 +00:00
|
|
|
|
2020-07-23 23:30:27 +00:00
|
|
|
@rem Generate the optional scalar code for tests.
|
2021-01-22 18:07:32 +00:00
|
|
|
..\%buildtype%\flatc.exe --java --kotlin --lobster --ts optional_scalars.fbs || goto FAIL
|
|
|
|
..\%buildtype%\flatc.exe --csharp --rust --gen-object-api optional_scalars.fbs || goto FAIL
|
2020-10-22 20:36:02 +00:00
|
|
|
..\%buildtype%\flatc.exe %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% --cpp optional_scalars.fbs || goto FAIL
|
2020-07-23 23:30:27 +00:00
|
|
|
|
2020-06-25 22:35:23 +00:00
|
|
|
@rem Generate the schema evolution tests
|
|
|
|
..\%buildtype%\flatc.exe --cpp --scoped-enums %TEST_CPP_FLAGS% -o evolution_test ./evolution_test/evolution_v1.fbs ./evolution_test/evolution_v2.fbs || goto FAIL
|
|
|
|
|
2019-12-23 20:13:48 +00:00
|
|
|
if NOT "%MONSTER_EXTRA%"=="skip" (
|
2019-01-07 18:04:44 +00:00
|
|
|
@echo Generate MosterExtra
|
2020-02-11 01:43:36 +00:00
|
|
|
..\%buildtype%\flatc.exe --cpp --java --csharp %TEST_NOINCL_FLAGS% %TEST_CPP_FLAGS% %TEST_CS_FLAGS% monster_extra.fbs monsterdata_extra.json || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
..\%buildtype%\flatc.exe --python %TEST_BASE_FLAGS% monster_extra.fbs monsterdata_extra.json || goto FAIL
|
2019-01-07 18:04:44 +00:00
|
|
|
) else (
|
|
|
|
@echo monster_extra.fbs skipped (the strtod function from MSVC2013 or older doesn't support NaN/Inf arguments)
|
|
|
|
)
|
|
|
|
|
2021-03-06 15:28:27 +00:00
|
|
|
set TEST_CPP17_FLAGS=--cpp --cpp-std c++17 --cpp-static-reflection -o ./cpp17/generated_cpp17 %TEST_NOINCL_FLAGS%
|
2019-12-23 20:13:48 +00:00
|
|
|
if NOT "%MONSTER_EXTRA%"=="skip" (
|
|
|
|
@rem Flag c++17 requires Clang6, GCC7, MSVC2017 (_MSC_VER >= 1914) or higher.
|
|
|
|
..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% -I include_test monster_test.fbs || goto FAIL
|
2020-10-22 20:36:02 +00:00
|
|
|
..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% optional_scalars.fbs || goto FAIL
|
2019-12-23 20:13:48 +00:00
|
|
|
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% arrays_test.fbs || goto FAIL
|
|
|
|
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% native_type_test.fbs || goto FAIL
|
|
|
|
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% monster_extra.fbs || goto FAIL
|
|
|
|
@rem..\%buildtype%\flatc.exe %TEST_CPP17_FLAGS% ./union_vector/union_vector.fbs || goto FAIL
|
|
|
|
)
|
|
|
|
|
2017-09-21 21:06:20 +00:00
|
|
|
cd ../samples
|
2019-12-23 20:13:48 +00:00
|
|
|
..\%buildtype%\flatc.exe --cpp --lobster %TEST_BASE_FLAGS% %TEST_CPP_FLAGS% monster.fbs || goto FAIL
|
2018-12-13 19:59:27 +00:00
|
|
|
..\%buildtype%\flatc.exe -b --schema --bfbs-comments --bfbs-builtins monster.fbs || goto FAIL
|
2017-09-21 21:06:20 +00:00
|
|
|
cd ../reflection
|
2018-10-22 22:41:12 +00:00
|
|
|
call generate_code.bat %1 %2 || goto FAIL
|
2017-09-21 21:06:20 +00:00
|
|
|
|
2018-10-22 22:41:12 +00:00
|
|
|
set EXITCODE=0
|
|
|
|
goto SUCCESS
|
|
|
|
:FAIL
|
|
|
|
set EXITCODE=1
|
|
|
|
:SUCCESS
|
2018-09-03 00:05:50 +00:00
|
|
|
cd ../tests
|
2018-10-22 22:41:12 +00:00
|
|
|
EXIT /B %EXITCODE%
|