1 //===- Library.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 "clang/InstallAPI/Library.h"
12 namespace clang::installapi
{
14 const Regex
Rule("(.+)/(.+)\\.framework/");
15 StringRef
Library::getFrameworkNameFromInstallName(StringRef InstallName
) {
16 assert(InstallName
.contains(".framework") && "expected a framework");
17 SmallVector
<StringRef
, 3> Match
;
18 Rule
.match(InstallName
, &Match
);
24 StringRef
Library::getName() const {
25 assert(!IsUnwrappedDylib
&& "expected a framework");
26 StringRef Path
= BaseDirectory
;
28 // Return the framework name extracted from path.
29 while (!Path
.empty()) {
30 if (Path
.ends_with(".framework"))
31 return sys::path::filename(Path
);
32 Path
= sys::path::parent_path(Path
);
35 // Otherwise, return the name of the BaseDirectory.
37 return sys::path::filename(Path
.rtrim("/"));
40 } // namespace clang::installapi