-
Notifications
You must be signed in to change notification settings - Fork 6k
Windows: Add UWP target stub [Flutter#14697] #21754
Windows: Add UWP target stub [Flutter#14697] #21754
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
0625b9b to
6d9defb
Compare
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 I just discovered that this has been sitting here as a draft review for over a week. I thought it was waiting for you to update based on feedback.
| switches.begin(), switches.end(), std::back_inserter(argv), | ||
| [](const std::string& arg) -> const char* { return arg.c_str(); }); | ||
|
|
||
| #ifndef FLUTTER_WINUWP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases where we know we are going to need an equivalent and there's nothing in the interface that's Win32-specific, we should really make an interface class--even if we currently don't have a UWP implementation-rather than scattering ifdefs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appols, please can you be more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything to do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed this. In particular, I think we should make an abstract TaskRunner class that the current Win32 version inherits from, and with a temporarily-no-op UWP subclass, and then most of the ifdefs about task runners in this file go away (in fact, if we declare a factory method in the abstract class's header, and implement it in each of the subclass files, then we don't need any ifdefs for task runner at all I think.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added an abstract taskrunner, made the win32 version inherit and add the winrt version as well (bonus.. it actually works ;-)). However, I'm not sure how to implement the factory pattern in a way that would eliminate the ifdef from flutter_windows_engine. Since c++ doesn't support virtual static inheritance i assume you are implying using a template function for the factory? If yes, that will not eliminate the need for an ifdef at the calling site. Also, note that there is another ifdef in that file so even if the factory is possible, that file won't be clean. Moving the ifdefs in question up into the caller will merely add ifdefs to a file that doesn't have any currently. So not quite sure what to do about the last aspect of the request here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reopen if you have more thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was envisioning a more low-tech solution:
- Declare a freestanding
CreateTaskRunnerfunction in task_runner.h - Implement that function twice, once in the Win32 .cc file, and once in the WinRT .cc file
Since only one of the files will be linked, only one implementation will be present.
|
One remaining clarifying question. This change is now dependent on a buildroot update: flutter/buildroot#409 |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just some more small structural cleanup so we're not adding more technical debt; overall seems like a good foundation.
| // host app can own its own message loop and flutter still gets to process | ||
| // tasks on a timely basis. | ||
| class Win32TaskRunner { | ||
| class Win32TaskRunner : public TaskRunner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really be calling these classes things like TaskRunnerWin32/TaskRunnerWinRt rather than the reverse. Let's fix that for this class in this PR (since it's adding a new file with the naming we should move away from), and I can do a follow-up to clean up the others after it lands.
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've addressed the comments from my last round of feedback.
@cbracken Since I've taken over the last part of this PR, could you review? I've made significant enough changes that it should get an approval from someone other than me.
|
@cbracken do you think you might get to this relatively soon? I'm holding off on the next UWP change until this is merged and I can cleanly rebuild the UWP prototype on ToT. |
cbracken
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor question/suggestion.
| // value in a dictionary with the given |key|. | ||
| virtual void GetPlainText( | ||
| std::unique_ptr<MethodResult<rapidjson::Document>> result, | ||
| const char* key) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why const char* here rather than std::string_view? Would allow for more flexibility at the call-site. Similarly SetPlainText could take a string_view.
|
Awesome, thx, I’ll address that, update to ToT and submit tomorrow. Thx so much Chris!
|
Description
This is the first in a series of patches to add support for a Windows UWP target, embedder implementation and runner per flutter/flutter#14967.
This change adds a new build target which is selected with target os
winuwpfor examplepython .\flutter\tools\gn --runtime-mode=debug --unoptimized --winuwpand will build a Windows binary flutter_windows_winuwp.dll. The implementation is stub only but the important aspect of this change is that all win32 specifics are now compiled behind an#ifdefwhich is only active for the win32 target. Once this PR has landed, the intent is to enable the target in CI to give some level of protection for the UWP target as new win32 functionality and os calls are added.This change cannot be landed until a small 5 line patch is made to dart to support target_os == "winuwp" which will be opened in due course and referenced here. Until that has happened this change will not build successfully in CI and should be consider WIP although it is ready for review now.
Related Issues
flutter/flutter#14967
Tests
Since this change is a stub, testing has not been added in anything but placeholder form.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.Reviewer Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.