xref: /aosp_15_r20/external/bazel-skylib/distribution/BUILD (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifanload("@bazel_skylib//:version.bzl", "version")
2*bcb5dc79SHONG Yifanload("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
3*bcb5dc79SHONG Yifanload("@rules_pkg//:pkg.bzl", "pkg_tar")
4*bcb5dc79SHONG Yifanload("distribution.bzl", "remove_internal_only")
5*bcb5dc79SHONG Yifan
6*bcb5dc79SHONG Yifanpackage(
7*bcb5dc79SHONG Yifan    default_applicable_licenses = ["//:license"],
8*bcb5dc79SHONG Yifan    default_visibility = ["//visibility:private"],
9*bcb5dc79SHONG Yifan)
10*bcb5dc79SHONG Yifan
11*bcb5dc79SHONG Yifanlicenses(["notice"])
12*bcb5dc79SHONG Yifan
13*bcb5dc79SHONG Yifanremove_internal_only(
14*bcb5dc79SHONG Yifan    name = "distro_workspace",
15*bcb5dc79SHONG Yifan    src = "//:WORKSPACE",
16*bcb5dc79SHONG Yifan    out = "WORKSPACE",
17*bcb5dc79SHONG Yifan)
18*bcb5dc79SHONG Yifan
19*bcb5dc79SHONG Yifanremove_internal_only(
20*bcb5dc79SHONG Yifan    name = "distro_module_bazel",
21*bcb5dc79SHONG Yifan    src = "//:MODULE.bazel",
22*bcb5dc79SHONG Yifan    out = "MODULE.bazel",
23*bcb5dc79SHONG Yifan)
24*bcb5dc79SHONG Yifan
25*bcb5dc79SHONG Yifan# remove "distribution/" path prefix
26*bcb5dc79SHONG Yifanpkg_files(
27*bcb5dc79SHONG Yifan    name = "distro-files-without-prefix",
28*bcb5dc79SHONG Yifan    srcs = [
29*bcb5dc79SHONG Yifan        "distro_module_bazel",
30*bcb5dc79SHONG Yifan        "distro_workspace",
31*bcb5dc79SHONG Yifan    ],
32*bcb5dc79SHONG Yifan    strip_prefix = strip_prefix.from_pkg(),
33*bcb5dc79SHONG Yifan)
34*bcb5dc79SHONG Yifan
35*bcb5dc79SHONG Yifanpkg_tar(
36*bcb5dc79SHONG Yifan    name = "bazel-skylib",
37*bcb5dc79SHONG Yifan    srcs = [
38*bcb5dc79SHONG Yifan        "distro-files-without-prefix",
39*bcb5dc79SHONG Yifan        "//:distribution",
40*bcb5dc79SHONG Yifan    ],
41*bcb5dc79SHONG Yifan    out = "bazel-skylib-%s.tar.gz" % version,
42*bcb5dc79SHONG Yifan    extension = "tar.gz",
43*bcb5dc79SHONG Yifan    mode = "0644",
44*bcb5dc79SHONG Yifan    # Make it owned by root so it does not have the uid of the CI robot.
45*bcb5dc79SHONG Yifan    owner = "0.0",
46*bcb5dc79SHONG Yifan    strip_prefix = strip_prefix.from_root(),
47*bcb5dc79SHONG Yifan)
48*bcb5dc79SHONG Yifan
49*bcb5dc79SHONG Yifan# @bazel_skylib_gazelle_plugin//:WORKSPACE refers to bazel-skylib in the parent
50*bcb5dc79SHONG Yifan# directory. For distribution, use the minimal WORSKPACE.bzlmod instead.
51*bcb5dc79SHONG Yifanpkg_files(
52*bcb5dc79SHONG Yifan    name = "bazel-skylib-gazelle-plugin-distro_workspace",
53*bcb5dc79SHONG Yifan    srcs = ["@bazel_skylib_gazelle_plugin//:WORKSPACE.bzlmod"],
54*bcb5dc79SHONG Yifan    renames = {"@bazel_skylib_gazelle_plugin//:WORKSPACE.bzlmod": "WORKSPACE"},
55*bcb5dc79SHONG Yifan)
56*bcb5dc79SHONG Yifan
57*bcb5dc79SHONG Yifanpkg_files(
58*bcb5dc79SHONG Yifan    name = "bazel-skylib-gazelle-plugin-without-external-prefix",
59*bcb5dc79SHONG Yifan    srcs = [
60*bcb5dc79SHONG Yifan        "@bazel_skylib_gazelle_plugin//:distribution",
61*bcb5dc79SHONG Yifan        "@bazel_skylib_gazelle_plugin//bzl:distribution",
62*bcb5dc79SHONG Yifan    ],
63*bcb5dc79SHONG Yifan    strip_prefix = strip_prefix.from_root(),
64*bcb5dc79SHONG Yifan)
65*bcb5dc79SHONG Yifan
66*bcb5dc79SHONG Yifanpkg_tar(
67*bcb5dc79SHONG Yifan    name = "bazel-skylib-gazelle-plugin",
68*bcb5dc79SHONG Yifan    srcs = [
69*bcb5dc79SHONG Yifan        "bazel-skylib-gazelle-plugin-distro_workspace",
70*bcb5dc79SHONG Yifan        "bazel-skylib-gazelle-plugin-without-external-prefix",
71*bcb5dc79SHONG Yifan        "//:LICENSE",
72*bcb5dc79SHONG Yifan    ],
73*bcb5dc79SHONG Yifan    out = "bazel-skylib-gazelle-plugin-%s.tar.gz" % version,
74*bcb5dc79SHONG Yifan    extension = "tar.gz",
75*bcb5dc79SHONG Yifan    mode = "0644",
76*bcb5dc79SHONG Yifan    # Make it owned by root so it does not have the uid of the CI robot.
77*bcb5dc79SHONG Yifan    owner = "0.0",
78*bcb5dc79SHONG Yifan)
79*bcb5dc79SHONG Yifan
80*bcb5dc79SHONG Yifan# Build the artifacts to put on the github release page.
81*bcb5dc79SHONG Yifanfilegroup(
82*bcb5dc79SHONG Yifan    name = "distribution",
83*bcb5dc79SHONG Yifan    srcs = [
84*bcb5dc79SHONG Yifan        "bazel-skylib",
85*bcb5dc79SHONG Yifan        "bazel-skylib-gazelle-plugin",
86*bcb5dc79SHONG Yifan    ],
87*bcb5dc79SHONG Yifan)
88