| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::FlutterProjectBundle Class Reference

`#include <flutter_project_bundle.h>`

## Public Member Functions
| FlutterProjectBundle (const FlutterDesktopEngineProperties &properties)
| ~FlutterProjectBundle ()
bool | HasValidPaths ()
const std::filesystem::path & | assets_path ()
const std::filesystem::path & | icu_path ()
const std::vector< std::string > | GetSwitches ()
void | SetSwitches (const std::vector< std::string > &switches)
UniqueAotDataPtr | LoadAotData (const FlutterEngineProcTable &engine_procs)
const std::string & | dart_entrypoint () const
const std::vector< std::string > & | dart_entrypoint_arguments () const

## Detailed Description

Definition at line 21 of file flutter_project_bundle.h.

## Constructor & Destructor Documentation

## ◆ FlutterProjectBundle()

flutter::FlutterProjectBundle::FlutterProjectBundle | ( | const FlutterDesktopEngineProperties & | properties | ) |
| explicit

Definition at line 15 of file flutter_project_bundle.cc.

17 : assets_path_(properties.assets_path),
18 icu_path_(properties.icu_data_path) {
19 if (properties.aot_library_path != nullptr) {
20 aot_library_path_ = std::filesystem::path(properties.aot_library_path);
21 }
22
23 if (properties.dart_entrypoint && properties.dart_entrypoint[0] != '\0') {
24 dart_entrypoint_ = properties.dart_entrypoint;
25 }
26
27 for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
28 dart_entrypoint_arguments_.push_back(
29 std::string(properties.dart_entrypoint_argv[i]));
30 }
31
32 // Resolve any relative paths.
33 if (assets_path_.is_relative() || icu_path_.is_relative() ||
34 (!aot_library_path_.empty() && aot_library_path_.is_relative())) {
35 std::filesystem::path executable_location = GetExecutableDirectory();
36 if (executable_location.empty()) {
37 FML_LOG(ERROR)
38 << "Unable to find executable location to resolve resource paths.";
39 assets_path_ = std::filesystem::path();
40 icu_path_ = std::filesystem::path();
41 } else {
42 assets_path_ = std::filesystem::path(executable_location) / assets_path_;
43 icu_path_ = std::filesystem::path(executable_location) / icu_path_;
44 if (!aot_library_path_.empty()) {
45 aot_library_path_ =
46 std::filesystem::path(executable_location) / aot_library_path_;
47 }
48 }
49 }
50 }

References FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, FlutterDesktopEngineProperties::dart_entrypoint_argv, and flutter::GetExecutableDirectory().

## ◆ ~FlutterProjectBundle()

flutter::FlutterProjectBundle::~FlutterProjectBundle | ( |  | ) |

Definition at line 83 of file flutter_project_bundle.cc.

83 {}

## Member Function Documentation

## ◆ assets_path()

const std::filesystem::path& flutter::FlutterProjectBundle::assets_path | ( |  | ) |
| inline

Definition at line 36 of file flutter_project_bundle.h.

36 { return assets_path_; }

Referenced by flutter::testing::TEST().

## ◆ dart_entrypoint()

const std::string& flutter::FlutterProjectBundle::dart_entrypoint | ( |  | ) | const
| inline

Definition at line 54 of file flutter_project_bundle.h.

54 { return dart_entrypoint_; }

## ◆ dart_entrypoint_arguments()

const std::vector<std::string>& flutter::FlutterProjectBundle::dart_entrypoint_arguments | ( |  | ) | const
| inline

Definition at line 58 of file flutter_project_bundle.h.

58 {
59 return dart_entrypoint_arguments_;
60 }

Referenced by flutter::testing::TEST().

## ◆ GetSwitches()

const std::vector< std::string > flutter::FlutterProjectBundle::GetSwitches | ( |  | ) |

Definition at line 90 of file flutter_project_bundle.cc.

90 {
91 if (engine_switches_.size() == 0) {
92 return GetSwitchesFromEnvironment();
93 }
94 std::vector<std::string> switches;
95 switches.insert(switches.end(), engine_switches_.begin(),
96 engine_switches_.end());
97
98 auto env_switches = GetSwitchesFromEnvironment();
99 switches.insert(switches.end(), env_switches.begin(), env_switches.end());
100
101 return switches;
102 }

References flutter::GetSwitchesFromEnvironment().

Referenced by flutter::testing::TEST().

## ◆ HasValidPaths()

bool flutter::FlutterProjectBundle::HasValidPaths | ( |  | ) |

Definition at line 52 of file flutter_project_bundle.cc.

52 {
53 return !assets_path_.empty() && !icu_path_.empty();
54 }

Referenced by flutter::testing::TEST().

## ◆ icu_path()

const std::filesystem::path& flutter::FlutterProjectBundle::icu_path | ( |  | ) |
| inline

Definition at line 39 of file flutter_project_bundle.h.

39 { return icu_path_; }

Referenced by flutter::testing::TEST().

## ◆ LoadAotData()

UniqueAotDataPtr flutter::FlutterProjectBundle::LoadAotData | ( | const FlutterEngineProcTable & | engine_procs | ) |

Definition at line 58 of file flutter_project_bundle.cc.

59 {
60 if (aot_library_path_.empty()) {
61 FML_LOG(ERROR)
62 << "Attempted to load AOT data, but no aot_library_path was provided.";
63 return UniqueAotDataPtr(nullptr, nullptr);
64 }
65 if (!std::filesystem::exists(aot_library_path_)) {
66 FML_LOG(ERROR) << "Can't load AOT data from "
67 << aot_library_path_.u8string() << "; no such file.";
68 return UniqueAotDataPtr(nullptr, nullptr);
69 }
70 std::string path_string = aot_library_path_.u8string();
71 FlutterEngineAOTDataSource source = {};
72 source.type = kFlutterEngineAOTDataSourceTypeElfPath;
73 source.elf_path = path_string.c_str();
74 FlutterEngineAOTData data = nullptr;
75 auto result = engine_procs.CreateAOTData(&source, &data);
76 if (result != kSuccess) {
77 FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
78 return UniqueAotDataPtr(nullptr, nullptr);
79 }
80 return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
81 }

## ◆ SetSwitches()

void flutter::FlutterProjectBundle::SetSwitches | ( | const std::vector< std::string > & | switches | ) |

Definition at line 85 of file flutter_project_bundle.cc.

86 {
87 engine_switches_ = switches;
88 }

The documentation for this class was generated from the following files:

- shell/platform/windows/flutter_project_bundle.h
- shell/platform/windows/flutter_project_bundle.cc

FlutterDesktopEngineProperties::aot_library_path
const wchar_t * aot_library_path
Definition: flutter_windows.h:54
flutter::UniqueAotDataPtr
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
Definition: flutter_project_bundle.h:18
FlutterDesktopEngineProperties::dart_entrypoint_argv
const char ** dart_entrypoint_argv
Definition: flutter_windows.h:69
FlutterDesktopEngineProperties::icu_data_path
const wchar_t * icu_data_path
Definition: flutter_windows.h:48
flutter::GetExecutableDirectory
std::filesystem::path GetExecutableDirectory()
Definition: path_utils.cc:16
FlutterDesktopEngineProperties::dart_entrypoint
const char * dart_entrypoint
Definition: flutter_windows.h:62
flutter::GetSwitchesFromEnvironment
std::vector< std::string > GetSwitchesFromEnvironment()
Definition: engine_switches.cc:14
FlutterDesktopEngineProperties::dart_entrypoint_argc
int dart_entrypoint_argc
Definition: flutter_windows.h:65
FlutterDesktopEngineProperties::assets_path
const wchar_t * assets_path
Definition: flutter_windows.h:43