1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15""" 16This file contains flags to be set on the toolchains 17""" 18 19load("@soong_injection//rust_toolchain:constants.bzl", "constants") 20 21# rust flags that are applied to both host and device build 22_global_rustc_flags = list(constants.GLOBAL_RUSTC_FLAGS) 23 24# https://github.com/bazelbuild/rules_rust/blob/aa4b3a862a8200c9422b7f7e050b12c7ef2c2a61/rust/private/rustc.bzl#L959 25# rules_rust already set `--color=always` 26_global_rustc_flags.remove("--color=always") 27 28# TODO: b/301466790 - Set linting flags to rustc before checking in BUILD files 29_global_rustc_flags.append("--cap-lints=allow") 30 31# host rust flags 32_linux_host_rustc_flags = ["-Clink-args={}".format(" ".join(constants.LINUX_HOST_GLOBAL_LINK_FLAGS))] 33 34# device rust flags 35_device_global_rustc_flags = list(constants.DEVICE_GLOBAL_RUSTC_FLAGS) 36 37_device_global_rustc_flags.extend( 38 ["-Clink-args={}".format(" ".join(constants.DEVICE_GLOBAL_LINK_FLAGS))], 39) 40 41flags = struct( 42 global_rustc_flags = _global_rustc_flags, 43 # host rust flags 44 linux_host_rustc_flags = _linux_host_rustc_flags, 45 # device rust flags 46 device_global_rustc_flags = _device_global_rustc_flags, 47 device_arm64_rustc_flags = constants.DEVICE_ARM64_RUSTC_FLAGS, 48 device_arm_rustc_flags = constants.DEVICE_ARM_RUSTC_FLAGS, 49 device_x86_64_rustc_flags = constants.DEVICE_X86_64_RUSTC_FLAGS, 50 device_x86_rustc_flags = constants.DEVICE_X86_RUSTC_FLAGS, 51) 52