[ELF] Reorder SectionBase/InputSectionBase members
[llvm-project.git] / utils / bazel / vulkan_sdk.bzl
blobe23dc42131c4ca3f0da839a80a7f933d3cdc3948
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 """Repository rule to statically link against the Vulkan SDK.
7 Requires installing the Vulkan SDK from https://vulkan.lunarg.com/.
9 If the Vulkan SDK is not installed, this generates an empty rule and you may
10 encounter linker errors like `error: undefined reference to 'vkCreateInstance'`.
11 """
13 def _impl(repository_ctx):
14     if "VULKAN_SDK" in repository_ctx.os.environ:
15         sdk_path = repository_ctx.os.environ["VULKAN_SDK"]
16         repository_ctx.symlink(sdk_path, "vulkan-sdk")
18         repository_ctx.file("BUILD", """
19 cc_library(
20     name = "sdk",
21     srcs = select({
22         "@platforms//os:windows": [
23             "vulkan-sdk/Lib/vulkan-1.lib"
24         ],
25         "//conditions:default": [
26             "vulkan-sdk/lib/libvulkan.so.1",
27         ],
28     }),
29     visibility = ["//visibility:public"],
30 )""")
31     else:
32         # Empty rule. Will fail to link for just targets that use Vulkan.
33         repository_ctx.file("BUILD", """
34 cc_library(
35     name = "sdk",
36     srcs = [],
37     visibility = ["//visibility:public"],
38 )""")
40 vulkan_sdk_setup = repository_rule(
41     implementation = _impl,
42     local = True,