Add Chromium-only Blender WebEngine parity work
This commit is contained in:
19
blender-5.2.0/extern/opensubdiv-source/tools/stringify/CMakeLists.txt
vendored
Normal file
19
blender-5.2.0/extern/opensubdiv-source/tools/stringify/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright 2013 Pixar
|
||||
#
|
||||
# Licensed under the terms set forth in the LICENSE.txt file available at
|
||||
# https://opensubdiv.org/license.
|
||||
#
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(STRINGIFY_LOCATION "STRINGIFY-NOTFOUND" CACHE FILEPATH "Point it to the stringify binary from a native build")
|
||||
add_executable(stringify IMPORTED GLOBAL)
|
||||
set_property(TARGET stringify PROPERTY IMPORTED_LOCATION ${STRINGIFY_LOCATION})
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
osd_add_executable(stringify "opensubdiv/tools"
|
||||
main.cpp
|
||||
)
|
||||
install(TARGETS stringify DESTINATION ${CMAKE_BINDIR_BASE})
|
||||
endif()
|
||||
73
blender-5.2.0/extern/opensubdiv-source/tools/stringify/main.cpp
vendored
Normal file
73
blender-5.2.0/extern/opensubdiv-source/tools/stringify/main.cpp
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright 2013 Pixar
|
||||
//
|
||||
// Licensed under the terms set forth in the LICENSE.txt file available at
|
||||
// https://opensubdiv.org/license.
|
||||
//
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
std::string stringify( std::string const & line ) {
|
||||
|
||||
bool inconstant=false;
|
||||
|
||||
std::stringstream s;
|
||||
for (int i=0; i<(int)line.size(); ++i) {
|
||||
|
||||
// escape double quotes
|
||||
if (line[i]=='"') {
|
||||
s << '\\' ;
|
||||
inconstant = inconstant ? false : true;
|
||||
}
|
||||
|
||||
if (line[i]=='\\' && line[i+1]=='\0') {
|
||||
s << "\"";
|
||||
return s.str();
|
||||
}
|
||||
|
||||
// escape backslash
|
||||
if (inconstant && line[i]=='\\')
|
||||
s << '\\' ;
|
||||
|
||||
s << line[i];
|
||||
}
|
||||
|
||||
s << "\\n\"";
|
||||
|
||||
return s.str();
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: stringify input-file output-file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ifstream input;
|
||||
input.open(argv[1]);
|
||||
if (! input.is_open()) {
|
||||
std::cerr << "Can not read from: " << argv[1] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::ofstream output;
|
||||
output.open(argv[2]);
|
||||
if (! output.is_open()) {
|
||||
std::cerr << "Can not write to: " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string line;
|
||||
|
||||
while (! input.eof()) {
|
||||
std::getline(input, line);
|
||||
output << "\"" << stringify(line) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
blender-5.2.0/extern/opensubdiv-source/tools/stringify/stringify.py
vendored
Normal file
44
blender-5.2.0/extern/opensubdiv-source/tools/stringify/stringify.py
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# Copyright 2022 Pixar
|
||||
#
|
||||
# Licensed under the terms set forth in the LICENSE.txt file available at
|
||||
# https://opensubdiv.org/license.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
|
||||
def stringify(s):
|
||||
withinStringConstant = False
|
||||
|
||||
result = ""
|
||||
for i in range(len(s)-1):
|
||||
# escape double quotes
|
||||
if s[i] == '"':
|
||||
result += '\\'
|
||||
withinStringConstant = not withinStringConstant
|
||||
|
||||
if s[i] == '\\' and i == len(s)-2:
|
||||
return '"' + result + '"\n'
|
||||
|
||||
# escape backslash
|
||||
if withinStringConstant and s[i] == '\\':
|
||||
result += '\\'
|
||||
|
||||
result += s[i]
|
||||
|
||||
return '"' + result + '\\n"\n'
|
||||
|
||||
def stringifyFile(inputFilename, outputFilename):
|
||||
with open(inputFilename, "r") as inputFile, \
|
||||
open(outputFilename, "w") as outputFile:
|
||||
for line in inputFile:
|
||||
outputFile.write(stringify(line))
|
||||
outputFile.write('"\\n"\n')
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: stringify input-file output-file")
|
||||
sys.exit(1)
|
||||
|
||||
stringifyFile(sys.argv[1], sys.argv[2])
|
||||
|
||||
Reference in New Issue
Block a user