blob: 394c024994fe84fc742e3df7933d98831d7d6c7d [file]
#!/usr/bin/env fuchsia-vendored-python
#
# Copyright 2024 The Fuchsia Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import sys
# Add //build/rust to Python path so bindgen import works.
FUCHSIA_DIR = os.environ.get(
"FUCHSIA_DIR",
os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", ".."),
)
sys.path.append(os.path.join(FUCHSIA_DIR, "build", "rust"))
from bindgen import Bindgen
RELATIVE_SCRIPT_PATH = os.path.relpath(__file__, FUCHSIA_DIR)
MODULE_DOC_COMMENT = f"""
//! WARNING - This file was auto generated by //{RELATIVE_SCRIPT_PATH}.
//! Do not modify this file. To re-generate, run the following command from the root of
//! your Fuchsia checkout:
//!
//! ./{RELATIVE_SCRIPT_PATH}
"""
RAW_LINES = MODULE_DOC_COMMENT
INCLUDE_DIRS = [
"src/paravirtualization/lib/vsock",
"zircon/third_party/ulib/musl/include",
"zircon/system/public",
]
INPUT_FILE = "src/paravirtualization/lib/vsock/vsock_sys/vsock_sys.h"
bindgen = Bindgen()
bindgen.ignore_functions = False
bindgen.enable_stdlib_include_dirs = False
bindgen.raw_lines = RAW_LINES
bindgen.include_dirs = INCLUDE_DIRS
rust_file = "src/paravirtualization/lib/vsock/vsock_sys/src/lib.rs"
bindgen.type_allowlist = [
"sockaddr_vm",
]
bindgen.function_allowlist = ["create_virtio_stream_socket", "get_local_cid"]
bindgen.run(INPUT_FILE, rust_file)