1import sys 2from pathlib import Path 3 4# Get the path where this script is located so we can invoke the script from 5# any directory and have the paths work correctly. 6script_path = Path(__file__).parent.resolve() 7 8# Get the root path as an absolute path, so all derived paths are absolute. 9root_path = script_path.parent.absolute() 10 11# Get the location of the schema 12schema_path = Path(script_path, "schema") 13 14# Too add the util package in /scripts/util.py 15sys.path.append(str(root_path.absolute())) 16 17from scripts.util import flatc 18 19 20def flatc_golden(options, schema, prefix): 21 # wrap the generic flatc call with specifis for these goldens. 22 flatc( 23 options=options, 24 # where the files are generated, typically the language (e.g. "cpp"). 25 prefix=prefix, 26 # The schema are relative to the schema directory. 27 schema=str(Path(schema_path, schema)), 28 # Run flatc from this location. 29 cwd=script_path, 30 ) 31