| #!/usr/bin/env bash |
| # Copyright 2022 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. |
| |
| # Determine paths for this script and its directory, and set $FUCHSIA_DIR. |
| readonly FULL_PATH="${BASH_SOURCE[0]}" |
| readonly SCRIPT_DIR="$(cd "$(dirname "${FULL_PATH}")" >/dev/null 2>&1 && pwd)" |
| source "${FUCHSIA_DIR}/tools/devshell/lib/vars.sh" |
| |
| set -eu |
| |
| cd "${SCRIPT_DIR}" |
| |
| readonly RELPATH="${FULL_PATH#${FUCHSIA_DIR}/}" |
| readonly BINDGEN="${PREBUILT_RUST_BINDGEN_DIR}/bindgen" |
| readonly HEADER_PATH="${FUCHSIA_DIR}/third_party/tpm2-tss/src/include/tss2" |
| # Generate annotations for the top of the generated source file. |
| readonly RAW_LINES="// Copyright 2022 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. |
| |
| // Generated by ${RELPATH} using $("${BINDGEN}" --version) |
| |
| #![allow(non_camel_case_types)] |
| #![allow(non_snake_case)] |
| #![allow(non_upper_case_globals)] |
| |
| mod tss2_tpm2_types; |
| |
| pub use crate::tss2_tpm2_types::*; |
| " |
| |
| readonly OUTPUT="src/lib.rs" |
| "${BINDGEN}" \ |
| "bindgen.h" \ |
| --blocklist-type=max_align_t \ |
| --disable-header-comment \ |
| --no-layout-tests \ |
| --raw-line "${RAW_LINES}" \ |
| --allowlist-function '(Tss2|Esys)_.+' \ |
| --allowlist-var '(ESYS)_.+' \ |
| -o"${OUTPUT}" \ |
| -- \ |
| -I "${HEADER_PATH}" |
| |
| fx format-code --files=${OUTPUT} |