diff options
author | 2017-06-14 15:32:41 +0200 | |
---|---|---|
committer | 2017-06-14 16:21:03 +0200 | |
commit | ba69b39468954ed382dc50bc3fc22a1446c5f9d8 (patch) | |
tree | f4fcd89bc689644af3ef7e6d644324471861bb71 /src/main/java/com/google/devtools/build | |
parent | 66c7f75a9abb254b3d204468a8cf58ccfd4d8669 (diff) |
Introduce --incompatible_load_argument_is_label (1st argument of load must be a label).
RELNOTES:
First argument of 'load' should be a label. Path syntax is deprecated
(label should start with '//' or ':').
PiperOrigin-RevId: 158971314
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java | 10 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java index e13074c0c5..fb30f03c0e 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java @@ -60,6 +60,16 @@ public final class LoadStatement extends Statement { @Override void doExec(Environment env) throws EvalException, InterruptedException { + if (env.getSemantics().incompatibleLoadArgumentIsLabel) { + String s = imp.getValue(); + if (!s.startsWith("//") && !s.startsWith(":")) { + throw new EvalException( + getLocation(), + "First argument of 'load' must be a label and start with either '//' or ':'. " + + "Use --incompatibleLoadArgumentIsLabel to temporarily disable this check."); + } + } + for (Map.Entry<Identifier, String> entry : symbolMap.entrySet()) { try { Identifier name = entry.getKey(); diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java index 3fd24c45fd..9f92cf978d 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemanticsOptions.java @@ -88,6 +88,16 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable public boolean incompatibleBzlDisallowLoadAfterStatement; @Option( + name = "incompatible_load_argument_is_label", + defaultValue = "false", + category = "incompatible changes", + help = + "If set to true, the first argument of 'load' statements is a label (not a path). " + + "It must start with '//' or ':'." + ) + public boolean incompatibleLoadArgumentIsLabel; + + @Option( name = "incompatible_disallow_toplevel_if_statement", defaultValue = "false", category = "incompatible changes", |