Lorenz Brun | 878f5f9 | 2020-05-12 16:15:39 +0200 | [diff] [blame^] | 1 | # Copyright 2020 The Monogon Project Authors. |
| 2 | # |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | def _os_release_impl(ctx): |
| 18 | ctx.actions.run( |
| 19 | mnemonic = "GenOSRelease", |
| 20 | progress_message = "Generating os-release", |
| 21 | inputs = [ctx.info_file], |
| 22 | outputs = [ctx.outputs.out], |
| 23 | executable = ctx.executable._genosrelease, |
| 24 | arguments = [ |
| 25 | "-status_file", |
| 26 | ctx.info_file.path, |
| 27 | "-out_file", |
| 28 | ctx.outputs.out.path, |
| 29 | "-stamp_var", |
| 30 | ctx.attr.stamp_var, |
| 31 | "-name", |
| 32 | ctx.attr.os_name, |
| 33 | "-id", |
| 34 | ctx.attr.os_id, |
| 35 | ], |
| 36 | ) |
| 37 | |
| 38 | os_release = rule( |
| 39 | implementation = _os_release_impl, |
| 40 | attrs = { |
| 41 | "os_name": attr.string(mandatory = True), |
| 42 | "os_id": attr.string(mandatory = True), |
| 43 | "stamp_var": attr.string(mandatory = True), |
| 44 | "_genosrelease": attr.label( |
| 45 | default = Label("//core/build/genosrelease"), |
| 46 | cfg = "host", |
| 47 | executable = True, |
| 48 | allow_files = True, |
| 49 | ), |
| 50 | }, |
| 51 | outputs = { |
| 52 | "out": "os-release", |
| 53 | }, |
| 54 | ) |