aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-03-24 14:17:24 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-03-24 20:06:16 +0000
commitf0e1ef60cad4b24105dfd22576d54e20b91ec5eb (patch)
treed17a1f4377bc655b7766ed643d448e7bfc7ce06b /src/main/java
parent0c8daf89b780c1f559e632d0fd1169fcdeaf20ad (diff)
Add executable argument to repository_ctx.download function.
repository.download function now creates the necessary directories before downloading. Fixes #1069 Fixes #1078 -- MOS_MIGRATED_REVID=118026986
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
index 97f0d5476d..5890996f37 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContext.java
@@ -354,18 +354,40 @@ public class SkylarkRepositoryContext {
+ " omit the SHA-256 as remote files can change. At best omitting this field will make"
+ " your build non-hermetic. It is optional to make development easier but should"
+ " be set before shipping."
+ + "\nexecutable: (optional) set the executable bit to on or off "
+ + "for downloaded file(default to False)."
)
- public void download(String url, Object output, String sha256)
+ public void download(String url, Object output, String sha256, Boolean executable)
throws RepositoryFunctionException, EvalException {
SkylarkPath outputPath = getPath("download()", output);
- checkInOutputDirectory(outputPath);
- HttpDownloader.download(url, sha256, null, outputPath.getPath(), env.getListener());
+ try {
+ checkInOutputDirectory(outputPath);
+ makeDirectories(outputPath.path);
+ HttpDownloader.download(url, sha256, null, outputPath.getPath(), env.getListener());
+ if (executable) {
+ outputPath.path.setExecutable(true);
+ }
+ } catch (IOException e) {
+ throw new RepositoryFunctionException(e, Transience.TRANSIENT);
+ }
+ }
+
+ @SkylarkCallable(name = "download", documented = false)
+ public void download(String url, Object output, String sha256)
+ throws RepositoryFunctionException, EvalException {
+ download(url, output, sha256, false);
+ }
+
+ @SkylarkCallable(name = "download", documented = false)
+ public void download(String url, Object output, Boolean executable)
+ throws RepositoryFunctionException, EvalException {
+ download(url, output, "", executable);
}
@SkylarkCallable(name = "download", documented = false)
public void download(String url, Object output)
throws RepositoryFunctionException, EvalException {
- download(url, output, "");
+ download(url, output, "", false);
}
@SkylarkCallable(