Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[macOS] Eliminate mirrors support #39694

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,4 @@ - (NSString*)ICUDataPath {
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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -337,7 +338,7 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint {

// 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(); });

Expand Down Expand Up @@ -917,6 +918,10 @@ - (NSPasteboard*)pasteboard {
return [NSPasteboard generalPasteboard];
}

- (std::vector<std::string>)switches {
return flutter::GetSwitchesFromEnvironment();
}

#pragma mark - FlutterBinaryMessenger

- (void)sendOnChannel:(nonnull NSString*)channel message:(nullable NSData*)message {
Expand Down
18 changes: 18 additions & 0 deletions shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ - (nonnull NSView*)createWithViewIdentifier:(int64_t)viewId arguments:(nullable
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"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down