aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Farrell <jamesfarrell@google.com>2023-01-19 20:23:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-01-19 20:23:25 +0000
commit8045a61b8c6b79c9fdaa86f36653a824880bab4d (patch)
tree07aded32876fb98324f1fb374440d20bd5f0e3ba
parent07078b0d4af6ef4f9dbd70d592302d42165c6dd2 (diff)
downloadshaderc-ndk-r27-release.tar.gz
Revert "Merge commit 'd0b02222f33e1e5e1f521e4e4e1cbfa7fe2cf540' ..."ndk-r26dndk-r26cndk-r26bndk-r26-rc1ndk-r26-beta1ndk-r26ndk-r27-releasendk-r26-releasemaster-ndk
Revert submission 2388945-update-shaderc Reason for revert: Breaks NDK build on darwin. Reverted changes: /q/submissionid:2388945-update-shaderc Change-Id: Ibc6fdbd0cf08d87cc74292a1246ecfc2d4f2c4c3
-rw-r--r--CHANGES13
-rw-r--r--CMakeLists.txt2
-rw-r--r--DEPS8
-rw-r--r--README.md23
-rw-r--r--cmake/setup_build.cmake74
-rw-r--r--glslc/CMakeLists.txt3
-rw-r--r--glslc/test/assembly.py2
-rw-r--r--glslc/test/expect.py2
-rw-r--r--glslc/test/option_dash_cap_O.py6
-rw-r--r--glslc/test/option_dash_o.py2
-rw-r--r--kokoro/linux/continuous_gcc_coverage.cfg16
-rw-r--r--kokoro/linux/presubmit_gcc_coverage.cfg16
-rw-r--r--libshaderc/CMakeLists.txt1
-rw-r--r--libshaderc/src/common_shaders_for_test.h6
-rw-r--r--libshaderc_util/include/libshaderc_util/string_piece.h2
-rwxr-xr-xutils/roll-deps6
16 files changed, 148 insertions, 34 deletions
diff --git a/CHANGES b/CHANGES
index fc1eb0d..0af1257 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,18 +1,5 @@
Revision history for Shaderc
-v2023.1 2022-01-13
- - General/Build
- - Removed support for GCC-based code coverage builds
- - Update minimum CMake to 3.17.2
- - Fix C++20 compatibility: explicitly construct string_piece when
- comparing to `char*`
-
-v2022.4 2022-11-30
- - Update to Glslang 11
- - Update SPIRV-Tools, SPIRV-Headers dependencies
- - Add Cmake BUNDLE DESTINATION option for target install
- - The code coverage build is no longer being tested
-
v2022.3 2022-10-12
- #1264: Implement defaults for SPV_EXT_mesh_shader builtins
- Update SPIRV-Tools to v2022.4
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0232f9b..3bf9d16 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.17.2)
+cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP00091)
# Enable MSVC Runtime Library Property
diff --git a/DEPS b/DEPS
index 440126d..61e1b72 100644
--- a/DEPS
+++ b/DEPS
@@ -5,11 +5,11 @@ vars = {
'khronos_git': 'https://github.com/KhronosGroup',
'effcee_revision' : '35912e1b7778ec2ddcff7e7188177761539e59',
- 'glslang_revision': '1fb2f1d7896627d62a289439a2c3e750e551a7ab',
+ 'glslang_revision': '89db4e1caa273a057ea46deba709c6e50001b314',
'googletest_revision': 'd9bb8412d60b993365abb53f00b6dad9b2c01b62',
- 're2_revision': '954656f47fe8fb505d4818da1e128417a79ea500',
- 'spirv_headers_revision': 'd13b52222c39a7e9a401b44646f0ca3a640fbd47',
- 'spirv_tools_revision': '0e6fbba7762c071118b3e84258a358ede31fb609',
+ 're2_revision': 'd2836d1b1c34c4e330a85a1006201db474bf2c8a',
+ 'spirv_headers_revision': '85a1ed200d50660786c1a88d9166e871123cce39',
+ 'spirv_tools_revision': 'eb0a36633d2acf4de82588504f951ad0f2cecacb',
}
deps = {
diff --git a/README.md b/README.md
index 7836f37..0e3075b 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,15 @@ installed regardless of your OS:
- Shaderc is tested with cmake 3.17.2
- [Python 3](http://www.python.org/): for utility scripts and running the test suite.
+On Linux, the following tools should be installed:
+
+- [`gcov`](https://gcc.gnu.org/onlinedocs/gcc/Gcov.html): for testing code
+ coverage, provided by the `gcc` package on Ubuntu.
+- [`lcov`](http://ltp.sourceforge.net/coverage/lcov.php): a graphical frontend
+ for `gcov`, provided by the `lcov` package on Ubuntu.
+- [`genhtml`](http://linux.die.net/man/1/genhtml): for creating reports in html
+ format from `lcov` output, provided by the `lcov` package on Ubuntu.
+
On Linux, if cross compiling to Windows:
- [`mingw`](http://www.mingw.org): A GCC-based cross compiler targeting Windows
so that generated executables use the Microsoft C runtime libraries.
@@ -216,6 +225,20 @@ test.vert
We track bugs using GitHub -- click on the "Issues" button on
[the project's GitHub page](https://github.com/google/shaderc).
+## Test coverage
+
+On Linux, you can obtain test coverage as follows:
+
+```sh
+cd $BUILD_DIR
+cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_CODE_COVERAGE=ON $SOURCE_DIR
+ninja
+ninja report-coverage
+```
+
+Then the coverage report can be found under the `$BUILD_DIR/coverage-report`
+directory.
+
## Bindings
Bindings are maintained by third parties, may contain content
diff --git a/cmake/setup_build.cmake b/cmake/setup_build.cmake
index 994de9f..5dab384 100644
--- a/cmake/setup_build.cmake
+++ b/cmake/setup_build.cmake
@@ -52,6 +52,80 @@ else()
find_package(PythonInterp 3 REQUIRED)
endif()
+
+option(ENABLE_CODE_COVERAGE "Enable collecting code coverage." OFF)
+if (ENABLE_CODE_COVERAGE)
+ message(STATUS "Shaderc: code coverage report is on.")
+ if (NOT UNIX)
+ message(FATAL_ERROR "Code coverage on non-UNIX system not supported yet.")
+ endif()
+ if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+ message(FATAL_ERROR "Code coverage with non-Debug build can be misleading.")
+ endif()
+ find_program(LCOV_EXE NAMES lcov)
+ if (NOT LCOV_EXE)
+ message(FATAL_ERROR "lcov was not found")
+ endif()
+ find_program(GENHTML_EXE NAMES genhtml)
+ if (NOT GENHTML_EXE)
+ message(FATAL_ERROR "genhtml was not found")
+ endif()
+
+ set(LCOV_BASE_DIR ${CMAKE_BINARY_DIR})
+ set(LCOV_INFO_FILE ${LCOV_BASE_DIR}/lcov.info)
+ set(COVERAGE_STAT_HTML_DIR ${LCOV_BASE_DIR}/coverage-report)
+
+ add_custom_target(clean-coverage
+ # Remove all gcov .gcda files in the directory recursively.
+ COMMAND ${LCOV_EXE} --directory . --zerocounters -q
+ # Remove all lcov .info files.
+ COMMAND ${CMAKE_COMMAND} -E remove ${LCOV_INFO_FILE}
+ # Remove all html report files.
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${COVERAGE_STAT_HTML_DIR}
+ # TODO(antiagainst): the following two commands are here to remedy the
+ # problem of "reached unexpected end of file" experienced by lcov.
+ # The symptom is that some .gcno files are wrong after code change and
+ # recompiling. We don't know the exact reason yet. Figure it out.
+ # Remove all .gcno files in the directory recursively.
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${shaderc_SOURCE_DIR}/utils/remove-file-by-suffix.py . ".gcno"
+ # .gcno files are not tracked by CMake. So no recompiling is triggered
+ # even if they are missing. Unfortunately, we just removed all of them
+ # in the above.
+ COMMAND ${CMAKE_COMMAND} --build . --target clean
+ WORKING_DIRECTORY ${LCOV_BASE_DIR}
+ COMMENT "Clean coverage files"
+ )
+
+ add_custom_target(report-coverage
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}
+ # Run all tests.
+ COMMAND ctest --output-on-failure
+ # Collect coverage data from gcov .gcda files.
+ COMMAND ${LCOV_EXE} --directory . --capture -o ${LCOV_INFO_FILE}
+ # Remove coverage info for system header files.
+ COMMAND ${LCOV_EXE}
+ --remove ${LCOV_INFO_FILE} '/usr/include/*' -o ${LCOV_INFO_FILE}
+ # Remove coverage info for external and third_party code.
+ COMMAND ${LCOV_EXE}
+ --remove ${LCOV_INFO_FILE} '${shaderc_SOURCE_DIR}/ext/*'
+ -o ${LCOV_INFO_FILE}
+
+ COMMAND ${LCOV_EXE}
+ --remove ${LCOV_INFO_FILE} '${shaderc_SOURCE_DIR}/third_party/*'
+ -o ${LCOV_INFO_FILE}
+ # Remove coverage info for tests.
+ COMMAND ${LCOV_EXE}
+ --remove ${LCOV_INFO_FILE} '*_test.cc' -o ${LCOV_INFO_FILE}
+ # Generate html report file.
+ COMMAND ${GENHTML_EXE}
+ ${LCOV_INFO_FILE} -t "Coverage Report" -o ${COVERAGE_STAT_HTML_DIR}
+ DEPENDS clean-coverage
+ WORKING_DIRECTORY ${LCOV_BASE_DIR}
+ COMMENT "Collect and analyze coverage data"
+ )
+endif()
+
option(DISABLE_RTTI "Disable RTTI in builds")
if(DISABLE_RTTI)
if(UNIX)
diff --git a/glslc/CMakeLists.txt b/glslc/CMakeLists.txt
index c8fa6d5..31664d1 100644
--- a/glslc/CMakeLists.txt
+++ b/glslc/CMakeLists.txt
@@ -67,8 +67,7 @@ shaderc_add_asciidoc(glslc_doc_README README)
if(SHADERC_ENABLE_INSTALL)
install(TARGETS glslc_exe
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR})
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(SHADERC_ENABLE_INSTALL)
add_subdirectory(test)
diff --git a/glslc/test/assembly.py b/glslc/test/assembly.py
index c7b8511..30fdba4 100644
--- a/glslc/test/assembly.py
+++ b/glslc/test/assembly.py
@@ -21,7 +21,7 @@ def assembly_comments():
return """
; SPIR-V
; Version: 1.0
- ; Generator: Google Shaderc over Glslang; 11
+ ; Generator: Google Shaderc over Glslang; 10
; Bound: 6
; Schema: 0"""
diff --git a/glslc/test/expect.py b/glslc/test/expect.py
index c58557d..9ac54b2 100644
--- a/glslc/test/expect.py
+++ b/glslc/test/expect.py
@@ -27,7 +27,7 @@ import sys
from glslc_test_framework import GlslCTest
from builtins import bytes
-GLSLANG_GENERATOR_VERSION=11
+GLSLANG_GENERATOR_VERSION=10
SHADERC_GENERATOR_NUMBER=13
SHADERC_GENERATOR_WORD=(SHADERC_GENERATOR_NUMBER << 16) + GLSLANG_GENERATOR_VERSION
ASSEMBLER_GENERATOR_WORD=(7<<16)
diff --git a/glslc/test/option_dash_cap_O.py b/glslc/test/option_dash_cap_O.py
index fa474f9..337610a 100644
--- a/glslc/test/option_dash_cap_O.py
+++ b/glslc/test/option_dash_cap_O.py
@@ -23,7 +23,7 @@ EMPTY_SHADER_IN_CWD = Directory('.', [File('shader.vert', MINIMAL_SHADER)])
ASSEMBLY_WITH_DEBUG_SOURCE = [
'; SPIR-V\n',
'; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
+ '; Generator: Google Shaderc over Glslang; 10\n',
'; Bound: 7\n',
'; Schema: 0\n',
' OpCapability Shader\n',
@@ -52,7 +52,7 @@ ASSEMBLY_WITH_DEBUG_SOURCE = [
ASSEMBLY_WITH_DEBUG = [
'; SPIR-V\n',
'; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
+ '; Generator: Google Shaderc over Glslang; 10\n',
'; Bound: 6\n',
'; Schema: 0\n',
' OpCapability Shader\n',
@@ -73,7 +73,7 @@ ASSEMBLY_WITH_DEBUG = [
ASSEMBLY_WITHOUT_DEBUG = [
'; SPIR-V\n',
'; Version: 1.0\n',
- '; Generator: Google Shaderc over Glslang; 11\n',
+ '; Generator: Google Shaderc over Glslang; 10\n',
'; Bound: 6\n',
'; Schema: 0\n',
' OpCapability Shader\n',
diff --git a/glslc/test/option_dash_o.py b/glslc/test/option_dash_o.py
index 5b9ef45..cd7f1d1 100644
--- a/glslc/test/option_dash_o.py
+++ b/glslc/test/option_dash_o.py
@@ -92,7 +92,7 @@ class OutputFileBinaryAvoidsCRLFTranslation(expect.ReturnCodeIsZero,
num_newlines = len(newlines)
if num_newlines % 4 == 0:
return False, "Bad test. Need nontrivial number of newlines"
- if num_newlines != 2:
+ if num_newlines != 3:
return False, ("Update this test. Expected 3 newlines in the "
"binary, but found {}").format(num_newlines)
return self.verify_binary_length_and_header(bytes(status.stdout))
diff --git a/kokoro/linux/continuous_gcc_coverage.cfg b/kokoro/linux/continuous_gcc_coverage.cfg
new file mode 100644
index 0000000..ab2878c
--- /dev/null
+++ b/kokoro/linux/continuous_gcc_coverage.cfg
@@ -0,0 +1,16 @@
+# Copyright (C) 2017 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Continuous build configuration.
+build_file: "shaderc/kokoro/linux/build_gcc_coverage.sh"
diff --git a/kokoro/linux/presubmit_gcc_coverage.cfg b/kokoro/linux/presubmit_gcc_coverage.cfg
new file mode 100644
index 0000000..54733b0
--- /dev/null
+++ b/kokoro/linux/presubmit_gcc_coverage.cfg
@@ -0,0 +1,16 @@
+# Copyright (C) 2017 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Presubmit build configuration.
+build_file: "shaderc/kokoro/linux/build_gcc_coverage.sh"
diff --git a/libshaderc/CMakeLists.txt b/libshaderc/CMakeLists.txt
index 2cced9e..3ada419 100644
--- a/libshaderc/CMakeLists.txt
+++ b/libshaderc/CMakeLists.txt
@@ -57,7 +57,6 @@ if(SHADERC_ENABLE_INSTALL)
install(TARGETS shaderc shaderc_shared
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
- BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(SHADERC_ENABLE_INSTALL)
diff --git a/libshaderc/src/common_shaders_for_test.h b/libshaderc/src/common_shaders_for_test.h
index b8c581f..e177797 100644
--- a/libshaderc/src/common_shaders_for_test.h
+++ b/libshaderc/src/common_shaders_for_test.h
@@ -233,7 +233,7 @@ const char kVertexOnlyShaderWithInvalidPragma[] =
const char* kMinimalShaderDisassemblySubstrings[] = {
"; SPIR-V\n"
"; Version: 1.0\n"
- "; Generator: Google Shaderc over Glslang; 11\n"
+ "; Generator: Google Shaderc over Glslang; 10\n"
"; Bound:",
" OpCapability Shader\n",
@@ -245,7 +245,7 @@ const char* kMinimalShaderDisassemblySubstrings[] = {
const char* kMinimalShaderDebugInfoDisassemblySubstrings[] = {
"; SPIR-V\n"
"; Version: 1.0\n"
- "; Generator: Google Shaderc over Glslang; 11\n"
+ "; Generator: Google Shaderc over Glslang; 10\n"
"; Bound:",
" OpCapability Shader\n",
@@ -257,7 +257,7 @@ const char* kMinimalShaderDebugInfoDisassemblySubstrings[] = {
const char kMinimalShaderAssembly[] = R"(
; SPIR-V
; Version: 1.0
- ; Generator: Google Shaderc over Glslang; 11
+ ; Generator: Google Shaderc over Glslang; 10
; Bound: 6
; Schema: 0
diff --git a/libshaderc_util/include/libshaderc_util/string_piece.h b/libshaderc_util/include/libshaderc_util/string_piece.h
index 8d334df..89049d9 100644
--- a/libshaderc_util/include/libshaderc_util/string_piece.h
+++ b/libshaderc_util/include/libshaderc_util/string_piece.h
@@ -332,7 +332,7 @@ inline std::ostream& operator<<(std::ostream& os, const string_piece& piece) {
}
inline bool operator==(const char* first, const string_piece second) {
- return second == string_piece(first);
+ return second == first;
}
inline bool operator!=(const char* first, const string_piece second) {
diff --git a/utils/roll-deps b/utils/roll-deps
index ab014cd..4962fd6 100755
--- a/utils/roll-deps
+++ b/utils/roll-deps
@@ -25,11 +25,11 @@ glslang_trunk="origin/master"
googletest_dir="third_party/googletest/"
googletest_trunk="origin/master"
re2_dir="third_party/re2/"
-re2_trunk="origin/main"
+re2_trunk="origin/master"
spirv_headers_dir="third_party/spirv-headers/"
-spirv_headers_trunk="origin/main"
+spirv_headers_trunk="origin/master"
spirv_tools_dir="third_party/spirv-tools/"
-spirv_tools_trunk="origin/main"
+spirv_tools_trunk="origin/master"
# This script assumes it's parent directory is the repo root.
repo_path=$(dirname "$0")/..