@@ -40,24 +40,29 @@ def lfs_smudge(repository_ctx, srcs, *, extract = False, stripPrefix = None, exe
4040 repository_ctx .extract (src .basename , stripPrefix = stripPrefix )
4141 repository_ctx .delete (src .basename )
4242
43- def _download_and_extract_lfs_archive (repository_ctx ):
43+ def _add_build_file (repository_ctx ):
4444 attr = repository_ctx .attr
45- src = repository_ctx .path (attr .src )
4645 if attr .build_file_content and attr .build_file :
4746 fail ("You should specify only one among build_file_content and build_file for rule @%s" % repository_ctx .name )
48- lfs_smudge (repository_ctx , [src ], extract = True , stripPrefix = attr .strip_prefix )
4947 if attr .build_file_content :
5048 repository_ctx .file ("BUILD.bazel" , attr .build_file_content )
5149 elif attr .build_file :
5250 repository_ctx .symlink (attr .build_file , "BUILD.bazel" )
5351
52+ def _download_and_extract_lfs_archive (repository_ctx ):
53+ attr = repository_ctx .attr
54+ lfs_smudge (repository_ctx , [repository_ctx .path (attr .src )], extract = True , stripPrefix = attr .strip_prefix )
55+ _add_build_file (repository_ctx )
56+
5457def _download_and_extract_lfs_archives (repository_ctx ):
55- lfs_smudge (
56- repository_ctx ,
57- [repository_ctx .path (src ) for src in repository_ctx .attr .srcs ],
58- extract = True ,
59- stripPrefix = repository_ctx .attr .strip_prefix ,
60- )
58+ for src in repository_ctx .attr .srcs :
59+ lfs_smudge (
60+ repository_ctx ,
61+ [repository_ctx .path (src )],
62+ extract = True ,
63+ stripPrefix = repository_ctx .attr .strip_prefix ,
64+ )
65+ _add_build_file (repository_ctx )
6166
6267def _download_lfs (repository_ctx ):
6368 attr = repository_ctx .attr
@@ -110,10 +115,11 @@ lfs_archives = repository_rule(
110115 "in `.lfsconfig`." ,
111116 implementation = _download_and_extract_lfs_archives ,
112117 attrs = {
113- "srcs" : attr .label_list (
114- doc = "Local paths to the LFS archives to extract in order." ,
115- mandatory = True ,
116- ),
118+ "build_file" : attr .label (doc = "The file to use as the BUILD file for this repository. " +
119+ "Either build_file or build_file_content can be specified, but not both." ),
120+ "build_file_content" : attr .string (doc = "The content for the BUILD file for this repository. " +
121+ "Either build_file or build_file_content can be specified, but not both." ),
122+ "srcs" : attr .label_list (doc = "Local paths to the LFS archives to extract in order." , mandatory = True ),
117123 "strip_prefix" : attr .string (default = "" , doc = "A directory prefix to strip from the extracted files." ),
118124 },
119125)
0 commit comments