[macOS] Eliminate mirrors support (flutter/engine#39694)

Support for using dart:mirrors has been deprecated for nearly two years.
this removes support for enabling mirrors from the embedder as
documented in the deprecation comment. This was primarily added as a
workaround for an internal tooling usecase, which no longer exists.

Issue: https://github.com/flutter/flutter/issues/120924
This commit is contained in:
Chris Bracken
2023-02-16 17:23:38 -08:00
committed by GitHub
parent a9e12287f6
commit 63fbaec5b1
6 changed files with 29 additions and 21 deletions

View File

@@ -29,13 +29,6 @@ FLUTTER_DARWIN_EXPORT
- (nonnull instancetype)initWithPrecompiledDartBundle:(nullable NSBundle*)bundle
NS_DESIGNATED_INITIALIZER;
/**
* If set, allows the Flutter project to use the dart:mirrors library.
*
* Deprecated: This function is temporary and will be removed in a future release.
*/
@property(nonatomic) bool enableMirrors;
/**
* An NSArray of NSStrings to be passed as command line arguments to the Dart entrypoint.
*

View File

@@ -81,12 +81,4 @@ static NSString* const kAppBundleIdentifier = @"io.flutter.flutter.app";
return path;
}
- (std::vector<std::string>)switches {
std::vector<std::string> arguments = flutter::GetSwitchesFromEnvironment();
if (self.enableMirrors) {
arguments.push_back("--dart-flags=--enable_mirrors=true");
}
return arguments;
}
@end

View File

@@ -25,11 +25,6 @@
*/
@property(nonatomic, readonly, nullable) NSString* ICUDataPath;
/**
* The command line arguments array for the engine.
*/
@property(nonatomic, readonly) std::vector<std::string> switches;
/**
* The callback invoked by the engine in root isolate scope.
*/

View File

@@ -9,6 +9,7 @@
#include <iostream>
#include <vector>
#include "flutter/shell/platform/common/engine_switches.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.h"
@@ -337,7 +338,7 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
// The first argument of argv is required to be the executable name.
std::vector<const char*> argv = {[self.executableName UTF8String]};
std::vector<std::string> switches = _project.switches;
std::vector<std::string> switches = self.switches;
std::transform(switches.begin(), switches.end(), std::back_inserter(argv),
[](const std::string& arg) -> const char* { return arg.c_str(); });
@@ -917,6 +918,10 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
return [NSPasteboard generalPasteboard];
}
- (std::vector<std::string>)switches {
return flutter::GetSwitchesFromEnvironment();
}
#pragma mark - FlutterBinaryMessenger
- (void)sendOnChannel:(nonnull NSString*)channel message:(nullable NSData*)message {

View File

@@ -69,6 +69,24 @@ TEST_F(FlutterEngineTest, HasNonNullExecutableName) {
latch.Wait();
}
#ifndef FLUTTER_RELEASE
TEST_F(FlutterEngineTest, Switches) {
setenv("FLUTTER_ENGINE_SWITCHES", "2", 1);
setenv("FLUTTER_ENGINE_SWITCH_1", "abc", 1);
setenv("FLUTTER_ENGINE_SWITCH_2", "foo=\"bar, baz\"", 1);
FlutterEngine* engine = GetFlutterEngine();
std::vector<std::string> switches = engine.switches;
ASSERT_EQ(switches.size(), 2UL);
EXPECT_EQ(switches[0], "--abc");
EXPECT_EQ(switches[1], "--foo=\"bar, baz\"");
unsetenv("FLUTTER_ENGINE_SWITCHES");
unsetenv("FLUTTER_ENGINE_SWITCH_1");
unsetenv("FLUTTER_ENGINE_SWITCH_2");
}
#endif // !FLUTTER_RELEASE
TEST_F(FlutterEngineTest, MessengerSend) {
FlutterEngine* engine = GetFlutterEngine();
EXPECT_TRUE([engine runWithEntrypoint:@"main"]);

View File

@@ -47,6 +47,11 @@
*/
@property(nonatomic, readonly, nonnull) NSPasteboard* pasteboard;
/**
* The command line arguments array for the engine.
*/
@property(nonatomic, readonly) std::vector<std::string> switches;
/**
* Attach a view controller to the engine as its default controller.
*