Skip to content
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

Genrule mixed module build test #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Empty file.
12 changes: 12 additions & 0 deletions tests/ios/frameworks/genrule-inputs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//rules:app.bzl", "ios_application")

ios_application(
name = "App",
srcs = ["App/main.swift"],
bundle_id = "com.example.app",
minimum_os_version = "10.0",
visibility = ["//visibility:public"],
deps = [
"//tests/ios/frameworks/genrule-inputs/a",
],
)
10 changes: 10 additions & 0 deletions tests/ios/frameworks/genrule-inputs/a/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("//rules:framework.bzl", "apple_framework")

apple_framework(
name = "a",
srcs = glob(["*.swift"]),
infoplists = ["//rules/test_host_app:Info.plist"],
platforms = {"ios": "10.0"},
visibility = ["//visibility:public"],
deps = ["//tests/ios/frameworks/genrule-inputs/b"],
)
5 changes: 5 additions & 0 deletions tests/ios/frameworks/genrule-inputs/a/lib.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import b

struct A {
public static func run() { B.run() }
}
9 changes: 9 additions & 0 deletions tests/ios/frameworks/genrule-inputs/b/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("//rules:framework.bzl", "apple_framework")

apple_framework(
name = "b",
srcs = glob(["*.swift"]),
platforms = {"ios": "10.0"},
visibility = ["//visibility:public"],
deps = ["//tests/ios/frameworks/genrule-inputs/c"],
)
10 changes: 10 additions & 0 deletions tests/ios/frameworks/genrule-inputs/b/lib.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import c

public struct B {
public static func run() {
C.run()
guard LibC != "B" else {
fatalError()
}
}
}
39 changes: 39 additions & 0 deletions tests/ios/frameworks/genrule-inputs/c/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
load("//rules:framework.bzl", "apple_framework")

genrule(
name="lib-src.swift",
cmd = """
cat > $(OUTS) <<-EOF
public struct C {

public static func run() {
print("runs here")
guard LibC == "LibC" else {
fatalError()
}
}
}
EOF
""",
outs = ["lib.swift"]
)

genrule(
name="lib-src.h",
cmd = """
cat > $(OUTS) <<-EOF
@import Foundation;
static NSString *const LibC = @"LibC";
EOF
""",
outs = ["lib-src.h"]
)

apple_framework(
name = "c",
# Note: supplying a hader file, e.g. `lib-src.h` named `:lib-src.h`
# string will cause the umbrella header rule to break.
srcs = [":lib-src.swift", "lib-src.h"],
platforms = {"ios": "10.0"},
visibility = ["//visibility:public"],
)
7 changes: 6 additions & 1 deletion tests/ios/unit-test/test-imports-app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,10 @@ ios_unit_test(
visibility = ["//visibility:public"],
deps = [
":TestImports-App_framework_unlinked",
],
] + select({
# Note: without using apple_framework, it won't set enable_framework_vfs
# imported it won't actually be seen
"@build_bazel_rules_ios//:virtualize_frameworks": [":SomeFramework"],
"//conditions:default": [],
}),
)