skip generating reflection.fbs in generate_scripts (#7077)

This commit is contained in:
Derek Bailey 2022-02-02 22:42:26 -08:00 committed by GitHub
parent fd0d1ed929
commit 826193ff68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 17 deletions

View File

@ -552,7 +552,7 @@ if(Python3_Interpreter_FOUND)
add_custom_command( add_custom_command(
TARGET flatc TARGET flatc
POST_BUILD POST_BUILD
COMMAND ${Python3_EXECUTABLE} scripts/generate_code.py ${GENERATION_OPTS} COMMAND ${Python3_EXECUTABLE} scripts/generate_code.py ${GENERATION_OPTS} --skip-gen-reflection
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMENT "Running scripts/generate_code.py..." COMMENT "Running scripts/generate_code.py..."
VERBATIM) VERBATIM)

View File

@ -34,6 +34,11 @@ parser.add_argument(
action="store_true", action="store_true",
help="skip generating tests involving monster_extra.fbs", 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() args = parser.parse_args()
# Get the path where this script is located so we can invoke the script from # 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", "--gen-object-api",
] ]
RUST_OPTS = BASE_OPTS + ["--rust", "--gen-all", "--gen-name-strings"] 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"] TS_OPTS = ["--ts", "--gen-name-strings"]
LOBSTER_OPTS = ["--lobster"] LOBSTER_OPTS = ["--lobster"]
SWIFT_OPTS = ["--swift", "--gen-json-emit", "--bfbs-filenames", str(tests_path)] SWIFT_OPTS = ["--swift", "--gen-json-emit", "--bfbs-filenames", str(tests_path)]
@ -138,7 +148,7 @@ flatc(
flatc( flatc(
["--lua", "--bfbs-filenames", str(tests_path)], ["--lua", "--bfbs-filenames", str(tests_path)],
schema="monster_test.fbs", schema="monster_test.fbs",
include="include_test" include="include_test",
) )
flatc( flatc(
@ -412,17 +422,22 @@ flatc(
) )
# Reflection # Reflection
temp_dir = ".tmp" # Skip generating the reflection if told too, as we run this script after
flatc( # 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"], ["-c", "--cpp-std", "c++0x", "--no-prefix"],
prefix=temp_dir, prefix=temp_dir,
schema="reflection.fbs", schema="reflection.fbs",
cwd=reflection_path, cwd=reflection_path,
) )
new_reflection_file = Path(reflection_path, temp_dir, "reflection_generated.h") new_reflection_file = Path(
original_reflection_file = Path( reflection_path, temp_dir, "reflection_generated.h"
)
original_reflection_file = Path(
root_path, "include/flatbuffers/reflection_generated.h" root_path, "include/flatbuffers/reflection_generated.h"
) )
if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)): if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)):
shutil.move(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))) shutil.rmtree(str(Path(reflection_path, temp_dir)))