Skip to content

Commit

Permalink
Add test showcasing issue with directory inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Sep 18, 2024
1 parent e74047f commit bbf9e46
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ios/directory-input/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//tests/ios/directory-input:sources_gen_to_dir.bzl", "sources_gen_to_dir")
load("//rules:framework.bzl", "apple_framework")

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

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(),
},
)

0 comments on commit bbf9e46

Please sign in to comment.