-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ios_bundle rule #1085
Add ios_bundle rule #1085
Conversation
0d0c1c3
to
ee48f80
Compare
"custom_bundles": """ | ||
A dict of depsets of zipped archives of bundles that need to be expanded into | ||
custom locations of the packaging bundle, where the key is the path to the | ||
custom location.""", |
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.
This is needed to support the EarlGray use case where the bundle needs to be placed at a custom location within the packaging bundle.
I'll fix the build errors soon |
@erikkerber Can you provide the BUILD file for EarlGrey? And an example one for a loadable bundle? I know we had a lot of trouble getting it to work correctly. |
The IPC bundle: load("@build_bazel_rules_apple//apple:ios.bzl", "ios_bundle")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("//bazel/rules:constants.bzl", "DEVICE_FAMILIES", "MIN_IOS_VERSION", "TEAM_ID")
load("//bazel/rules:provisioning_profiles.bzl", "provisioning_profile")
ios_bundle(
name = "Bundle",
bundle_id = "com.target.Target.EarlGreyIPCBundle",
bundle_location = "EarlGreyHelperBundles",
bundle_name = "FlagshipEarlGreyIPCBundle",
families = DEVICE_FAMILIES,
frameworks = ["//src/Apps/Shared/EarlGrey:IPCFramework"],
infoplists = ["Info.plist"],
minimum_os_version = MIN_IOS_VERSION,
provisioning_profile = provisioning_profile(
"Bundle",
{
"//:dev_signed": "Test App Wildcard Development",
"//conditions:default": None,
},
bundle_id = "com.target.Target.EarlGreyIPCBundle",
team_id = TEAM_ID,
),
version = "//src/Apps/Flagship:Version",
visibility = ["//src/Apps/Flagship:__pkg__"],
deps = [":Bundle.__tgt__.library"],
)
swift_library(
name = "Bundle.__tgt__.library",
srcs = glob(["Implementations/**/*.swift"]),
module_name = "FlagshipEarlGreyIPC",
deps = [
":Interfaces",
"@com_github_alisoftware_ohhttpstubs//:OHHTTPStubs",
"@com_github_alisoftware_ohhttpstubs//:OHHTTPStubsSwift",
"@com_github_google_earlgrey//:EarlGreyIPC",
],
)
swift_library(
name = "Interfaces",
srcs = glob(["Interfaces/**/*.swift"]),
module_name = "FlagshipEarlGreyIPCInterfaces",
# TODO: Limit visibility to UI tests
visibility = ["//visibility:public"],
) EarlGrey: load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")
# This is the framework that IPC bundles will link against.
# It mirrors the framework that is bundled in the app under test, but has `bundle_only = False`.
ios_framework(
name = "IPCFramework",
bundle_id = "com.google.earlgrey.AppFramework",
bundle_name = "AppFramework",
families = [
"iphone",
"ipad",
],
infoplists = ["@com_github_google_earlgrey//:AppFramework/Info.plist"],
minimum_os_version = "10.0",
# TODO: This should be limited to IPC bundles only
visibility = ["//visibility:public"],
deps = ["@com_github_google_earlgrey//:EarlGreyIPC"],
) |
EarlGrey itself: load("@build_bazel_rules_apple//apple:ios.bzl", "ios_framework")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load("@rules_cc//cc:defs.bzl", "objc_library")
# This project is super sloppy, they allow includes from all of the libraries
ALL_INCLUDES = [
"AppFramework/Action",
"AppFramework/Additions",
"AppFramework/Assertion",
"AppFramework/AutomationSetup",
"AppFramework/Config",
"AppFramework/Core",
"AppFramework/Delegate",
"AppFramework/DistantObject",
"AppFramework/EarlGreyApp",
"AppFramework/Error",
"AppFramework/Event",
"AppFramework/IdlingResources",
"AppFramework/Keyboard",
"AppFramework/Matcher",
"AppFramework/Synchronization",
"CommonLib/",
"CommonLib/Additions",
"CommonLib/Assertion",
"CommonLib/Config",
"CommonLib/DistantObject",
"CommonLib/Error",
"CommonLib/Event",
"CommonLib/Exceptions",
"CommonLib/Matcher",
"CommonLib/Provider",
"TestLib/AlertHandling",
"TestLib/AppleInternals",
"TestLib/Assertion",
"TestLib/Condition",
"TestLib/Config",
"TestLib/DistantObject",
"TestLib/EarlGreyImpl",
"TestLib/Exception",
"TestLib/Execution",
"TestLib/XCTestCase",
"UILib",
"UILib/Additions",
"UILib/Provider",
"UILib/Traversal",
"UILib/Visibility",
]
APPFRAMEWORK_SRCS = glob(["AppFramework/**/*.m"])
COMMONLIB_SRCS = glob(["CommonLib/**/*.m"])
TESTLIB_SRCS = glob(["TestLib/**/*.m"]) + [
"AppFramework/Action/GREYActionsShorthand.m",
"AppFramework/Matcher/GREYMatchersShorthand.m",
]
UILIB_SRCS = glob(["UILib/**/*.m"])
objc_library(
name = "TestLib",
copts = ["-DSLOPPY_IMPORTS"],
module_name = "TestLib",
includes = ALL_INCLUDES,
hdrs = glob([
"AppFramework/**/*.h",
"CommonLib/**/*.h",
"TestLib/**/*.h",
"UILib/**/*.h",
], exclude = ["TestLib/Swift/*.h"]),
srcs = TESTLIB_SRCS + COMMONLIB_SRCS,
deps = [
"@com_github_google_edistantobject//:eDistantObject",
],
)
# This is the target that will actually be imported into our UI test targets
genrule(
name = "Imports",
outs = ["Imports.swift"],
cmd = """cat <<-END > $@
@_exported import TestLib
END
"""
)
swift_library(
name = "EarlGrey",
srcs = glob(["TestLib/Swift/**/*.swift"]) + [":Imports"],
visibility = ["//visibility:public"],
deps = [
":TestLib",
],
)
# This target will get linked into our loadable IPC bundles, via a `AppFramework`
objc_library(
name = "EarlGreyIPC",
copts = ["-DSLOPPY_IMPORTS"],
hdrs = glob([
"AppFramework/**/*.h",
"CommonLib/**/*.h",
"UILib/**/*.h",
]),
includes = ALL_INCLUDES,
srcs = APPFRAMEWORK_SRCS + COMMONLIB_SRCS + UILIB_SRCS,
module_name = "EarlGreyIPC",
sdk_frameworks = [
"CoreData",
"CoreGraphics",
"IOKit",
"QuartzCore",
"WebKit",
],
visibility = ["//visibility:public"],
deps = [
"@com_github_facebook_fishhook//:fishhook",
"@com_github_google_edistantobject//:eDistantObject",
],
)
# This target will get bundle into the app, only under test
ios_framework(
name = "AppFramework",
bundle_id = "com.google.earlgrey.AppFramework",
bundle_only = True,
families = ["iphone", "ipad"],
infoplists = ["AppFramework/Info.plist"],
minimum_os_version = "10.0",
visibility = ["//visibility:public"],
deps = [":EarlGreyIPC"],
)
# This needs to be public, to allow building the loadable bundle's AppFramework.framework
# (which is done outside of this repo, because of )
exports_files(["AppFramework/Info.plist"]) |
@ajanuar Hopefully the above will set you in the right direction. I'll try to fix this PR soon, just been bogged down. |
thanks @erikkerber ! one more question, how to use |
|
Yes. In your ios_application(
...
bundles = select({
"//:dbg": ["//src/EarlGreyIPC:Bundle"],
"//conditions:default": [],
})
...
} And like Brentley said, |
Thanks! Will try today. |
ee48f80
to
a45e3f6
Compare
a45e3f6
to
543d057
Compare
Build is green. For this to get over the finish line it needs some tests. @erikkerber (or a delegate) or @ajanuar, could either of you contribute some? |
I can run our EarlGreyTest now, thanks all. And yes, I can help to add some tests. |
Hello guys, I have case that need to create if I do this, when I run EarlGreyTests ( Is there any way to avoid this?
Note: Example in BUCK
|
Can you show an error? We never had duplicate symbol errors. |
An example:
It lists all public headers from Y & Z. Is it because objc_library's output a fully linked static library? |
I wouldn't expect something called |
Hi @erikkerber @brentleyjones I just want to clarify what @ajanuar meant. Maybe this is different case by case (or maybe OOT, tied to specific earlgrey 2 usage). In earlgrey, the helper bundle act as an extension of From what I learn from the docs, Thus, there will be 2 duplicate symbol in the Does it mean that we have to split shared header between |
We didn't have something like This rule could be fixed to include the |
Noted on that. I understand better on how to use it. Thank you by the way! |
Is the idea to add new parameter to rules_apple/apple/internal/testing/apple_test_rule_support.bzl Lines 149 to 150 in d49933a
|
|
Hi @brentleyjones , let me clarify my understanding, these rules below are in circular dependencies.
Assume we can use the
I am available to help if you can guide me steps to enable this. thanks! |
Yes, that is the correct understanding. |
Hi @brentleyjones , sharing a little update. we've successfully built ios bundle with workaround for our EarlGrey test case. This won't be ideal, but it runs perfectly for us.
I also create PR to add test #1108, not sure these tests are sufficient. Thanks! |
Hi guys, may i know is there any chance to merge this PR into master branch? |
If anyone wants an |
Note: I haven't tested this rebase of 558ea6a. I'm just placing this here as a request in #1081.
Resolves #1081.