| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728 |
- load(
- ":build_defs.bzl",
- "CLDEBUGINFO100_GRAMMAR_JSON_FILE",
- "COMMON_COPTS",
- "DEBUGINFO_GRAMMAR_JSON_FILE",
- "SHDEBUGINFO100_GRAMMAR_JSON_FILE",
- "TEST_COPTS",
- "generate_core_tables",
- "generate_enum_string_mapping",
- "generate_extinst_lang_headers",
- "generate_glsl_tables",
- "generate_opencl_tables",
- "generate_vendor_tables",
- "incompatible_with",
- )
- package(
- default_visibility = ["//visibility:private"],
- features = [
- "layering_check",
- ],
- )
- licenses(["notice"])
- exports_files([
- "CHANGES",
- "LICENSE",
- ])
- py_binary(
- name = "generate_grammar_tables",
- srcs = ["utils/generate_grammar_tables.py"],
- )
- py_binary(
- name = "generate_language_headers",
- srcs = ["utils/generate_language_headers.py"],
- )
- generate_core_tables(version = "unified1")
- generate_enum_string_mapping(version = "unified1")
- generate_opencl_tables(version = "unified1")
- generate_glsl_tables(version = "unified1")
- generate_vendor_tables(extension = "spv-amd-shader-explicit-vertex-parameter")
- generate_vendor_tables(extension = "spv-amd-shader-trinary-minmax")
- generate_vendor_tables(extension = "spv-amd-gcn-shader")
- generate_vendor_tables(extension = "spv-amd-shader-ballot")
- generate_vendor_tables(extension = "debuginfo")
- generate_vendor_tables(extension = "nonsemantic.clspvreflection")
- generate_vendor_tables(extension = "nonsemantic.vkspreflection")
- generate_vendor_tables(
- extension = "opencl.debuginfo.100",
- operand_kind_prefix = "CLDEBUG100_",
- )
- generate_vendor_tables(
- extension = "nonsemantic.shader.debuginfo.100",
- operand_kind_prefix = "SHDEBUG100_",
- )
- generate_extinst_lang_headers(
- name = "DebugInfo",
- grammar = DEBUGINFO_GRAMMAR_JSON_FILE,
- )
- generate_extinst_lang_headers(
- name = "OpenCLDebugInfo100",
- grammar = CLDEBUGINFO100_GRAMMAR_JSON_FILE,
- )
- generate_extinst_lang_headers(
- name = "NonSemanticShaderDebugInfo100",
- grammar = SHDEBUGINFO100_GRAMMAR_JSON_FILE,
- )
- py_binary(
- name = "generate_registry_tables",
- srcs = ["utils/generate_registry_tables.py"],
- )
- genrule(
- name = "generators_inc",
- srcs = ["@spirv_headers//:spirv_xml_registry"],
- outs = ["generators.inc"],
- cmd = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)",
- cmd_bat = "$(location :generate_registry_tables) --xml=$(location @spirv_headers//:spirv_xml_registry) --generator-output=$(location generators.inc)",
- tools = [":generate_registry_tables"],
- )
- py_binary(
- name = "update_build_version",
- srcs = ["utils/update_build_version.py"],
- )
- genrule(
- name = "build_version_inc",
- srcs = ["CHANGES"],
- outs = ["build-version.inc"],
- cmd = "SOURCE_DATE_EPOCH=0 $(location :update_build_version) $(location CHANGES) $(location build-version.inc)",
- cmd_bat = "set SOURCE_DATE_EPOCH=0 && $(location :update_build_version) $(location CHANGES) $(location build-version.inc)",
- tools = [":update_build_version"],
- )
- # Libraries
- cc_library(
- name = "spirv_tools",
- hdrs = [
- "include/spirv-tools/libspirv.h",
- "include/spirv-tools/libspirv.hpp",
- ],
- copts = COMMON_COPTS,
- includes = ["include"],
- linkstatic = 1,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ],
- )
- cc_library(
- name = "spirv_tools_internal",
- srcs = glob([
- "source/*.cpp",
- "source/util/*.cpp",
- "source/val/*.cpp",
- ]) + [
- ":build_version_inc",
- ":gen_core_tables_unified1",
- ":gen_enum_string_mapping",
- ":gen_extinst_lang_headers_DebugInfo",
- ":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
- ":gen_extinst_lang_headers_OpenCLDebugInfo100",
- ":gen_glsl_tables_unified1",
- ":gen_opencl_tables_unified1",
- ":gen_vendor_tables_debuginfo",
- ":gen_vendor_tables_nonsemantic_clspvreflection",
- ":gen_vendor_tables_nonsemantic_vkspreflection",
- ":gen_vendor_tables_nonsemantic_shader_debuginfo_100",
- ":gen_vendor_tables_opencl_debuginfo_100",
- ":gen_vendor_tables_spv_amd_gcn_shader",
- ":gen_vendor_tables_spv_amd_shader_ballot",
- ":gen_vendor_tables_spv_amd_shader_explicit_vertex_parameter",
- ":gen_vendor_tables_spv_amd_shader_trinary_minmax",
- ":generators_inc",
- ],
- hdrs = [
- "include/spirv-tools/libspirv.h",
- "include/spirv-tools/libspirv.hpp",
- ":gen_extinst_lang_headers_DebugInfo",
- ":gen_extinst_lang_headers_NonSemanticShaderDebugInfo100",
- ":gen_extinst_lang_headers_OpenCLDebugInfo100",
- ] + glob([
- "source/*.h",
- "source/util/*.h",
- "source/val/*.h",
- ]),
- copts = COMMON_COPTS,
- includes = ["include"],
- deps = [
- "@spirv_headers//:spirv_common_headers",
- "@spirv_headers//:spirv_cpp11_headers",
- ],
- )
- cc_library(
- name = "spirv_tools_opt",
- hdrs = [
- "include/spirv-tools/optimizer.hpp",
- ],
- copts = COMMON_COPTS,
- linkstatic = 1,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools",
- ":spirv_tools_opt_internal",
- ],
- )
- cc_library(
- name = "spirv_tools_opt_internal",
- srcs = glob(["source/opt/*.cpp"]) + [
- ":gen_vendor_tables_spv_amd_shader_ballot",
- ],
- hdrs = glob(["source/opt/*.h"]) + [
- "include/spirv-tools/optimizer.hpp",
- ],
- copts = COMMON_COPTS,
- deps = [
- ":spirv_tools_internal",
- "@spirv_headers//:spirv_common_headers",
- "@spirv_headers//:spirv_c_headers",
- ],
- )
- cc_library(
- name = "spirv_tools_reduce",
- srcs = glob(["source/reduce/*.cpp"]),
- hdrs = glob(["source/reduce/*.h"]),
- copts = COMMON_COPTS,
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ],
- )
- cc_library(
- name = "spirv_tools_link",
- srcs = glob(["source/link/*.cpp"]),
- hdrs = ["include/spirv-tools/linker.hpp"],
- copts = COMMON_COPTS,
- linkstatic = 1,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ],
- )
- cc_library(
- name = "spirv_tools_lint_internal",
- srcs = glob([
- "source/lint/*.cpp",
- "source/lint/*.h",
- ]),
- hdrs = ["include/spirv-tools/linter.hpp"] + glob([
- "source/lint/*.h",
- ]),
- copts = COMMON_COPTS,
- includes = ["include"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ],
- )
- cc_library(
- name = "spirv_tools_lint",
- hdrs = ["include/spirv-tools/linter.hpp"],
- copts = COMMON_COPTS,
- includes = ["include"],
- linkstatic = 1,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools",
- ":spirv_tools_lint_internal",
- ],
- )
- cc_library(
- name = "tools_util",
- srcs = glob(["tools/util/*.cpp"]),
- hdrs = glob(["tools/util/*.h"]),
- copts = COMMON_COPTS,
- deps = [":spirv_tools"],
- )
- cc_library(
- name = "tools_io",
- hdrs = ["tools/io.h"],
- srcs = ["tools/io.cpp"],
- copts = COMMON_COPTS,
- )
- # Tools
- cc_binary(
- name = "spirv-as",
- srcs = [
- "tools/as/as.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-dis",
- srcs = [
- "tools/dis/dis.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-objdump",
- srcs = [
- "tools/objdump/extract_source.cpp",
- "tools/objdump/extract_source.h",
- "tools/objdump/objdump.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ":tools_io",
- ":tools_util",
- "@spirv_headers//:spirv_cpp_headers",
- ],
- )
- cc_binary(
- name = "spirv-val",
- srcs = [
- "tools/val/val.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-opt",
- srcs = [
- "tools/opt/opt.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-reduce",
- srcs = [
- "tools/reduce/reduce.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ":spirv_tools_reduce",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-link",
- srcs = [
- "tools/link/linker.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_link",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-lint",
- srcs = [
- "tools/lint/lint.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_lint",
- ":spirv_tools_opt_internal",
- ":tools_io",
- ":tools_util",
- ],
- )
- cc_binary(
- name = "spirv-cfg",
- srcs = [
- "tools/cfg/bin_to_dot.cpp",
- "tools/cfg/bin_to_dot.h",
- "tools/cfg/cfg.cpp",
- ],
- copts = COMMON_COPTS,
- visibility = ["//visibility:public"],
- deps = [
- ":spirv_tools_internal",
- ":tools_io",
- ":tools_util",
- ],
- )
- # Unit tests
- cc_library(
- name = "test_lib",
- testonly = 1,
- srcs = [
- "test/unit_spirv.cpp",
- ],
- hdrs = [
- "test/test_fixture.h",
- "test/unit_spirv.h",
- ],
- copts = TEST_COPTS,
- deps = [
- ":spirv_tools_internal",
- "@googletest//:gtest",
- ],
- )
- # PCH (precompiled header) tests only work when using CMake and MSVC on Windows,
- # so they will be skipped in the Bazel builds.
- [cc_test(
- name = "base_{testcase}_test".format(testcase = f[len("test/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS + ["-DTESTING"],
- linkstatic = 1,
- target_compatible_with = {
- "test/timer_test.cpp": incompatible_with(["@bazel_tools//src/conditions:windows"]),
- }.get(f, []),
- deps = [
- "tools_util",
- ":spirv_tools_internal",
- ":test_lib",
- ":tools_io",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- [
- "test/*_test.cpp",
- "test/tools/*_test.cpp",
- ],
- exclude = [
- "test/cpp_interface_test.cpp",
- "test/pch_test.cpp",
- ],
- )]
- cc_test(
- name = "base_cpp_interface_test",
- size = "small",
- srcs = ["test/cpp_interface_test.cpp"],
- linkstatic = 1,
- deps = [
- ":spirv_tools_opt_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- "@spirv_headers//:spirv_cpp11_headers",
- ],
- )
- cc_test(
- name = "base_ilist_test",
- size = "small",
- srcs = ["test/util/ilist_test.cpp"],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":spirv_tools_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- )
- cc_library(
- name = "link_test_lib",
- testonly = 1,
- hdrs = ["test/link/linker_fixture.h"],
- copts = TEST_COPTS,
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_link",
- ":test_lib",
- "@effcee//:effcee",
- "@re2//:re2",
- ],
- )
- [cc_test(
- name = "link_{testcase}_test".format(testcase = f[len("test/link/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":link_test_lib",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- ["test/link/*_test.cpp"],
- )]
- [cc_test(
- name = "lint_{testcase}_test".format(testcase = f[len("test/lint/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":spirv_tools",
- ":spirv_tools_lint_internal",
- ":spirv_tools_opt_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- ["test/lint/*_test.cpp"],
- )]
- cc_library(
- name = "opt_test_lib",
- testonly = 1,
- srcs = [
- "test/opt/pass_utils.cpp",
- ],
- hdrs = [
- "test/opt/assembly_builder.h",
- "test/opt/function_utils.h",
- "test/opt/module_utils.h",
- "test/opt/pass_fixture.h",
- "test/opt/pass_utils.h",
- ],
- copts = TEST_COPTS,
- deps = [
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- "@effcee//:effcee",
- "@googletest//:gtest",
- ],
- )
- [cc_test(
- name = "opt_{testcase}_test".format(testcase = f[len("test/opt/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":opt_test_lib",
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ":test_lib",
- "@effcee//:effcee",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(["test/opt/*_test.cpp"])]
- [cc_test(
- name = "opt_dom_tree_{testcase}_test".format(testcase = f[len("test/opt/dominator_tree/"):-len(".cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":opt_test_lib",
- ":spirv_tools_opt_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- ["test/opt/dominator_tree/*.cpp"],
- exclude = ["test/opt/dominator_tree/pch_test_opt_dom.cpp"],
- )]
- [cc_test(
- name = "opt_loop_{testcase}_test".format(testcase = f[len("test/opt/loop_optimizations/"):-len(".cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":opt_test_lib",
- ":spirv_tools",
- ":spirv_tools_opt_internal",
- "@effcee//:effcee",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- ["test/opt/loop_optimizations/*.cpp"],
- exclude = ["test/opt/loop_optimizations/pch_test_opt_loop.cpp"],
- )]
- cc_library(
- name = "reduce_test_lib",
- testonly = 1,
- srcs = [
- "test/reduce/reduce_test_util.cpp",
- ],
- hdrs = ["test/reduce/reduce_test_util.h"],
- copts = TEST_COPTS,
- deps = [
- ":spirv_tools",
- ":spirv_tools_opt_internal",
- ":spirv_tools_reduce",
- ":test_lib",
- ":tools_io",
- "@googletest//:gtest",
- ],
- )
- [cc_test(
- name = "reduce_{testcase}_test".format(testcase = f[len("test/reduce/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":reduce_test_lib",
- ":spirv_tools_internal",
- ":spirv_tools_opt_internal",
- ":spirv_tools_reduce",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(["test/reduce/*_test.cpp"])]
- [cc_test(
- name = "util_{testcase}_test".format(testcase = f[len("test/util/"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":spirv_tools_internal",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(["test/util/*_test.cpp"])]
- cc_library(
- name = "val_test_lib",
- testonly = 1,
- srcs = [
- "test/val/val_code_generator.cpp",
- ],
- hdrs = [
- "test/val/val_code_generator.h",
- "test/val/val_fixtures.h",
- ],
- copts = TEST_COPTS,
- deps = [
- ":spirv_tools_internal",
- ":test_lib",
- ],
- )
- [cc_test(
- name = "val_{testcase}_test".format(testcase = f[len("test/val/val_"):-len("_test.cpp")]),
- size = "small",
- srcs = [f],
- copts = TEST_COPTS,
- linkstatic = 1,
- deps = [
- ":spirv_tools_internal",
- ":test_lib",
- ":val_test_lib",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- ) for f in glob(
- ["test/val/val_*_test.cpp"],
- exclude = [
- "test/val/val_capability_test.cpp",
- "test/val/val_limits_test.cpp",
- ],
- )]
- cc_test(
- name = "val_capability_test",
- size = "large",
- timeout = "long",
- srcs = ["test/val/val_capability_test.cpp"],
- copts = TEST_COPTS + ["-O3"],
- linkstatic = 1,
- deps = [
- ":spirv_tools_internal",
- ":test_lib",
- ":val_test_lib",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- )
- cc_test(
- name = "val_limits_test",
- size = "large",
- timeout = "long",
- srcs = ["test/val/val_limits_test.cpp"],
- copts = TEST_COPTS + [
- "-O3",
- ],
- linkstatic = 1,
- deps = [
- ":test_lib",
- ":val_test_lib",
- "@googletest//:gtest",
- "@googletest//:gtest_main",
- ],
- )
|