Commit ca133cde authored by Alexander Shaposhnikov's avatar Alexander Shaposhnikov
Browse files

[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
parent af5e61bf
# RUN: llvm-objcopy -h | 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 # 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 # 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 --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: 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 -h | FileCheck --check-prefix=STRIP-USAGE %s --match-full-lines
# RUN: llvm-strip --help | FileCheck --check-prefix=STRIP-USAGE %s # 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 # 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 --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 # 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 # STRIP-USAGE: USAGE: llvm-strip [options] inputs...
# OBJCOPY-USAGE: @FILE # STRIP-USAGE: Pass @FILE as argument to read options from FILE.
# STRIP-USAGE: USAGE: llvm-strip
# STRIP-USAGE: @FILE
# UNKNOWN-ARG: unknown argument '{{-+}}abcabc' # UNKNOWN-ARG: unknown argument '{{-+}}abcabc'
# NO-INPUT-FILES: no input file specified # NO-INPUT-FILES: no input file specified
# RUN: llvm-install-name-tool -h | 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 # 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 # 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
# 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: USAGE: llvm-install-name-tool [options] input
# INSTALL-NAME-TOOL-USAGE: @FILE # INSTALL-NAME-TOOL-USAGE: Pass @FILE as argument to read options from FILE.
# UNKNOWN-ARG: unknown argument '{{-+}}abcabc' # UNKNOWN-ARG: unknown argument '{{-+}}abcabc'
...@@ -393,9 +393,30 @@ template <class T> static ErrorOr<T> getAsInteger(StringRef Val) { ...@@ -393,9 +393,30 @@ template <class T> static ErrorOr<T> getAsInteger(StringRef Val) {
return Result; return Result;
} }
namespace {
enum class ToolType { Objcopy, Strip, InstallNameTool };
} // anonymous namespace
static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS, static void printHelp(const opt::OptTable &OptTable, raw_ostream &OS,
StringRef ToolName) { ToolType Tool) {
OptTable.PrintHelp(OS, (ToolName + " input [output]").str().c_str(), 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()); (ToolName + " tool").str().c_str());
// TODO: Replace this with libOption call once it adds extrahelp support. // TODO: Replace this with libOption call once it adds extrahelp support.
// The CommandLine library has a cl::extrahelp class to support this, // The CommandLine library has a cl::extrahelp class to support this,
...@@ -416,12 +437,12 @@ parseObjcopyOptions(ArrayRef<const char *> ArgsArr, ...@@ -416,12 +437,12 @@ parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) { if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-objcopy"); printHelp(T, errs(), ToolType::Objcopy);
exit(1); exit(1);
} }
if (InputArgs.hasArg(OBJCOPY_help)) { if (InputArgs.hasArg(OBJCOPY_help)) {
printHelp(T, outs(), "llvm-objcopy"); printHelp(T, outs(), ToolType::Objcopy);
exit(0); exit(0);
} }
...@@ -807,12 +828,12 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) { ...@@ -807,12 +828,12 @@ parseInstallNameToolOptions(ArrayRef<const char *> ArgsArr) {
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) { if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-install-name-tool"); printHelp(T, errs(), ToolType::InstallNameTool);
exit(1); exit(1);
} }
if (InputArgs.hasArg(INSTALL_NAME_TOOL_help)) { if (InputArgs.hasArg(INSTALL_NAME_TOOL_help)) {
printHelp(T, outs(), "llvm-install-name-tool"); printHelp(T, outs(), ToolType::InstallNameTool);
exit(0); exit(0);
} }
...@@ -870,12 +891,12 @@ parseStripOptions(ArrayRef<const char *> ArgsArr, ...@@ -870,12 +891,12 @@ parseStripOptions(ArrayRef<const char *> ArgsArr,
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount); T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) { if (InputArgs.size() == 0) {
printHelp(T, errs(), "llvm-strip"); printHelp(T, errs(), ToolType::Strip);
exit(1); exit(1);
} }
if (InputArgs.hasArg(STRIP_help)) { if (InputArgs.hasArg(STRIP_help)) {
printHelp(T, outs(), "llvm-strip"); printHelp(T, outs(), ToolType::Strip);
exit(0); exit(0);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment