diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/runtime/commands')
7 files changed, 38 insertions, 34 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java index 1080c4594b..923f89473e 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CleanCommand.java @@ -105,8 +105,8 @@ public final class CleanCommand implements BlazeCommand { env.getReporter().handle(Event.info(null/*location*/, cleanBanner)); try { - String symlinkPrefix = - options.getOptions(BuildRequest.BuildRequestOptions.class).getSymlinkPrefix(); + String symlinkPrefix = options.getOptions(BuildRequest.BuildRequestOptions.class) + .getSymlinkPrefix(env.getRuntime().getProductName()); actuallyClean(env, env.getOutputBase(), cleanOptions, symlinkPrefix); return ExitCode.SUCCESS; } catch (IOException e) { @@ -174,7 +174,8 @@ public final class CleanCommand implements BlazeCommand { } // remove convenience links OutputDirectoryLinksUtils.removeOutputDirectoryLinks( - env.getWorkspaceName(), env.getWorkspace(), env.getReporter(), symlinkPrefix); + env.getWorkspaceName(), env.getWorkspace(), env.getReporter(), symlinkPrefix, + env.getRuntime().getProductName()); // shutdown on expunge cleans if (cleanOptions.expunge || cleanOptions.expunge_async) { throw new ShutdownBlazeServerException(0, ShutdownMethod.EXPUNGE); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java index b18714e695..03adf0570a 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/DumpCommand.java @@ -135,7 +135,8 @@ public class DumpCommand implements BlazeCommand { getClass().getAnnotation(Command.class).name(), getClass().getAnnotation(Command.class).help(), getClass(), - optionList, categories, OptionsParser.HelpVerbosity.LONG)); + optionList, categories, OptionsParser.HelpVerbosity.LONG, + runtime.getProductName())); return ExitCode.ANALYSIS_FAILURE; } PrintStream out = new PrintStream(env.getReporter().getOutErr().getOutputStream()); diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java index 08ef73eae8..8e11e08cde 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/HelpCommand.java @@ -17,7 +17,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.docgen.BlazeRuleHelpPrinter; -import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BlazeVersionInfo; import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider; import com.google.devtools.build.lib.analysis.NoBuildEvent; @@ -88,7 +87,7 @@ public final class HelpCommand implements BlazeCommand { */ private ImmutableMap<String, String> getOptionCategories(BlazeRuntime runtime) { ImmutableMap.Builder<String, String> optionCategoriesBuilder = ImmutableMap.builder(); - String name = Constants.PRODUCT_NAME; + String name = runtime.getProductName(); optionCategoriesBuilder .put("checking", String.format( "Checking options, which control %s's error checking and/or warnings", name)) @@ -141,7 +140,7 @@ public final class HelpCommand implements BlazeCommand { OutErr outErr = env.getReporter().getOutErr(); Options helpOptions = options.getOptions(Options.class); if (options.getResidue().isEmpty()) { - emitBlazeVersionInfo(outErr); + emitBlazeVersionInfo(outErr, runtime.getProductName()); emitGenericHelp(runtime, outErr); return ExitCode.SUCCESS; } @@ -151,12 +150,12 @@ public final class HelpCommand implements BlazeCommand { } String helpSubject = options.getResidue().get(0); if (helpSubject.equals("startup_options")) { - emitBlazeVersionInfo(outErr); + emitBlazeVersionInfo(outErr, runtime.getProductName()); emitStartupOptions(outErr, helpOptions.helpVerbosity, runtime, getOptionCategories(runtime)); return ExitCode.SUCCESS; } else if (helpSubject.equals("target-syntax")) { - emitBlazeVersionInfo(outErr); - emitTargetSyntaxHelp(outErr, getOptionCategories(runtime)); + emitBlazeVersionInfo(outErr, runtime.getProductName()); + emitTargetSyntaxHelp(outErr, getOptionCategories(runtime), runtime.getProductName()); return ExitCode.SUCCESS; } else if (helpSubject.equals("info-keys")) { emitInfoKeysHelp(env, outErr); @@ -180,19 +179,20 @@ public final class HelpCommand implements BlazeCommand { return ExitCode.COMMAND_LINE_ERROR; } } - emitBlazeVersionInfo(outErr); + emitBlazeVersionInfo(outErr, runtime.getProductName()); outErr.printOut(BlazeCommandUtils.getUsage( command.getClass(), getOptionCategories(runtime), helpOptions.helpVerbosity, runtime.getBlazeModules(), - runtime.getRuleClassProvider())); + runtime.getRuleClassProvider(), + runtime.getProductName())); return ExitCode.SUCCESS; } - private void emitBlazeVersionInfo(OutErr outErr) { + private void emitBlazeVersionInfo(OutErr outErr, String productName) { String releaseInfo = BlazeVersionInfo.instance().getReleaseName(); - String line = String.format("[%s %s]", Constants.PRODUCT_NAME, releaseInfo); + String line = String.format("[%s %s]", productName, releaseInfo); outErr.printOut(String.format("%80s\n", line)); } @@ -205,7 +205,8 @@ public final class HelpCommand implements BlazeCommand { getClass(), BlazeCommandUtils.getStartupOptions(runtime.getBlazeModules()), optionCategories, - helpVerbosity)); + helpVerbosity, + runtime.getProductName())); } private void emitCompletionHelp(BlazeRuntime runtime, OutErr outErr) { @@ -218,7 +219,7 @@ public final class HelpCommand implements BlazeCommand { outErr.printOutLn("BAZEL_COMMAND_LIST=\"" + SPACE_JOINER.join(commands) + "\""); outErr.printOutLn("BAZEL_INFO_KEYS=\""); - for (String name : InfoCommand.getHardwiredInfoItemNames(Constants.PRODUCT_NAME)) { + for (String name : InfoCommand.getHardwiredInfoItemNames(runtime.getProductName())) { outErr.printOutLn(name); } outErr.printOutLn("\""); @@ -244,13 +245,15 @@ public final class HelpCommand implements BlazeCommand { } } - private void emitTargetSyntaxHelp(OutErr outErr, ImmutableMap<String, String> optionCategories) { + private void emitTargetSyntaxHelp(OutErr outErr, ImmutableMap<String, String> optionCategories, + String productName) { outErr.printOut(BlazeCommandUtils.expandHelpTopic("target-syntax", "resource:target-syntax.txt", getClass(), ImmutableList.<Class<? extends OptionsBase>>of(), optionCategories, - OptionsParser.HelpVerbosity.MEDIUM)); + OptionsParser.HelpVerbosity.MEDIUM, + productName)); } private void emitInfoKeysHelp(CommandEnvironment env, OutErr outErr) { @@ -263,7 +266,7 @@ public final class HelpCommand implements BlazeCommand { private void emitGenericHelp(BlazeRuntime runtime, OutErr outErr) { outErr.printOut(String.format("Usage: %s <command> <options> ...\n\n", - Constants.PRODUCT_NAME)); + runtime.getProductName())); outErr.printOut("Available commands:\n"); @@ -279,20 +282,20 @@ public final class HelpCommand implements BlazeCommand { } String shortDescription = annotation.shortDescription(). - replace("%{product}", Constants.PRODUCT_NAME); + replace("%{product}", runtime.getProductName()); outErr.printOut(String.format(" %-19s %s\n", name, shortDescription)); } outErr.printOut("\n"); outErr.printOut("Getting more help:\n"); - outErr.printOut(String.format(" %s help <command>\n", Constants.PRODUCT_NAME)); + outErr.printOut(String.format(" %s help <command>\n", runtime.getProductName())); outErr.printOut(" Prints help and options for <command>.\n"); - outErr.printOut(String.format(" %s help startup_options\n", Constants.PRODUCT_NAME)); + outErr.printOut(String.format(" %s help startup_options\n", runtime.getProductName())); outErr.printOut(String.format(" Options for the JVM hosting %s.\n", - Constants.PRODUCT_NAME)); - outErr.printOut(String.format(" %s help target-syntax\n", Constants.PRODUCT_NAME)); + runtime.getProductName())); + outErr.printOut(String.format(" %s help target-syntax\n", runtime.getProductName())); outErr.printOut(" Explains the syntax for specifying targets.\n"); - outErr.printOut(String.format(" %s help info-keys\n", Constants.PRODUCT_NAME)); + outErr.printOut(String.format(" %s help info-keys\n", runtime.getProductName())); outErr.printOut(" Displays a list of keys used by the info command.\n"); } } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java index a2badf3c31..7ba1e2daaf 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java @@ -17,7 +17,6 @@ import com.google.common.base.Supplier; import com.google.common.base.Verify; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.NoBuildEvent; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; @@ -198,7 +197,7 @@ public class InfoCommand implements BlazeCommand { List<InfoItem> hardwiredInfoItems = ImmutableList.<InfoItem>of( new InfoItem.WorkspaceInfoItem(), new InfoItem.InstallBaseInfoItem(), - new InfoItem.OutputBaseInfoItem(), + new InfoItem.OutputBaseInfoItem(productName), new InfoItem.ExecutionRootInfoItem(), new InfoItem.OutputPathInfoItem(), new InfoItem.BlazeBinInfoItem(productName), @@ -242,7 +241,7 @@ public class InfoCommand implements BlazeCommand { result.put(item.getName(), item); } } - result.putAll(getHardwiredInfoItemMap(commandOptions, Constants.PRODUCT_NAME)); + result.putAll(getHardwiredInfoItemMap(commandOptions, env.getRuntime().getProductName())); return result; } } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java index 923f29ce0c..8237317cfb 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java @@ -20,7 +20,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Supplier; import com.google.common.collect.Iterables; -import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BlazeVersionInfo; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.packages.Attribute; @@ -149,9 +148,9 @@ public abstract class InfoItem { * Info item for the output_base directory. */ public static final class OutputBaseInfoItem extends InfoItem { - public OutputBaseInfoItem() { + public OutputBaseInfoItem(String productName) { super("output_base", - "A directory for shared " + Constants.PRODUCT_NAME + "A directory for shared " + productName + " state as well as tool and strategy specific subdirectories.", false); } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java index cf857fd810..9af780e5eb 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java @@ -19,7 +19,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.NoBuildEvent; import com.google.devtools.build.lib.collect.CompactHashSet; import com.google.devtools.build.lib.events.Event; @@ -118,7 +117,7 @@ public final class QueryCommand implements BlazeCommand { } else { env.getReporter().handle(Event.error(String.format( "missing query expression. Type '%s help query' for syntax and help", - Constants.PRODUCT_NAME))); + runtime.getProductName()))); return ExitCode.COMMAND_LINE_ERROR; } diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java index be47fc1a7d..729bace0ef 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java @@ -233,6 +233,7 @@ public class RunCommand implements BlazeCommand { } } + String productName = env.getRuntime().getProductName(); // // We now have a unique executable ready to be run. // @@ -242,7 +243,8 @@ public class RunCommand implements BlazeCommand { PathFragment prettyExecutablePath = OutputDirectoryLinksUtils.getPrettyPath(executablePath, env.getWorkspaceName(), env.getWorkspace(), - options.getOptions(BuildRequestOptions.class).getSymlinkPrefix()); + options.getOptions(BuildRequestOptions.class).getSymlinkPrefix(productName), + productName); List<String> cmdLine = new ArrayList<>(); if (runOptions.scriptPath == null) { PathFragment processWrapperPath = |