-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathshaderc.rb
82 lines (69 loc) · 2.72 KB
/
shaderc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
class Shaderc < Formula
desc "Collection of tools, libraries, and tests for Vulkan shader compilation"
homepage "https://github.com/google/shaderc"
license "Apache-2.0"
stable do # Last buildable version on macOS <10.15
url "https://github.com/google/shaderc/archive/refs/tags/v2023.3.tar.gz"
sha256 "6cbb041245bcfbf349954dc99c7e93608d3d9dd0c13dc891182b58eb255c848b"
resource "glslang" do
# https://github.com/google/shaderc/blob/known-good/known_good.json
url "https://github.com/KhronosGroup/glslang.git",
revision: "ef77cf3a92490f7c37f36f20263cd3cd8c94f009"
end
resource "spirv-headers" do
# https://github.com/google/shaderc/blob/known-good/known_good.json
url "https://github.com/KhronosGroup/SPIRV-Headers.git",
revision: "1feaf4414eb2b353764d01d88f8aa4bcc67b60db"
end
resource "spirv-tools" do
# https://github.com/google/shaderc/blob/known-good/known_good.json
url "https://github.com/KhronosGroup/SPIRV-Tools.git",
revision: "44d72a9b36702f093dd20815561a56778b2d181e"
end
end
head do
url "https://github.com/google/shaderc.git", branch: "main"
resource "glslang" do
url "https://github.com/KhronosGroup/glslang.git", branch: "main"
end
resource "spirv-tools" do
url "https://github.com/KhronosGroup/SPIRV-Tools.git", branch: "main"
end
resource "spirv-headers" do
url "https://github.com/KhronosGroup/SPIRV-Headers.git", branch: "main"
end
end
depends_on "cmake" => :build
depends_on "[email protected]" => :build
def install
ENV.append "CFLAGS", (Hardware::CPU.arm? ? "-mcpu=native" : "-march=native -mtune=native") + " -Ofast -flto=thin"
resources.each do |res|
res.stage(buildpath/"third_party"/res.name)
end
# Avoid installing packages that conflict with other formulae.
inreplace "third_party/CMakeLists.txt", "${SHADERC_SKIP_INSTALL}", "ON"
system "cmake", "-S", ".", "-B", "build",
"-DSHADERC_SKIP_TESTS=ON",
"-DSKIP_GLSLANG_INSTALL=ON",
"-DSKIP_SPIRV_TOOLS_INSTALL=ON",
"-DSKIP_GOOGLETEST_INSTALL=ON",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
test do
(testpath/"test.c").write <<~EOS
#include <shaderc/shaderc.h>
int main() {
int version;
shaderc_profile profile;
if (!shaderc_parse_version_profile("450core", &version, &profile))
return 1;
return (profile == shaderc_profile_core) ? 0 : 1;
}
EOS
system ENV.cc, "-o", "test", "test.c", "-I#{include}",
"-L#{lib}", "-lshaderc_shared"
system "./test"
end
end