iirina | d4651e8 | 2019-03-15 03:15:37 -0700 | [diff] [blame] | 1 | # 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 | |
iirina | a4de484 | 2019-08-08 03:05:51 -0700 | [diff] [blame] | 17 | load("@rules_java//java:defs.bzl", "java_import") |
| 18 | |
iirina | d4651e8 | 2019-03-15 03:15:37 -0700 | [diff] [blame] | 19 | def _get_args(target, attr, **kwargs): |
| 20 | workspace_target_dict = { |
| 21 | "//src/conditions:linux_x86_64": ["@remote_java_tools_linux//" + target], |
| 22 | "//src/conditions:darwin": ["@remote_java_tools_darwin//" + target], |
| 23 | "//src/conditions:darwin_x86_64": ["@remote_java_tools_darwin//" + target], |
| 24 | "//src/conditions:windows": ["@remote_java_tools_windows//" + target], |
| 25 | # On different platforms the linux repository can be used. |
| 26 | # The deploy jars inside the linux repository are platform-agnostic. |
| 27 | # The ijar target inside the repository identifies the different |
| 28 | # platform and builds ijar from source instead of returning the |
| 29 | # precompiled binary. |
| 30 | "//conditions:default": ["@remote_java_tools_linux//" + target], |
| 31 | } |
| 32 | workspace_target_select = select(workspace_target_dict) |
| 33 | args = dict({attr: workspace_target_select}) |
| 34 | args.update(kwargs) |
| 35 | return args |
| 36 | |
| 37 | def remote_java_tools_filegroup(name, target, **kwargs): |
| 38 | args = _get_args(target, "srcs", **kwargs) |
| 39 | native.filegroup(name = name, **args) |
| 40 | |
| 41 | def remote_java_tools_java_import(name, target, **kwargs): |
| 42 | args = _get_args(target, "jars", **kwargs) |
iirina | a4de484 | 2019-08-08 03:05:51 -0700 | [diff] [blame] | 43 | java_import(name = name, **args) |