forked from BigfootDev/flatbuffers
Use ${PYTHON_EXECUTABLE} instead of py in cmake (#7042)
* Emit include for bfbs-gen-embed * Use python3 explicitly * bump min python version to 3.6 * Sort find_package for python * try casting Path to string * cast WindowsPath to string to please CI * stringify the wrong thing * another stringify path
This commit is contained in:
@@ -526,16 +526,16 @@ function(compile_flatbuffers_schema_to_embedded_binary SRC_FBS OPT)
|
|||||||
register_generated_output(${GEN_BFBS_HEADER})
|
register_generated_output(${GEN_BFBS_HEADER})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Look if we have python 3 installed so that we can run the generate code python
|
# Look if we have python 3.5 installed so that we can run the generate code
|
||||||
# script after flatc is built.
|
# python script after flatc is built.
|
||||||
find_package(PythonInterp 3)
|
find_package(PythonInterp 3.5)
|
||||||
|
|
||||||
if(PYTHONINTERP_FOUND AND
|
if(PYTHONINTERP_FOUND AND
|
||||||
# Skip doing this if the MSVC version is below VS 12.
|
# Skip doing this if the MSVC version is below VS 12.
|
||||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(GENERATION_SCRIPT py scripts/generate_code.py)
|
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
||||||
else()
|
else()
|
||||||
set(GENERATION_SCRIPT scripts/generate_code.py)
|
set(GENERATION_SCRIPT scripts/generate_code.py)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def flatc(
|
|||||||
cmd += [schema] if isinstance(schema, str) else schema
|
cmd += [schema] if isinstance(schema, str) else schema
|
||||||
if data:
|
if data:
|
||||||
cmd += [data] if isinstance(data, str) else data
|
cmd += [data] if isinstance(data, str) else data
|
||||||
result = subprocess.run(cmd, cwd=cwd, check=True)
|
result = subprocess.run(cmd, cwd=str(cwd), check=True)
|
||||||
|
|
||||||
|
|
||||||
# Glob a pattern relative to file path
|
# Glob a pattern relative to file path
|
||||||
@@ -360,7 +360,7 @@ assert (
|
|||||||
new_monster_file.exists()
|
new_monster_file.exists()
|
||||||
), "filename suffix option did not produce a file"
|
), "filename suffix option did not produce a file"
|
||||||
assert filecmp.cmp(
|
assert filecmp.cmp(
|
||||||
orig_monster_file, new_monster_file
|
str(orig_monster_file), str(new_monster_file)
|
||||||
), "filename suffix option did not produce identical results"
|
), "filename suffix option did not produce identical results"
|
||||||
new_monster_file.unlink()
|
new_monster_file.unlink()
|
||||||
|
|
||||||
@@ -409,6 +409,6 @@ new_reflection_file = Path(reflection_path, temp_dir, "reflection_generated.h")
|
|||||||
original_reflection_file = Path(
|
original_reflection_file = Path(
|
||||||
root_path, "include/flatbuffers/reflection_generated.h"
|
root_path, "include/flatbuffers/reflection_generated.h"
|
||||||
)
|
)
|
||||||
if not filecmp.cmp(new_reflection_file, original_reflection_file):
|
if not filecmp.cmp(str(new_reflection_file), str(original_reflection_file)):
|
||||||
shutil.move(new_reflection_file, original_reflection_file)
|
shutil.move(str(new_reflection_file), str(original_reflection_file))
|
||||||
shutil.rmtree(Path(reflection_path, temp_dir))
|
shutil.rmtree(str(Path(reflection_path, temp_dir)))
|
||||||
|
|||||||
Reference in New Issue
Block a user