Path: blob/main/contrib/llvm-project/clang/lib/InstallAPI/Library.cpp
35232 views
//===- Library.cpp --------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "clang/InstallAPI/Library.h"910using namespace llvm;11namespace clang::installapi {1213const Regex Rule("(.+)/(.+)\\.framework/");14StringRef Library::getFrameworkNameFromInstallName(StringRef InstallName) {15assert(InstallName.contains(".framework") && "expected a framework");16SmallVector<StringRef, 3> Match;17Rule.match(InstallName, &Match);18if (Match.empty())19return "";20return Match.back();21}2223StringRef Library::getName() const {24assert(!IsUnwrappedDylib && "expected a framework");25StringRef Path = BaseDirectory;2627// Return the framework name extracted from path.28while (!Path.empty()) {29if (Path.ends_with(".framework"))30return sys::path::filename(Path);31Path = sys::path::parent_path(Path);32}3334// Otherwise, return the name of the BaseDirectory.35Path = BaseDirectory;36return sys::path::filename(Path.rtrim("/"));37}3839} // namespace clang::installapi404142