================ @@ -0,0 +1,332 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file A utility for operating on LLVM CAS. +/// +//===----------------------------------------------------------------------===// + +#include "llvm/CAS/ActionCache.h" +#include "llvm/CAS/BuiltinUnifiedCASDatabases.h" +#include "llvm/CAS/ObjectStore.h" +#include "llvm/CAS/UnifiedOnDiskCache.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/InitLLVM.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/raw_ostream.h" +#include <memory> +#include <system_error> + +using namespace llvm; +using namespace llvm::cas; + +static cl::list<std::string> Inputs(cl::Positional, cl::desc("Input object")); + +static int dump(ObjectStore &CAS); +static int listObjectReferences(ObjectStore &CAS, const CASID &ID); +static int catNodeData(ObjectStore &CAS, const CASID &ID); +static int makeBlob(ObjectStore &CAS, StringRef DataPath); +static int makeNode(ObjectStore &CAS, ArrayRef<std::string> References, + StringRef DataPath); +static int import(ObjectStore &FromCAS, ObjectStore &ToCAS, + ArrayRef<std::string> Objects); +static int putCacheKey(ObjectStore &CAS, ActionCache &AC, + ArrayRef<std::string> Objects); +static int getCacheResult(ObjectStore &CAS, ActionCache &AC, const CASID &ID); +static int validateObject(ObjectStore &CAS, const CASID &ID); +static int validate(ObjectStore &CAS, ActionCache &AC, bool CheckHash); +static int validateIfNeeded(StringRef Path, bool CheckHash, bool Force, + bool AllowRecovery, bool InProcess, + const char *Argv0); +static int prune(cas::ObjectStore &CAS); + +int main(int Argc, char **Argv) { + InitLLVM X(Argc, Argv); + cl::opt<std::string> CASPath("cas", cl::desc("Path to CAS on disk."), + cl::value_desc("path")); + cl::opt<std::string> UpstreamCASPath( + "upstream-cas", cl::desc("Path to another CAS."), cl::value_desc("path")); + cl::opt<std::string> DataPath("data", + cl::desc("Path to data or '-' for stdin."), + cl::value_desc("path")); + cl::opt<bool> CheckHash("check-hash", + cl::desc("check all hashes during validation")); + cl::opt<bool> AllowRecovery("allow-recovery", + cl::desc("allow recovery of cas data")); + cl::opt<bool> Force("force", + cl::desc("force validation even if unnecessary")); + cl::opt<bool> InProcess("in-process", cl::desc("validate in-process")); + + enum CommandKind { + Invalid, + Dump, + CatNodeData, + MakeBlob, + MakeNode, + ListObjectReferences, + Import, + PutCacheKey, + GetCacheResult, + Validate, + ValidateObject, + ValidateIfNeeded, + Prune, + }; + cl::opt<CommandKind> Command( ---------------- cachemeifyoucan wrote:
Let me switch to OptTable no matter what. This started with a simple test tool but we end up shipping it because it is really helpful for debugging purposes. https://github.com/llvm/llvm-project/pull/114104 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
