Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package shaderc for openSUSE:Factory checked in at 2021-05-07 16:45:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/shaderc (Old) and /work/SRC/openSUSE:Factory/.shaderc.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "shaderc" Fri May 7 16:45:31 2021 rev:10 rq:890659 version:2021.0 Changes: -------- --- /work/SRC/openSUSE:Factory/shaderc/shaderc.changes 2021-03-12 13:31:43.198191206 +0100 +++ /work/SRC/openSUSE:Factory/.shaderc.new.2988/shaderc.changes 2021-05-07 16:45:46.588282389 +0200 @@ -1,0 +2,6 @@ +Wed May 5 09:28:57 UTC 2021 - Jan Engelhardt <jeng...@inai.de> + +- Upddate to release 2021.0 + * No user-visible changes + +------------------------------------------------------------------- Old: ---- v2020.5.tar.gz New: ---- v2021.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ shaderc.spec ++++++ --- /var/tmp/diff_new_pack.iIaR49/_old 2021-05-07 16:45:47.040280968 +0200 +++ /var/tmp/diff_new_pack.iIaR49/_new 2021-05-07 16:45:47.040280968 +0200 @@ -18,7 +18,7 @@ Name: shaderc %define lname libshaderc_shared1 -Version: 2020.5 +Version: 2021.0 Release: 0 Summary: A collection of tools, libraries and tests for shader compilation License: Apache-2.0 ++++++ v2020.5.tar.gz -> v2021.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/BUILD.gn new/shaderc-2021.0/BUILD.gn --- old/shaderc-2020.5/BUILD.gn 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/BUILD.gn 2021-04-21 23:13:25.000000000 +0200 @@ -28,7 +28,7 @@ "libshaderc_util/include/libshaderc_util/exceptions.h", "libshaderc_util/include/libshaderc_util/file_finder.h", "libshaderc_util/include/libshaderc_util/format.h", - "libshaderc_util/include/libshaderc_util/io.h", + "libshaderc_util/include/libshaderc_util/io_shaderc.h", "libshaderc_util/include/libshaderc_util/message.h", "libshaderc_util/include/libshaderc_util/mutex.h", "libshaderc_util/include/libshaderc_util/resources.h", @@ -38,7 +38,7 @@ "libshaderc_util/include/libshaderc_util/version_profile.h", "libshaderc_util/src/compiler.cc", "libshaderc_util/src/file_finder.cc", - "libshaderc_util/src/io.cc", + "libshaderc_util/src/io_shaderc.cc", "libshaderc_util/src/message.cc", "libshaderc_util/src/resources.cc", "libshaderc_util/src/shader_stage.cc", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/CHANGES new/shaderc-2021.0/CHANGES --- old/shaderc-2020.5/CHANGES 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/CHANGES 2021-04-21 23:13:25.000000000 +0200 @@ -1,5 +1,13 @@ Revision history for Shaderc +v2021.0 2021-04-21 + - Refresh dependencies (in DEPS): + - SPIRV-Tools v2021.1 + - SPIRV-Headers snapshot 2021-04-21 + - Glslang 11.2.0, snapshot 2021-04-21 + - Fixes: + #1174: Windows Bazel support: rename internal headers io.* to io_shaderc.* + v2020.5 2021-02-19 - Refresh dependencies (in DEPS): - SPIRV-Tools v2020.7 + 1 patch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/DEPS new/shaderc-2021.0/DEPS --- old/shaderc-2020.5/DEPS 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/DEPS 2021-04-21 23:13:25.000000000 +0200 @@ -5,11 +5,11 @@ 'khronos_git': 'https://github.com/KhronosGroup', 'effcee_revision' : '2ec8f8738118cc483b67c04a759fee53496c5659', - 'glslang_revision': 'e56beaee736863ce48455955158f1839e6e4c1a1', + 'glslang_revision': '60ce877de03ff03bb87fb9ef6b744ee33d076034', 'googletest_revision': '389cb68b87193358358ae87cc56d257fd0d80189', 're2_revision': '7107ebc4fbf7205151d8d2a57b2fc6e7853125d4', - 'spirv_headers_revision': 'a3fdfe81465d57efc97cfd28ac6c8190fb31a6c8', - 'spirv_tools_revision': 'ef3290bbea35935ba8fd623970511ed9f045bbd7', + 'spirv_headers_revision': 'dafead1765f6c1a5f9f8a76387dcb2abe4e54acd', + 'spirv_tools_revision': 'c2d5375fa7cc87c93f692e7200d5d974283d4391', } deps = { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/glslc/src/dependency_info.cc new/shaderc-2021.0/glslc/src/dependency_info.cc --- old/shaderc-2020.5/glslc/src/dependency_info.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/glslc/src/dependency_info.cc 2021-04-21 23:13:25.000000000 +0200 @@ -19,7 +19,7 @@ #include <sstream> #include "file.h" -#include "libshaderc_util/io.h" +#include "libshaderc_util/io_shaderc.h" namespace glslc { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/glslc/src/file_compiler.cc new/shaderc-2021.0/glslc/src/file_compiler.cc --- old/shaderc-2020.5/glslc/src/file_compiler.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/glslc/src/file_compiler.cc 2021-04-21 23:13:25.000000000 +0200 @@ -28,7 +28,7 @@ #include "file_includer.h" #include "shader_stage.h" -#include "libshaderc_util/io.h" +#include "libshaderc_util/io_shaderc.h" #include "libshaderc_util/message.h" namespace { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/glslc/src/file_includer.cc new/shaderc-2021.0/glslc/src/file_includer.cc --- old/shaderc-2020.5/glslc/src/file_includer.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/glslc/src/file_includer.cc 2021-04-21 23:13:25.000000000 +0200 @@ -17,7 +17,7 @@ #include <mutex> #include <utility> -#include "libshaderc_util/io.h" +#include "libshaderc_util/io_shaderc.h" namespace glslc { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/glslc/src/main.cc new/shaderc-2021.0/glslc/src/main.cc --- old/shaderc-2020.5/glslc/src/main.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/glslc/src/main.cc 2021-04-21 23:13:25.000000000 +0200 @@ -28,7 +28,7 @@ #include "file_compiler.h" #include "libshaderc_util/args.h" #include "libshaderc_util/compiler.h" -#include "libshaderc_util/io.h" +#include "libshaderc_util/io_shaderc.h" #include "libshaderc_util/string_piece.h" #include "resource_parse.h" #include "shader_stage.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/Android.mk new/shaderc-2021.0/libshaderc_util/Android.mk --- old/shaderc-2020.5/libshaderc_util/Android.mk 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/Android.mk 2021-04-21 23:13:25.000000000 +0200 @@ -21,7 +21,7 @@ LOCAL_SRC_FILES:=src/args.cc \ src/compiler.cc \ src/file_finder.cc \ - src/io.cc \ + src/io_shaderc.cc \ src/message.cc \ src/resources.cc \ src/shader_stage.cc \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/CMakeLists.txt new/shaderc-2021.0/libshaderc_util/CMakeLists.txt --- old/shaderc-2020.5/libshaderc_util/CMakeLists.txt 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/CMakeLists.txt 2021-04-21 23:13:25.000000000 +0200 @@ -18,7 +18,7 @@ include/libshaderc_util/counting_includer.h include/libshaderc_util/file_finder.h include/libshaderc_util/format.h - include/libshaderc_util/io.h + include/libshaderc_util/io_shaderc.h include/libshaderc_util/mutex.h include/libshaderc_util/message.h include/libshaderc_util/resources.h @@ -29,7 +29,7 @@ src/args.cc src/compiler.cc src/file_finder.cc - src/io.cc + src/io_shaderc.cc src/message.cc src/resources.cc src/shader_stage.cc @@ -57,7 +57,7 @@ string_piece format file_finder - io + io_shaderc message mutex version_profile) @@ -85,5 +85,5 @@ if(${SHADERC_ENABLE_TESTS}) add_dependencies(shaderc_util_file_finder_test testdata) - add_dependencies(shaderc_util_io_test testdata) + add_dependencies(shaderc_util_io_shaderc_test testdata) endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/include/libshaderc_util/io.h new/shaderc-2021.0/libshaderc_util/include/libshaderc_util/io.h --- old/shaderc-2020.5/libshaderc_util/include/libshaderc_util/io.h 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/include/libshaderc_util/io.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,69 +0,0 @@ -// Copyright 2015 The Shaderc Authors. All rights reserved. -// -// 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. - -#ifndef LIBSHADERC_UTIL_IO_H_ -#define LIBSHADERC_UTIL_IO_H_ - -#include <string> -#include <vector> - -#include "string_piece.h" - -namespace shaderc_util { - -// Returns true if the given path is an absolute path. -bool IsAbsolutePath(const std::string& path); - -// A helper function to return the base file name from either absolute path or -// relative path representation of a file. It keeps the component from the last -// '/' or '\' to the end of the given string. If the component is '..' or '.', -// returns an empty string. If '/' or '\' is the last char of the given string, -// also returns an empty string. -// e.g.: dir_a/dir_b/file_c.vert => file_c.vert -// dir_a/dir_b/.. => <empty string> -// dir_a/dir_b/. => <empty string> -// dir_a/dirb/c/ => <empty string> -// Note that this method doesn't check whether the given path is a valid one or -// not. -std::string GetBaseFileName(const std::string& file_path); - -// Reads all of the characters in a given file into input_data. Outputs an -// error message to std::cerr if the file could not be read and returns false if -// there was an error. If the input_file is "-", then input is read from -// std::cin. -bool ReadFile(const std::string& input_file_name, - std::vector<char>* input_data); - -// Returns and initializes the file_stream parameter if the output_filename -// refers to a file, or returns &std::cout if the output_filename is "-". -// Returns nullptr and emits an error message to err if the file could -// not be opened for writing. If the output refers to a file, and the open -// failed for writing, file_stream is left with its fail_bit set. -std::ostream* GetOutputStream(const string_piece& output_filename, - std::ofstream* file_stream, std::ostream* err); - -// Writes output_data to a file, overwriting if it exists. If output_file_name -// is "-", writes to std::cout. -bool WriteFile(std::ostream* output_stream, const string_piece& output_data); - -// Flush the standard output stream and set it to binary mode. Subsequent -// output will not translate newlines to carriage-return newline pairs. -void FlushAndSetBinaryModeOnStdout(); -// Flush the standard output stream and set it to text mode. Subsequent -// output will translate newlines to carriage-return newline pairs. -void FlushAndSetTextModeOnStdout(); - -} // namespace shaderc_util - -#endif // LIBSHADERC_UTIL_IO_H_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/include/libshaderc_util/io_shaderc.h new/shaderc-2021.0/libshaderc_util/include/libshaderc_util/io_shaderc.h --- old/shaderc-2020.5/libshaderc_util/include/libshaderc_util/io_shaderc.h 1970-01-01 01:00:00.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/include/libshaderc_util/io_shaderc.h 2021-04-21 23:13:25.000000000 +0200 @@ -0,0 +1,69 @@ +// Copyright 2015 The Shaderc Authors. All rights reserved. +// +// 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. + +#ifndef LIBSHADERC_UTIL_IO_H_ +#define LIBSHADERC_UTIL_IO_H_ + +#include <string> +#include <vector> + +#include "string_piece.h" + +namespace shaderc_util { + +// Returns true if the given path is an absolute path. +bool IsAbsolutePath(const std::string& path); + +// A helper function to return the base file name from either absolute path or +// relative path representation of a file. It keeps the component from the last +// '/' or '\' to the end of the given string. If the component is '..' or '.', +// returns an empty string. If '/' or '\' is the last char of the given string, +// also returns an empty string. +// e.g.: dir_a/dir_b/file_c.vert => file_c.vert +// dir_a/dir_b/.. => <empty string> +// dir_a/dir_b/. => <empty string> +// dir_a/dirb/c/ => <empty string> +// Note that this method doesn't check whether the given path is a valid one or +// not. +std::string GetBaseFileName(const std::string& file_path); + +// Reads all of the characters in a given file into input_data. Outputs an +// error message to std::cerr if the file could not be read and returns false if +// there was an error. If the input_file is "-", then input is read from +// std::cin. +bool ReadFile(const std::string& input_file_name, + std::vector<char>* input_data); + +// Returns and initializes the file_stream parameter if the output_filename +// refers to a file, or returns &std::cout if the output_filename is "-". +// Returns nullptr and emits an error message to err if the file could +// not be opened for writing. If the output refers to a file, and the open +// failed for writing, file_stream is left with its fail_bit set. +std::ostream* GetOutputStream(const string_piece& output_filename, + std::ofstream* file_stream, std::ostream* err); + +// Writes output_data to a file, overwriting if it exists. If output_file_name +// is "-", writes to std::cout. +bool WriteFile(std::ostream* output_stream, const string_piece& output_data); + +// Flush the standard output stream and set it to binary mode. Subsequent +// output will not translate newlines to carriage-return newline pairs. +void FlushAndSetBinaryModeOnStdout(); +// Flush the standard output stream and set it to text mode. Subsequent +// output will translate newlines to carriage-return newline pairs. +void FlushAndSetTextModeOnStdout(); + +} // namespace shaderc_util + +#endif // LIBSHADERC_UTIL_IO_H_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/src/compiler.cc new/shaderc-2021.0/libshaderc_util/src/compiler.cc --- old/shaderc-2020.5/libshaderc_util/src/compiler.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/src/compiler.cc 2021-04-21 23:13:25.000000000 +0200 @@ -22,7 +22,7 @@ #include "SPIRV/GlslangToSpv.h" #include "libshaderc_util/format.h" -#include "libshaderc_util/io.h" +#include "libshaderc_util/io_shaderc.h" #include "libshaderc_util/message.h" #include "libshaderc_util/resources.h" #include "libshaderc_util/shader_stage.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/src/io.cc new/shaderc-2021.0/libshaderc_util/src/io.cc --- old/shaderc-2020.5/libshaderc_util/src/io.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/src/io.cc 1970-01-01 01:00:00.000000000 +0100 @@ -1,145 +0,0 @@ -// Copyright 2015 The Shaderc Authors. All rights reserved. -// -// 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. - -#include "libshaderc_util/io.h" - -#include "libshaderc_util/universal_unistd.h" - -#if _WIN32 -// Need _fileno from stdio.h -// Need _O_BINARY and _O_TEXT from fcntl.h -#include <fcntl.h> -#include <stdio.h> -#endif - -#include <errno.h> -#include <cstdio> -#include <cstring> -#include <fstream> -#include <iostream> - -namespace { - -// Outputs a descriptive message for errno_value to cerr. -// This may be truncated to 1023 bytes on certain platforms. -void OutputFileErrorMessage(int errno_value) { -#ifdef _MSC_VER - // If the error message is more than 1023 bytes it will be truncated. - char buffer[1024]; - strerror_s(buffer, errno_value); - std::cerr << ": " << buffer << std::endl; -#else - std::cerr << ": " << strerror(errno_value) << std::endl; -#endif -} - -} // anonymous namespace - -namespace shaderc_util { - -bool IsAbsolutePath(const std::string& path) { - if (path.empty()) return false; - // Unix-like OS: /path/to/file - if (path.front() == '/') return true; - // Windows: \\server\user\file - if (path.size() > 1 && path[0] == '\\' && path[1] == '\\') { - return true; - } - // Windows: X:\path\to\file - if (path.size() > 2 && ::isalpha(path[0]) && path[1] == ':' && - path[2] == '\\') { - return true; - } - return false; -} - -std::string GetBaseFileName(const std::string& file_path) { - size_t loc_slash = file_path.find_last_of("/\\"); - std::string base_name = - file_path.substr((loc_slash == std::string::npos ? -1 : loc_slash) + 1); - if (base_name == ".." || base_name == ".") { - base_name = ""; - } - return base_name; -} - -bool ReadFile(const std::string& input_file_name, - std::vector<char>* input_data) { - std::istream* stream = &std::cin; - std::ifstream input_file; - if (input_file_name != "-") { - input_file.open(input_file_name, std::ios_base::binary); - stream = &input_file; - if (input_file.fail()) { - std::cerr << "glslc: error: cannot open input file: '" << input_file_name - << "'"; - if (access(input_file_name.c_str(), R_OK) != 0) { - OutputFileErrorMessage(errno); - return false; - } - std::cerr << std::endl; - return false; - } - } - *input_data = std::vector<char>((std::istreambuf_iterator<char>(*stream)), - std::istreambuf_iterator<char>()); - return true; -} - -std::ostream* GetOutputStream(const string_piece& output_filename, - std::ofstream* file_stream, std::ostream* err) { - std::ostream* stream = &std::cout; - if (output_filename != "-") { - file_stream->open(output_filename.str(), std::ios_base::binary); - stream = file_stream; - if (file_stream->fail()) { - *err << "glslc: error: cannot open output file: '" << output_filename - << "'"; - if (access(output_filename.str().c_str(), W_OK) != 0) { - OutputFileErrorMessage(errno); - return nullptr; - } - std::cerr << std::endl; - return nullptr; - } - } - return stream; -} - -bool WriteFile(std::ostream* stream, const string_piece& output_data) { - if (output_data.size() > 0) { - stream->write(output_data.data(), output_data.size()); - if (!stream->good()) { - return false; - } - } - stream->flush(); - return true; -} - -void FlushAndSetBinaryModeOnStdout() { - std::fflush(stdout); -#if _WIN32 - _setmode(_fileno(stdout), _O_BINARY); -#endif -} - -void FlushAndSetTextModeOnStdout() { - std::fflush(stdout); -#if _WIN32 - _setmode(_fileno(stdout), _O_TEXT); -#endif -} - -} // namespace shaderc_util diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/src/io_shaderc.cc new/shaderc-2021.0/libshaderc_util/src/io_shaderc.cc --- old/shaderc-2020.5/libshaderc_util/src/io_shaderc.cc 1970-01-01 01:00:00.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/src/io_shaderc.cc 2021-04-21 23:13:25.000000000 +0200 @@ -0,0 +1,146 @@ +// Copyright 2015 The Shaderc Authors. All rights reserved. +// +// 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. + +#include "libshaderc_util/io_shaderc.h" + +#include "libshaderc_util/universal_unistd.h" + +#if _WIN32 +// Need _fileno from stdio.h +// Need _O_BINARY and _O_TEXT from fcntl.h +#include <fcntl.h> +#include <stdio.h> +#endif + +#include <errno.h> + +#include <cstdio> +#include <cstring> +#include <fstream> +#include <iostream> + +namespace { + +// Outputs a descriptive message for errno_value to cerr. +// This may be truncated to 1023 bytes on certain platforms. +void OutputFileErrorMessage(int errno_value) { +#ifdef _MSC_VER + // If the error message is more than 1023 bytes it will be truncated. + char buffer[1024]; + strerror_s(buffer, errno_value); + std::cerr << ": " << buffer << std::endl; +#else + std::cerr << ": " << strerror(errno_value) << std::endl; +#endif +} + +} // anonymous namespace + +namespace shaderc_util { + +bool IsAbsolutePath(const std::string& path) { + if (path.empty()) return false; + // Unix-like OS: /path/to/file + if (path.front() == '/') return true; + // Windows: \\server\user\file + if (path.size() > 1 && path[0] == '\\' && path[1] == '\\') { + return true; + } + // Windows: X:\path\to\file + if (path.size() > 2 && ::isalpha(path[0]) && path[1] == ':' && + path[2] == '\\') { + return true; + } + return false; +} + +std::string GetBaseFileName(const std::string& file_path) { + size_t loc_slash = file_path.find_last_of("/\\"); + std::string base_name = + file_path.substr((loc_slash == std::string::npos ? -1 : loc_slash) + 1); + if (base_name == ".." || base_name == ".") { + base_name = ""; + } + return base_name; +} + +bool ReadFile(const std::string& input_file_name, + std::vector<char>* input_data) { + std::istream* stream = &std::cin; + std::ifstream input_file; + if (input_file_name != "-") { + input_file.open(input_file_name, std::ios_base::binary); + stream = &input_file; + if (input_file.fail()) { + std::cerr << "glslc: error: cannot open input file: '" << input_file_name + << "'"; + if (access(input_file_name.c_str(), R_OK) != 0) { + OutputFileErrorMessage(errno); + return false; + } + std::cerr << std::endl; + return false; + } + } + *input_data = std::vector<char>((std::istreambuf_iterator<char>(*stream)), + std::istreambuf_iterator<char>()); + return true; +} + +std::ostream* GetOutputStream(const string_piece& output_filename, + std::ofstream* file_stream, std::ostream* err) { + std::ostream* stream = &std::cout; + if (output_filename != "-") { + file_stream->open(output_filename.str(), std::ios_base::binary); + stream = file_stream; + if (file_stream->fail()) { + *err << "glslc: error: cannot open output file: '" << output_filename + << "'"; + if (access(output_filename.str().c_str(), W_OK) != 0) { + OutputFileErrorMessage(errno); + return nullptr; + } + std::cerr << std::endl; + return nullptr; + } + } + return stream; +} + +bool WriteFile(std::ostream* stream, const string_piece& output_data) { + if (output_data.size() > 0) { + stream->write(output_data.data(), output_data.size()); + if (!stream->good()) { + return false; + } + } + stream->flush(); + return true; +} + +void FlushAndSetBinaryModeOnStdout() { + std::fflush(stdout); +#if _WIN32 + _setmode(_fileno(stdout), _O_BINARY); +#endif +} + +void FlushAndSetTextModeOnStdout() { + std::fflush(stdout); +#if _WIN32 + _setmode(_fileno(stdout), _O_TEXT); +#endif +} + +} // namespace shaderc_util diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/src/io_shaderc_test.cc new/shaderc-2021.0/libshaderc_util/src/io_shaderc_test.cc --- old/shaderc-2020.5/libshaderc_util/src/io_shaderc_test.cc 1970-01-01 01:00:00.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/src/io_shaderc_test.cc 2021-04-21 23:13:25.000000000 +0200 @@ -0,0 +1,139 @@ +// Copyright 2015 The Shaderc Authors. All rights reserved. +// +// 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. + +#include "libshaderc_util/io_shaderc.h" + +#include <gmock/gmock.h> + +#include <fstream> + +namespace { + +using shaderc_util::GetBaseFileName; +using shaderc_util::GetOutputStream; +using shaderc_util::IsAbsolutePath; +using shaderc_util::ReadFile; +using shaderc_util::WriteFile; +using testing::Eq; +using testing::HasSubstr; + +std::string ToString(const std::vector<char>& v) { + return std::string(v.data(), v.size()); +} + +class ReadFileTest : public testing::Test { + protected: + // A vector to pass to ReadFile. + std::vector<char> read_data; +}; + +TEST(IsAbsolutePathTest, Linux) { + EXPECT_FALSE(IsAbsolutePath("")); + EXPECT_TRUE(IsAbsolutePath("/")); + EXPECT_FALSE(IsAbsolutePath(".")); + EXPECT_FALSE(IsAbsolutePath("..")); + EXPECT_TRUE(IsAbsolutePath("/bin/echo")); + EXPECT_TRUE(IsAbsolutePath("//etc/shadow")); + EXPECT_TRUE(IsAbsolutePath("/../../../lib")); + EXPECT_FALSE(IsAbsolutePath("./something")); + EXPECT_FALSE(IsAbsolutePath("input")); + EXPECT_FALSE(IsAbsolutePath("../test")); + EXPECT_FALSE(IsAbsolutePath(" /abc")); + EXPECT_TRUE(IsAbsolutePath("/abc def/ttt")); +} + +TEST(IsAbsolutePathTest, Windows) { + EXPECT_TRUE(IsAbsolutePath(R"(\\Server1000\superuser\file)")); + EXPECT_TRUE(IsAbsolutePath(R"(\\zzzz 1000\user with space\file with space)")); + EXPECT_TRUE( + IsAbsolutePath(R"(C:\Program Files (x86)\Windows Folder\shader.glsl)")); + EXPECT_FALSE(IsAbsolutePath(R"(third_party\gmock)")); + EXPECT_FALSE(IsAbsolutePath(R"(C:..\File.txt)")); +} + +TEST(GetBaseFileName, Linux) { + EXPECT_EQ("", GetBaseFileName("")); + EXPECT_EQ("", GetBaseFileName("/")); + EXPECT_EQ("", GetBaseFileName(".")); + EXPECT_EQ("", GetBaseFileName("..")); + EXPECT_EQ("echo", GetBaseFileName("/bin/echo")); + EXPECT_EQ("shadow", GetBaseFileName("//etc/shadow")); + EXPECT_EQ("lib", GetBaseFileName("/../../../lib")); + EXPECT_EQ("something", GetBaseFileName("./something")); + EXPECT_EQ("input", GetBaseFileName("input")); + EXPECT_EQ("test", GetBaseFileName("../test")); + EXPECT_EQ("abc", GetBaseFileName(" /abc")); + EXPECT_EQ("ttt", GetBaseFileName("/abc def/ttt")); +} + +TEST(GetBaseFileName, Windows) { + EXPECT_EQ("file", GetBaseFileName(R"(\\Server1000\superuser\file)")); + EXPECT_EQ("file with space", + GetBaseFileName(R"(\\zzzz 1000\user with space\file with space)")); + EXPECT_EQ( + "shader.glsl", + GetBaseFileName(R"(C:\Program Files (x86)\Windows Folder\shader.glsl)")); + EXPECT_EQ("gmock", GetBaseFileName(R"(third_party\gmock)")); + EXPECT_EQ("File.txt", GetBaseFileName(R"(C:..\File.txt)")); +} + +TEST_F(ReadFileTest, CorrectContent) { + ASSERT_TRUE(ReadFile("include_file.1", &read_data)); + EXPECT_EQ("The quick brown fox jumps over a lazy dog.", ToString(read_data)); +} + +TEST_F(ReadFileTest, EmptyContent) { + ASSERT_TRUE(ReadFile("dir/subdir/include_file.2", &read_data)); + EXPECT_TRUE(read_data.empty()); +} + +TEST_F(ReadFileTest, FileNotFound) { + EXPECT_FALSE(ReadFile("garbage garbage vjoiarhiupo hrfewi", &read_data)); +} + +TEST_F(ReadFileTest, EmptyFilename) { EXPECT_FALSE(ReadFile("", &read_data)); } + +TEST(WriteFiletest, BadStream) { + std::ofstream fstream; + std::ostringstream err; + std::ostream* output_stream = GetOutputStream( + "/this/should/not/be/writable/asdfasdfasdfasdf", &fstream, &err); + EXPECT_EQ(nullptr, output_stream); + EXPECT_TRUE(fstream.fail()); + EXPECT_EQ(nullptr, output_stream); + EXPECT_THAT(err.str(), HasSubstr("cannot open output file")); +} + +TEST(WriteFileTest, Roundtrip) { + const std::string content = "random content 12345"; + const std::string filename = "WriteFileTestOutput.tmp"; + std::ofstream fstream; + std::ostringstream err; + std::ostream* output_stream = GetOutputStream(filename, &fstream, &err); + ASSERT_EQ(output_stream, &fstream); + EXPECT_THAT(err.str(), Eq("")); + ASSERT_TRUE(WriteFile(output_stream, content)); + std::vector<char> read_data; + ASSERT_TRUE(ReadFile(filename, &read_data)); + EXPECT_EQ(content, ToString(read_data)); +} + +TEST(OutputStreamTest, Stdout) { + std::ofstream fstream; + std::ostringstream err; + std::ostream* output_stream = GetOutputStream("-", &fstream, &err); + EXPECT_EQ(&std::cout, output_stream); + EXPECT_THAT(err.str(), Eq("")); +} +} // anonymous namespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/libshaderc_util/src/io_test.cc new/shaderc-2021.0/libshaderc_util/src/io_test.cc --- old/shaderc-2020.5/libshaderc_util/src/io_test.cc 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/libshaderc_util/src/io_test.cc 1970-01-01 01:00:00.000000000 +0100 @@ -1,140 +0,0 @@ -// Copyright 2015 The Shaderc Authors. All rights reserved. -// -// 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. - -#include "libshaderc_util/io.h" - -#include <fstream> - -#include <gmock/gmock.h> - -namespace { - -using shaderc_util::IsAbsolutePath; -using shaderc_util::ReadFile; -using shaderc_util::WriteFile; -using shaderc_util::GetOutputStream; -using shaderc_util::GetBaseFileName; -using testing::Eq; -using testing::HasSubstr; - -std::string ToString(const std::vector<char>& v) { - return std::string(v.data(), v.size()); -} - -class ReadFileTest : public testing::Test { - protected: - // A vector to pass to ReadFile. - std::vector<char> read_data; -}; - -TEST(IsAbsolutePathTest, Linux) { - EXPECT_FALSE(IsAbsolutePath("")); - EXPECT_TRUE(IsAbsolutePath("/")); - EXPECT_FALSE(IsAbsolutePath(".")); - EXPECT_FALSE(IsAbsolutePath("..")); - EXPECT_TRUE(IsAbsolutePath("/bin/echo")); - EXPECT_TRUE(IsAbsolutePath("//etc/shadow")); - EXPECT_TRUE(IsAbsolutePath("/../../../lib")); - EXPECT_FALSE(IsAbsolutePath("./something")); - EXPECT_FALSE(IsAbsolutePath("input")); - EXPECT_FALSE(IsAbsolutePath("../test")); - EXPECT_FALSE(IsAbsolutePath(" /abc")); - EXPECT_TRUE(IsAbsolutePath("/abc def/ttt")); -} - -TEST(IsAbsolutePathTest, Windows) { - EXPECT_TRUE(IsAbsolutePath(R"(\\Server1000\superuser\file)")); - EXPECT_TRUE(IsAbsolutePath(R"(\\zzzz 1000\user with space\file with space)")); - EXPECT_TRUE( - IsAbsolutePath(R"(C:\Program Files (x86)\Windows Folder\shader.glsl)")); - EXPECT_FALSE(IsAbsolutePath(R"(third_party\gmock)")); - EXPECT_FALSE(IsAbsolutePath(R"(C:..\File.txt)")); -} - -TEST(GetBaseFileName, Linux) { - EXPECT_EQ("", GetBaseFileName("")); - EXPECT_EQ("", GetBaseFileName("/")); - EXPECT_EQ("", GetBaseFileName(".")); - EXPECT_EQ("", GetBaseFileName("..")); - EXPECT_EQ("echo", GetBaseFileName("/bin/echo")); - EXPECT_EQ("shadow", GetBaseFileName("//etc/shadow")); - EXPECT_EQ("lib", GetBaseFileName("/../../../lib")); - EXPECT_EQ("something", GetBaseFileName("./something")); - EXPECT_EQ("input", GetBaseFileName("input")); - EXPECT_EQ("test", GetBaseFileName("../test")); - EXPECT_EQ("abc", GetBaseFileName(" /abc")); - EXPECT_EQ("ttt", GetBaseFileName("/abc def/ttt")); -} - -TEST(GetBaseFileName, Windows) { - EXPECT_EQ("file", GetBaseFileName(R"(\\Server1000\superuser\file)")); - EXPECT_EQ("file with space", - GetBaseFileName(R"(\\zzzz 1000\user with space\file with space)")); - EXPECT_EQ( - "shader.glsl", - GetBaseFileName(R"(C:\Program Files (x86)\Windows Folder\shader.glsl)")); - EXPECT_EQ("gmock", GetBaseFileName(R"(third_party\gmock)")); - EXPECT_EQ("File.txt", GetBaseFileName(R"(C:..\File.txt)")); -} - -TEST_F(ReadFileTest, CorrectContent) { - ASSERT_TRUE(ReadFile("include_file.1", &read_data)); - EXPECT_EQ("The quick brown fox jumps over a lazy dog.", - ToString(read_data)); -} - -TEST_F(ReadFileTest, EmptyContent) { - ASSERT_TRUE(ReadFile("dir/subdir/include_file.2", &read_data)); - EXPECT_TRUE(read_data.empty()); -} - -TEST_F(ReadFileTest, FileNotFound) { - EXPECT_FALSE(ReadFile("garbage garbage vjoiarhiupo hrfewi", &read_data)); -} - -TEST_F(ReadFileTest, EmptyFilename) { EXPECT_FALSE(ReadFile("", &read_data)); } - -TEST(WriteFiletest, BadStream) { - std::ofstream fstream; - std::ostringstream err; - std::ostream* output_stream = GetOutputStream( - "/this/should/not/be/writable/asdfasdfasdfasdf", &fstream, &err); - EXPECT_EQ(nullptr, output_stream); - EXPECT_TRUE(fstream.fail()); - EXPECT_EQ(nullptr, output_stream); - EXPECT_THAT(err.str(), HasSubstr("cannot open output file")); -} - -TEST(WriteFileTest, Roundtrip) { - const std::string content = "random content 12345"; - const std::string filename = "WriteFileTestOutput.tmp"; - std::ofstream fstream; - std::ostringstream err; - std::ostream* output_stream = GetOutputStream(filename, &fstream, &err); - ASSERT_EQ(output_stream, &fstream); - EXPECT_THAT(err.str(), Eq("")); - ASSERT_TRUE(WriteFile(output_stream, content)); - std::vector<char> read_data; - ASSERT_TRUE(ReadFile(filename, &read_data)); - EXPECT_EQ(content, ToString(read_data)); -} - -TEST(OutputStreamTest, Stdout) { - std::ofstream fstream; - std::ostringstream err; - std::ostream* output_stream = GetOutputStream("-", &fstream, &err); - EXPECT_EQ(&std::cout, output_stream); - EXPECT_THAT(err.str(), Eq("")); -} -} // anonymous namespace diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/shaderc-2020.5/license-checker.cfg new/shaderc-2021.0/license-checker.cfg --- old/shaderc-2020.5/license-checker.cfg 2021-02-19 22:08:08.000000000 +0100 +++ new/shaderc-2021.0/license-checker.cfg 2021-04-21 23:13:25.000000000 +0200 @@ -1,6 +1,6 @@ [ { - "licenses": [ "Apache-2.0-Header" ], + "licenses": [ "Apache-2.0" ], "paths": [ { "exclude": [ @@ -33,4 +33,4 @@ { "include": [ "utils/git-sync-deps" ] } ] } -] \ No newline at end of file +]