blob: e1a7b4836f0a839fa41df311b93cbf55acddfbc9 [file] [log] [blame]
#!/usr/bin/env fuchsia-vendored-python
#
# Copyright 2024 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import sys
from pathlib import Path
# Add //build/rust to Python path so the bindgen import works.
FUCHSIA_DIR = Path(__file__).parent.parent.parent.parent.parent
sys.path.append(str(FUCHSIA_DIR / "build" / "rust"))
from bindgen import Bindgen
TEE_INTERNAL_API_DIR = (
FUCHSIA_DIR / "src" / "microfuchsia" / "tee" / "tee_internal_api"
)
INPUT_FILE = (
TEE_INTERNAL_API_DIR
/ "include"
/ "lib"
/ "tee_internal_api"
/ "tee_internal_api.h"
)
OUTPUT_FILE = TEE_INTERNAL_API_DIR / "src" / "binding.rs"
RELATIVE_SCRIPT_PATH = Path(__file__).relative_to(FUCHSIA_DIR)
RAW_LINES = f"""
// This file is automatically generated by //{RELATIVE_SCRIPT_PATH}.
"""
bindgen = Bindgen()
bindgen.raw_lines = RAW_LINES
bindgen.include_dirs = ["zircon/system/public"]
bindgen.std_impls = ["debug"]
bindgen.std_derives = ["partialeq"]
bindgen.function_allowlist = ["TEE_.*", "TA_.*"]
bindgen.type_allowlist = ["TEE_.*"]
bindgen.var_allowlist = ["TEE_.*"]
bindgen.run(str(INPUT_FILE), str(OUTPUT_FILE))