From 128d4ee0c64027c3fe2a590ba5d70f3d25fc84da Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Sat, 5 Nov 2022 17:25:23 -0700 Subject: [PATCH] Apply the Windows friendly path solution in remaining spots (flutter/engine#37344) --- .../src/flutter/impeller/compiler/impellerc_main.cc | 6 ++---- engine/src/flutter/impeller/compiler/switches.cc | 2 +- engine/src/flutter/impeller/compiler/types.cc | 12 ++---------- engine/src/flutter/impeller/compiler/types.h | 4 ---- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/engine/src/flutter/impeller/compiler/impellerc_main.cc b/engine/src/flutter/impeller/compiler/impellerc_main.cc index b73a72b8fc..e6a7e9a44a 100644 --- a/engine/src/flutter/impeller/compiler/impellerc_main.cc +++ b/engine/src/flutter/impeller/compiler/impellerc_main.cc @@ -77,10 +77,8 @@ bool Main(const fml::CommandLine& command_line) { reflector_options.entry_point_name = options.entry_point_name; reflector_options.shader_name = InferShaderNameFromPath(switches.source_file_name); - reflector_options.header_file_name = - ToUtf8(std::filesystem::path{switches.reflection_header_name} - .filename() - .native()); + reflector_options.header_file_name = Utf8FromPath( + std::filesystem::path{switches.reflection_header_name}.filename()); // Generate SkSL if needed. std::shared_ptr sksl_mapping; diff --git a/engine/src/flutter/impeller/compiler/switches.cc b/engine/src/flutter/impeller/compiler/switches.cc index 29ef80c19c..4ca2a27d5c 100644 --- a/engine/src/flutter/impeller/compiler/switches.cc +++ b/engine/src/flutter/impeller/compiler/switches.cc @@ -100,7 +100,7 @@ static SourceType SourceTypeFromCommandLine( Switches::Switches(const fml::CommandLine& command_line) : target_platform(TargetPlatformFromCommandLine(command_line)), working_directory(std::make_shared(fml::OpenDirectory( - ToUtf8(std::filesystem::current_path().native()).c_str(), + Utf8FromPath(std::filesystem::current_path()).c_str(), false, // create if necessary, fml::FilePermission::kRead))), source_file_name(command_line.GetOptionValueWithDefault("input", "")), diff --git a/engine/src/flutter/impeller/compiler/types.cc b/engine/src/flutter/impeller/compiler/types.cc index b7e13e5aba..cf1dae31a1 100644 --- a/engine/src/flutter/impeller/compiler/types.cc +++ b/engine/src/flutter/impeller/compiler/types.cc @@ -8,6 +8,7 @@ #include #include "flutter/fml/logging.h" +#include "impeller/compiler/utilities.h" namespace impeller { namespace compiler { @@ -77,7 +78,7 @@ std::string EntryPointFunctionNameFromSourceName(const std::string& file_name, SourceType type) { std::stringstream stream; std::filesystem::path file_path(file_name); - stream << ToUtf8(file_path.stem().native()) << "_"; + stream << Utf8FromPath(file_path.stem()) << "_"; switch (type) { case SourceType::kUnknown: stream << "unknown"; @@ -253,15 +254,6 @@ std::string TargetPlatformSLExtension(TargetPlatform platform) { FML_UNREACHABLE(); } -std::string ToUtf8(const std::wstring& wstring) { - std::wstring_convert> myconv; - return myconv.to_bytes(wstring); -} - -std::string ToUtf8(const std::string& string) { - return string; -} - bool TargetPlatformIsOpenGL(TargetPlatform platform) { switch (platform) { case TargetPlatform::kOpenGLES: diff --git a/engine/src/flutter/impeller/compiler/types.h b/engine/src/flutter/impeller/compiler/types.h index dd274cf6d6..754f2020f5 100644 --- a/engine/src/flutter/impeller/compiler/types.h +++ b/engine/src/flutter/impeller/compiler/types.h @@ -67,9 +67,5 @@ spv::ExecutionModel ToExecutionModel(SourceType type); spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform( TargetPlatform platform); -std::string ToUtf8(const std::wstring& wstring); - -std::string ToUtf8(const std::string& string); - } // namespace compiler } // namespace impeller