Skip to content

Commit 46844cc

Browse files
authored
Merge pull request #2 from Ryang20718/user/ryang/add_patch_cmds
[feat] add patch cmds post patch
2 parents fd07a1b + ec848aa commit 46844cc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cloud_archive.bzl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def cloud_archive_download(
7575
strip_prefix = "",
7676
build_file = "",
7777
build_file_contents = "",
78-
profile = ""):
78+
profile = "",
79+
patch_cmds = []):
7980
""" Securely downloads and unpacks an archive from Minio, then places a
8081
BUILD file inside. """
8182
filename = repo_ctx.path(file_path).basename
@@ -148,6 +149,11 @@ def cloud_archive_download(
148149
if result.return_code != 0:
149150
fail("Patch {} failed to apply.".format(patch))
150151

152+
# apply patch_cmds one by one after all patches have been applied
153+
bash_path = repo_ctx.os.environ.get("BAZEL_SH", "bash")
154+
for cmd in patch_cmds:
155+
repo_ctx.execute([bash_path, "-c", cmd])
156+
151157
def _cloud_archive_impl(ctx):
152158
cloud_archive_download(
153159
ctx,
@@ -156,6 +162,7 @@ def _cloud_archive_impl(ctx):
156162
provider = ctx.attr._provider,
157163
patches = ctx.attr.patches,
158164
patch_args = ctx.attr.patch_args,
165+
patch_cmds = ctx.attr.patch_cmds,
159166
strip_prefix = ctx.attr.strip_prefix,
160167
build_file = ctx.attr.build_file,
161168
build_file_contents = ctx.attr.build_file_contents,
@@ -178,6 +185,7 @@ minio_archive = repository_rule(
178185
"build_file_contents": attr.string(doc = "The contents of the build file for the target"),
179186
"patches": attr.label_list(doc = "Patches to apply, if any.", allow_files = True),
180187
"patch_args": attr.string_list(doc = "Arguments to use when applying patches."),
188+
"patch_cmds": attr.string_list(doc = "Sequence of Bash commands to be applied after patches are applied."),
181189
"strip_prefix": attr.string(doc = "Prefix to strip when archive is unpacked"),
182190
"_provider": attr.string(default = "minio"),
183191
},
@@ -200,6 +208,7 @@ s3_archive = repository_rule(
200208
"build_file_contents": attr.string(doc = "The contents of the build file for the target"),
201209
"patches": attr.label_list(doc = "Patches to apply, if any.", allow_files = True),
202210
"patch_args": attr.string_list(doc = "Arguments to use when applying patches."),
211+
"patch_cmds": attr.string_list(doc = "Sequence of Bash commands to be applied after patches are applied."),
203212
"strip_prefix": attr.string(doc = "Prefix to strip when archive is unpacked"),
204213
"_provider": attr.string(default = "s3"),
205214
},
@@ -221,6 +230,7 @@ gs_archive = repository_rule(
221230
"build_file_contents": attr.string(doc = "The contents of the build file for the target"),
222231
"patches": attr.label_list(doc = "Patches to apply, if any.", allow_files = True),
223232
"patch_args": attr.string_list(doc = "Arguments to use when applying patches."),
233+
"patch_cmds": attr.string_list(doc = "Sequence of Bash commands to be applied after patches are applied."),
224234
"strip_prefix": attr.string(doc = "Prefix to strip when archive is unpacked"),
225235
"_provider": attr.string(default = "google"),
226236
},
@@ -242,6 +252,7 @@ b2_archive = repository_rule(
242252
"build_file_contents": attr.string(doc = "The contents of the build file for the target"),
243253
"patches": attr.label_list(doc = "Patches to apply, if any.", allow_files = True),
244254
"patch_args": attr.string_list(doc = "Arguments to use when applying patches."),
255+
"patch_cmds": attr.string_list(doc = "Sequence of Bash commands to be applied after patches are applied."),
245256
"strip_prefix": attr.string(doc = "Prefix to strip when archive is unpacked"),
246257
"_provider": attr.string(default = "backblaze"),
247258
},

0 commit comments

Comments
 (0)