diff --git a/llvm/docs/CommandGuide/index.rst b/llvm/docs/CommandGuide/index.rst --- a/llvm/docs/CommandGuide/index.rst +++ b/llvm/docs/CommandGuide/index.rst @@ -19,6 +19,7 @@ opt llc lli + llvm-libtool-darwin llvm-link llvm-lib llvm-lipo diff --git a/llvm/docs/CommandGuide/llvm-libtool-darwin.rst b/llvm/docs/CommandGuide/llvm-libtool-darwin.rst new file mode 100644 --- /dev/null +++ b/llvm/docs/CommandGuide/llvm-libtool-darwin.rst @@ -0,0 +1,45 @@ +llvm-libtool-darwin - LLVM tool for creating libraries for Darwin +================================================================= + +.. program:: llvm-libtool-darwin + +SYNOPSIS +-------- + +:program:`llvm-libtool-darwin` [*options*] ** + +DESCRIPTION +----------- + +:program:`llvm-libtool-darwin` is a tool for creating static and dynamic +libraries for Darwin. + +For most scenarios, it works as a drop-in replacement for cctool's +:program:`libtool`. + +OPTIONS +-------- +:program:`llvm-libtool-darwin` supports the following options: + +.. option:: -help, -h + + Display usage information and exit. + +.. option:: -version + + Display the version of this program. + +.. option:: -o filename + + Specify the output file name. Must be specified exactly once. + +EXIT STATUS +----------- + +:program:`llvm-libtool-darwin` exits with a non-zero exit code if there is an error. +Otherwise, it exits with code 0. + +BUGS +---- + +To report bugs, please visit . diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -82,6 +82,7 @@ llvm-install-name-tool llvm-jitlink llvm-lib + llvm-libtool-darwin llvm-link llvm-lipo llvm-locstats diff --git a/llvm/test/tools/llvm-libtool-darwin/help-message.test b/llvm/test/tools/llvm-libtool-darwin/help-message.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-libtool-darwin/help-message.test @@ -0,0 +1,10 @@ +## This test checks that the help message is displayed correctly. + +# RUN: llvm-libtool-darwin -h | FileCheck --check-prefix=LIBTOOL-USAGE %s --match-full-lines +# RUN: llvm-libtool-darwin --help | FileCheck --check-prefix=LIBTOOL-USAGE %s --match-full-lines +# RUN: not llvm-libtool-darwin -abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s +# RUN: not llvm-libtool-darwin --abcabc 2>&1 | FileCheck --check-prefix=UNKNOWN-ARG %s + +# LIBTOOL-USAGE: USAGE: llvm-libtool-darwin{{(\.exe)?}} [options] + +# UNKNOWN-ARG: Unknown command line argument '{{-+}}abcabc' diff --git a/llvm/test/tools/llvm-libtool-darwin/invalid-arguments.test b/llvm/test/tools/llvm-libtool-darwin/invalid-arguments.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-libtool-darwin/invalid-arguments.test @@ -0,0 +1,25 @@ +## This test checks that an error is thrown in case of invalid argument(s). + +## Missing input file: +# RUN: not llvm-libtool-darwin -o libOut.a 2>&1 | \ +# RUN: FileCheck %s --check-prefix=NO-INPUT + +# NO-INPUT: Must specify at least 1 positional argument + +## Missing output file: +# RUN: not llvm-libtool-darwin %t 2>&1 | \ +# RUN: FileCheck %s --check-prefix=NO-OUTPUT + +# NO-OUTPUT: for the --output option: must be specified at least once! + +## Missing argument to -o: +# RUN: not llvm-libtool-darwin %t -o 2>&1 | \ +# RUN: FileCheck %s --check-prefix=MISSING + +# MISSING: for the -o option: requires a value! + +## Passing in two output files: +# RUN: not llvm-libtool-darwin %t -o Output1 -o Output2 2>&1 | \ +# RUN: FileCheck %s --check-prefix=DOUBLE-OUTPUT + +# DOUBLE-OUTPUT: for the --output option: must occur exactly one time! diff --git a/llvm/tools/llvm-libtool-darwin/CMakeLists.txt b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/llvm/tools/llvm-libtool-darwin/CMakeLists.txt @@ -0,0 +1,7 @@ +set(LLVM_LINK_COMPONENTS + Support + ) + +add_llvm_tool(llvm-libtool-darwin + llvm-libtool-darwin.cpp +) diff --git a/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt b/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt new file mode 100644 --- /dev/null +++ b/llvm/tools/llvm-libtool-darwin/LLVMBuild.txt @@ -0,0 +1,20 @@ +;===- ./tools/llvm-libtool-darwin/LVMBuild.txt -----------------*- Conf -*--===; +; +; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +; See https://llvm.org/LICENSE.txt for license information. +; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; +[component_0] +type = Tool +name = llvm-libtool-darwin +parent = Tools +required_libraries = Support diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp new file mode 100644 --- /dev/null +++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp @@ -0,0 +1,33 @@ +//===-- llvm-libtool-darwin.cpp - a tool for creating libraries -----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A utility for creating static and dynamic libraries for Darwin. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/InitLLVM.h" + +using namespace llvm; + +static cl::opt OutputFile("output", + cl::desc("Specify output filename"), + cl::value_desc("filename"), + cl::Required); +static cl::alias OutputFileShort("o", cl::desc("Alias for -output"), + cl::aliasopt(OutputFile)); + +static cl::list + InputFiles(cl::Positional, cl::desc(""), cl::OneOrMore); + +int main(int Argc, char **Argv) { + InitLLVM X(Argc, Argv); + cl::ParseCommandLineOptions(Argc, Argv, "llvm-libtool\n"); + + return EXIT_SUCCESS; +}