# Copyright (C) 2025 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.
#
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULE := $(LOCAL_DIR)
MODULE_SRCS := $(LOCAL_DIR)/src/lib.rs
MODULE_CRATE_NAME := peer_id
MODULE_ADD_IMPLICIT_DEPS := false
MODULE_LIBRARY_EXPORTED_DEPS += \
$(
call FIND_CRATE,zerocopy) \
trusty/kernel/lib/shared/peer_id \
# In userspace we get our ffi types from trusty-ffi-sys instead of core::ffi.
ifeq ($(
call TOBOOL,$(TRUSTY_USERSPACE)),true)
MODULE_LIBRARY_EXPORTED_DEPS += \
trusty/user/base/lib/trusty-types-sys \
trusty/user/base/lib/libc-trusty \
MODULE_RUSTFLAGS += --cfg
'feature="userspace"'
endif
MODULE_LIBRARY_DEPS += \
trusty/user/base/lib/libcore-rust \
trusty/user/base/lib/libcompiler_builtins-rust \
MODULE_RUST_USE_CLIPPY := true
MODULE_BINDGEN_ALLOW_TYPES := \
uuid \
trusty_peer_id \
trusty_peer_id_kind_t \
trusty_peer_id_storage \
trusty_peer_id_uuid \
trusty_peer_id_vmid_ffa \
trusty_peer_id_sized \
trusty_peer_id_uuid_sized \
trusty_peer_id_vmid_ffa_sized \
MODULE_BINDGEN_ALLOW_VARS := \
kernel_uuid \
zero_uuid \
TRUSTY_AT_SELF_PEER_IDS \
TRUSTY_PEER_ID_KIND_FIRST_USERSPACE_AVAILABLE \
TRUSTY_PEER_ID_KIND_INVALID \
TRUSTY_PEER_ID_KIND_UUID \
TRUSTY_PEER_ID_KIND_VMID_FFA \
UUID_STR_SIZE \
MODULE_BINDGEN_SRC_HEADER := $(LOCAL_DIR)/bindings.h
MODULE_BINDGEN_FLAGS := \
--with-derive-eq \
--with-derive-hash \
--no-debug uuid \
--with-derive-custom=
"uuid=zerocopy::IntoBytes, zerocopy::Immutable, zerocopy::FromBytes" \
--with-derive-custom=
"trusty_peer_id_storage=zerocopy::FromBytes, zerocopy::IntoBytes, zerocopy::Immutable" \
include make/library.mk