David Ostrovsky | b81b4f7 | 2016-05-21 19:55:01 +0200 | [diff] [blame] | 1 | # Copyright (C) 2016 The Android Open Source Project |
| 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 | # Syntactic sugar for native genrule() rule: |
| 16 | # expose ROOT shell variable |
| 17 | # expose TMP shell variable |
David Ostrovsky | b81b4f7 | 2016-05-21 19:55:01 +0200 | [diff] [blame] | 18 | |
Han-Wen Nienhuys | 29cced5 | 2016-10-27 11:57:01 +0200 | [diff] [blame] | 19 | def genrule2(cmd, **kwargs): |
Han-Wen Nienhuys | b6a4048 | 2018-07-10 11:51:36 +0200 | [diff] [blame] | 20 | cmd = " && ".join([ |
| 21 | "ROOT=$$PWD", |
| 22 | "TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)", |
| 23 | "(" + cmd + ")", |
David Ostrovsky | df03895 | 2019-10-31 23:43:47 +0100 | [diff] [blame] | 24 | "rm -rf $$TMP", |
Han-Wen Nienhuys | b6a4048 | 2018-07-10 11:51:36 +0200 | [diff] [blame] | 25 | ]) |
| 26 | native.genrule( |
| 27 | cmd = cmd, |
| 28 | **kwargs |
| 29 | ) |