Skip to content

Commit

Permalink
[iOS/GN] Convert //ios/third_party/earl_grey to build with GN.
Browse files Browse the repository at this point in the history
Fix the ios_framework_bundle template to create a new public config
so that anyone depending on the target will correctly link against
it. Change framework_bundle to use public_deps in order to make the
public config accessible.

Create //ios/third_party/earl_grey target.

BUG=599321

Review URL: https://codereview.chromium.org/1879003002

Cr-Commit-Position: refs/heads/master@{#387265}
  • Loading branch information
sdefresne authored and Commit bot committed Apr 14, 2016
1 parent 2cb71a8 commit 22de3c9
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 18 deletions.
3 changes: 1 addition & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ group("both_gn_and_gyp") {
"//ios/public/provider/chrome/browser",
"//ios/public/provider/web",
"//ios/testing:ocmock_support_unittest",
"//ios/third_party/fishhook",
"//ios/third_party/ochamcrest",
"//ios/third_party/earl_grey",
"//ios/web:ios_web_inttests",
"//ios/web:ios_web_unittests",
"//ios/web/shell:ios_web_shell",
Expand Down
63 changes: 52 additions & 11 deletions build/config/ios/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,18 @@ template("bundle_data_xib") {
# See "gn help shared_library" for more information on arguments supported
# by shared library target.
template("ios_framework_bundle") {
if (defined(invoker.public_headers) && invoker.public_headers != []) {
assert(defined(invoker.sources) && invoker.sources != [],
"sources must be set for $target_name when public_headers is set")

_target_name = target_name
_output_name = target_name
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
}
_target_name = target_name
_output_name = target_name
if (defined(invoker.output_name)) {
_output_name = invoker.output_name
}
_framework_target = _target_name

if (defined(invoker.public_headers) && invoker.public_headers != []) {
_public_headers = invoker.public_headers
_framework_name = _output_name + ".framework"
_framework_root = "$root_out_dir/$_framework_name"
_framework_target = target_name + "_internal"

_header_map_filename = "$target_gen_dir/$_output_name.headers.hmap"
_framework_headers_target = _target_name + "_framework_headers"
Expand Down Expand Up @@ -327,6 +326,18 @@ template("ios_framework_bundle") {
include_dirs = [ _header_map_filename ]
}

_framework_public_config = _target_name + "_public_config"
config(_framework_public_config) {
# TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
# and include_dirs to avoid duplicate values on the command-line.
common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ]
cflags_objc = common_flags
cflags_objcc = common_flags
ldflags = common_flags
lib_dirs = [ root_out_dir ]
libs = [ _framework_name ]
}

group(_framework_headers_target) {
deps = [
":$_compile_headers_map_target",
Expand All @@ -336,15 +347,45 @@ template("ios_framework_bundle") {
}
}

framework_bundle(target_name) {
forward_variables_from(invoker, "*", [ "public_headers" ])
framework_bundle(_framework_target) {
forward_variables_from(invoker,
"*",
[
"output_name",
"public_headers",
"visibility",
])
output_name = _output_name

if (defined(_public_headers)) {
visibility = [ ":$_target_name" ]
configs += [ ":$_headers_map_config" ]

if (!defined(deps)) {
deps = []
}
deps += [ ":$_framework_headers_target" ]
} else {
forward_variables_from(invoker, [ "visibility" ])
}
}

if (defined(_public_headers)) {
group(_target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
"public_configs",
])

deps = [
":$_framework_target",
]
if (!defined(public_configs)) {
public_configs = []
}
public_configs += [ ":$_framework_public_config" ]
}
}
}
8 changes: 4 additions & 4 deletions build/config/mac/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ template("framework_bundle") {
forward_variables_from(invoker, [ "visibility" ])
}

if (!defined(deps)) {
deps = []
if (!defined(public_deps)) {
public_deps = []
}
deps += [ ":$_shared_library_bundle_data" ]
public_deps += [ ":$_shared_library_bundle_data" ]

bundle_root_dir = _framework_root_dir
bundle_resources_dir = "$bundle_root_dir/Resources"
Expand All @@ -114,7 +114,7 @@ template("framework_bundle") {
"$_framework_name",
"$_framework_version",
]
deps = [
public_deps = [
":$_framework_target",
]
}
Expand Down
256 changes: 256 additions & 0 deletions ios/third_party/earl_grey/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/ios/ios_sdk.gni")
import("//build/config/ios/rules.gni")

config("config") {
include_dirs = [ "src/EarlGrey" ]

# EarlGrey and its dependencies need to link to XCTest.framework
# that is not under $ios_sdk_path.
common_flags = [ "-F$ios_sdk_path/../../Library/Frameworks" ]
cflags_objc = common_flags
cflags_objcc = common_flags
ldflags = common_flags
}

ios_framework_bundle("earl_grey") {
output_name = "EarlGrey"

testonly = true
sources = [
"src/EarlGrey/Action/GREYAction.h",
"src/EarlGrey/Action/GREYActionBlock.h",
"src/EarlGrey/Action/GREYActionBlock.m",
"src/EarlGrey/Action/GREYActions.h",
"src/EarlGrey/Action/GREYActions.m",
"src/EarlGrey/Action/GREYBaseAction.h",
"src/EarlGrey/Action/GREYBaseAction.m",
"src/EarlGrey/Action/GREYChangeStepperAction.h",
"src/EarlGrey/Action/GREYChangeStepperAction.m",
"src/EarlGrey/Action/GREYPathGestureUtils.h",
"src/EarlGrey/Action/GREYPathGestureUtils.m",
"src/EarlGrey/Action/GREYPickerAction.h",
"src/EarlGrey/Action/GREYPickerAction.m",
"src/EarlGrey/Action/GREYScrollAction.h",
"src/EarlGrey/Action/GREYScrollAction.m",
"src/EarlGrey/Action/GREYScrollActionError.h",
"src/EarlGrey/Action/GREYScrollActionError.m",
"src/EarlGrey/Action/GREYScrollToContentEdgeAction.h",
"src/EarlGrey/Action/GREYScrollToContentEdgeAction.m",
"src/EarlGrey/Action/GREYSlideAction.h",
"src/EarlGrey/Action/GREYSlideAction.m",
"src/EarlGrey/Action/GREYSwipeAction.h",
"src/EarlGrey/Action/GREYSwipeAction.m",
"src/EarlGrey/Action/GREYTapAction.h",
"src/EarlGrey/Action/GREYTapAction.m",
"src/EarlGrey/Action/GREYTapper.h",
"src/EarlGrey/Action/GREYTapper.m",
"src/EarlGrey/Additions/CAAnimation+GREYAdditions.h",
"src/EarlGrey/Additions/CAAnimation+GREYAdditions.m",
"src/EarlGrey/Additions/CALayer+GREYAdditions.h",
"src/EarlGrey/Additions/CALayer+GREYAdditions.m",
"src/EarlGrey/Additions/CGGeometry+GREYAdditions.h",
"src/EarlGrey/Additions/CGGeometry+GREYAdditions.m",
"src/EarlGrey/Additions/NSError+GREYAdditions.h",
"src/EarlGrey/Additions/NSError+GREYAdditions.m",
"src/EarlGrey/Additions/NSObject+GREYAdditions.h",
"src/EarlGrey/Additions/NSObject+GREYAdditions.m",
"src/EarlGrey/Additions/NSRunLoop+GREYAdditions.h",
"src/EarlGrey/Additions/NSRunLoop+GREYAdditions.m",
"src/EarlGrey/Additions/NSString+GREYAdditions.h",
"src/EarlGrey/Additions/NSString+GREYAdditions.m",
"src/EarlGrey/Additions/NSTimer+GREYAdditions.h",
"src/EarlGrey/Additions/NSTimer+GREYAdditions.m",
"src/EarlGrey/Additions/NSURL+GREYAdditions.h",
"src/EarlGrey/Additions/NSURL+GREYAdditions.m",
"src/EarlGrey/Additions/NSURLConnection+GREYAdditions.h",
"src/EarlGrey/Additions/NSURLConnection+GREYAdditions.m",
"src/EarlGrey/Additions/UIAnimation+GREYAdditions.h",
"src/EarlGrey/Additions/UIAnimation+GREYAdditions.m",
"src/EarlGrey/Additions/UIApplication+GREYAdditions.h",
"src/EarlGrey/Additions/UIApplication+GREYAdditions.m",
"src/EarlGrey/Additions/UIScrollView+GREYAdditions.h",
"src/EarlGrey/Additions/UIScrollView+GREYAdditions.m",
"src/EarlGrey/Additions/UISwitch+GREYAdditions.h",
"src/EarlGrey/Additions/UISwitch+GREYAdditions.m",
"src/EarlGrey/Additions/UITouch+GREYAdditions.h",
"src/EarlGrey/Additions/UITouch+GREYAdditions.m",
"src/EarlGrey/Additions/UIView+GREYAdditions.h",
"src/EarlGrey/Additions/UIView+GREYAdditions.m",
"src/EarlGrey/Additions/UIViewController+GREYAdditions.h",
"src/EarlGrey/Additions/UIViewController+GREYAdditions.m",
"src/EarlGrey/Additions/UIWebView+GREYAdditions.h",
"src/EarlGrey/Additions/UIWebView+GREYAdditions.m",
"src/EarlGrey/Additions/UIWindow+GREYAdditions.h",
"src/EarlGrey/Additions/UIWindow+GREYAdditions.m",
"src/EarlGrey/Additions/XCTestCase+GREYAdditions.h",
"src/EarlGrey/Additions/XCTestCase+GREYAdditions.m",
"src/EarlGrey/Additions/_UIGestureRecognizerFailureMap_GREYAdditions.h",
"src/EarlGrey/Additions/_UIGestureRecognizerFailureMap_GREYAdditions.m",
"src/EarlGrey/Additions/_UIModalItemsPresentingViewController_GREYAdditions.h",
"src/EarlGrey/Additions/_UIModalItemsPresentingViewController_GREYAdditions.m",
"src/EarlGrey/Additions/__NSCFLocalDataTask_GREYAdditions.h",
"src/EarlGrey/Additions/__NSCFLocalDataTask_GREYAdditions.m",
"src/EarlGrey/AppSupport/GREYIdlingResource.h",
"src/EarlGrey/Assertion/GREYAssertion.h",
"src/EarlGrey/Assertion/GREYAssertionBlock.h",
"src/EarlGrey/Assertion/GREYAssertionBlock.m",
"src/EarlGrey/Assertion/GREYAssertionDefines.h",
"src/EarlGrey/Assertion/GREYAssertions.h",
"src/EarlGrey/Assertion/GREYAssertions.m",
"src/EarlGrey/Common/GREYAnalytics.h",
"src/EarlGrey/Common/GREYAnalytics.m",
"src/EarlGrey/Common/GREYConfiguration.h",
"src/EarlGrey/Common/GREYConfiguration.m",
"src/EarlGrey/Common/GREYConstants.h",
"src/EarlGrey/Common/GREYConstants.m",
"src/EarlGrey/Common/GREYDefines.h",
"src/EarlGrey/Common/GREYElementHierarchy.h",
"src/EarlGrey/Common/GREYElementHierarchy.m",
"src/EarlGrey/Common/GREYExposed.h",
"src/EarlGrey/Common/GREYPrivate.h",
"src/EarlGrey/Common/GREYScreenshotUtil.h",
"src/EarlGrey/Common/GREYScreenshotUtil.m",
"src/EarlGrey/Common/GREYSwizzler.h",
"src/EarlGrey/Common/GREYSwizzler.m",
"src/EarlGrey/Common/GREYVisibilityChecker.h",
"src/EarlGrey/Common/GREYVisibilityChecker.m",
"src/EarlGrey/Core/GREYElementFinder.h",
"src/EarlGrey/Core/GREYElementFinder.m",
"src/EarlGrey/Core/GREYElementInteraction.h",
"src/EarlGrey/Core/GREYElementInteraction.m",
"src/EarlGrey/Core/GREYInteraction.h",
"src/EarlGrey/Core/GREYInteractionDataSource.h",
"src/EarlGrey/Core/GREYKeyboard.h",
"src/EarlGrey/Core/GREYKeyboard.m",
"src/EarlGrey/Delegate/GREYCAAnimationDelegate.h",
"src/EarlGrey/Delegate/GREYCAAnimationDelegate.m",
"src/EarlGrey/Delegate/GREYNSURLConnectionDelegate.h",
"src/EarlGrey/Delegate/GREYNSURLConnectionDelegate.m",
"src/EarlGrey/Delegate/GREYSurrogateDelegate.h",
"src/EarlGrey/Delegate/GREYSurrogateDelegate.m",
"src/EarlGrey/Delegate/GREYUIWebViewDelegate.h",
"src/EarlGrey/Delegate/GREYUIWebViewDelegate.m",
"src/EarlGrey/EarlGrey.h",
"src/EarlGrey/EarlGrey.m",
"src/EarlGrey/Event/GREYSingleSequenceTouchInjector.h",
"src/EarlGrey/Event/GREYSingleSequenceTouchInjector.m",
"src/EarlGrey/Event/GREYSyntheticEvents.h",
"src/EarlGrey/Event/GREYSyntheticEvents.m",
"src/EarlGrey/Exception/GREYDefaultFailureHandler.h",
"src/EarlGrey/Exception/GREYDefaultFailureHandler.m",
"src/EarlGrey/Exception/GREYFailureHandler.h",
"src/EarlGrey/Exception/GREYFrameworkException.h",
"src/EarlGrey/Exception/GREYFrameworkException.m",
"src/EarlGrey/Matcher/GREYAllOf.h",
"src/EarlGrey/Matcher/GREYAllOf.m",
"src/EarlGrey/Matcher/GREYAnyOf.h",
"src/EarlGrey/Matcher/GREYAnyOf.m",
"src/EarlGrey/Matcher/GREYBaseMatcher.h",
"src/EarlGrey/Matcher/GREYBaseMatcher.m",
"src/EarlGrey/Matcher/GREYDescription.h",
"src/EarlGrey/Matcher/GREYElementMatcherBlock.h",
"src/EarlGrey/Matcher/GREYElementMatcherBlock.m",
"src/EarlGrey/Matcher/GREYHCMatcher.h",
"src/EarlGrey/Matcher/GREYHCMatcher.m",
"src/EarlGrey/Matcher/GREYLayoutConstraint.h",
"src/EarlGrey/Matcher/GREYLayoutConstraint.m",
"src/EarlGrey/Matcher/GREYMatcher.h",
"src/EarlGrey/Matcher/GREYMatchers.h",
"src/EarlGrey/Matcher/GREYMatchers.m",
"src/EarlGrey/Matcher/GREYNot.h",
"src/EarlGrey/Matcher/GREYNot.m",
"src/EarlGrey/Matcher/GREYStringDescription.h",
"src/EarlGrey/Matcher/GREYStringDescription.m",
"src/EarlGrey/Provider/GREYDataEnumerator.h",
"src/EarlGrey/Provider/GREYDataEnumerator.m",
"src/EarlGrey/Provider/GREYElementProvider.h",
"src/EarlGrey/Provider/GREYElementProvider.m",
"src/EarlGrey/Provider/GREYProvider.h",
"src/EarlGrey/Provider/GREYUIWindowProvider.h",
"src/EarlGrey/Provider/GREYUIWindowProvider.m",
"src/EarlGrey/Synchronization/GREYAppStateTracker.h",
"src/EarlGrey/Synchronization/GREYAppStateTracker.m",
"src/EarlGrey/Synchronization/GREYBeaconImageProtocol.h",
"src/EarlGrey/Synchronization/GREYBeaconImageProtocol.m",
"src/EarlGrey/Synchronization/GREYCondition.h",
"src/EarlGrey/Synchronization/GREYCondition.m",
"src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.h",
"src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.m",
"src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.h",
"src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.m",
"src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.h",
"src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.m",
"src/EarlGrey/Synchronization/GREYSyncAPI.h",
"src/EarlGrey/Synchronization/GREYSyncAPI.m",
"src/EarlGrey/Synchronization/GREYTimedIdlingResource.h",
"src/EarlGrey/Synchronization/GREYTimedIdlingResource.m",
"src/EarlGrey/Synchronization/GREYUIThreadExecutor.h",
"src/EarlGrey/Synchronization/GREYUIThreadExecutor.m",
"src/EarlGrey/Synchronization/GREYUIWebViewIdlingResource.h",
"src/EarlGrey/Synchronization/GREYUIWebViewIdlingResource.m",
]
public_headers = [
"src/EarlGrey/EarlGrey.h",
"src/EarlGrey/Action/GREYAction.h",
"src/EarlGrey/Action/GREYActionBlock.h",
"src/EarlGrey/Action/GREYActions.h",
"src/EarlGrey/Action/GREYBaseAction.h",
"src/EarlGrey/Action/GREYScrollActionError.h",
"src/EarlGrey/AppSupport/GREYIdlingResource.h",
"src/EarlGrey/Assertion/GREYAssertion.h",
"src/EarlGrey/Assertion/GREYAssertionBlock.h",
"src/EarlGrey/Assertion/GREYAssertionDefines.h",
"src/EarlGrey/Assertion/GREYAssertions.h",
"src/EarlGrey/Common/GREYConfiguration.h",
"src/EarlGrey/Common/GREYConstants.h",
"src/EarlGrey/Common/GREYDefines.h",
"src/EarlGrey/Common/GREYElementHierarchy.h",
"src/EarlGrey/Common/GREYScreenshotUtil.h",
"src/EarlGrey/Core/GREYElementFinder.h",
"src/EarlGrey/Core/GREYElementInteraction.h",
"src/EarlGrey/Core/GREYInteraction.h",
"src/EarlGrey/Exception/GREYFailureHandler.h",
"src/EarlGrey/Exception/GREYFrameworkException.h",
"src/EarlGrey/Matcher/GREYAllOf.h",
"src/EarlGrey/Matcher/GREYAnyOf.h",
"src/EarlGrey/Matcher/GREYBaseMatcher.h",
"src/EarlGrey/Matcher/GREYDescription.h",
"src/EarlGrey/Matcher/GREYElementMatcherBlock.h",
"src/EarlGrey/Matcher/GREYLayoutConstraint.h",
"src/EarlGrey/Matcher/GREYMatcher.h",
"src/EarlGrey/Matcher/GREYMatchers.h",
"src/EarlGrey/Matcher/GREYNot.h",
"src/EarlGrey/Provider/GREYDataEnumerator.h",
"src/EarlGrey/Provider/GREYProvider.h",
"src/EarlGrey/Synchronization/GREYNSTimerIdlingResource.h",
"src/EarlGrey/Synchronization/GREYOperationQueueIdlingResource.h",
"src/EarlGrey/Synchronization/GREYDispatchQueueIdlingResource.h",
"src/EarlGrey/Synchronization/GREYSyncAPI.h",
"src/EarlGrey/Synchronization/GREYCondition.h",
"src/EarlGrey/Synchronization/GREYUIThreadExecutor.h",
]
deps = [
"//ios/third_party/fishhook",
"//third_party/google_toolbox_for_mac",
]
public_deps = [
"//ios/third_party/ochamcrest",
]

libs = [
"CoreGraphics.framework",
"Foundation.framework",
"IOKit.framework",
"QuartzCore.framework",
"UIKit.framework",
"XCTest.framework",
]

public_configs = [ ":config" ]
configs += [ "//build/config/compiler:enable_arc" ]
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
}
3 changes: 2 additions & 1 deletion ios/third_party/ochamcrest/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
import("//build/config/ios/rules.gni")

ios_framework_bundle("ochamcrest") {
testonly = true
output_name = "OCHamcrest"

testonly = true
sources = [
"src/Source/Core/HCAssertThat.h",
"src/Source/Core/HCAssertThat.m",
Expand Down

0 comments on commit 22de3c9

Please sign in to comment.