Chris Frantz | 74f9095 | 2022-04-18 20:57:01 -0700 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | NONHERMETIC_ENV_VARS = [ |
| 6 | "HOME", |
| 7 | "PATH", |
| 8 | "XILINX_VIVADO", |
| 9 | "XILINX_HLS", |
| 10 | "XILINXD_LICENSE_FILE", |
| 11 | ] |
| 12 | |
| 13 | def _nonhermetic_repo_impl(rctx): |
| 14 | env = "\n".join([" \"{}\": \"{}\",".format(v, rctx.os.environ.get(v, "")) for v in NONHERMETIC_ENV_VARS]) |
| 15 | rctx.file("env.bzl", "ENV = {{\n{}\n}}\n".format(env)) |
| 16 | rctx.file("BUILD.bazel", "exports_files(glob([\"**\"]))\n") |
| 17 | |
| 18 | nonhermetic_repo = repository_rule( |
| 19 | implementation = _nonhermetic_repo_impl, |
| 20 | attrs = {}, |
| 21 | environ = NONHERMETIC_ENV_VARS, |
| 22 | ) |