diff options
author | 2018-03-20 08:23:10 -0700 | |
---|---|---|
committer | 2018-03-20 08:24:33 -0700 | |
commit | f87a656610413ffbc4ef44cb89081c9a111b4827 (patch) | |
tree | 72dc9b5e172eb25b11df9993dd25b1d28843ec96 /src/main/java/com/google/devtools | |
parent | 3c5373c50c7c492842f8a468906eda2c0bc90787 (diff) |
Allow path options to use user specific paths
Fixes #2054.
Allow users to be able to specify user specific paths. With this option
we can now commit bazel configuration file and force local action cache
activation per default:
$ cat tools/bazel.rc
build --experimental_local_disk_cache_path=~/.gerrit/bazel-cache/cas
build --experimental_local_disk_cache
build --experimental_strict_action_env
Test Plan:
$ bazel test //src/test/java/com/google/devtools/build/lib:util_test
Closes #4852.
PiperOrigin-RevId: 189744599
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java index c94863ed86..029d08c8c1 100644 --- a/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java +++ b/src/main/java/com/google/devtools/build/lib/util/OptionsUtils.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.util; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Converter; @@ -103,7 +104,11 @@ public final class OptionsUtils { @Override public PathFragment convert(String input) { - return PathFragment.create(input); + String path = Preconditions.checkNotNull(input); + if (!path.isEmpty() && path.startsWith("~/")) { + path = path.replace("~", System.getProperty("user.home")); + } + return PathFragment.create(path); } @Override @@ -123,6 +128,9 @@ public final class OptionsUtils { List<PathFragment> list = new ArrayList<>(); for (String piece : input.split(":")) { if (!piece.isEmpty()) { + if (piece.startsWith("~/")) { + piece = piece.replace("~", System.getProperty("user.home")); + } list.add(PathFragment.create(piece)); } } |