[llvm-objcopy] Update help messages

This diff updates the help messages for llvm-objcopy, llvm-strip and
llvm-install-name-tool.

Patch by Sameer Arora!

Test plan: make check-all

Differential revision: https://reviews.llvm.org/D81907
This commit is contained in:
Alexander Shaposhnikov 2020-06-24 11:19:31 -07:00
parent af5e61bf4f
commit ca133cdecf
3 changed files with 44 additions and 24 deletions

View File

@ -1,23 +1,22 @@
# RUN: llvm-objcopy -h | FileCheck --check-prefix=OBJCOPY-USAGE %s
# RUN: llvm-objcopy --help | FileCheck --check-prefix=OBJCOPY-USAGE %s
# RUN: not llvm-objcopy 2>&1 | FileCheck --check-prefix=OBJCOPY-USAGE %s
# RUN: llvm-objcopy -h | FileCheck --check-prefix=OBJCOPY-USAGE %s --match-full-lines
# RUN: llvm-objcopy --help | FileCheck --check-prefix=OBJCOPY-USAGE %s --match-full-lines
# RUN: not llvm-objcopy 2>&1 | FileCheck --check-prefix=OBJCOPY-USAGE %s --match-full-lines
# RUN: not llvm-objcopy -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# RUN: not llvm-objcopy --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# RUN: not llvm-objcopy --strip-debug 2>&1 | FileCheck %s --check-prefix=NO-INPUT-FILES
# RUN: llvm-strip -h | FileCheck --check-prefix=STRIP-USAGE %s
# RUN: llvm-strip --help | FileCheck --check-prefix=STRIP-USAGE %s
# RUN: not llvm-strip 2>&1 | FileCheck --check-prefix=STRIP-USAGE %s
# RUN: llvm-strip -h | FileCheck --check-prefix=STRIP-USAGE %s --match-full-lines
# RUN: llvm-strip --help | FileCheck --check-prefix=STRIP-USAGE %s --match-full-lines
# RUN: not llvm-strip 2>&1 | FileCheck --check-prefix=STRIP-USAGE %s --match-full-lines
# RUN: not llvm-strip -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# RUN: not llvm-strip --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# RUN: not llvm-strip --strip-debug 2>&1 | FileCheck %s --check-prefix=NO-INPUT-FILES
# OBJCOPY-USAGE: USAGE: llvm-objcopy [options] input [output]
# OBJCOPY-USAGE: Pass @FILE as argument to read options from FILE.
# OBJCOPY-USAGE: USAGE: llvm-objcopy
# OBJCOPY-USAGE: @FILE
# STRIP-USAGE: USAGE: llvm-strip
# STRIP-USAGE: @FILE
# STRIP-USAGE: USAGE: llvm-strip [options] inputs...
# STRIP-USAGE: Pass @FILE as argument to read options from FILE.
# UNKNOWN-ARG: unknown argument '{{-+}}abcabc'
# NO-INPUT-FILES: no input file specified

View File

@ -1,10 +1,10 @@
# RUN: llvm-install-name-tool -h | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s
# RUN: llvm-install-name-tool --help | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s
# RUN: not llvm-install-name-tool 2>&1 | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s
# RUN: llvm-install-name-tool -h | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s --match-full-lines
# RUN: llvm-install-name-tool --help | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s --match-full-lines
# RUN: not llvm-install-name-tool 2>&1 | FileCheck --check-prefix=INSTALL-NAME-TOOL-USAGE %s --match-full-lines
# RUN: not llvm-install-name-tool -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# RUN: not llvm-install-name-tool --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s
# INSTALL-NAME-TOOL-USAGE: USAGE: llvm-install-name-tool
# INSTALL-NAME-TOOL-USAGE: @FILE
# INSTALL-NAME-TOOL-USAGE: USAGE: llvm-install-name-tool [options] input
# INSTALL-NAME-TOOL-USAGE: Pass @FILE as argument to read options from FILE.
# UNKNOWN-ARG: unknown argument '{{-+}}abcabc'

View File

@ -393,9 +393,30 @@ template <class T> static ErrorOr<T> getAsInteger(StringRef Val) {
return Result;
}
namespace {
enum class ToolType { Objcopy, Strip, InstallNameTool };
} // anonymous namespace
static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS,
StringRef ToolName) {
OptTable.PrintHelp(OS, (ToolName + " input [output]").str().c_str(),
ToolType Tool) {
StringRef HelpText, ToolName;
switch (Tool) {
case ToolType::Objcopy:
ToolName = "llvm-objcopy";
HelpText = " [options] input [output]";
break;
case ToolType::Strip:
ToolName = "llvm-strip";
HelpText = " [options] inputs...";
break;
case ToolType::InstallNameTool:
ToolName = "llvm-install-name-tool";
HelpText = " [options] input";
break;
}
OptTable.PrintHelp(OS, (ToolName + HelpText).str().c_str(),
(ToolName + " tool").str().c_str());
// TODO: Replace this with libOption call once it adds extrahelp support.
// The CommandLine library has a cl::extrahelp class to support this,
@ -416,12 +437,12 @@ parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-objcopy");
printHelp(T, errs(), ToolType::Objcopy);
exit(1);
}
if (InputArgs.hasArg(OBJCOPY_help)) {
printHelp(T, outs(), "llvm-objcopy");
printHelp(T, outs(), ToolType::Objcopy);
exit(0);
}
@ -807,12 +828,12 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-install-name-tool");
printHelp(T, errs(), ToolType::InstallNameTool);
exit(1);
}
if (InputArgs.hasArg(INSTALL_NAME_TOOL_help)) {
printHelp(T, outs(), "llvm-install-name-tool");
printHelp(T, outs(), ToolType::InstallNameTool);
exit(0);
}
@ -870,12 +891,12 @@ parseStripOptions(ArrayRef<const char *> ArgsArr,
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-strip");
printHelp(T, errs(), ToolType::Strip);
exit(1);
}
if (InputArgs.hasArg(STRIP_help)) {
printHelp(T, outs(), "llvm-strip");
printHelp(T, outs(), ToolType::Strip);
exit(0);
}