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

Add test showcasing issue with directory inputs #921

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions tests/ios/directory-input/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("//tests/ios/directory-input:sources_gen_to_dir.bzl", "sources_gen_to_dir")
load("//rules:framework.bzl", "apple_framework")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

sources_gen_to_dir(
name = "gen_sources.swift",
output_dir = "gen_sources",
)

swift_library(
name = "LibraryFromGeneratedDirectory",
srcs = [":gen_sources.swift"],
)

apple_framework(
name = "FrameworkFromGeneratedDirectory",
srcs = [":gen_sources.swift"],
)
1 change: 1 addition & 0 deletions tests/ios/directory-input/gen_sources/baz.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let bar = "bar"
1 change: 1 addition & 0 deletions tests/ios/directory-input/gen_sources/foo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let foo = "foo"
25 changes: 25 additions & 0 deletions tests/ios/directory-input/sources_gen_to_dir.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Example rule which uses `declare_directory` to declare a directory output fake Swift sources."""

def _sources_gen_to_dir_impl(ctx):
directory = ctx.actions.declare_directory(ctx.attr.output_dir)
args = ctx.actions.args()
args.add(directory.path)

ctx.actions.run_shell(
arguments = [args],
command = """mkdir -p "$1" && echo 'let foo = "foo"' > $1/foo.swift && echo 'let bar = "bar"' > $1/baz.swift""",
inputs = [],
outputs = [directory],
)

return [
DefaultInfo(files = depset([directory])),
]


sources_gen_to_dir = rule(
implementation = _sources_gen_to_dir_impl,
attrs = {
"output_dir": attr.string(),
},
)
Loading