blob: 3ea91f259e9c9390ab30b674f15637aad5791fcf [file] [log] [blame]
iirinad4651e82019-03-15 03:15:37 -07001# Copyright 2017 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"""A collection of macros that retrieve targets from the remote java tools."""
16
17def _get_args(target, attr, **kwargs):
18 workspace_target_dict = {
19 "//src/conditions:linux_x86_64": ["@remote_java_tools_linux//" + target],
20 "//src/conditions:darwin": ["@remote_java_tools_darwin//" + target],
21 "//src/conditions:darwin_x86_64": ["@remote_java_tools_darwin//" + target],
22 "//src/conditions:windows": ["@remote_java_tools_windows//" + target],
23 # On different platforms the linux repository can be used.
24 # The deploy jars inside the linux repository are platform-agnostic.
25 # The ijar target inside the repository identifies the different
26 # platform and builds ijar from source instead of returning the
27 # precompiled binary.
28 "//conditions:default": ["@remote_java_tools_linux//" + target],
29 }
30 workspace_target_select = select(workspace_target_dict)
31 args = dict({attr: workspace_target_select})
32 args.update(kwargs)
33 return args
34
35def remote_java_tools_filegroup(name, target, **kwargs):
36 args = _get_args(target, "srcs", **kwargs)
37 native.filegroup(name = name, **args)
38
39def remote_java_tools_java_import(name, target, **kwargs):
40 args = _get_args(target, "jars", **kwargs)
41 native.java_import(name = name, **args)