mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-10 20:19:07 +00:00
This search/replace updates all copyright notices to drop the "All rights reserved", Use "ChromiumOS" instead of "Chromium OS" and drops the trailing dots. This fulfills the request from legal and unifies our notices. ./tools/health-check has been updated to only accept this style. BUG=b:246579983 TEST=./tools/health-check Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dennis Kempin <denniskempin@google.com>
74 lines
2.7 KiB
Bash
Executable file
74 lines
2.7 KiB
Bash
Executable file
# Copyright 2022 The ChromiumOS Authors
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Helper functions for bindgen scripts sourced by tools/bindgen-all-the-things.
|
|
|
|
# virtio-video bindings need some types that are only in the 5.10-arcvm branch.
|
|
# This should be switched to a vanilla kernel when these are upstream.
|
|
export BINDGEN_LINUX="${PWD}/../../third_party/kernel/v5.10-arcvm"
|
|
|
|
export BINDGEN_PLATFORM2="${PWD}/../../platform2"
|
|
|
|
export BINDGEN_OPTS=(
|
|
'--disable-header-comment'
|
|
'--no-layout-tests'
|
|
'--no-doc-comments'
|
|
'--with-derive-default'
|
|
'--size_t-is-usize'
|
|
)
|
|
|
|
export BINDGEN_HEADER="/* automatically generated by tools/bindgen-all-the-things */
|
|
|
|
#![allow(non_upper_case_globals)]
|
|
#![allow(non_camel_case_types)]
|
|
#![allow(non_snake_case)]
|
|
#![allow(dead_code)]
|
|
"
|
|
|
|
# Delete definitions of types like __u32 and replace their uses with the equivalent native Rust
|
|
# type, like u32. This ensures that the types are correctly sized on all platforms, unlike the
|
|
# definitions from the system headers, which resolve to C types like short/int/long that may vary
|
|
# across architectures.
|
|
replace_linux_int_types() {
|
|
sed -E -e '/^pub type __(u|s)(8|16|32|64) =/d' -e 's/__u(8|16|32|64)/u\1/g' -e 's/__s(8|16|32|64)/i\1/g'
|
|
cat
|
|
}
|
|
|
|
# Delete definitions of types like __le32 and __be32 and replace their uses with the equivalent
|
|
# data_model types.
|
|
replace_linux_endian_types() {
|
|
sed -E -e '/^pub type __(l|b)e(16|32|64) =/d' -e 's/__le(16|32|64)/Le\1/g' -e 's/__be(16|32|64)/Be\1/g'
|
|
}
|
|
|
|
# Wrapper for bindgen used by the various bindgen.sh scripts.
|
|
# Pass extra bindgen options and the .h filename as parameters.
|
|
# Output is produced on stdout and should be redirected to a file.
|
|
bindgen_generate() {
|
|
echo "${BINDGEN_HEADER}"
|
|
bindgen "${BINDGEN_OPTS[@]}" "$@"
|
|
}
|
|
|
|
bindgen_cleanup() {
|
|
rm -rf "${BINDGEN_LINUX_X86_HEADERS}" "${BINDGEN_LINUX_ARM64_HEADERS}"
|
|
}
|
|
|
|
# Install Linux kernel headers for x86 and arm into temporary locations. These are used for KVM bindings.
|
|
|
|
if [[ -z "${BINDGEN_LINUX_X86_HEADERS+x}" || ! -d "${BINDGEN_LINUX_X86_HEADERS}" || \
|
|
-z "${BINDGEN_LINUX_ARM64_HEADERS+x}" || ! -d "${BINDGEN_LINUX_ARM64_HEADERS}" ]]; then
|
|
export BINDGEN_LINUX_X86_HEADERS='/tmp/bindgen_linux_x86_headers'
|
|
export BINDGEN_LINUX_ARM64_HEADERS='/tmp/bindgen_linux_arm64_headers'
|
|
|
|
trap bindgen_cleanup EXIT
|
|
|
|
echo -n "Installing Linux headers for x86 and arm64..."
|
|
(
|
|
cd "${BINDGEN_LINUX}"
|
|
nproc=$(nproc)
|
|
make -s headers_install ARCH=x86 INSTALL_HDR_PATH="${BINDGEN_LINUX_X86_HEADERS}" -j "${nproc}"
|
|
make -s headers_install ARCH=arm64 INSTALL_HDR_PATH="${BINDGEN_LINUX_ARM64_HEADERS}" -j "${nproc}"
|
|
make -s mrproper
|
|
)
|
|
echo " done."
|
|
fi
|