Skip to content

Commit 24bcd67

Browse files
akyrtzibenlangmuir
authored andcommitted
[llvm-cas] Add -fcas-plugin-path and -fcas-plugin-option options for convience
This matches the options for `clang` and `clang-cas-test`. (cherry picked from commit d9c488f)
1 parent 37f3217 commit 24bcd67

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

llvm/test/tools/llvm-cas/ingest.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/cas.id | FileCheck %s
77
// Using the plugin.
88
RUN: llvm-cas --cas plugin://%llvmshlibdir/libCASPluginTest%pluginext?ondisk-path=%t/cas-plugin --ingest --data %S/Inputs > %t/cas-plugin.id
99
RUN: llvm-cas --cas plugin://%llvmshlibdir/libCASPluginTest%pluginext?ondisk-path=%t/cas-plugin --ls-tree-recursive @%t/cas-plugin.id | FileCheck %s
10+
RUN: llvm-cas --cas %t/cas-plugin -fcas-plugin-path %llvmshlibdir/libCASPluginTest%pluginext --ls-tree-recursive @%t/cas-plugin.id | FileCheck %s
1011

1112
CHECK: syml
1213
CHECK-SAME: broken_symlink -> missing

llvm/tools/llvm-cas/llvm-cas.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ int main(int Argc, char **Argv) {
6767
cl::list<std::string> Objects(cl::Positional, cl::desc("<object>..."));
6868
cl::opt<std::string> CASPath("cas", cl::desc("Path to CAS on disk."),
6969
cl::value_desc("path"));
70+
cl::opt<std::string> CASPluginPath("fcas-plugin-path",
71+
cl::desc("Path to plugin CAS library"),
72+
cl::value_desc("path"));
73+
cl::list<std::string> CASPluginOpts("fcas-plugin-option",
74+
cl::desc("Plugin CAS Options"));
7075
cl::opt<std::string> UpstreamCASPath(
7176
"upstream-cas", cl::desc("Path to another CAS."), cl::value_desc("path"));
7277
cl::opt<std::string> DataPath("data",
@@ -133,11 +138,21 @@ int main(int Argc, char **Argv) {
133138
createStringError(inconvertibleErrorCode(), "missing --cas=<path>"));
134139

135140
std::shared_ptr<ObjectStore> CAS;
136-
std::unique_ptr<ActionCache> AC;
141+
std::shared_ptr<ActionCache> AC;
137142
std::optional<StringRef> CASFilePath;
138143
if (sys::path::is_absolute(CASPath)) {
139144
CASFilePath = CASPath;
140-
std::tie(CAS, AC) = ExitOnErr(createOnDiskUnifiedCASDatabases(CASPath));
145+
if (!CASPluginPath.empty()) {
146+
SmallVector<std::pair<std::string, std::string>> PluginOptions;
147+
for (const auto &PluginOpt : CASPluginOpts) {
148+
auto [Name, Val] = StringRef(PluginOpt).split('=');
149+
PluginOptions.push_back({std::string(Name), std::string(Val)});
150+
}
151+
std::tie(CAS, AC) = ExitOnErr(
152+
createPluginCASDatabases(CASPluginPath, CASPath, PluginOptions));
153+
} else {
154+
std::tie(CAS, AC) = ExitOnErr(createOnDiskUnifiedCASDatabases(CASPath));
155+
}
141156
} else {
142157
CAS = ExitOnErr(createCASFromIdentifier(CASPath));
143158
}

0 commit comments

Comments
 (0)