diff --git a/BUILD b/BUILD index 9cd9963..b8d5f3d 100644 --- a/BUILD +++ b/BUILD @@ -1,3 +1,4 @@ +load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file") load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_filegroup") load("@llvm-project//:vars.bzl", "LLVM_VERSION_MAJOR") load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") @@ -48,6 +49,47 @@ DIST_FLAVORS = { for (suffix, props) in DIST_FLAVORS.items() ] +# Note, there are some inconsistencies in naming so expanding the templates. +LIB_PREFIX = "lib/clang/%s/lib/" % LLVM_VERSION_MAJOR + +copy_file( + name = "copy_libclang_rt.profile_osx", + src = "@llvm-project//compiler-rt:profile", + out = "libclang_rt.profile_osx.a", +) + +pkg_files( + name = "libclang_rt.profile_osx", + srcs = ["libclang_rt.profile_osx.a"], + prefix = LIB_PREFIX + "darwin", +) + +copy_file( + name = "copy_libclang_rt.profile_linux_aarch64", + src = "@llvm-project//compiler-rt:profile", + out = "libclang_rt.profile_linux-aarch64.a", +) + +pkg_files( + name = "libclang_rt.profile_linux_aarch64", + srcs = ["libclang_rt.profile_linux-aarch64.a"], + prefix = LIB_PREFIX + "linux", +) + +# TODO(zbarsky): Not sure if this is the right name. +# Hopefully someone yells at me if it's wrong. +copy_file( + name = "copy_libclang_rt.profile_linux_x84_64", + src = "@llvm-project//compiler-rt:profile", + out = "libclang_rt.profile_linux-x86_64.a", +) + +pkg_files( + name = "libclang_rt.profile_linux_x86_64", + srcs = ["libclang_rt.profile_linux-x86_64.a"], + prefix = LIB_PREFIX + "linux", +) + [ pkg_tar( name = "dist" + suffix, @@ -55,7 +97,11 @@ DIST_FLAVORS = { ":bins" + suffix, "//:builtin_headers_pkg_files", "@llvm-raw//:libcxx_include", - ], + ] + select({ + "@bazel_tools//src/conditions:darwin": [":libclang_rt.profile_osx"], + "@bazel_tools//src/conditions:linux_aarch64": [":libclang_rt.profile_linux_aarch64"], + "@bazel_tools//src/conditions:linux_x86_64": [":libclang_rt.profile_linux_x86_64"], + }), empty_files = props.get("extra_empty_files", []), extension = ".tar.xz", symlinks = {