Fix SkSL dehydration on Windows machines
Replace SkOSPath with bespoke code that handles both kinds of slashes.
Change-Id: I291be5456631e6abe88492f7aea9f543f37c59f1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/569622
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/gn/sksl.gni b/gn/sksl.gni
index d6d2f75..ce01a02 100644
--- a/gn/sksl.gni
+++ b/gn/sksl.gni
@@ -260,7 +260,6 @@
"$_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",
diff --git a/tools/sksl-precompile/SkSLPrecompile.cpp b/tools/sksl-precompile/SkSLPrecompile.cpp
index 2e54f28..7ea197a 100644
--- a/tools/sksl-precompile/SkSLPrecompile.cpp
+++ b/tools/sksl-precompile/SkSLPrecompile.cpp
@@ -21,7 +21,6 @@
#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>
@@ -50,6 +49,16 @@
kOutputError = 3,
};
+static std::string base_name(const std::string& path) {
+ size_t slashPos = path.find_last_of("/\\");
+ return path.substr(slashPos == std::string::npos ? 0 : slashPos + 1);
+}
+
+static std::string remove_extension(const std::string& path) {
+ size_t dotPos = path.find_last_of('.');
+ return path.substr(0, dotPos);
+}
+
/**
* Displays a usage banner; used when the command line arguments don't make sense.
*/
@@ -104,10 +113,7 @@
SkSL::Dehydrator dehydrator;
dehydrator.write(*module.fSymbols);
dehydrator.write(module.fElements);
- SkString baseName = SkOSPath::Basename(inputPath.c_str());
- if (int extension = baseName.findLastOf('.'); extension > 0) {
- baseName.resize(extension);
- }
+ std::string baseName = remove_extension(base_name(inputPath));
SkSL::StringStream buffer;
dehydrator.finish(buffer);