diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -3,6 +3,13 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@bazel_skylib//rules:expand_template.bzl", "expand_template") +load( + "@rules_pkg//pkg:mappings.bzl", + "pkg_attributes", + "pkg_filegroup", + "pkg_files", + "pkg_mklink", +) load("//llvm:tblgen.bzl", "gentbl") load("//llvm:binary_alias.bzl", "binary_alias") load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") @@ -2241,3 +2248,51 @@ "//llvm:Support", ], ) + +# For packaging + +CLANG_EXE = "clang-{}".format(LLVM_VERSION_MAJOR) + +pkg_files( + name="pkg-clang-exe", + attributes=pkg_attributes( + mode="0755", + ), + renames={ + ":clang": CLANG_EXE, + }, + srcs=[ + ":clang", + ], +) + +pkg_mklink( + name="pkg-clang-symlink", + link_name="clang", + target=CLANG_EXE, +) + +pkg_mklink( + name="pkg-clangxx-symlink", + link_name="clang++", + target=CLANG_EXE, +) + +pkg_filegroup( + name="pkg-clang", + prefix="bin", + srcs=[ + ":pkg-clang-exe", + ":pkg-clang-symlink", + ":pkg-clangxx-symlink", + ], +) + +pkg_files( + name="pkg-clang-resources", + prefix="lib/clang/{}/include".format(LLVM_VERSION_MAJOR), + srcs=[ + ":builtin_headers_gen", + ], + strip_prefix="staging/include", +) diff --git a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel b/utils/bazel/llvm-project-overlay/lld/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/lld/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/lld/BUILD.bazel @@ -3,6 +3,13 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@bazel_skylib//rules:expand_template.bzl", "expand_template") +load( + "@rules_pkg//pkg:mappings.bzl", + "pkg_attributes", + "pkg_filegroup", + "pkg_files", + "pkg_mklink", +) load("//llvm:tblgen.bzl", "gentbl") load( @@ -317,3 +324,30 @@ "target=$$(basename $<); for n in ld.lld ld64.lld lld-link wasm-ld; do ln -sf $$target $(@D)/$$n; done", output_to_bindir = 1, ) + +# For packaging + +pkg_files( + name="pkg-lld-exe", + attributes=pkg_attributes( + mode="0755", + ), + srcs=[ + ":lld", + ], +) + +pkg_mklink( + name="pkg-ld.lld-symlink", + link_name="ld.lld", + target="lld", +) + +pkg_filegroup( + name="pkg-lld", + prefix="bin", + srcs=[ + ":pkg-ld.lld-symlink", + ":pkg-lld-exe", + ], +) diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -4,6 +4,11 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@bazel_skylib//rules:expand_template.bzl", "expand_template") +load( + "@rules_pkg//pkg:mappings.bzl", + "pkg_attributes", + "pkg_files", +) load(":tblgen.bzl", "gentbl") load(":config.bzl", "llvm_config_defines") load(":targets.bzl", "llvm_targets") @@ -4884,3 +4889,16 @@ ":Support", ], ) + +# For packaging + +pkg_files( + name="pkg-llvm-ar", + attributes=pkg_attributes( + mode="0755", + ), + prefix="bin", + srcs=[ + ":llvm-ar", + ], +)