[offload] [test] Use test compiler ID rather than host (#124408)
[llvm-project.git] / clang / lib / InstallAPI / Library.cpp
blobbdfa3535273e1fa010b19bff192c1bc50ab1cd43
1 //===- Library.cpp --------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "clang/InstallAPI/Library.h"
11 using namespace llvm;
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);
19 if (Match.empty())
20 return "";
21 return Match.back();
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.
36 Path = BaseDirectory;
37 return sys::path::filename(Path.rtrim("/"));
40 } // namespace clang::installapi