dist: Also support declared directories.
When a target's default outputs include a declared directory
via ctx.actions.declare_directory, copy everything inside that
declared directory. Don't ignore directories.
The directory structure inside the declared directory is kept,
regardless of the --flat option. This is because the directory
itself is treated as an output, not its contents.
Test: bazel run //common:kernel_aarch64_abi_dist
Change-Id: Ib6bbd135cfb62be4df84b915bd2266b950e8f731
diff --git a/dist/dist.py b/dist/dist.py
index b124e11..028105d 100644
--- a/dist/dist.py
+++ b/dist/dist.py
@@ -58,20 +58,21 @@
archive_prefix):
for src in files:
- if not os.path.isfile(src):
- continue
-
src_relpath = os.path.basename(src) if flat else src
src_relpath = os.path.join(prefix, src_relpath)
src_abspath = os.path.abspath(src)
dst = os.path.join(dist_dir, src_relpath)
- dst_dirname = os.path.dirname(dst)
- print("[dist] Copying file: %s" % dst)
- if not os.path.exists(dst_dirname):
- os.makedirs(dst_dirname)
+ if os.path.isfile(src):
+ dst_dirname = os.path.dirname(dst)
+ print("[dist] Copying file: %s" % dst)
+ if not os.path.exists(dst_dirname):
+ os.makedirs(dst_dirname)
- shutil.copyfile(src_abspath, dst, follow_symlinks=True)
+ shutil.copyfile(src_abspath, dst, follow_symlinks=True)
+ elif os.path.isdir(src):
+ print("[dist] Copying dir: %s" % dst)
+ shutil.copytree(src_abspath, dst)
for archive in archives:
try: