Skip to content

Commit 80bb5f9

Browse files
committed
Windows (flutter#144)
Speculative fixes for Windows build
1 parent 4d50315 commit 80bb5f9

File tree

10 files changed

+30
-9
lines changed

10 files changed

+30
-9
lines changed

impeller/base/comparable.cc

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "impeller/base/comparable.h"
66

7+
#include <atomic>
8+
79
namespace impeller {
810

911
static std::atomic_size_t sLastID;

impeller/base/thread.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include <memory>
8+
#include <mutex>
89
#include <thread>
910

1011
#include "flutter/fml/macros.h"

impeller/compiler/impellerc_main.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ bool Main(const fml::CommandLine& command_line) {
5252
reflector_options.shader_name =
5353
InferShaderNameFromPath(switches.source_file_name);
5454
reflector_options.header_file_name =
55-
std::filesystem::path{switches.reflection_header_name}
56-
.filename()
57-
.native();
55+
ToUtf8(std::filesystem::path{switches.reflection_header_name}
56+
.filename()
57+
.native());
5858

5959
Compiler compiler(*source_file_mapping, options, reflector_options);
6060
if (!compiler.IsValid()) {

impeller/compiler/switches.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ static TargetPlatform TargetPlatformFromCommandLine(
6262

6363
Switches::Switches(const fml::CommandLine& command_line)
6464
: target_platform(TargetPlatformFromCommandLine(command_line)),
65-
working_directory(std::make_shared<fml::UniqueFD>(
66-
fml::OpenDirectory(std::filesystem::current_path().native().c_str(),
67-
false, // create if necessary,
68-
fml::FilePermission::kRead))),
65+
working_directory(std::make_shared<fml::UniqueFD>(fml::OpenDirectory(
66+
ToUtf8(std::filesystem::current_path().native()).c_str(),
67+
false, // create if necessary,
68+
fml::FilePermission::kRead))),
6969
source_file_name(command_line.GetOptionValueWithDefault("input", "")),
7070
sl_file_name(command_line.GetOptionValueWithDefault("sl", "")),
7171
spirv_file_name(command_line.GetOptionValueWithDefault("spirv", "")),

impeller/compiler/switches.h

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "flutter/fml/unique_fd.h"
1313
#include "impeller/compiler/compiler.h"
1414
#include "impeller/compiler/include_dir.h"
15+
#include "impeller/compiler/types.h"
1516

1617
namespace impeller {
1718
namespace compiler {

impeller/compiler/types.cc

+10-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static std::string UniqueEntryPointFunctionNameFromSourceName(
6060
SourceType type) {
6161
std::stringstream stream;
6262
std::filesystem::path file_path(file_name);
63-
stream << file_path.stem().native() << "_";
63+
stream << ToUtf8(file_path.stem().native()) << "_";
6464
switch (type) {
6565
case SourceType::kUnknown:
6666
stream << "unknown";
@@ -212,5 +212,14 @@ std::string TargetPlatformSLExtension(TargetPlatform platform) {
212212
FML_UNREACHABLE();
213213
}
214214

215+
std::string ToUtf8(const std::wstring& wstring) {
216+
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
217+
return myconv.to_bytes(wstring);
218+
}
219+
220+
std::string ToUtf8(const std::string& string) {
221+
return string;
222+
}
223+
215224
} // namespace compiler
216225
} // namespace impeller

impeller/compiler/types.h

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#pragma once
66

7+
#include <codecvt>
8+
#include <locale>
79
#include <string>
810

911
#include "flutter/fml/macros.h"
@@ -54,5 +56,9 @@ spv::ExecutionModel ToExecutionModel(SourceType type);
5456
spirv_cross::CompilerMSL::Options::Platform TargetPlatformToMSLPlatform(
5557
TargetPlatform platform);
5658

59+
std::string ToUtf8(const std::wstring& wstring);
60+
61+
std::string ToUtf8(const std::string& string);
62+
5763
} // namespace compiler
5864
} // namespace impeller

impeller/compiler/utilities.cc

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <filesystem>
88
#include <sstream>
9+
#include <string>
910

1011
namespace impeller {
1112
namespace compiler {

impeller/geometry/rect.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct TRect {
147147
constexpr std::array<TPoint<T>, 4> GetTransformedPoints(
148148
const Matrix& transform) const {
149149
auto points = GetPoints();
150-
for (uint i = 0; i < points.size(); i++) {
150+
for (int i = 0; i < points.size(); i++) {
151151
points[i] = transform * points[i];
152152
}
153153
return points;

impeller/geometry/size.h

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#pragma once
66

7+
#include <algorithm>
78
#include <cmath>
89
#include <limits>
910
#include <ostream>

0 commit comments

Comments
 (0)