Flutter Engine
 
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 ()
 

Detailed Description

Definition at line 32 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 gpu_preference_ =
33 static_cast<FlutterGpuPreference>(properties.gpu_preference);
34
35 ui_thread_policy_ =
36 static_cast<FlutterUIThreadPolicy>(properties.ui_thread_policy);
37
38 // Resolve any relative paths.
39 if (assets_path_.is_relative() || icu_path_.is_relative() ||
40 (!aot_library_path_.empty() && aot_library_path_.is_relative())) {
41 std::filesystem::path executable_location = GetExecutableDirectory();
42 if (executable_location.empty()) {
43 FML_LOG(ERROR)
44 << "Unable to find executable location to resolve resource paths.";
45 assets_path_ = std::filesystem::path();
46 icu_path_ = std::filesystem::path();
47 } else {
48 assets_path_ = std::filesystem::path(executable_location) / assets_path_;
49 icu_path_ = std::filesystem::path(executable_location) / icu_path_;
50 if (!aot_library_path_.empty()) {
51 aot_library_path_ =
52 std::filesystem::path(executable_location) / aot_library_path_;
53 }
54 }
55 }
56}
#define FML_LOG(severity)
Definition logging.h:101
std::filesystem::path GetExecutableDirectory()
Definition path_utils.cc:16
FlutterDesktopUIThreadPolicy ui_thread_policy
FlutterDesktopGpuPreference gpu_preference

References 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 89 of file flutter_project_bundle.cc.

89{}

Member Function Documentation

◆ assets_path()

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

Definition at line 47 of file flutter_project_bundle.h.

47{ 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 65 of file flutter_project_bundle.h.

65{ return dart_entrypoint_; }

◆ dart_entrypoint_arguments()

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

Definition at line 69 of file flutter_project_bundle.h.

69 {
70 return dart_entrypoint_arguments_;
71 }

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

◆ GetSwitches()

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

Definition at line 96 of file flutter_project_bundle.cc.

96 {
97 if (engine_switches_.size() == 0) {
99 }
100 std::vector<std::string> switches;
101 switches.insert(switches.end(), engine_switches_.begin(),
102 engine_switches_.end());
103
104 auto env_switches = GetSwitchesFromEnvironment();
105 switches.insert(switches.end(), env_switches.begin(), env_switches.end());
106
107 return switches;
108}
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 74 of file flutter_project_bundle.h.

74{ return gpu_preference_; }

◆ HasValidPaths()

bool flutter::FlutterProjectBundle::HasValidPaths ( )

Definition at line 58 of file flutter_project_bundle.cc.

58 {
59 return !assets_path_.empty() && !icu_path_.empty();
60}

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

◆ icu_path()

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

Definition at line 50 of file flutter_project_bundle.h.

50{ return icu_path_; }

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

◆ LoadAotData()

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

Definition at line 64 of file flutter_project_bundle.cc.

65 {
66 if (aot_library_path_.empty()) {
67 FML_LOG(ERROR)
68 << "Attempted to load AOT data, but no aot_library_path was provided.";
69 return UniqueAotDataPtr(nullptr, nullptr);
70 }
71 if (!std::filesystem::exists(aot_library_path_)) {
72 FML_LOG(ERROR) << "Can't load AOT data from " << aot_library_path_
73 << "; no such file.";
74 return UniqueAotDataPtr(nullptr, nullptr);
75 }
76 std::string path_string = aot_library_path_.string();
79 source.elf_path = path_string.c_str();
80 FlutterEngineAOTData data = nullptr;
81 auto result = engine_procs.CreateAOTData(&source, &data);
82 if (result != kSuccess) {
83 FML_LOG(ERROR) << "Failed to load AOT data from: " << path_string;
84 return UniqueAotDataPtr(nullptr, nullptr);
85 }
86 return UniqueAotDataPtr(data, engine_procs.CollectAOTData);
87}
@ kFlutterEngineAOTDataSourceTypeElfPath
Definition embedder.h:2428
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
FlutterEngineAOTDataSourceType type
Definition embedder.h:2434
const char * elf_path
Absolute path to an ELF library file.
Definition embedder.h:2437
FlutterEngineCreateAOTDataFnPtr CreateAOTData
Definition embedder.h:3708
FlutterEngineCollectAOTDataFnPtr CollectAOTData
Definition embedder.h:3709

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

◆ SetSwitches()

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

Definition at line 91 of file flutter_project_bundle.cc.

92 {
93 engine_switches_ = switches;
94}

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

◆ ui_thread_policy()

FlutterUIThreadPolicy flutter::FlutterProjectBundle::ui_thread_policy ( )
inline

Definition at line 77 of file flutter_project_bundle.h.

77{ return ui_thread_policy_; }

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