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