Files
flatbuffers/tests/rust_usage_test/outdir/build.rs
Casper c58ae94225 Add the file a symbol is declared in to Reflection (#6613)
* Add the file a symbol is declared in to Reflection

If we move a code-generator to depend on Reflection,
it may need to know which file something was declared in
to properly name generated files.

* Doc comments in reflection, and more precise tests

* Add --project-root flag to flatc, normalize declaraion_file to this root

* fix --project-root stuff

* posixpath

* fix scripts

* format

* rename --project-root to --bfbs-filenames

Also, make it optional, rather than defaulting to `./`, if its not
specified, then don't serialize the filenames.

* bfbs generation

* fix some tests

* uncomment a thing

* add  to project root directory conditionally

* fix

* git clang format

* Added help description and removed != nullptr

* "

* Remove accidental change to docs

* Remove accidental change to docs

* Pool strings

Co-authored-by: Casper Neo <cneo@google.com>
2021-06-17 11:50:04 -04:00

39 lines
1.0 KiB
Rust

fn main() {
use std::process::Command;
let project_root = std::env::current_dir()
.unwrap()
.parent() // flatbuffers/tests/rust_usage test
.unwrap()
.parent() // flatbuffers/tests
.unwrap()
.parent() // flatbuffers/
.unwrap()
.to_path_buf();
let sample_schema = {
let mut s = project_root.to_path_buf();
s.push("samples");
s.push("monster.fbs");
s
};
let flatc = {
let mut f = project_root.to_path_buf();
f.push("flatc");
f
};
let out_dir = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).to_path_buf();
Command::new(&flatc)
.arg("--rust")
.arg(&sample_schema)
.arg("--filename-suffix")
.arg("_gen")
.output()
.expect("Failed to generate file");
let genfile = "monster_gen.rs";
std::fs::rename(&genfile, out_dir.join("monster_generated.rs"))
.expect("Could not rename monster_ge.rs to monster_generated.rs");
}