Remove complex path simplification code.
Now that we can call into Skia utils directly, we can use the preexisting code from SkOSPath instead. Change-Id: I67e3099e97ec0e93acc08c7f2142a01a2af48f15 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/531416 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
931ce6efbc
commit
56bc24c004
@ -254,6 +254,7 @@ skslc_deps = [
|
||||
"$_src/ports/SkOSFile_stdio.cpp",
|
||||
"$_src/utils/SkJSON.cpp",
|
||||
"$_src/utils/SkJSONWriter.cpp",
|
||||
"$_src/utils/SkOSPath.cpp",
|
||||
"$_src/utils/SkParse.cpp",
|
||||
"$_src/utils/SkShaderUtils.cpp",
|
||||
"$_src/utils/SkUTF.cpp",
|
||||
|
@ -21,6 +21,7 @@ generated_cc_atom(
|
||||
"//src/sksl:SkSLUtil_hdr",
|
||||
"//src/sksl/ir:SkSLUnresolvedFunction_hdr",
|
||||
"//src/sksl/ir:SkSLVarDeclarations_hdr",
|
||||
"//src/utils:SkOSPath_hdr",
|
||||
"//src/utils:SkShaderUtils_hdr",
|
||||
],
|
||||
)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
#include "src/sksl/ir/SkSLUnresolvedFunction.h"
|
||||
#include "src/sksl/ir/SkSLVarDeclarations.h"
|
||||
#include "src/utils/SkOSPath.h"
|
||||
#include "src/utils/SkShaderUtils.h"
|
||||
|
||||
#include <fstream>
|
||||
@ -47,24 +48,6 @@ enum class ResultCode {
|
||||
kOutputError = 3,
|
||||
};
|
||||
|
||||
// Given the path to a file (e.g. 'src/sksl/sksl_gpu.sksl') and the expected prefix and suffix
|
||||
// (e.g. 'sksl_' and '.sksl'), returns the "base name" of the file (in this case, 'gpu').
|
||||
// If no match, returns the empty string.
|
||||
static std::string base_name(const std::string& fpPath, const char* prefix, const char* suffix) {
|
||||
std::string result;
|
||||
const char* end = &*fpPath.end();
|
||||
const char* fileName = end;
|
||||
// back up until we find a slash
|
||||
while (fileName != fpPath && '/' != *(fileName - 1) && '\\' != *(fileName - 1)) {
|
||||
--fileName;
|
||||
}
|
||||
if (!strncmp(fileName, prefix, strlen(prefix)) &&
|
||||
!strncmp(end - strlen(suffix), suffix, strlen(suffix))) {
|
||||
result.append(fileName + strlen(prefix), end - fileName - strlen(prefix) - strlen(suffix));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a usage banner; used when the command line arguments don't make sense.
|
||||
*/
|
||||
@ -118,7 +101,11 @@ ResultCode processCommand(const std::vector<std::string>& paths) {
|
||||
SkSL::Dehydrator dehydrator;
|
||||
dehydrator.write(*module.fSymbols);
|
||||
dehydrator.write(module.fElements);
|
||||
std::string baseName = base_name(inputPath, "", ".sksl");
|
||||
SkString baseName = SkOSPath::Basename(inputPath.c_str());
|
||||
if (int extension = baseName.findLastOf('.'); extension > 0) {
|
||||
baseName.resize(extension);
|
||||
}
|
||||
|
||||
SkSL::StringStream buffer;
|
||||
dehydrator.finish(buffer);
|
||||
const std::string& data = buffer.str();
|
||||
|
Loading…
Reference in New Issue
Block a user