Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e132e9

Browse files
committed
Bazel: add executable attribute to lfs_files
1 parent 1529b58 commit 8e132e9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

misc/bazel/lfs.bzl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def lfs_smudge(repository_ctx, srcs, extract = False, stripPrefix = None):
1+
def lfs_smudge(repository_ctx, srcs, *, extract = False, stripPrefix = None, executable = False):
22
python = repository_ctx.which("python3") or repository_ctx.which("python")
33
if not python:
44
fail("Neither python3 nor python executables found")
@@ -25,15 +25,15 @@ def lfs_smudge(repository_ctx, srcs, extract = False, stripPrefix = None):
2525
repository_ctx.symlink(src, src.basename)
2626
else:
2727
repository_ctx.report_progress("trying cache for remote %s" % src.basename)
28-
res = repository_ctx.download([], src.basename, sha256 = info, allow_fail = True)
28+
res = repository_ctx.download([], src.basename, sha256 = info, allow_fail = True, executable = executable)
2929
if not res.success:
3030
remote.append(src)
3131
if remote:
3232
infos = probe(remote)
3333
for src, info in zip(remote, infos):
3434
sha256, _, url = info.partition(" ")
3535
repository_ctx.report_progress("downloading remote %s" % src.basename)
36-
repository_ctx.download(url, src.basename, sha256 = sha256)
36+
repository_ctx.download(url, src.basename, sha256 = sha256, executable = executable)
3737
if extract:
3838
for src in srcs:
3939
repository_ctx.report_progress("extracting %s" % src.basename)
@@ -62,7 +62,7 @@ def _download_lfs(repository_ctx):
6262
if not dir.is_dir:
6363
fail("`dir` not a directory in @%s" % repository_ctx.name)
6464
srcs = [f for f in dir.readdir() if not f.is_dir]
65-
lfs_smudge(repository_ctx, srcs)
65+
lfs_smudge(repository_ctx, srcs, executable = repository_ctx.attr.executable)
6666

6767
# with bzlmod the name is qualified with `~` separators, and we want the base name here
6868
name = repository_ctx.name.split("~")[-1]
@@ -98,5 +98,6 @@ lfs_files = repository_rule(
9898
"srcs": attr.label_list(doc = "Local paths to the LFS files to export."),
9999
"dir": attr.label(doc = "Local path to a directory containing LFS files to export. Only the direct contents " +
100100
"of the directory are exported"),
101+
"executable": attr.bool(doc = "Whether files should be marked as executable"),
101102
},
102103
)

0 commit comments

Comments
 (0)