mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-06 13:37:25 +00:00
Fixes Rust code generation for single file output when using namespaces (#8877)
* Adds tests for Rust single file mode All existing tests only compile Rust code using --rust-module-root-file. * Adds standalone include tests for Rust The imports for these tests have been moved to their own file, as the existing intergration_test.rs file hides compilation issues from code generation due to symbols brought into scope outside of the generated code (e.g. `extern crate alloc`). * Declare alloc crate in every Rust namespace When performing code generation within a single file, extern crate alloc needs to be delcared to bring alloc into scope within every inner namespace. * Regenerates generated schemas
This commit is contained in:
@@ -85,6 +85,11 @@ RUST_OPTS = BASE_OPTS + [
|
||||
"--gen-name-strings",
|
||||
"--rust-module-root-file",
|
||||
]
|
||||
RUST_STANDALONE_OPTS = BASE_OPTS + [
|
||||
"--rust",
|
||||
"--gen-all",
|
||||
"--gen-name-strings",
|
||||
]
|
||||
RUST_SERIALIZE_OPTS = BASE_OPTS + [
|
||||
"--rust",
|
||||
"--gen-all",
|
||||
@@ -288,6 +293,12 @@ flatc(
|
||||
schema="include_test/include_test1.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_STANDALONE_OPTS,
|
||||
include="include_test",
|
||||
schema="include_test/include_test1.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_OPTS,
|
||||
prefix="include_test2",
|
||||
@@ -295,6 +306,12 @@ flatc(
|
||||
schema="include_test/sub/include_test2.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
RUST_STANDALONE_OPTS,
|
||||
include="include_test",
|
||||
schema="include_test/sub/include_test2.fbs",
|
||||
)
|
||||
|
||||
flatc(
|
||||
BINARY_OPTS + ["--bfbs-filenames", str(tests_path)],
|
||||
include="include_test",
|
||||
|
||||
Reference in New Issue
Block a user