mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Fix binary output different in different platform (#7718)
* Fix binary output different in different platform, due to the nan serialization * Add check generated code on windows ci * Remove resdundant script * Fix eof, and check script * Minor bug in gen code script * Fix windows script, remove redundant scripts * Undelete redundante codes * Fix github action * Ignore eof generate grpc Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -29,7 +29,7 @@ root_path = script_path.parent.absolute()
|
||||
print("Generating GRPC code...")
|
||||
generate_grpc_examples.GenerateGRPCExamples()
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
|
||||
@@ -26,7 +26,7 @@ script_path = Path(__file__).parent.resolve()
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
@@ -46,7 +46,7 @@ if platform.system() == "Windows":
|
||||
gen_cmd = ["py"] + gen_cmd
|
||||
subprocess.run(gen_cmd, cwd=root_path)
|
||||
|
||||
result = subprocess.run(["git", "diff", "--quiet"], cwd=root_path)
|
||||
result = subprocess.run(["git", "diff", "--quiet", "--ignore-cr-at-eol"], cwd=root_path)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(
|
||||
|
||||
@@ -14,73 +14,19 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import filecmp
|
||||
import glob
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import generate_grpc_examples
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--flatc",
|
||||
help="path of the Flat C compiler relative to the root directory",
|
||||
)
|
||||
parser.add_argument("--cpp-0x", action="store_true", help="use --cpp-std c++ox")
|
||||
parser.add_argument(
|
||||
"--skip-monster-extra",
|
||||
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
|
||||
# any directory and have the paths work correctly.
|
||||
script_path = Path(__file__).parent.resolve()
|
||||
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
|
||||
# Get the location of the flatc executable, reading from the first command line
|
||||
# argument or defaulting to default names.
|
||||
flatc_exe = Path(
|
||||
("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
if not args.flatc
|
||||
else args.flatc
|
||||
)
|
||||
|
||||
# Find and assert flatc compiler is present.
|
||||
if root_path in flatc_exe.parents:
|
||||
flatc_exe = flatc_exe.relative_to(root_path)
|
||||
flatc_path = Path(root_path, flatc_exe)
|
||||
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
|
||||
from util import flatc, root_path, tests_path, args, flatc_path
|
||||
|
||||
# Specify the other paths that will be referenced
|
||||
tests_path = Path(root_path, "tests")
|
||||
swift_code_gen = Path(root_path, "tests/swift/tests/CodeGenerationTests")
|
||||
samples_path = Path(root_path, "samples")
|
||||
reflection_path = Path(root_path, "reflection")
|
||||
|
||||
# Execute the flatc compiler with the specified parameters
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
|
||||
cmd = [str(flatc_path)] + options
|
||||
if prefix:
|
||||
cmd += ["-o"] + [prefix]
|
||||
if include:
|
||||
cmd += ["-I"] + [include]
|
||||
cmd += [schema] if isinstance(schema, str) else schema
|
||||
if data:
|
||||
cmd += [data] if isinstance(data, str) else data
|
||||
result = subprocess.run(cmd, cwd=str(cwd), check=True)
|
||||
|
||||
|
||||
# Generate the code for flatbuffers reflection schema
|
||||
def flatc_reflection(options, location, target):
|
||||
full_options = ["--no-prefix"] + options
|
||||
@@ -150,7 +96,7 @@ SWIFT_OPTS_CODE_GEN = [
|
||||
"--swift",
|
||||
"--gen-json-emit",
|
||||
"--bfbs-filenames",
|
||||
swift_code_gen
|
||||
str(swift_code_gen)
|
||||
]
|
||||
JAVA_OPTS = ["--java"]
|
||||
KOTLIN_OPTS = ["--kotlin"]
|
||||
|
||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
||||
|
||||
grpc_examples_path = Path(root_path, "grpc/examples")
|
||||
|
||||
greeter_schema = Path(grpc_examples_path, "greeter.fbs")
|
||||
greeter_schema = str(Path(grpc_examples_path, "greeter.fbs"))
|
||||
|
||||
COMMON_ARGS = [
|
||||
"--grpc",
|
||||
|
||||
@@ -12,20 +12,44 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import argparse
|
||||
import platform
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--flatc",
|
||||
help="path of the Flat C compiler relative to the root directory",
|
||||
)
|
||||
parser.add_argument("--cpp-0x", action="store_true", help="use --cpp-std c++ox")
|
||||
parser.add_argument(
|
||||
"--skip-monster-extra",
|
||||
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
|
||||
# any directory and have the paths work correctly.
|
||||
script_path = Path(__file__).parent.resolve()
|
||||
|
||||
# Get the root path as an absolute path, so all derived paths are absolute.
|
||||
root_path = script_path.parent.absolute()
|
||||
tests_path = Path(root_path, "tests")
|
||||
|
||||
# Get the location of the flatc executable, reading from the first command line
|
||||
# argument or defaulting to default names.
|
||||
flatc_exe = Path("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
flatc_exe = Path(
|
||||
("flatc" if not platform.system() == "Windows" else "flatc.exe")
|
||||
if not args.flatc
|
||||
else args.flatc
|
||||
)
|
||||
|
||||
# Find and assert flatc compiler is present.
|
||||
if root_path in flatc_exe.parents:
|
||||
@@ -34,18 +58,13 @@ flatc_path = Path(root_path, flatc_exe)
|
||||
assert flatc_path.exists(), "Cannot find the flatc compiler " + str(flatc_path)
|
||||
|
||||
# Execute the flatc compiler with the specified parameters
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=root_path):
|
||||
def flatc(options, schema, prefix=None, include=None, data=None, cwd=tests_path):
|
||||
cmd = [str(flatc_path)] + options
|
||||
if prefix:
|
||||
cmd += ["-o"] + [prefix]
|
||||
if include:
|
||||
cmd += ["-I"] + [include]
|
||||
if isinstance(schema, Path):
|
||||
cmd += [str(schema)]
|
||||
elif isinstance(schema, str):
|
||||
cmd += [schema]
|
||||
else:
|
||||
cmd += schema
|
||||
cmd += [schema] if isinstance(schema, str) else schema
|
||||
if data:
|
||||
cmd += [data] if isinstance(data, str) else data
|
||||
return subprocess.check_call(cmd, cwd=str(cwd))
|
||||
result = subprocess.run(cmd, cwd=str(cwd), check=True)
|
||||
|
||||
Reference in New Issue
Block a user