MCPcopy Create free account
hub / github.com/apache/fory / compile_file_recursive

Function compile_file_recursive

compiler/fory_compiler/cli.py:847–951  ·  view source on GitHub ↗
(
    file_path: Path,
    lang_output_dirs: Dict[str, Path],
    import_paths: List[Path],
    go_nested_type_style: Optional[str],
    swift_namespace_style: Optional[str],
    emit_fdl: bool,
    emit_fdl_path: Optional[Path],
    generated: Set[Path],
    stack: Set[Path],
    resolve_cache: Dict[Path, Schema],
    go_module_root: Optional[Path],
    generated_outputs: Dict[Path, Path],
    grpc: bool = False,
    grpc_web: bool = False,
    grpc_python_mode: str = "async",
)

Source from the content-addressed store, hash-verified

845
846
847def compile_file_recursive(
848 file_path: Path,
849 lang_output_dirs: Dict[str, Path],
850 import_paths: List[Path],
851 go_nested_type_style: Optional[str],
852 swift_namespace_style: Optional[str],
853 emit_fdl: bool,
854 emit_fdl_path: Optional[Path],
855 generated: Set[Path],
856 stack: Set[Path],
857 resolve_cache: Dict[Path, Schema],
858 go_module_root: Optional[Path],
859 generated_outputs: Dict[Path, Path],
860 grpc: bool = False,
861 grpc_web: bool = False,
862 grpc_python_mode: str = "async",
863) -> bool:
864 file_path = file_path.resolve()
865 if file_path in generated:
866 return True
867 if file_path in stack:
868 raise ImportError(f"Circular import detected: {file_path}")
869
870 stack.add(file_path)
871 try:
872 schema = parse_idl_file(file_path)
873 except OSError as e:
874 print(f"Error reading {file_path}: {e}", file=sys.stderr)
875 stack.remove(file_path)
876 return False
877 except (FrontendError, ValueError) as e:
878 print(f"Error: {e}", file=sys.stderr)
879 stack.remove(file_path)
880 return False
881
882 if "go" in lang_output_dirs and go_module_root is None:
883 go_module_root = resolve_go_module_root(lang_output_dirs["go"], schema)
884
885 effective_outputs = lang_output_dirs
886 if "go" in lang_output_dirs:
887 go_root = go_module_root or lang_output_dirs["go"]
888 if (
889 schema.get_option("go_package") is None
890 and lang_output_dirs["go"] != go_root
891 ):
892 go_out = lang_output_dirs["go"]
893 else:
894 go_out = resolve_go_output_dir(go_root, schema)
895 if go_out != lang_output_dirs["go"]:
896 effective_outputs = dict(lang_output_dirs)
897 effective_outputs["go"] = go_out
898
899 for imp in schema.imports:
900 import_path = resolve_import_path(imp.path, file_path, import_paths)
901 if import_path is None:
902 searched = [str(file_path.parent)]
903 searched.extend(str(p) for p in import_paths)
904 line = imp.location.line if imp.location else imp.line

Callers 1

cmd_compileFunction · 0.85

Calls 10

parse_idl_fileFunction · 0.90
resolve_import_pathFunction · 0.90
ImportErrorClass · 0.85
resolve_go_module_rootFunction · 0.85
resolve_go_output_dirFunction · 0.85
compile_fileFunction · 0.85
get_optionMethod · 0.80
extendMethod · 0.80
addMethod · 0.65
removeMethod · 0.45

Tested by

no test coverage detected