brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · e23dc42 Raw
44 lines · plain
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-exception4 5"""Repository rule to statically link against the Vulkan SDK.6 7Requires installing the Vulkan SDK from https://vulkan.lunarg.com/.8 9If the Vulkan SDK is not installed, this generates an empty rule and you may10encounter linker errors like `error: undefined reference to 'vkCreateInstance'`.11"""12 13def _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")17 18        repository_ctx.file("BUILD", """19cc_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", """34cc_library(35    name = "sdk",36    srcs = [],37    visibility = ["//visibility:public"],38)""")39 40vulkan_sdk_setup = repository_rule(41    implementation = _impl,42    local = True,43)44