| Flutter Windows Embedder |

flutter_project_bundle.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
7
8 #include <filesystem>
9 #include <string>
10 #include <vector>
11
12 #include "flutter/shell/platform/embedder/embedder.h"
13 #include "flutter/shell/platform/windows/public/flutter_windows.h"
14
15 namespace flutter {
16
17 using UniqueAotDataPtr =
18 std::unique_ptr<_FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr>;
19
20 // The data associated with a Flutter project needed to run it in an engine.
21 class FlutterProjectBundle {
22 public:
23 // Creates a new project bundle from the given properties.
24 //
25 // Treats any relative paths as relative to the directory of this executable.
26 explicit FlutterProjectBundle(
27 const FlutterDesktopEngineProperties& properties);
28
29 ~FlutterProjectBundle();
30
31 // Whether or not the bundle is valid. This does not check that the paths
32 // exist, or contain valid data, just that paths were able to be constructed.
33 bool HasValidPaths();
34
35 // Returns the path to the assets directory.
36 const std::filesystem::path& assets_path() { return assets_path_; }
37
38 // Returns the path to the ICU data file.
39 const std::filesystem::path& icu_path() { return icu_path_; }
40
41 // Returns any switches that should be passed to the engine.
42 const std::vector<std::string> GetSwitches();
43
44 // Sets engine switches.
45 void SetSwitches(const std::vector<std::string>& switches);
46
47 // Attempts to load AOT data for this bundle. The returned data must be
48 // retained until any engine instance it is passed to has been shut down.
49 //
50 // Logs and returns nullptr on failure.
51 UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable& engine_procs);
52
53 // Returns the Dart entrypoint.
54 const std::string& dart_entrypoint() const { return dart_entrypoint_; }
55
56 // Returns the command line arguments to be passed through to the Dart
57 // entrypoint.
58 const std::vector<std::string>& dart_entrypoint_arguments() const {
59 return dart_entrypoint_arguments_;
60 }
61
62 private:
63 std::filesystem::path assets_path_;
64 std::filesystem::path icu_path_;
65
66 // Path to the AOT library file, if any.
67 std::filesystem::path aot_library_path_;
68
69 // The Dart entrypoint to launch.
70 std::string dart_entrypoint_;
71
72 // Dart entrypoint arguments.
73 std::vector<std::string> dart_entrypoint_arguments_;
74
75 // Engine switches.
76 std::vector<std::string> engine_switches_;
77 };
78
79 } // namespace flutter
80
81 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_PROJECT_BUNDLE_H_
flutter::FlutterProjectBundle
Definition: flutter_project_bundle.h:21
flutter::UniqueAotDataPtr
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
Definition: flutter_project_bundle.h:18
FlutterDesktopEngineProperties
Definition: flutter_windows.h:39
flutter::FlutterProjectBundle::GetSwitches
const std::vector< std::string > GetSwitches()
Definition: flutter_project_bundle.cc:90
flutter::FlutterProjectBundle::icu_path
const std::filesystem::path & icu_path()
Definition: flutter_project_bundle.h:39
flutter::FlutterProjectBundle::dart_entrypoint
const std::string & dart_entrypoint() const
Definition: flutter_project_bundle.h:54
flutter::FlutterProjectBundle::assets_path
const std::filesystem::path & assets_path()
Definition: flutter_project_bundle.h:36
flutter::FlutterProjectBundle::dart_entrypoint_arguments
const std::vector< std::string > & dart_entrypoint_arguments() const
Definition: flutter_project_bundle.h:58
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::FlutterProjectBundle::~FlutterProjectBundle
~FlutterProjectBundle()
Definition: flutter_project_bundle.cc:83
flutter::FlutterProjectBundle::FlutterProjectBundle
FlutterProjectBundle(const FlutterDesktopEngineProperties &properties)
Definition: flutter_project_bundle.cc:15
flutter::FlutterProjectBundle::LoadAotData
UniqueAotDataPtr LoadAotData(const FlutterEngineProcTable &engine_procs)
Definition: flutter_project_bundle.cc:58
flutter_windows.h
flutter::FlutterProjectBundle::HasValidPaths
bool HasValidPaths()
Definition: flutter_project_bundle.cc:52
flutter::FlutterProjectBundle::SetSwitches
void SetSwitches(const std::vector< std::string > &switches)
Definition: flutter_project_bundle.cc:85