Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 1 | package( |
| 2 | default_visibility = ["//visibility:public"], |
| 3 | ) |
| 4 | |
| 5 | # Description: |
| 6 | # |
| 7 | # Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator. |
| 8 | |
Ehsan Nasiri | 4b9b07a | 2019-10-23 15:03:38 -0400 | [diff] [blame] | 9 | licenses(["notice"]) |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 10 | |
| 11 | exports_files(["LICENSE"]) |
| 12 | |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 13 | COMMON_COPTS = select({ |
| 14 | "@bazel_tools//src/conditions:windows": [""], |
| 15 | "//conditions:default": [ |
| 16 | "-Wall", |
| 17 | "-Wuninitialized", |
| 18 | "-Wunused", |
| 19 | "-Wunused-local-typedefs", |
| 20 | "-Wunused-parameter", |
| 21 | "-Wunused-value", |
| 22 | "-Wunused-variable", |
| 23 | "-Wno-reorder", |
| 24 | "-std=c++11", |
| 25 | "-fvisibility=hidden", |
| 26 | "-fvisibility-inlines-hidden", |
| 27 | "-fno-exceptions", |
| 28 | "-fno-rtti", |
| 29 | ], |
| 30 | }) |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 31 | |
| 32 | cc_library( |
| 33 | name = "glslang", |
| 34 | srcs = glob( |
| 35 | [ |
| 36 | "glslang/GenericCodeGen/*.cpp", |
| 37 | "glslang/MachineIndependent/*.cpp", |
| 38 | "glslang/MachineIndependent/preprocessor/*.cpp", |
| 39 | "hlsl/*.cpp", |
| 40 | ], |
| 41 | exclude = [ |
| 42 | "glslang/MachineIndependent/pch.cpp", |
| 43 | "glslang/MachineIndependent/pch.h", |
| 44 | "hlsl/pch.cpp", |
| 45 | "hlsl/pch.h", |
| 46 | ], |
| 47 | ) + [ |
| 48 | "OGLCompilersDLL/InitializeDll.cpp", |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 49 | ] + select({ |
| 50 | "@bazel_tools//src/conditions:windows": |
Ehsan Nasiri | af7991e | 2019-10-18 12:21:11 -0400 | [diff] [blame] | 51 | ["glslang/OSDependent/Windows/ossource.cpp"], |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 52 | "//conditions:default": |
Ehsan Nasiri | af7991e | 2019-10-18 12:21:11 -0400 | [diff] [blame] | 53 | ["glslang/OSDependent/Unix/ossource.cpp"], |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 54 | }), |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 55 | hdrs = glob([ |
| 56 | "glslang/Include/*.h", |
| 57 | "glslang/MachineIndependent/*.h", |
| 58 | "glslang/MachineIndependent/preprocessor/*.h", |
| 59 | "hlsl/*.h", |
| 60 | ]) + [ |
| 61 | "OGLCompilersDLL/InitializeDll.h", |
| 62 | "StandAlone/DirStackFileIncluder.h", |
| 63 | "glslang/OSDependent/osinclude.h", |
| 64 | "glslang/Public/ShaderLang.h", |
| 65 | ], |
| 66 | copts = COMMON_COPTS, |
| 67 | defines = [ |
| 68 | "AMD_EXTENSIONS", |
| 69 | "ENABLE_HLSL=0", |
| 70 | "ENABLE_OPT=0", |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 71 | "NV_EXTENSIONS", |
| 72 | ], |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 73 | linkopts = select({ |
| 74 | "@bazel_tools//src/conditions:windows": [""], |
| 75 | "//conditions:default": ["-lm", "-lpthread"], |
| 76 | }), |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 77 | linkstatic = 1, |
| 78 | ) |
| 79 | |
| 80 | genrule( |
| 81 | name = "export_spirv_headers", |
| 82 | srcs = [ |
| 83 | "SPIRV/GLSL.ext.AMD.h", |
| 84 | "SPIRV/GLSL.ext.EXT.h", |
| 85 | "SPIRV/GLSL.ext.KHR.h", |
| 86 | "SPIRV/GLSL.ext.NV.h", |
| 87 | "SPIRV/GLSL.std.450.h", |
Jeff Bolz | 04d7373 | 2019-05-31 13:06:01 -0500 | [diff] [blame] | 88 | "SPIRV/NonSemanticDebugPrintf.h",
|
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 89 | "SPIRV/spirv.hpp", |
| 90 | ], |
| 91 | outs = [ |
| 92 | "include/SPIRV/GLSL.ext.AMD.h", |
| 93 | "include/SPIRV/GLSL.ext.EXT.h", |
| 94 | "include/SPIRV/GLSL.ext.KHR.h", |
| 95 | "include/SPIRV/GLSL.ext.NV.h", |
| 96 | "include/SPIRV/GLSL.std.450.h", |
Jeff Bolz | 04d7373 | 2019-05-31 13:06:01 -0500 | [diff] [blame] | 97 | "include/SPIRV/NonSemanticDebugPrintf.h",
|
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 98 | "include/SPIRV/spirv.hpp", |
| 99 | ], |
| 100 | cmd = "mkdir -p $(@D)/include/SPIRV && cp $(SRCS) $(@D)/include/SPIRV/", |
| 101 | ) |
| 102 | |
| 103 | cc_library( |
| 104 | name = "SPIRV_headers", |
| 105 | hdrs = [":export_spirv_headers"], |
| 106 | copts = COMMON_COPTS, |
| 107 | includes = [ |
| 108 | "include", |
| 109 | "include/SPIRV", |
| 110 | ], |
| 111 | linkstatic = 1, |
| 112 | ) |
| 113 | |
| 114 | cc_library( |
| 115 | name = "SPIRV", |
| 116 | srcs = glob( |
| 117 | ["SPIRV/*.cpp"], |
| 118 | exclude = [ |
| 119 | "SPIRV/SpvTools.cpp", |
| 120 | ], |
| 121 | ), |
| 122 | hdrs = [ |
| 123 | "SPIRV/GlslangToSpv.h", |
| 124 | "SPIRV/Logger.h", |
| 125 | "SPIRV/SPVRemapper.h", |
| 126 | "SPIRV/SpvBuilder.h", |
| 127 | "SPIRV/SpvTools.h", |
| 128 | "SPIRV/bitutils.h", |
| 129 | "SPIRV/disassemble.h", |
| 130 | "SPIRV/doc.h", |
| 131 | "SPIRV/hex_float.h", |
| 132 | "SPIRV/spvIR.h", |
| 133 | ], |
| 134 | copts = COMMON_COPTS, |
| 135 | includes = ["SPIRV"], |
Ehsan Nasiri | dccaa59 | 2019-10-17 15:14:20 -0400 | [diff] [blame] | 136 | linkopts = select({ |
| 137 | "@bazel_tools//src/conditions:windows": [""], |
| 138 | "//conditions:default": ["-lm"], |
| 139 | }), |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 140 | linkstatic = 1, |
| 141 | deps = [ |
| 142 | ":SPIRV_headers", |
| 143 | ":glslang", |
| 144 | ], |
| 145 | ) |
| 146 | |
| 147 | cc_library( |
| 148 | name = "glslang-default-resource-limits", |
| 149 | srcs = ["StandAlone/ResourceLimits.cpp"], |
| 150 | hdrs = ["StandAlone/ResourceLimits.h"], |
| 151 | copts = COMMON_COPTS, |
| 152 | linkstatic = 1, |
| 153 | deps = [":glslang"], |
| 154 | ) |
| 155 | |
| 156 | cc_binary( |
| 157 | name = "glslangValidator", |
| 158 | srcs = [ |
| 159 | "StandAlone/StandAlone.cpp", |
| 160 | "StandAlone/Worklist.h", |
| 161 | ], |
| 162 | copts = COMMON_COPTS, |
| 163 | deps = [ |
| 164 | ":SPIRV", |
| 165 | ":glslang", |
| 166 | ":glslang-default-resource-limits", |
| 167 | ], |
| 168 | ) |
| 169 | |
| 170 | cc_binary( |
| 171 | name = "spirv-remap", |
| 172 | srcs = ["StandAlone/spirv-remap.cpp"], |
| 173 | copts = COMMON_COPTS, |
| 174 | deps = [ |
| 175 | ":SPIRV", |
| 176 | ":glslang", |
| 177 | ":glslang-default-resource-limits", |
| 178 | ], |
| 179 | ) |
| 180 | |
| 181 | filegroup( |
| 182 | name = "test_files", |
| 183 | srcs = glob( |
| 184 | ["Test/**"], |
| 185 | exclude = [ |
| 186 | "Test/bump", |
| 187 | "Test/glslangValidator", |
| 188 | "Test/runtests", |
| 189 | ], |
| 190 | ), |
| 191 | ) |
| 192 | |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 193 | cc_library( |
| 194 | name = "glslang_test_lib", |
| 195 | testonly = 1, |
| 196 | srcs = [ |
| 197 | "gtests/HexFloat.cpp", |
| 198 | "gtests/Initializer.h", |
| 199 | "gtests/Settings.cpp", |
| 200 | "gtests/Settings.h", |
| 201 | "gtests/TestFixture.cpp", |
| 202 | "gtests/TestFixture.h", |
| 203 | "gtests/main.cpp", |
| 204 | ], |
| 205 | copts = COMMON_COPTS, |
| 206 | data = [":test_files"], |
Ehsan Nasiri | af7991e | 2019-10-18 12:21:11 -0400 | [diff] [blame] | 207 | defines = select({ |
| 208 | # Unfortunately we can't use $(location) in cc_library at the moment. |
| 209 | # See https://github.com/bazelbuild/bazel/issues/1023 |
| 210 | # So we'll specify the path manually. |
| 211 | "@bazel_tools//src/conditions:windows": |
| 212 | ["GLSLANG_TEST_DIRECTORY='\"../../../../../Test\"'"], |
| 213 | "//conditions:default": |
| 214 | ["GLSLANG_TEST_DIRECTORY='\"Test\"'"], |
| 215 | }), |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 216 | linkstatic = 1, |
| 217 | deps = [ |
| 218 | ":SPIRV", |
| 219 | ":glslang", |
| 220 | ":glslang-default-resource-limits", |
| 221 | "@com_google_googletest//:gtest", |
| 222 | ], |
| 223 | ) |
| 224 | |
| 225 | GLSLANG_TESTS = glob( |
| 226 | ["gtests/*.FromFile.cpp"], |
| 227 | # Since we are not building the SPIRV-Tools dependency, the following tests |
| 228 | # cannot be performed. |
| 229 | exclude = [ |
| 230 | "gtests/Hlsl.FromFile.cpp", |
| 231 | "gtests/Spv.FromFile.cpp", |
| 232 | ], |
| 233 | ) |
| 234 | |
| 235 | [cc_test( |
| 236 | name = test_file.replace("gtests/", "").replace(".FromFile.cpp", "") + "_test", |
| 237 | srcs = [test_file], |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 238 | copts = COMMON_COPTS, |
| 239 | data = [ |
Ehsan Nasiri | 0608b9d | 2019-10-16 16:55:23 -0400 | [diff] [blame] | 240 | ":test_files", |
| 241 | ], |
| 242 | deps = [ |
| 243 | ":SPIRV", |
| 244 | ":glslang", |
| 245 | ":glslang_test_lib", |
| 246 | ], |
| 247 | ) for test_file in GLSLANG_TESTS] |