summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDerek Bailey <derekbailey@google.com>2022-02-02 22:42:26 -0800
committerGitHub <noreply@github.com>2022-02-02 22:42:26 -0800
commit826193ff68f72af87d800b1ff0dca0e29dcb9e34 (patch)
tree38f98aa4131ee9e640469a98984f6e620d377662 /scripts
parentfd0d1ed9298d4f495492bfea7e58935d52489bd5 (diff)
downloadflatbuffers-826193ff68f72af87d800b1ff0dca0e29dcb9e34.tar.gz
flatbuffers-826193ff68f72af87d800b1ff0dca0e29dcb9e34.tar.bz2
flatbuffers-826193ff68f72af87d800b1ff0dca0e29dcb9e34.zip
skip generating reflection.fbs in generate_scripts (#7077)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_code.py47
1 files changed, 31 insertions, 16 deletions
diff --git a/scripts/generate_code.py b/scripts/generate_code.py
index 5b3c225e..7a20eddd 100755
--- a/scripts/generate_code.py
+++ b/scripts/generate_code.py
@@ -34,6 +34,11 @@ parser.add_argument(
action="store_true",
help="skip generating tests involving monster_extra.fbs",
)
+parser.add_argument(
+ "--skip-gen-reflection",
+ action="store_true",
+ help="skip generating the reflection.fbs files",
+)
args = parser.parse_args()
# Get the path where this script is located so we can invoke the script from
@@ -103,7 +108,12 @@ CPP_17_OPTS = NO_INCL_OPTS + [
"--gen-object-api",
]
RUST_OPTS = BASE_OPTS + ["--rust", "--gen-all", "--gen-name-strings"]
-RUST_SERIALIZE_OPTS = BASE_OPTS + ["--rust", "--gen-all", "--gen-name-strings", "--rust-serialize"]
+RUST_SERIALIZE_OPTS = BASE_OPTS + [
+ "--rust",
+ "--gen-all",
+ "--gen-name-strings",
+ "--rust-serialize",
+]
TS_OPTS = ["--ts", "--gen-name-strings"]
LOBSTER_OPTS = ["--lobster"]
SWIFT_OPTS = ["--swift", "--gen-json-emit", "--bfbs-filenames", str(tests_path)]
@@ -138,7 +148,7 @@ flatc(
flatc(
["--lua", "--bfbs-filenames", str(tests_path)],
schema="monster_test.fbs",
- include="include_test"
+ include="include_test",
)
flatc(
@@ -412,17 +422,22 @@ flatc(
)
# Reflection
-temp_dir = ".tmp"
-flatc(
- ["-c", "--cpp-std", "c++0x", "--no-prefix"],
- prefix=temp_dir,
- schema="reflection.fbs",
- cwd=reflection_path,
-)
-new_reflection_file = Path(reflection_path, temp_dir, "reflection_generated.h")
-original_reflection_file = Path(
- root_path, "include/flatbuffers/reflection_generated.h"
-)
-if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)):
- shutil.move(str(new_reflection_file), str(original_reflection_file))
-shutil.rmtree(str(Path(reflection_path, temp_dir)))
+# Skip generating the reflection if told too, as we run this script after
+# building flatc which uses the reflection_generated.h itself.
+if not args.skip_gen_reflection:
+ temp_dir = ".tmp"
+ flatc(
+ ["-c", "--cpp-std", "c++0x", "--no-prefix"],
+ prefix=temp_dir,
+ schema="reflection.fbs",
+ cwd=reflection_path,
+ )
+ new_reflection_file = Path(
+ reflection_path, temp_dir, "reflection_generated.h"
+ )
+ original_reflection_file = Path(
+ root_path, "include/flatbuffers/reflection_generated.h"
+ )
+ if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)):
+ shutil.move(str(new_reflection_file), str(original_reflection_file))
+ shutil.rmtree(str(Path(reflection_path, temp_dir)))