Skip to content

Commit 8ae0d4c

Browse files
authored
Merge pull request #285 from rabbitmq/erl_libs_contents-expand_ezs-fix
Fix an issue with erl_libs_contents function expand_ezs option
2 parents 3ee550e + e9356d6 commit 8ae0d4c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

private/escript_archive.bzl

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
load(
2-
"//tools:erlang_toolchain.bzl",
3-
"erlang_dirs",
4-
"maybe_install_erlang",
5-
)
61
load(
72
"//:erlang_app_info.bzl",
83
"ErlangAppInfo",
@@ -12,6 +7,11 @@ load(
127
"//:util.bzl",
138
"path_join",
149
)
10+
load(
11+
"//tools:erlang_toolchain.bzl",
12+
"erlang_dirs",
13+
"maybe_install_erlang",
14+
)
1515
load(
1616
":util.bzl",
1717
"additional_file_dest_relative_path",
@@ -40,34 +40,35 @@ def _impl(ctx):
4040
archive_path = ""
4141
else:
4242
archive_path = path_join(lib_info.app_name, "ebin")
43-
elif ctx.attr.flat:
44-
archive_path = src.basename
4543
else:
46-
archive_path = path_join(lib_info.app_name, "ebin", src.basename)
47-
if archive_path in entries:
48-
fail("Duplicate entry for", archive_path)
44+
if ctx.attr.flat:
45+
archive_path = src.basename
46+
else:
47+
archive_path = path_join(lib_info.app_name, "ebin", src.basename)
48+
if archive_path in entries:
49+
fail("Duplicate entry for %s: '%s'" % (src, archive_path))
4950
entries[archive_path] = src
5051
for src in ([] if ctx.attr.drop_hrl else lib_info.include) + lib_info.priv:
51-
rp = additional_file_dest_relative_path(dep.label, src)
5252
if ctx.attr.flat:
5353
archive_path = src.basename
5454
else:
55+
rp = additional_file_dest_relative_path(dep.label, src)
5556
archive_path = path_join(lib_info.app_name, rp)
5657
if archive_path in entries:
57-
fail("Duplicate entry for", archive_path)
58+
fail("Duplicate entry for %s: '%s'" % (src, archive_path))
5859
entries[archive_path] = src
5960

6061
commands = ["set -euo pipefail"]
6162
for dest, src in entries.items():
6263
full_dest = path_join(contents_dir.path, dest)
6364
commands.append('mkdir -p $(dirname "{}")'.format(full_dest))
6465
if src.is_directory:
65-
commands.append("cp -r {src}/ {dest}".format(
66+
commands.append('mkdir -p "{dest}" && cp -r "{src}"/* "{dest}"'.format(
6667
src = src.path,
6768
dest = full_dest,
6869
))
6970
else:
70-
commands.append("cp {src} {dest}".format(
71+
commands.append('cp "{src}" "{dest}"'.format(
7172
src = src.path,
7273
dest = full_dest,
7374
))

private/util.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def erl_libs_contents(
6565
for src in lib_info.beam:
6666
if src.is_directory:
6767
if len(lib_info.beam) != 1:
68-
fail("ErlangAppInfo.beam must be a collection of files, or a single ebin dir")
68+
fail("ErlangAppInfo.beam must be a collection of files, or a single ebin dir: {} {}".format(lib_info.app_name, lib_info.beam))
6969
dest = ctx.actions.declare_directory(path_join(dep_path, "ebin"))
7070
ctx.actions.run_shell(
7171
inputs = [src],
@@ -89,7 +89,7 @@ def erl_libs_contents(
8989
outputs = [dest],
9090
command = "unzip -q {} -d {}".format(
9191
ez.path,
92-
dest.path,
92+
dest.dirname,
9393
),
9494
mnemonic = "RulesErlangCopyErlLibsExpandEz",
9595
)

0 commit comments

Comments
 (0)