aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Kessenich <johnkslang@users.noreply.github.com>2019-09-24 08:45:29 -0600
committerGitHub <noreply@github.com>2019-09-24 08:45:29 -0600
commit836e001d7be0092d71bf5e04989e7eaaa066c5c1 (patch)
treeb9627ec0a882e15efe6681b5fa8ea63c26c475fd
parent601d738723ac381741311c6c98c36d6170be14a2 (diff)
parentab22babed072a2456502162d44c9583aa9a0084e (diff)
downloadSPIRV-Headers-836e001d7be0092d71bf5e04989e7eaaa066c5c1.tar.gz
Merge pull request #127 from ehsannas/add_bazel_build
Add a Bazel build file.
-rw-r--r--BUILD.bazel124
-rw-r--r--README.md46
-rw-r--r--WORKSPACE0
3 files changed, 170 insertions, 0 deletions
diff --git a/BUILD.bazel b/BUILD.bazel
new file mode 100644
index 0000000..29f43ce
--- /dev/null
+++ b/BUILD.bazel
@@ -0,0 +1,124 @@
+package(
+ default_visibility = ["//visibility:public"],
+)
+
+licenses(["notice"])
+
+exports_files(["LICENSE"])
+
+filegroup(
+ name = "spirv_core_grammar_1.0",
+ srcs = ["include/spirv/1.0/spirv.core.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_glsl_grammar_1.0",
+ srcs = ["include/spirv/1.0/extinst.glsl.std.450.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_opencl_grammar_1.0",
+ srcs = ["include/spirv/1.0/extinst.opencl.std.100.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_core_grammar_1.1",
+ srcs = ["include/spirv/1.1/spirv.core.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_glsl_grammar_1.1",
+ srcs = ["include/spirv/1.1/extinst.glsl.std.450.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_opencl_grammar_1.1",
+ srcs = ["include/spirv/1.1/extinst.opencl.std.100.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_core_grammar_1.2",
+ srcs = ["include/spirv/1.2/spirv.core.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_glsl_grammar_1.2",
+ srcs = ["include/spirv/1.2/extinst.glsl.std.450.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_opencl_grammar_1.2",
+ srcs = ["include/spirv/1.2/extinst.opencl.std.100.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_core_grammar_unified1",
+ srcs = ["include/spirv/unified1/spirv.core.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_glsl_grammar_unified1",
+ srcs = ["include/spirv/unified1/extinst.glsl.std.450.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_opencl_grammar_unified1",
+ srcs = ["include/spirv/unified1/extinst.opencl.std.100.grammar.json"],
+)
+
+filegroup(
+ name = "spirv_xml_registry",
+ srcs = ["include/spirv/spir-v.xml"],
+)
+
+cc_library(
+ name = "spirv_common_headers",
+ hdrs = [
+ "include/spirv/1.0/GLSL.std.450.h",
+ "include/spirv/1.0/OpenCL.std.h",
+ "include/spirv/1.1/GLSL.std.450.h",
+ "include/spirv/1.1/OpenCL.std.h",
+ "include/spirv/1.2/GLSL.std.450.h",
+ "include/spirv/1.2/OpenCL.std.h",
+ "include/spirv/unified1/GLSL.std.450.h",
+ "include/spirv/unified1/OpenCL.std.h",
+ ],
+ includes = ["include"],
+)
+
+cc_library(
+ name = "spirv_c_headers",
+ hdrs = [
+ "include/spirv/1.0/spirv.h",
+ "include/spirv/1.1/spirv.h",
+ "include/spirv/1.2/spirv.h",
+ "include/spirv/unified1/spirv.h",
+ ],
+ includes = ["include"],
+ deps = [":spirv_common_headers"],
+)
+
+cc_library(
+ name = "spirv_cpp_headers",
+ hdrs = [
+ "include/spirv/1.0/spirv.hpp",
+ "include/spirv/1.1/spirv.hpp",
+ "include/spirv/1.2/spirv.hpp",
+ "include/spirv/unified1/spirv.hpp",
+ ],
+ includes = ["include"],
+ deps = [":spirv_common_headers"],
+)
+
+cc_library(
+ name = "spirv_cpp11_headers",
+ hdrs = [
+ "include/spirv/1.0/spirv.hpp11",
+ "include/spirv/1.1/spirv.hpp11",
+ "include/spirv/1.2/spirv.hpp11",
+ "include/spirv/unified1/spirv.hpp11",
+ ],
+ includes = ["include"],
+ deps = [":spirv_common_headers"],
+)
+
diff --git a/README.md b/README.md
index beb1b7e..27b393a 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ If you want to install them somewhere else, then use
## Using the headers without installing
+### Using CMake
A CMake-based project can use the headers without installing, as follows:
1. Add an `add_subdirectory` directive to include this source tree.
@@ -69,6 +70,51 @@ A CMake-based project can use the headers without installing, as follows:
See also the [example](example/) subdirectory. But since that example is
*inside* this repostory, it doesn't use and `add_subdirectory` directive.
+### Using Bazel
+A Bazel-based project can use the headers without installing, as follows:
+
+1. Add a `local_repository` to your `WORKSPACE` file. For example:
+```
+local_repository(
+ name = "spirv_headers",
+ path = "external/spirv-headers",
+)
+```
+
+2. Add one of the following to the `deps` of your build target based on your
+needs:
+```
+@spirv_headers//:spirv_c_headers
+@spirv_headers//:spirv_cpp_headers
+@spirv_headers//:spirv_cpp11_headers
+```
+
+For example:
+
+```
+cc_library(
+ name = "project",
+ srcs = [
+ # Path to project sources
+ ],
+ hdrs = [
+ # Path to project headers
+ ],
+ deps = [
+ "@spirv_tools//:spirv_c_headers",
+ # Other dependencies,
+ ],
+)
+```
+
+3. In your C or C++ source code use `#include` directives that explicitly mention
+ the `spirv` path component.
+```
+#include "spirv/unified1/GLSL.std.450.h"
+#include "spirv/unified1/OpenCL.std.h"
+#include "spirv/unified1/spirv.hpp"
+```
+
## Generating the headers from the JSON grammar
This will generally be done by Khronos, for a change to the JSON grammar.
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/WORKSPACE