| #!/bin/bash |
| |
| # Copyright 2023 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. |
| # |
| # This script generates Rust bindings for the usb_bulk C++ library. |
| |
| # 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 "${SCRIPT_DIR}/../../../tools/devshell/lib/vars.sh" |
| |
| set -eu |
| |
| cd "${SCRIPT_DIR}" |
| |
| readonly RELPATH="${FULL_PATH#${FUCHSIA_DIR}/}" |
| readonly BINDGEN="${PREBUILT_RUST_BINDGEN_DIR}/bindgen" |
| |
| # Generate annotations for the top of the generated source file. |
| readonly RAW_LINES="// Copyright 2023 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(dead_code)] |
| #![allow(non_camel_case_types)] |
| #![allow(non_snake_case)] |
| #![allow(non_upper_case_globals)] |
| #![allow(improper_ctypes)] |
| #![allow(clippy::approx_constant)] |
| |
| // Configure linkage for MacOS. |
| #[cfg(target_os = \"macos\")] |
| #[link(name = \"IOKit\", kind = \"framework\")] |
| #[link(name = \"CoreFoundation\", kind = \"framework\")] |
| extern \"C\" {}" |
| |
| "${BINDGEN}" \ |
| ${SCRIPT_DIR}/iokit_usb_stub.h \ |
| --disable-header-comment \ |
| --raw-line "${RAW_LINES}" \ |
| --with-derive-default \ |
| --impl-debug \ |
| --no-debug "mach_voucher_attr_recipe_data|IOAsyncCompletionContent|IOUSBDeviceCapabilitySuperSpeedPlusUSB|IOUSBDeviceCapabilityBillboard" \ |
| --output src/usb_osx/iokit_usb.rs \ |
| -- -isysroot $(xcrun --sdk macosx --show-sdk-path) |