GN: Enable ARC for Mac and iOS in rtc_* templates
Remove all uses of retain/release and NSAutoreleasePool.
This makes transformation to Bazel easier.
This CL subsumes https://codereview.webrtc.org/2778163002 and depends on https://codereview.webrtc.org/2784483002/
BUG=webrtc:6412
Review-Url: https://codereview.webrtc.org/2781713004
Cr-Commit-Position: refs/heads/master@{#17780}
diff --git a/webrtc/examples/BUILD.gn b/webrtc/examples/BUILD.gn
index 10deaf2..d8e2545 100644
--- a/webrtc/examples/BUILD.gn
+++ b/webrtc/examples/BUILD.gn
@@ -160,7 +160,6 @@
"objc/AppRTCMobile/common/ARDUtilities.h",
"objc/AppRTCMobile/common/ARDUtilities.m",
]
- configs += [ "//build/config/compiler:enable_arc" ]
public_configs = [ ":apprtc_common_config" ]
deps = [
@@ -227,7 +226,6 @@
"objc/AppRTCMobile/RTCSessionDescription+JSON.h",
"objc/AppRTCMobile/RTCSessionDescription+JSON.m",
]
- configs += [ "//build/config/compiler:enable_arc" ]
public_configs = [ ":apprtc_signaling_config" ]
deps = [
":apprtc_common",
@@ -260,7 +258,6 @@
"objc/AppRTCMobile/ios/UIImage+ARDUtilities.h",
"objc/AppRTCMobile/ios/UIImage+ARDUtilities.m",
]
- configs += [ "//build/config/compiler:enable_arc" ]
deps = [
":apprtc_common",
@@ -337,10 +334,7 @@
"objc/AppRTCMobile/mac/APPRTCViewController.h",
"objc/AppRTCMobile/mac/APPRTCViewController.m",
]
- configs += [
- "//webrtc:common_objc",
- "//build/config/compiler:enable_arc",
- ]
+ configs += [ "//webrtc:common_objc" ]
deps = [
":apprtc_common",
":apprtc_signaling",
@@ -394,10 +388,7 @@
"objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.h",
"objc/AppRTCMobile/third_party/SocketRocket/SRWebSocket.m",
]
- configs += [
- "//build/config/compiler:enable_arc",
- ":socketrocket_warning_config",
- ]
+ configs += [ ":socketrocket_warning_config" ]
public_configs = [ ":socketrocket_include_config" ]
libs = [
@@ -430,7 +421,6 @@
"//build/config/ios:xctest",
"//third_party/ocmock",
]
- configs += [ "//build/config/compiler:enable_arc" ]
}
rtc_ios_xctest_test("apprtcmobile_tests") {
diff --git a/webrtc/modules/audio_device/BUILD.gn b/webrtc/modules/audio_device/BUILD.gn
index 3fa06b5..fcf445e 100644
--- a/webrtc/modules/audio_device/BUILD.gn
+++ b/webrtc/modules/audio_device/BUILD.gn
@@ -192,8 +192,6 @@
"ios/voice_processing_audio_unit.h",
"ios/voice_processing_audio_unit.mm",
]
- configs += [ "//build/config/compiler:enable_arc" ]
-
libs = [
"AudioToolbox.framework",
"AVFoundation.framework",
@@ -291,7 +289,6 @@
}
if (is_ios) {
sources += [ "ios/objc/RTCAudioSessionTest.mm" ]
- configs += [ "//build/config/compiler:enable_arc" ]
if (target_cpu != "x64") {
sources += [ "ios/audio_device_unittest_ios.cc" ]
}
diff --git a/webrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/webrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 2130719..73d5e02 100644
--- a/webrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/webrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -36,7 +36,7 @@
// setting.
NSImage* PaintInCurrentContext(NSImage* source) {
NSSize size = [source size];
- NSImage* new_image = [[[NSImage alloc] initWithSize:size] autorelease];
+ NSImage* new_image = [[NSImage alloc] initWithSize:size];
[new_image lockFocus];
NSRect frame = NSMakeRect(0, 0, size.width, size.height);
[source drawInRect:frame
diff --git a/webrtc/sdk/BUILD.gn b/webrtc/sdk/BUILD.gn
index 38c5b68..c27811a 100644
--- a/webrtc/sdk/BUILD.gn
+++ b/webrtc/sdk/BUILD.gn
@@ -31,10 +31,7 @@
deps = [
"../base:rtc_base",
]
- configs += [
- "..:common_objc",
- "//build/config/compiler:enable_arc",
- ]
+ configs += [ "..:common_objc" ]
public_configs = [ ":rtc_sdk_common_objc_config" ]
sources = [
"objc/Framework/Classes/NSString+StdString.h",
@@ -230,10 +227,7 @@
]
}
- configs += [
- "..:common_objc",
- "//build/config/compiler:enable_arc",
- ]
+ configs += [ "..:common_objc" ]
public_configs = [ ":rtc_sdk_common_objc_config" ]
@@ -373,10 +367,7 @@
"VideoToolbox.framework",
]
- configs += [
- "..:common_objc",
- "//build/config/compiler:enable_arc",
- ]
+ configs += [ "..:common_objc" ]
public_configs = [ ":rtc_sdk_common_objc_config" ]
@@ -406,10 +397,7 @@
"objc/Framework/Classes/h264_video_toolbox_nalu.h",
]
- configs += [
- "//webrtc:common_objc",
- "//build/config/compiler:enable_arc",
- ]
+ configs += [ "//webrtc:common_objc" ]
deps = [
":rtc_sdk_common_objc",
diff --git a/webrtc/sdk/objc/Framework/UnitTests/avformatmappertests.mm b/webrtc/sdk/objc/Framework/UnitTests/avformatmappertests.mm
index 624eec3..cbc2e50 100644
--- a/webrtc/sdk/objc/Framework/UnitTests/avformatmappertests.mm
+++ b/webrtc/sdk/objc/Framework/UnitTests/avformatmappertests.mm
@@ -97,7 +97,6 @@
CFRelease(_format);
_format = nil;
}
- [super dealloc];
}
// Redefinition of AVCaptureDevice methods we want to mock.
diff --git a/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn
index 64b6e03..e76ff03 100644
--- a/webrtc/test/BUILD.gn
+++ b/webrtc/test/BUILD.gn
@@ -128,7 +128,6 @@
]
if (is_ios) {
sources += [ "testsupport/iosfileutils.mm" ]
- configs += [ "//build/config/compiler:enable_arc" ]
}
visibility = [ ":*" ]
deps = [
diff --git a/webrtc/test/mac/run_test.mm b/webrtc/test/mac/run_test.mm
index 4e0093a..d6df69c 100644
--- a/webrtc/test/mac/run_test.mm
+++ b/webrtc/test/mac/run_test.mm
@@ -36,10 +36,10 @@
}
- (void)runAllTests:(TestBlock)testBlock {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- testBlock();
- running_ = NO;
- [pool release];
+ @autoreleasepool {
+ testBlock();
+ running_ = NO;
+ }
}
- (BOOL)running {
@@ -51,24 +51,23 @@
namespace test {
void RunTest(void(*test)()) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [NSApplication sharedApplication];
+ @autoreleasepool {
+ [NSApplication sharedApplication];
- // Convert the function pointer to an Objective-C block and call on a
- // separate thread, to avoid blocking the main thread.
- TestRunner *testRunner = [[TestRunner alloc] init];
- TestBlock testBlock = functionToBlock(test);
- [NSThread detachNewThreadSelector:@selector(runAllTests:)
- toTarget:testRunner
- withObject:testBlock];
+ // Convert the function pointer to an Objective-C block and call on a
+ // separate thread, to avoid blocking the main thread.
+ TestRunner *testRunner = [[TestRunner alloc] init];
+ TestBlock testBlock = functionToBlock(test);
+ [NSThread detachNewThreadSelector:@selector(runAllTests:)
+ toTarget:testRunner
+ withObject:testBlock];
- NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
- while ([testRunner running] &&
- [runLoop runMode:NSDefaultRunLoopMode
- beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]);
+ NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
+ while ([testRunner running] &&
+ [runLoop runMode:NSDefaultRunLoopMode
+ beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]);
+ }
- [testRunner release];
- [pool release];
}
} // namespace test
diff --git a/webrtc/test/mac/video_renderer_mac.mm b/webrtc/test/mac/video_renderer_mac.mm
index f79aecf..ee1f906 100644
--- a/webrtc/test/mac/video_renderer_mac.mm
+++ b/webrtc/test/mac/video_renderer_mac.mm
@@ -43,11 +43,6 @@
return self;
}
-- (void)dealloc {
- [window_ release];
- [super dealloc];
-}
-
- (void)createWindow:(NSObject *)ignored {
NSInteger xOrigin = nextXOrigin_;
NSRect screenFrame = [[NSScreen mainScreen] frame];
@@ -71,8 +66,8 @@
defer:NO];
NSRect viewFrame = NSMakeRect(0, 0, width_, height_);
- NSOpenGLView *view = [[[NSOpenGLView alloc] initWithFrame:viewFrame
- pixelFormat:nil] autorelease];
+ NSOpenGLView *view = [[NSOpenGLView alloc] initWithFrame:viewFrame
+ pixelFormat:nil];
context_ = [view openGLContext];
[[window_ contentView] addSubview:view];
@@ -105,7 +100,6 @@
MacRenderer::~MacRenderer() {
GlRenderer::Destroy();
- [window_ release];
}
bool MacRenderer::Init(const char* window_title, int width, int height) {
diff --git a/webrtc/webrtc.gni b/webrtc/webrtc.gni
index 6f902c9..e47ac08 100644
--- a/webrtc/webrtc.gni
+++ b/webrtc/webrtc.gni
@@ -211,6 +211,10 @@
# native code is built as part of Chromium.
rtc_common_configs = [ webrtc_root + ":common_config" ]
+if (is_mac || is_ios) {
+ rtc_common_configs += [ "//build/config/compiler:enable_arc" ]
+}
+
# Global public configuration that should be applied to all WebRTC targets. You
# normally shouldn't need to include this in your target as it's automatically
# included when using the rtc_* templates. It set the defines, include paths and