diff --git a/tests/ios/directory-input/BUILD.bazel b/tests/ios/directory-input/BUILD.bazel new file mode 100644 index 00000000..2f536bda --- /dev/null +++ b/tests/ios/directory-input/BUILD.bazel @@ -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"], +) diff --git a/tests/ios/directory-input/gen_sources/baz.swift b/tests/ios/directory-input/gen_sources/baz.swift new file mode 100644 index 00000000..b007b079 --- /dev/null +++ b/tests/ios/directory-input/gen_sources/baz.swift @@ -0,0 +1 @@ +let bar = "bar" diff --git a/tests/ios/directory-input/gen_sources/foo.swift b/tests/ios/directory-input/gen_sources/foo.swift new file mode 100644 index 00000000..74e839c5 --- /dev/null +++ b/tests/ios/directory-input/gen_sources/foo.swift @@ -0,0 +1 @@ +let foo = "foo" diff --git a/tests/ios/directory-input/sources_gen_to_dir.bzl b/tests/ios/directory-input/sources_gen_to_dir.bzl new file mode 100644 index 00000000..318a7709 --- /dev/null +++ b/tests/ios/directory-input/sources_gen_to_dir.bzl @@ -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(), + }, +)