aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2022-09-20 15:37:49 -0700
committerKeith Smiley <keithbsmiley@gmail.com>2022-10-03 09:53:02 -0700
commit10f22335f3b7c7b78b54ee6b995f6ed97e4c225d (patch)
tree7f84697e889298af04394befbddf4303a6d1a049 /llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
parente8c10fc1811f2cf7e9a2b4921d9a065ee6384588 (diff)
downloadllvm-10f22335f3b7c7b78b54ee6b995f6ed97e4c225d.zip
llvm-10f22335f3b7c7b78b54ee6b995f6ed97e4c225d.tar.gz
llvm-10f22335f3b7c7b78b54ee6b995f6ed97e4c225d.tar.bz2
[llvm-libtool-darwin] Add support for -dependency_info
When using llvm-libtool-darwin as a drop in replacement for cctools libtool, Xcode expects you to create a dependency info file. This file is a very simple format describing the input files, the output files, and the version of the tool. This logic is mirrored from that of ld64.lld, which supports creating this file as well. Ideally we could extract it, but I don't think we want to throw this into one of the grab-bag libraries given how small the logic is. Differential Revision: https://reviews.llvm.org/D134322
Diffstat (limited to 'llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp')
-rw-r--r--llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index 8d4529c..5fec847 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+#include "DependencyInfo.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Object/ArchiveWriter.h"
@@ -87,6 +88,12 @@ static cl::list<std::string> LibrarySearchDirs(
" libraries"),
cl::Prefix, cl::cat(LibtoolCategory));
+static cl::opt<std::string> DependencyInfoPath(
+ "dependency_info",
+ cl::desc("Write an Xcode dependency info file describing the dependencies "
+ "of the created library"),
+ cl::cat(LibtoolCategory));
+
static cl::opt<bool>
VersionOption("V", cl::desc("Print the version number and exit"),
cl::cat(LibtoolCategory));
@@ -109,6 +116,8 @@ static const std::array<std::string, 3> StandardSearchDirs{
"/usr/local/lib",
};
+std::unique_ptr<DependencyInfo> GlobalDependencyInfo;
+
struct Config {
bool Deterministic = true; // Updated by 'D' and 'U' modifiers.
uint32_t ArchCPUType;
@@ -116,7 +125,6 @@ struct Config {
};
static Expected<std::string> searchForFile(const Twine &FileName) {
-
auto FindLib =
[FileName](ArrayRef<std::string> SearchDirs) -> Optional<std::string> {
for (StringRef Dir : SearchDirs) {
@@ -125,6 +133,8 @@ static Expected<std::string> searchForFile(const Twine &FileName) {
if (sys::fs::exists(Path))
return std::string(Path);
+
+ GlobalDependencyInfo->addMissingInput(Path);
}
return None;
};
@@ -652,6 +662,11 @@ static Expected<Config> parseCommandLine(int Argc, char **Argv) {
return C;
}
+ GlobalDependencyInfo =
+ DependencyInfoPath.empty()
+ ? std::make_unique<DummyDependencyInfo>()
+ : std::make_unique<DependencyInfo>(DependencyInfoPath);
+
if (OutputFile.empty()) {
std::string Error;
raw_string_ostream Stream(Error);
@@ -686,6 +701,9 @@ static Expected<Config> parseCommandLine(int Argc, char **Argv) {
MachO::getArchitectureFromName(ArchType));
}
+ GlobalDependencyInfo->write("llvm-libtool-darwin " LLVM_VERSION_STRING,
+ InputFiles, OutputFile);
+
return C;
}