From 5a70335bf1c858b8cf6a22e35dcc41090496c3c1 Mon Sep 17 00:00:00 2001 From: David Neto Date: Wed, 17 Feb 2016 14:44:00 -0500 Subject: [PATCH] Rearrange headers Now we have public headers arranged as follows: $SPIRV_TOOLS_ROOT/include/spirv-tools/libspirv.h $SPIRV_TOOLS_ROOT/include/spirv/spirv.h $SPIRV_TOOLS_ROOT/include/spirv/GLSL.std.450.h $SPIRV_TOOLS_ROOT/include/spirv/OpenCL.std.h A project should use -I$SPIRV_TOOLS_ROOT/include and then #include "spirv-tools/libspirv.h" The headers from the SPIR-V Registry can be accessed as "spirv/spirv." for example. The install target should also install the headers from the SPIR-V Registry. The libspirv.h header is broken otherwise. The SPIRV-Tools library depends on the headers from the SPIR-V Registry. The util/bitutils.h and util/hex_float.h are pulled into the internal source tree. Those are not part of the public API to SPIRV-Tools. --- CMakeLists.txt | 23 ++++++++++++------- include/{libspirv => spirv-tools}/libspirv.h | 12 +++++----- .../headers => include/spirv}/GLSL.std.450.h | 0 .../headers => include/spirv}/OpenCL.std.h | 0 .../include/headers => include/spirv}/spirv.h | 0 .../headers => include/spirv}/spirv.py | 0 source/assembly_grammar.h | 2 +- source/binary.cpp | 2 +- source/binary.h | 2 +- source/diagnostic.cpp | 2 +- source/diagnostic.h | 2 +- source/disassemble.cpp | 2 +- source/ext_inst.h | 2 +- source/instruction.h | 2 +- source/opcode.cpp | 2 +- source/opcode.h | 2 +- source/operand.h | 2 +- source/spirv_constant.h | 2 +- source/spirv_definition.h | 2 +- source/spirv_endian.h | 2 +- source/table.h | 2 +- source/text.cpp | 2 +- source/text.h | 2 +- source/text_handler.h | 2 +- {include => source}/util/bitutils.h | 0 {include => source}/util/hex_float.h | 6 ++--- source/validate.cpp | 2 +- source/validate.h | 3 +-- source/validate_id.cpp | 2 +- source/validate_layout.cpp | 2 +- source/validate_types.cpp | 2 +- test/HexFloat.cpp | 2 +- test/ImmediateInt.cpp | 2 +- test/TextToBinary.cpp | 4 ++-- test/UnitSPIRV.h | 2 +- test/ValidationState.cpp | 2 +- tools/as/as.cpp | 2 +- tools/dis/dis.cpp | 2 +- tools/val/val.cpp | 2 +- 39 files changed, 56 insertions(+), 50 deletions(-) rename include/{libspirv => spirv-tools}/libspirv.h (98%) rename {external/include/headers => include/spirv}/GLSL.std.450.h (100%) rename {external/include/headers => include/spirv}/OpenCL.std.h (100%) rename {external/include/headers => include/spirv}/spirv.h (100%) rename {external/include/headers => include/spirv}/spirv.py (100%) rename {include => source}/util/bitutils.h (100%) rename {include => source}/util/hex_float.h (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f200b09c..f9f56eb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,9 +104,12 @@ function(spvtools_default_compile_options TARGET) endfunction() set(SPIRV_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/include/libspirv/libspirv.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/util/bitutils.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/util/hex_float.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/spirv.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/GLSL.std.450.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/OpenCL.std.h + ${CMAKE_CURRENT_SOURCE_DIR}/source/util/bitutils.h + ${CMAKE_CURRENT_SOURCE_DIR}/source/util/hex_float.h ${CMAKE_CURRENT_SOURCE_DIR}/source/assembly_grammar.h ${CMAKE_CURRENT_SOURCE_DIR}/source/binary.h ${CMAKE_CURRENT_SOURCE_DIR}/source/diagnostic.h @@ -145,9 +148,7 @@ set(SPIRV_SOURCES add_library(${SPIRV_TOOLS} ${SPIRV_SOURCES}) spvtools_default_compile_options(${SPIRV_TOOLS}) -target_include_directories(${SPIRV_TOOLS} PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/external/include) +target_include_directories(${SPIRV_TOOLS} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) # Defaults to OFF if the user didn't set it. option(SPIRV_SKIP_EXECUTABLES @@ -277,5 +278,11 @@ install(TARGETS ${SPIRV_INSTALL_TARGETS} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/libspirv/libspirv.h - DESTINATION include/libspirv/) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv-tools/libspirv.h + DESTINATION include/spirv-tools/) +# The installation is broken without these header files from the SPIR-V Registry. +# The libspirv.h header includes them. +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/spirv.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/GLSL.std.450.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv/OpenCL.std.h + DESTINATION include/spirv/) diff --git a/include/libspirv/libspirv.h b/include/spirv-tools/libspirv.h similarity index 98% rename from include/libspirv/libspirv.h rename to include/spirv-tools/libspirv.h index 25b97554..9073bcfe 100644 --- a/include/libspirv/libspirv.h +++ b/include/spirv-tools/libspirv.h @@ -24,12 +24,12 @@ // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -#ifndef LIBSPIRV_LIBSPIRV_LIBSPIRV_H_ -#define LIBSPIRV_LIBSPIRV_LIBSPIRV_H_ +#ifndef SPIRV_TOOLS_LIBSPIRV_H_ +#define SPIRV_TOOLS_LIBSPIRV_H_ -#include "headers/GLSL.std.450.h" -#include "headers/OpenCL.std.h" -#include "headers/spirv.h" +#include "spirv/GLSL.std.450.h" +#include "spirv/OpenCL.std.h" +#include "spirv/spirv.h" #ifdef __cplusplus extern "C" { @@ -448,4 +448,4 @@ spv_result_t spvBinaryParse(const spv_const_context context, void* user_data, } #endif -#endif // LIBSPIRV_LIBSPIRV_LIBSPIRV_H_ +#endif // SPIRV_TOOLS_LIBSPIRV_H_ diff --git a/external/include/headers/GLSL.std.450.h b/include/spirv/GLSL.std.450.h similarity index 100% rename from external/include/headers/GLSL.std.450.h rename to include/spirv/GLSL.std.450.h diff --git a/external/include/headers/OpenCL.std.h b/include/spirv/OpenCL.std.h similarity index 100% rename from external/include/headers/OpenCL.std.h rename to include/spirv/OpenCL.std.h diff --git a/external/include/headers/spirv.h b/include/spirv/spirv.h similarity index 100% rename from external/include/headers/spirv.h rename to include/spirv/spirv.h diff --git a/external/include/headers/spirv.py b/include/spirv/spirv.py similarity index 100% rename from external/include/headers/spirv.py rename to include/spirv/spirv.py diff --git a/source/assembly_grammar.h b/source/assembly_grammar.h index 15f34da8..fab31b89 100644 --- a/source/assembly_grammar.h +++ b/source/assembly_grammar.h @@ -27,8 +27,8 @@ #ifndef LIBSPIRV_ASSEMBLY_GRAMMAR_H_ #define LIBSPIRV_ASSEMBLY_GRAMMAR_H_ -#include "libspirv/libspirv.h" #include "operand.h" +#include "spirv-tools/libspirv.h" #include "table.h" namespace libspirv { diff --git a/source/binary.cpp b/source/binary.cpp index bedd3b03..4db32269 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -36,9 +36,9 @@ #include "assembly_grammar.h" #include "diagnostic.h" #include "ext_inst.h" -#include "libspirv/libspirv.h" #include "opcode.h" #include "operand.h" +#include "spirv-tools/libspirv.h" #include "spirv_constant.h" #include "spirv_endian.h" diff --git a/source/binary.h b/source/binary.h index c51fe5fd..7155597e 100644 --- a/source/binary.h +++ b/source/binary.h @@ -27,7 +27,7 @@ #ifndef LIBSPIRV_BINARY_H_ #define LIBSPIRV_BINARY_H_ -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "table.h" // Functions diff --git a/source/diagnostic.cpp b/source/diagnostic.cpp index 60502c02..a785354e 100644 --- a/source/diagnostic.cpp +++ b/source/diagnostic.cpp @@ -31,7 +31,7 @@ #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" // Diagnostic API diff --git a/source/diagnostic.h b/source/diagnostic.h index c80b77d4..38a35ea0 100644 --- a/source/diagnostic.h +++ b/source/diagnostic.h @@ -31,7 +31,7 @@ #include #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" namespace libspirv { diff --git a/source/disassemble.cpp b/source/disassemble.cpp index 1605924d..9fae7e5a 100644 --- a/source/disassemble.cpp +++ b/source/disassemble.cpp @@ -36,9 +36,9 @@ #include "binary.h" #include "diagnostic.h" #include "ext_inst.h" -#include "libspirv/libspirv.h" #include "opcode.h" #include "print.h" +#include "spirv-tools/libspirv.h" #include "spirv_constant.h" #include "spirv_endian.h" #include "util/hex_float.h" diff --git a/source/ext_inst.h b/source/ext_inst.h index 1fd58137..f4dcecbb 100644 --- a/source/ext_inst.h +++ b/source/ext_inst.h @@ -27,7 +27,7 @@ #ifndef LIBSPIRV_EXT_INST_H_ #define LIBSPIRV_EXT_INST_H_ -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "table.h" // Gets the type of the extended instruction set with the specified name. diff --git a/source/instruction.h b/source/instruction.h index 61549b67..9188592a 100644 --- a/source/instruction.h +++ b/source/instruction.h @@ -30,7 +30,7 @@ #include #include -#include "headers/spirv.h" +#include "spirv/spirv.h" #include "table.h" diff --git a/source/opcode.cpp b/source/opcode.cpp index 68c45bb5..63ba9a9c 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -32,7 +32,7 @@ #include #include "instruction.h" -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "spirv_constant.h" #include "spirv_endian.h" #include "spirv_operands.h" diff --git a/source/opcode.h b/source/opcode.h index 8fe9e1fb..e6ff14a2 100644 --- a/source/opcode.h +++ b/source/opcode.h @@ -28,7 +28,7 @@ #define LIBSPIRV_OPCODE_H_ #include "instruction.h" -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "table.h" // Returns the name of a registered SPIR-V generator as a null-terminated diff --git a/source/operand.h b/source/operand.h index fe15a421..78fc9184 100644 --- a/source/operand.h +++ b/source/operand.h @@ -29,7 +29,7 @@ #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "table.h" // A sequence of operand types. diff --git a/source/spirv_constant.h b/source/spirv_constant.h index 0c85fbf3..3ade7ccd 100644 --- a/source/spirv_constant.h +++ b/source/spirv_constant.h @@ -27,7 +27,7 @@ #ifndef LIBSPIRV_SPIRV_CONSTANT_H_ #define LIBSPIRV_SPIRV_CONSTANT_H_ -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" // Version number macros. diff --git a/source/spirv_definition.h b/source/spirv_definition.h index 3872e760..d7424dc4 100644 --- a/source/spirv_definition.h +++ b/source/spirv_definition.h @@ -29,7 +29,7 @@ #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" // A bit mask representing a set of capabilities. // Currently there are 57 distinct capabilities, so 64 bits diff --git a/source/spirv_endian.h b/source/spirv_endian.h index 9d06b293..57ffc4f9 100644 --- a/source/spirv_endian.h +++ b/source/spirv_endian.h @@ -27,7 +27,7 @@ #ifndef LIBSPIRV_SPIRV_ENDIAN_H_ #define LIBSPIRV_SPIRV_ENDIAN_H_ -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" // Converts a word in the specified endianness to the host native endianness. uint32_t spvFixWord(const uint32_t word, const spv_endianness_t endianness); diff --git a/source/table.h b/source/table.h index c52b9f24..9e427dd4 100644 --- a/source/table.h +++ b/source/table.h @@ -27,7 +27,7 @@ #ifndef LIBSPIRV_TABLE_H_ #define LIBSPIRV_TABLE_H_ -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "spirv_definition.h" #include "spirv_operands.h" diff --git a/source/text.cpp b/source/text.cpp index bdac21bb..84b92deb 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -43,9 +43,9 @@ #include "diagnostic.h" #include "ext_inst.h" #include "instruction.h" -#include "libspirv/libspirv.h" #include "opcode.h" #include "operand.h" +#include "spirv-tools/libspirv.h" #include "spirv_constant.h" #include "table.h" #include "text_handler.h" diff --git a/source/text.h b/source/text.h index 03755229..c6841746 100644 --- a/source/text.h +++ b/source/text.h @@ -29,8 +29,8 @@ #include -#include "libspirv/libspirv.h" #include "operand.h" +#include "spirv-tools/libspirv.h" #include "spirv_constant.h" typedef enum spv_literal_type_t { diff --git a/source/text_handler.h b/source/text_handler.h index 1e962063..6f003db0 100644 --- a/source/text_handler.h +++ b/source/text_handler.h @@ -34,7 +34,7 @@ #include "diagnostic.h" #include "instruction.h" -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "text.h" namespace libspirv { diff --git a/include/util/bitutils.h b/source/util/bitutils.h similarity index 100% rename from include/util/bitutils.h rename to source/util/bitutils.h diff --git a/include/util/hex_float.h b/source/util/hex_float.h similarity index 99% rename from include/util/hex_float.h rename to source/util/hex_float.h index 3ed4efcf..879d0ce2 100644 --- a/include/util/hex_float.h +++ b/source/util/hex_float.h @@ -24,8 +24,8 @@ // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -#ifndef _LIBSPIRV_UTIL_HEX_FLOAT_H_ -#define _LIBSPIRV_UTIL_HEX_FLOAT_H_ +#ifndef LIBSPIRV_UTIL_HEX_FLOAT_H_ +#define LIBSPIRV_UTIL_HEX_FLOAT_H_ #include #include @@ -1087,4 +1087,4 @@ inline std::ostream& operator<<(std::ostream& os, } } -#endif // _LIBSPIRV_UTIL_HEX_FLOAT_H_ +#endif // LIBSPIRV_UTIL_HEX_FLOAT_H_ diff --git a/source/validate.cpp b/source/validate.cpp index f06c462d..585053df 100644 --- a/source/validate.cpp +++ b/source/validate.cpp @@ -30,7 +30,7 @@ #include "binary.h" #include "diagnostic.h" #include "instruction.h" -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "opcode.h" #include "operand.h" #include "spirv_constant.h" diff --git a/source/validate.h b/source/validate.h index c87aa08a..d6e180ac 100644 --- a/source/validate.h +++ b/source/validate.h @@ -34,12 +34,11 @@ #include #include -#include "libspirv/libspirv.h" - #include "assembly_grammar.h" #include "binary.h" #include "diagnostic.h" #include "instruction.h" +#include "spirv-tools/libspirv.h" #include "spirv_definition.h" #include "table.h" diff --git a/source/validate_id.cpp b/source/validate_id.cpp index f5118a86..4668504a 100644 --- a/source/validate_id.cpp +++ b/source/validate_id.cpp @@ -31,8 +31,8 @@ #include "diagnostic.h" #include "instruction.h" -#include "libspirv/libspirv.h" #include "opcode.h" +#include "spirv-tools/libspirv.h" #include "validate.h" #define spvCheck(condition, action) \ diff --git a/source/validate_layout.cpp b/source/validate_layout.cpp index dd30c2b3..42f935cd 100644 --- a/source/validate_layout.cpp +++ b/source/validate_layout.cpp @@ -27,7 +27,7 @@ // Source code for logical layout validation as described in section 2.4 #include "validate_passes.h" -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" #include "diagnostic.h" #include "opcode.h" diff --git a/source/validate_types.cpp b/source/validate_types.cpp index 39fcdcf8..f0bb998c 100644 --- a/source/validate_types.cpp +++ b/source/validate_types.cpp @@ -31,7 +31,7 @@ #include #include -#include "headers/spirv.h" +#include "spirv/spirv.h" #include "spirv_definition.h" #include "validate.h" diff --git a/test/HexFloat.cpp b/test/HexFloat.cpp index a2c5521c..1c783cd2 100644 --- a/test/HexFloat.cpp +++ b/test/HexFloat.cpp @@ -33,7 +33,7 @@ #include #include "UnitSPIRV.h" -#include "util/hex_float.h" +#include "source/util/hex_float.h" namespace { using ::testing::Eq; diff --git a/test/ImmediateInt.cpp b/test/ImmediateInt.cpp index ebd30a24..bdfdd874 100644 --- a/test/ImmediateInt.cpp +++ b/test/ImmediateInt.cpp @@ -30,8 +30,8 @@ #include +#include "source/util/bitutils.h" #include "TestFixture.h" -#include "util/bitutils.h" namespace { diff --git a/test/TextToBinary.cpp b/test/TextToBinary.cpp index 9f518673..e30e3328 100644 --- a/test/TextToBinary.cpp +++ b/test/TextToBinary.cpp @@ -33,8 +33,8 @@ #include "TestFixture.h" #include "UnitSPIRV.h" #include "source/spirv_constant.h" -#include "util/bitutils.h" -#include "util/hex_float.h" +#include "source/util/bitutils.h" +#include "source/util/hex_float.h" namespace { diff --git a/test/UnitSPIRV.h b/test/UnitSPIRV.h index 0264bdf6..558b790c 100644 --- a/test/UnitSPIRV.h +++ b/test/UnitSPIRV.h @@ -31,7 +31,6 @@ #include -#include "libspirv/libspirv.h" #include "source/assembly_grammar.h" #include "source/binary.h" #include "source/diagnostic.h" @@ -40,6 +39,7 @@ #include "source/text.h" #include "source/text_handler.h" #include "source/validate.h" +#include "spirv-tools/libspirv.h" #include diff --git a/test/ValidationState.cpp b/test/ValidationState.cpp index fc164b94..a172b978 100644 --- a/test/ValidationState.cpp +++ b/test/ValidationState.cpp @@ -30,7 +30,7 @@ #include #include -#include "headers/spirv.h" +#include "spirv/spirv.h" #include "source/validate.h" diff --git a/tools/as/as.cpp b/tools/as/as.cpp index 96f2cada..c7380b65 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -28,7 +28,7 @@ #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" void print_usage(char* argv0) { printf( diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 48664de6..cd472d0c 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -29,7 +29,7 @@ #include #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" static void print_usage(char* argv0) { printf( diff --git a/tools/val/val.cpp b/tools/val/val.cpp index bc29dd4e..db053643 100644 --- a/tools/val/val.cpp +++ b/tools/val/val.cpp @@ -30,7 +30,7 @@ #include -#include "libspirv/libspirv.h" +#include "spirv-tools/libspirv.h" void print_usage(char* argv0) { printf(