1 //===- DriverUtils.cpp ----------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "DriverUtils.h"
10 #include "InputFiles.h"
12 #include "lld/Common/ErrorHandler.h"
13 #include "lld/Common/Memory.h"
14 #include "llvm/Support/Path.h"
15 #include "llvm/TextAPI/MachO/TextAPIReader.h"
18 using namespace llvm::MachO
;
19 using namespace llvm::sys
;
21 using namespace lld::macho
;
23 Optional
<std::string
> macho::resolveDylibPath(StringRef path
) {
24 // TODO: if a tbd and dylib are both present, we should check to make sure
25 // they are consistent.
27 return std::string(path
);
29 SmallString
<261> location
= path
;
30 path::replace_extension(location
, ".tbd");
31 if (fs::exists(location
))
32 return std::string(location
);
37 Optional
<DylibFile
*> macho::makeDylibFromTAPI(MemoryBufferRef mbref
,
38 DylibFile
*umbrella
) {
39 Expected
<std::unique_ptr
<InterfaceFile
>> result
= TextAPIReader::get(mbref
);
41 error("could not load TAPI file at " + mbref
.getBufferIdentifier() + ": " +
42 toString(result
.takeError()));
45 return make
<DylibFile
>(**result
, umbrella
);