1# Copyright 2019 The Bazel Authors. All rights reserved. 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"""Defines the emulator_toolchain rule to allow configuring emulator binaries to use.""" 16 17EmulatorInfo = provider( 18 doc = "Information used to launch a specific version of the emulator.", 19 fields = { 20 "emulator": "A label for the emulator launcher executable at stable version.", 21 "emulator_deps": "Additional files required to launch the stable version of emulator.", 22 "emulator_suffix": "An optional path suffix used to find emulator binary under the emulator label path", 23 }, 24) 25 26def _emulator_toolchain_impl(ctx): 27 toolchain_info = platform_common.ToolchainInfo( 28 info = EmulatorInfo( 29 emulator = ctx.attr.emulator, 30 emulator_deps = ctx.attr.emulator_deps, 31 emulator_suffix = ctx.attr.emulator_suffix, 32 ), 33 ) 34 return [toolchain_info] 35 36emulator_toolchain = rule( 37 implementation = _emulator_toolchain_impl, 38 attrs = { 39 "emulator": attr.label( 40 allow_files = True, 41 cfg = "host", 42 mandatory = True, 43 ), 44 "emulator_deps": attr.label_list( 45 allow_files = True, 46 cfg = "host", 47 ), 48 "emulator_head": attr.label( 49 allow_files = True, 50 cfg = "host", 51 ), 52 "emulator_head_deps": attr.label_list( 53 allow_files = True, 54 cfg = "host", 55 ), 56 "emulator_suffix": attr.string(default = ""), 57 "emulator_head_suffix": attr.string(default = ""), 58 }, 59) 60