| #!/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 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) |
| |
| RAW_LINES = 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} |
| """ |
| |
| bindgen = Bindgen() |
| bindgen.raw_lines = RAW_LINES |
| bindgen.additional_clang_flags = ["-x", "c++", "-std=c++17"] |
| |
| # Avoid bringing in all of the C standard types unnecessarily. |
| bindgen.function_allowlist = [ |
| "symbolizer_global_init", |
| "symbolizer_global_cleanup", |
| "symbolizer_new", |
| "symbolizer_free", |
| "symbolizer_reset", |
| "symbolizer_add_module", |
| "symbolizer_add_mapping", |
| "symbolizer_resolve_address", |
| ] |
| |
| bindgen.run( |
| "src/developer/ffx/lib/symbolize/sys/wrapper.h", |
| "src/developer/ffx/lib/symbolize/sys/src/lib.rs", |
| ) |