Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dgp1130 committed Feb 10, 2023
1 parent fe1dc9c commit 33e3ed9
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 1 deletion.
Empty file.
1 change: 1 addition & 0 deletions e2e/external_copy_to_directory/.bazelversion
7 changes: 7 additions & 0 deletions e2e/external_copy_to_directory/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load(":directory.bzl", "directory")

directory(
name = "dir",
srcs = ["foo.txt"],
visibility = ["//visibility:public"],
)
10 changes: 10 additions & 0 deletions e2e/external_copy_to_directory/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
workspace(name = "external_copy_to_directory")

local_repository(
name = "aspect_bazel_lib",
path = "../..",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

aspect_bazel_lib_dependencies()
30 changes: 30 additions & 0 deletions e2e/external_copy_to_directory/directory.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory_bin_action")

def _directory_impl(ctx):
dst = ctx.actions.declare_directory(ctx.attr.name)

copy_to_directory_bin_action(
ctx,
name = ctx.attr.name,
copy_to_directory_bin = ctx.toolchains["@aspect_bazel_lib//lib:copy_to_directory_toolchain_type"].copy_to_directory_info.bin,
dst = dst,
files = ctx.files.srcs,
verbose = True,
include_external_repositories = ["external_copy_to_directory"],
)

return DefaultInfo(
files = depset([dst]),
runfiles = ctx.runfiles([dst]),
)

directory = rule(
implementation = _directory_impl,
attrs = {
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
},
toolchains = ["@aspect_bazel_lib//lib:copy_to_directory_toolchain_type"],
)
1 change: 1 addition & 0 deletions e2e/external_copy_to_directory/foo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
Empty file.
1 change: 1 addition & 0 deletions e2e/external_copy_to_directory/workspace/.bazelversion
6 changes: 6 additions & 0 deletions e2e/external_copy_to_directory/workspace/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sh_test(
name = "test",
srcs = ["test.sh"],
data = ["@external_copy_to_directory//:dir"],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
12 changes: 12 additions & 0 deletions e2e/external_copy_to_directory/workspace/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local_repository(
name = "external_copy_to_directory",
path = "..",
)
local_repository(
name = "aspect_bazel_lib",
path = "../../..",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")

aspect_bazel_lib_dependencies()
12 changes: 12 additions & 0 deletions e2e/external_copy_to_directory/workspace/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---

ls "$(rlocation external_copy_to_directory/dir/)"
2 changes: 1 addition & 1 deletion lib/private/copy_to_directory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def copy_to_directory_bin_action(
inputs = file_inputs + [config_file],
outputs = [dst],
executable = copy_to_directory_bin,
arguments = [config_file.path],
arguments = [config_file.path, ctx.workspace_name],
mnemonic = "CopyToDirectory",
progress_message = "Copying files to directory %s" % _progress_path(dst),
execution_requirements = _COPY_EXECUTION_REQUIREMENTS,
Expand Down

0 comments on commit 33e3ed9

Please sign in to comment.