Merge pull request #127 from ehsannas/add_bazel_build

Add a Bazel build file.
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 @@
 
 ## 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 @@
 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