| #!/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_NOTICE_HEADER = f""" |
| /* |
| * Copyright (C) 2021 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| """ |
| |
| |
| 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 |
| + """ |
| |
| use binder_ndk_sys::AIBinder; |
| |
| """ |
| ) |
| |
| |
| # Cross-architecture include paths (the ArchInfo class also has an arch-specific one to add). |
| INCLUDE_DIRS = [ |
| "third_party/android/platform/frameworks/native/libs/binder/ndk/include_cpp", |
| "third_party/android/platform/frameworks/native/libs/binder/ndk/include_ndk", |
| "third_party/android/platform/frameworks/native/libs/binder/ndk/include_platform", |
| "third_party/android/platform/frameworks/native/libs/binder/include_rpc_unstable", |
| ] |
| |
| INPUT_FILE = "third_party/android/platform/frameworks/native/libs/binder/rust/rpcbinder/BinderBindings.hpp" |
| |
| bindgen = Bindgen() |
| bindgen.ignore_functions = False |
| bindgen.enable_stdlib_include_dirs = True |
| bindgen.clang_target = "x86_64-linux-gnu" |
| bindgen.notice_header = MODULE_NOTICE_HEADER |
| bindgen.raw_lines = RAW_LINES |
| bindgen.include_dirs = INCLUDE_DIRS |
| rust_file = "src/lib/android/binder/rust/rpcbinder/third_party/binder_rpc_unstable_bindgen/lib.rs" |
| bindgen.additional_clang_flags = ["--std=c++20", "-x", "c++"] |
| bindgen.type_allowlist = [ |
| "ARpc.*", |
| ] |
| bindgen.type_blocklist = [ |
| "AIBinder", |
| ] |
| bindgen.function_allowlist = ["ARpc.*"] |
| bindgen.additional_bindgen_flags = [ |
| "--rustified-enum", |
| "ARpcSession_FileDescriptorTransportMode", |
| ] |
| bindgen.run(INPUT_FILE, rust_file) |