Skip to content

Commit

Permalink
Windows (flutter#144)
Browse files Browse the repository at this point in the history
Speculative fixes for Windows build
  • Loading branch information
dnfield committed Apr 27, 2022
1 parent 4d50315 commit 80bb5f9
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 9 deletions.
2 changes: 2 additions & 0 deletions impeller/base/comparable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "impeller/base/comparable.h"

#include <atomic>

namespace impeller {

static std::atomic_size_t sLastID;
Expand Down
1 change: 1 addition & 0 deletions impeller/base/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <memory>
#include <mutex>
#include <thread>

#include "flutter/fml/macros.h"
Expand Down
6 changes: 3 additions & 3 deletions impeller/compiler/impellerc_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ bool Main(const fml::CommandLine& command_line) {
reflector_options.shader_name =
InferShaderNameFromPath(switches.source_file_name);
reflector_options.header_file_name =
std::filesystem::path{switches.reflection_header_name}
.filename()
.native();
ToUtf8(std::filesystem::path{switches.reflection_header_name}
.filename()
.native());

Compiler compiler(*source_file_mapping, options, reflector_options);
if (!compiler.IsValid()) {
Expand Down
8 changes: 4 additions & 4 deletions impeller/compiler/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ static TargetPlatform TargetPlatformFromCommandLine(

Switches::Switches(const fml::CommandLine& command_line)
: target_platform(TargetPlatformFromCommandLine(command_line)),
working_directory(std::make_shared<fml::UniqueFD>(
fml::OpenDirectory(std::filesystem::current_path().native().c_str(),
false, // create if necessary,
fml::FilePermission::kRead))),
working_directory(std::make_shared<fml::UniqueFD>(fml::OpenDirectory(
ToUtf8(std::filesystem::current_path().native()).c_str(),
false, // create if necessary,
fml::FilePermission::kRead))),
source_file_name(command_line.GetOptionValueWithDefault("input", "")),
sl_file_name(command_line.GetOptionValueWithDefault("sl", "")),
spirv_file_name(command_line.GetOptionValueWithDefault("spirv", "")),
Expand Down
1 change: 1 addition & 0 deletions impeller/compiler/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "flutter/fml/unique_fd.h"
#include "impeller/compiler/compiler.h"
#include "impeller/compiler/include_dir.h"
#include "impeller/compiler/types.h"

namespace impeller {
namespace compiler {
Expand Down
11 changes: 10 additions & 1 deletion impeller/compiler/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static std::string UniqueEntryPointFunctionNameFromSourceName(
SourceType type) {
std::stringstream stream;
std::filesystem::path file_path(file_name);
stream << file_path.stem().native() << "_";
stream << ToUtf8(file_path.stem().native()) << "_";
switch (type) {
case SourceType::kUnknown:
stream << "unknown";
Expand Down Expand Up @@ -212,5 +212,14 @@ std::string TargetPlatformSLExtension(TargetPlatform platform) {
FML_UNREACHABLE();
}

std::string ToUtf8(const std::wstring& wstring) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
return myconv.to_bytes(wstring);
}

std::string ToUtf8(const std::string& string) {
return string;
}

} // namespace compiler
} // namespace impeller
6 changes: 6 additions & 0 deletions impeller/compiler/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#pragma once

#include <codecvt>
#include <locale>
#include <string>

#include "flutter/fml/macros.h"
Expand Down Expand Up @@ -54,5 +56,9 @@ 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
1 change: 1 addition & 0 deletions impeller/compiler/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <filesystem>
#include <sstream>
#include <string>

namespace impeller {
namespace compiler {
Expand Down
2 changes: 1 addition & 1 deletion impeller/geometry/rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct TRect {
constexpr std::array<TPoint<T>, 4> GetTransformedPoints(
const Matrix& transform) const {
auto points = GetPoints();
for (uint i = 0; i < points.size(); i++) {
for (int i = 0; i < points.size(); i++) {
points[i] = transform * points[i];
}
return points;
Expand Down
1 change: 1 addition & 0 deletions impeller/geometry/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once

#include <algorithm>
#include <cmath>
#include <limits>
#include <ostream>
Expand Down

0 comments on commit 80bb5f9

Please sign in to comment.