Thomas Vachuska | 9379a07 | 2018-08-21 14:19:02 -0700 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
| 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 | def _local_jar_impl(repository_ctx): |
Thomas Vachuska | 6a17acd | 2018-10-29 15:17:17 -0700 | [diff] [blame] | 16 | file = repository_ctx.attr.path.split("/")[-1] |
| 17 | repository_ctx.symlink(repository_ctx.attr.path, "%s" % file) |
| 18 | repository_ctx.file("BUILD", content = """ |
Thomas Vachuska | 9379a07 | 2018-08-21 14:19:02 -0700 | [diff] [blame] | 19 | # DO NOT EDIT: automatically generated BUILD file for local_jar rule |
| 20 | java_import( |
Thomas Vachuska | 6a17acd | 2018-10-29 15:17:17 -0700 | [diff] [blame] | 21 | name = "%s", |
| 22 | jars = ["%s"], |
Thomas Vachuska | 9379a07 | 2018-08-21 14:19:02 -0700 | [diff] [blame] | 23 | visibility = ['//visibility:public'] |
| 24 | ) |
Thomas Vachuska | 6a17acd | 2018-10-29 15:17:17 -0700 | [diff] [blame] | 25 | """ % (repository_ctx.attr.name, file)) |
| 26 | repository_ctx.file("WORKSPACE", content = """ |
| 27 | # DO NOT EDIT: automatically generated BUILD file for local_jar rule |
| 28 | workspace(name = "%s") |
| 29 | """ % repository_ctx.attr.name) |
| 30 | repository_ctx.file("jar/BUILD", content = """ |
| 31 | # DO NOT EDIT: automatically generated BUILD file for local_jar rule |
| 32 | |
| 33 | package(default_visibility = ["//visibility:public"]) |
| 34 | |
| 35 | alias( |
| 36 | name = "jar", |
| 37 | actual = "@%s", |
| 38 | ) |
Thomas Vachuska | 9379a07 | 2018-08-21 14:19:02 -0700 | [diff] [blame] | 39 | """ % repository_ctx.attr.name) |
| 40 | |
| 41 | # Workspace rule to allow override of a single locally built 3rd party jar |
| 42 | local_jar = repository_rule( |
| 43 | implementation = _local_jar_impl, |
| 44 | local = True, |
| 45 | attrs = {"path": attr.string(mandatory = True)}, |
| 46 | ) |
| 47 | |
| 48 | # Macro to allow building ONOS against locally-built Atomix artifacts |
| 49 | def local_atomix(path, version): |
| 50 | local_jar( |
| 51 | name = "atomix", |
| 52 | path = "%s/core/target/atomix-%s.jar" % (path, version), |
| 53 | ) |
| 54 | local_jar( |
| 55 | name = "atomix_cluster", |
| 56 | path = "%s/cluster/target/atomix-cluster-%s.jar" % (path, version), |
| 57 | ) |
| 58 | local_jar( |
| 59 | name = "atomix_dist", |
| 60 | path = "%s/dist/target/atomix-dist-%s.jar" % (path, version), |
| 61 | ) |
| 62 | local_jar( |
| 63 | name = "atomix_primitive", |
| 64 | path = "%s/primitive/target/atomix-primitive-%s.jar" % (path, version), |
| 65 | ) |
| 66 | local_jar( |
| 67 | name = "atomix_tests", |
| 68 | path = "%s/tests/target/atomix-tests-%s.jar" % (path, version), |
| 69 | ) |
| 70 | local_jar( |
| 71 | name = "atomix_utils", |
| 72 | path = "%s/utils/target/atomix-utils-%s.jar" % (path, version), |
| 73 | ) |
| 74 | local_jar( |
| 75 | name = "atomix_agent", |
| 76 | path = "%s/agent/target/atomix-agent-%s.jar" % (path, version), |
| 77 | ) |
| 78 | local_jar( |
| 79 | name = "atomix_storage", |
| 80 | path = "%s/storage/target/atomix-storage-%s.jar" % (path, version), |
| 81 | ) |
| 82 | local_jar( |
| 83 | name = "atomix_gossip", |
| 84 | path = "%s/protocols/gossip/target/atomix-gossip-%s.jar" % (path, version), |
| 85 | ) |
| 86 | local_jar( |
| 87 | name = "atomix_primary_backup", |
| 88 | path = "%s/protocols/primary-backup/target/atomix-primary-backup-%s.jar" % (path, version), |
| 89 | ) |
| 90 | local_jar( |
| 91 | name = "atomix_raft", |
| 92 | path = "%s/protocols/raft/target/atomix-raft-%s.jar" % (path, version), |
| 93 | ) |
| 94 | local_jar( |
| 95 | name = "atomix_rest", |
| 96 | path = "%s/rest/target/atomix-rest-%s.jar" % (path, version), |
| 97 | ) |
| 98 | |
Thomas Vachuska | c4d0377 | 2018-11-26 10:53:58 -0800 | [diff] [blame] | 99 | # Macro to allow building ONOS against locally-built YANG tools artifacts |
| 100 | def local_yang_tools(path, version): |
| 101 | local_jar( |
| 102 | name = "onos_yang_model", |
| 103 | path = "%s/model/target/onos-yang-model-%s.jar" % (path, version), |
| 104 | ) |
| 105 | local_jar( |
| 106 | name = "onos_yang_compiler_api", |
| 107 | path = "%s/compiler/api/target/onos-yang-compiler-api-%s.jar" % (path, version), |
| 108 | ) |
| 109 | local_jar( |
| 110 | name = "onos_yang_compiler_main", |
| 111 | path = "%s/compiler/plugin/main/target/onos-yang-compiler-main-%s.jar" % (path, version), |
| 112 | ) |
| 113 | local_jar( |
| 114 | name = "onos_yang_runtime", |
| 115 | path = "%s/runtime/target/onos-yang-runtime-%s.jar" % (path, version), |
| 116 | ) |
| 117 | local_jar( |
| 118 | name = "onos_yang_serializers_json", |
| 119 | path = "%s/serializers/json/target/onos-yang-serializers-json-%s.jar" % (path, version), |
| 120 | ) |
| 121 | local_jar( |
| 122 | name = "onos_yang_serializers_xml", |
| 123 | path = "%s/serializers/xml/target/onos-yang-serializers-xml-%s.jar" % (path, version), |
| 124 | ) |
| 125 | local_jar( |
| 126 | name = "onos_yang_serializers_utils", |
| 127 | path = "%s/serializers/utils/target/onos-yang-serializers-utils-%s.jar" % (path, version), |
| 128 | ) |