Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
 
FlutterGpuPreference gpu_preference () const
 
FlutterUIThreadPolicy ui_thread_policy ()
 
FlutterAccessibilityMode accessibility_mode () const
 

Detailed Description

Definition at line 39 of file flutter_project_bundle.h.

Constructor & Destructor Documentation

◆ FlutterProjectBundle()

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

Definition at line 16 of file flutter_project_bundle.cc.

18 : assets_path_(properties.assets_path),
19 icu_path_(properties.icu_data_path) {
20 if (properties.aot_library_path != nullptr) {
21 aot_library_path_ = std::filesystem::path(properties.aot_library_path);
22 }
23
24 if (properties.dart_entrypoint && properties.dart_entrypoint[0] != '\0') {
25 dart_entrypoint_ = properties.dart_entrypoint;
26 }
27
28 for (int i = 0; i < properties.dart_entrypoint_argc; i++) {
29 dart_entrypoint_arguments_.push_back(
30 std::string(properties.dart_entrypoint_argv[i]));
31 }
32
33 gpu_preference_ =
34 static_cast<FlutterGpuPreference>(properties.gpu_preference);
35
36 ui_thread_policy_ =
37 static_cast<FlutterUIThreadPolicy>(properties.ui_thread_policy);
38
39 accessibility_mode_ =
40 static_cast<FlutterAccessibilityMode>(properties.accessibility_mode);
41
42 // Resolve any relative paths.
43 if (assets_path_.is_relative() || icu_path_.is_relative() ||
44 (!aot_library_path_.empty() && aot_library_path_.is_relative())) {
45 std::filesystem::path executable_location = GetExecutableDirectory();
46 if (executable_location.empty()) {
47 FML_LOG(ERROR)
48 << "Unable to find executable location to resolve resource paths.";
49 assets_path_ = std::filesystem::path();
50 icu_path_ = std::filesystem::path();
51 } else {
52 assets_path_ = std::filesystem::path(executable_location) / assets_path_;
53 icu_path_ = std::filesystem::path(executable_location) / icu_path_;
54 if (!aot_library_path_.empty()) {
55 aot_library_path_ =
56 std::filesystem::path(executable_location) / aot_library_path_;
57 }
58 }
59 }
60}
#define FML_LOG(severity)
Definition logging.h:101
std::filesystem::path GetExecutableDirectory()
Definition path_utils.cc:16
FlutterDesktopAccessibilityMode accessibility_mode
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference

References FlutterDesktopEngineProperties::accessibility_mode, FlutterDesktopEngineProperties::aot_library_path, FlutterDesktopEngineProperties::dart_entrypoint, FlutterDesktopEngineProperties::dart_entrypoint_argc, FlutterDesktopEngineProperties::dart_entrypoint_argv, FML_LOG, flutter::GetExecutableDirectory(), FlutterDesktopEngineProperties::gpu_preference, i, and FlutterDesktopEngineProperties::ui_thread_policy.

◆ ~FlutterProjectBundle()

flutter::FlutterProjectBundle::~FlutterProjectBundle ( )

Definition at line 93 of file flutter_project_bundle.cc.

93{}

Member Function Documentation

◆ accessibility_mode()

FlutterAccessibilityMode flutter::FlutterProjectBundle::accessibility_mode ( ) const
inline

Definition at line 87 of file flutter_project_bundle.h.

87 {
88 return accessibility_mode_;
89 }

◆ assets_path()

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

Definition at line 54 of file flutter_project_bundle.h.

54{ return assets_path_; }

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

◆ dart_entrypoint()

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

Definition at line 72 of file flutter_project_bundle.h.

72{ return dart_entrypoint_; }

◆ dart_entrypoint_arguments()

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

Definition at line 76 of file flutter_project_bundle.h.

76 {
77 return dart_entrypoint_arguments_;
78 }

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

◆ GetSwitches()

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

Definition at line 100 of file flutter_project_bundle.cc.

100 {
101 if (engine_switches_.size() == 0) {
103 }
104 std::vector<std::string> switches;
105 switches.insert(switches.end(), engine_switches_.begin(),
106 engine_switches_.end());
107
108 auto env_switches = GetSwitchesFromEnvironment();
109 switches.insert(switches.end(), env_switches.begin(), env_switches.end());
110
111 return switches;
112}
std::vector< std::string > GetSwitchesFromEnvironment()

References flutter::GetSwitchesFromEnvironment().

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

◆ gpu_preference()

FlutterGpuPreference flutter::FlutterProjectBundle::gpu_preference ( ) const
inline

Definition at line 81 of file flutter_project_bundle.h.

81{ return gpu_preference_; }

◆ HasValidPaths()

bool flutter::FlutterProjectBundle::HasValidPaths ( )

Definition at line 62 of file flutter_project_bundle.cc.

62 {
63 return !assets_path_.empty() && !icu_path_.empty();
64}

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

◆ icu_path()

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

Definition at line 57 of file flutter_project_bundle.h.

57{ return icu_path_; }

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

◆ LoadAotData()

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

Definition at line 68 of file flutter_project_bundle.cc.

69 {
70 if (aot_library_path_.empty()) {
71 FML_LOG(ERROR)
72 << "Attempted to load AOT data, but no aot_library_path was provided.";
73 return UniqueAotDataPtr(nullptr, nullptr);
74 }
75 if (!std::filesystem::exists(aot_library_path_)) {
76 FML_LOG(ERROR) << "Can't load AOT data from " << aot_library_path_
77 << "; no such file.";
78 return UniqueAotDataPtr(nullptr, nullptr);
79 }
80 std::string path_string = fml::PathToUtf8(aot_library_path_);
83 source.elf_path = path_string.c_str();
84 FlutterEngineAOTData data = nullptr;
85 auto result = engine_procs.CreateAOTData(&source, &data);
86 if (result != kSuccess) {
87 FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
88 return UniqueAotDataPtr(nullptr, nullptr);
89 }
90 return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
91}
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition embedder.h:2466
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switch_defs.h:36
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
std::string PathToUtf8(const std::filesystem::path &path)
FlutterEngineAOTDataSourceType type
Definition embedder.h:2472
const char * elf_path
Absolute path to an ELF library file.
Definition embedder.h:2475
FlutterEngineCreateAOTDataFnPtr CreateAOTData
Definition embedder.h:3750
FlutterEngineCollectAOTDataFnPtr CollectAOTData
Definition embedder.h:3751

References FlutterEngineProcTable::CollectAOTData, FlutterEngineProcTable::CreateAOTData, flutter::data, FlutterEngineAOTDataSource::elf_path, FML_LOG, kFlutterEngineAOTDataSourceTypeElfPath, flutter::kSuccess, fml::PathToUtf8(), and FlutterEngineAOTDataSource::type.

◆ SetSwitches()

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

Definition at line 95 of file flutter_project_bundle.cc.

96 {
97 engine_switches_ = switches;
98}

Referenced by flutter::testing::FlutterWindowsEngineBuilder::Build().

◆ ui_thread_policy()

FlutterUIThreadPolicy flutter::FlutterProjectBundle::ui_thread_policy ( )
inline

Definition at line 84 of file flutter_project_bundle.h.

84{ return ui_thread_policy_; }

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