blob: 253abbf80a9026f44a58def4d6099d9e6548e11d [file] [log] [blame]
Serge Bazanski9e861a82020-09-16 13:46:41 +02001# 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"""
18A generic workspace rule that extracts some subpaths from a tarball.
19
20TODO(q3k): This should maybe be moved to //build/utils and called differently.
21"""
22
23def _musl_sysroot_rule_impl(rctx):
24 rctx.extract(rctx.attr.snapshot)
25 rctx.file("BUILD.bazel", """
26filegroup(
27 name = "all",
28 srcs = glob(["include/**", "lib/**"]),
29 visibility = ["//visibility:public"],
30)
31""")
32
33
34musl_sysroot_rule = repository_rule(
35 implementation = _musl_sysroot_rule_impl,
36 attrs = {
37 "snapshot": attr.label(
38 default = Label("//build/toolchain/musl-host-gcc:sysroot.tar.xz"),
39 allow_single_file = True,
40 ),
41 },
42)