Windows: Allow win32 apps to initialize with different assets path or AOT filename (flutter/engine#27098)

This commit is contained in:
Lau Ching Jun 2021-07-01 13:54:34 -07:00 committed by GitHub
parent 7ab00f0c0b
commit f64df660b4
2 changed files with 21 additions and 13 deletions

View File

@ -35,4 +35,11 @@ TEST_F(DartProjectTest, StandardProjectFormat) {
EXPECT_EQ(GetProjectAotLibraryPath(project), L"test\\app.so");
}
TEST_F(DartProjectTest, ProjectWithCustomPaths) {
DartProject project(L"data\\assets", L"icu\\icudtl.dat", L"lib\\file.so");
EXPECT_EQ(GetProjectIcuDataPath(project), L"icu\\icudtl.dat");
EXPECT_EQ(GetProjectAssetsPath(project), L"data\\assets");
EXPECT_EQ(GetProjectAotLibraryPath(project), L"lib\\file.so");
}
} // namespace flutter

View File

@ -13,22 +13,23 @@ namespace flutter {
// A set of Flutter and Dart assets used to initialize a Flutter engine.
class DartProject {
public:
#ifdef WINUWP
// Creates a DartProject from a series of absolute paths.
// The directory should contain the following top-level items:
// - icudtl.dat (provided as a resource by the Flutter tool)
// - flutter_assets (as built by the Flutter tool)
// - app.so, for an AOT build (as built by the Flutter tool)
// The three paths are:
// - assets_path: Path to the assets directory as built by the Flutter tool.
// - icu_data_path: Path to the icudtl.dat file.
// - aot_library_path: Path to the AOT snapshot file.
//
// The path must be absolute.
explicit DartProject(const std::wstring& assetspath,
const std::wstring& icupath,
const std::wstring& aotpath) {
assets_path_ = assetspath;
icu_data_path_ = icupath;
aot_library_path_ = aotpath;
// The paths must be absolute in a UWP app. In a win32 app, they can be
// relative to the directory containing the running executable.
explicit DartProject(const std::wstring& assets_path,
const std::wstring& icu_data_path,
const std::wstring& aot_library_path) {
assets_path_ = assets_path;
icu_data_path_ = icu_data_path;
aot_library_path_ = aot_library_path;
}
#else
#ifndef WINUWP
// Creates a DartProject from a directory path. The directory should contain
// the following top-level items:
// - icudtl.dat (provided as a resource by the Flutter tool)