-
Notifications
You must be signed in to change notification settings - Fork 12
Windows build #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows build #94
Changes from all commits
233c644
dce8560
c646971
2c8e287
be0ad73
59571a1
ca1298f
4187543
a3eb71f
ae45482
4c1e068
1b834b3
f871d4f
a63c7b3
8bf5e5b
530a002
104a1d5
0b3a19b
d49b2ae
68d7a29
c12edfe
aeaea17
91640d2
5969746
8593e7e
d4a61af
a3313bd
4e4ac41
b93aeb1
5852885
48e61d8
6f1a6b5
a9e4fb2
28b07d7
ef0091d
4f2351a
ec8c644
c0e4596
ee1410e
753d3f9
181035c
a9a1cce
6bcd83e
1c622d2
a699821
2bf9b7c
32bd681
6e09a4a
f98353f
99a17ed
2595ff1
4c34dd7
636fd08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| #include "flutter/shell/common/shorebird/snapshots_data_handle.h" | ||
| #include "flutter/shell/common/switches.h" | ||
| #include "fml/logging.h" | ||
| #include "shell/platform/embedder/embedder.h" | ||
| #include "third_party/dart/runtime/include/dart_tools_api.h" | ||
|
|
||
| #include "third_party/updater/library/include/updater.h" | ||
|
|
@@ -79,8 +80,100 @@ FileCallbacks ShorebirdFileCallbacks() { | |
| }; | ||
| } | ||
|
|
||
| // FIXME: consolidate this with the other ConfigureShorebird | ||
| bool ConfigureShorebird(const ShorebirdConfigArgs& args, | ||
| std::string& patch_path) { | ||
| patch_path = args.release_app_library_path; | ||
| auto shorebird_updater_dir_name = "shorebird_updater"; | ||
|
|
||
| auto code_cache_dir = fml::paths::JoinPaths( | ||
| {std::move(args.code_cache_path), shorebird_updater_dir_name}); | ||
| auto app_storage_dir = fml::paths::JoinPaths( | ||
| {std::move(args.app_storage_path), shorebird_updater_dir_name}); | ||
|
|
||
| fml::CreateDirectory(fml::paths::GetCachesDirectory(), | ||
| {shorebird_updater_dir_name}, | ||
| fml::FilePermission::kReadWrite); | ||
|
|
||
| bool init_result; | ||
| // Using a block to make AppParameters lifetime explicit. | ||
| { | ||
| AppParameters app_parameters; | ||
| // Combine version and version_code into a single string. | ||
| // We could also pass these separately through to the updater if needed. | ||
| auto release_version = | ||
| args.release_version.version + "+" + args.release_version.build_number; | ||
| app_parameters.release_version = release_version.c_str(); | ||
| app_parameters.code_cache_dir = code_cache_dir.c_str(); | ||
| app_parameters.app_storage_dir = app_storage_dir.c_str(); | ||
|
|
||
| // https://stackoverflow.com/questions/26032039/convert-vectorstring-into-char-c | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we do this in the Android codepath too.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, this function and the other ConfigureShorebird need to be consolidated. Doing that as a followup PR, as it affects the macOS bits There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant specifically the "turn a vector into vector<char*> |
||
| std::vector<const char*> c_paths{}; | ||
| c_paths.push_back(args.release_app_library_path.c_str()); | ||
| // Do not modify application_library_path or c_strings will invalidate. | ||
|
|
||
| app_parameters.original_libapp_paths = c_paths.data(); | ||
| app_parameters.original_libapp_paths_size = c_paths.size(); | ||
|
|
||
| // shorebird_init copies from app_parameters and shorebirdYaml. | ||
| init_result = shorebird_init(&app_parameters, ShorebirdFileCallbacks(), | ||
| args.shorebird_yaml.c_str()); | ||
| } | ||
|
|
||
| // We've decided not to support synchronous updates on launch for now. | ||
| // It's a terrible user experience (having the app hang on launch) and | ||
| // instead we will provide examples of how to build a custom update UI | ||
| // within Dart, including updating as part of login, etc. | ||
| // https://github.com/shorebirdtech/shorebird/issues/950 | ||
|
|
||
| // We only set the base snapshot on iOS for now. | ||
| // TODO: this won't compile as we don't have a settings object here. | ||
| // #if FML_OS_IOS || FML_OS_MACOSX | ||
| // SetBaseSnapshot(settings); | ||
| // #endif | ||
|
|
||
| FML_LOG(INFO) << "Checking for active patch"; | ||
| char* c_active_path = shorebird_next_boot_patch_path(); | ||
| if (c_active_path != NULL) { | ||
| patch_path = c_active_path; | ||
| shorebird_free_string(c_active_path); | ||
| FML_LOG(INFO) << "Shorebird updater: patch path: " << patch_path; | ||
| } else { | ||
| FML_LOG(INFO) << "Shorebird updater: no active patch."; | ||
| } | ||
|
|
||
| // We are careful only to report a launch start in the case where it's the | ||
| // first time we've configured shorebird this process. Otherwise we could end | ||
| // up in a case where we report a launch start, but never a completion (e.g. | ||
| // from package:flutter_work_manager which sometimes creates a FlutterEngine | ||
| // (and thus configures shorebird) but never runs it. The proper fix for this | ||
| // is probably to move the launch_start() call to be later in the lifecycle | ||
| // (when the snapshot is loaded and run, rather than when FlutterEngine is | ||
| // initialized). This "hack" will still have a problem where FlutterEngine is | ||
| // initialized but never run before the app is quit, could still cause us to | ||
| // suddenly mark-bad a patch that was never actually attempted to launch. | ||
| if (!init_result) { | ||
| return false; | ||
| } | ||
|
|
||
| // Once start_update_thread is called, the next_boot_patch* functions may | ||
| // change their return values if the shorebird_report_launch_failed | ||
| // function is called. | ||
| shorebird_report_launch_start(); | ||
|
|
||
| if (shorebird_should_auto_update()) { | ||
| FML_LOG(INFO) << "Starting Shorebird update"; | ||
| shorebird_start_update_thread(); | ||
| } else { | ||
| FML_LOG(INFO) | ||
| << "Shorebird auto_update disabled, not checking for updates."; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| void ConfigureShorebird(const ShorebirdFlutterProjectArgs& args, | ||
| flutter::Settings& settings) { | ||
| Settings& settings) { | ||
| // cache_path is used for both code_cache and app_storage, as we don't persist | ||
| // any data between releases. args.app_path is appended to | ||
| // the settings.application_library_path vector at this function's call site. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.