Skip to content

Commit ff8c093

Browse files
[CAS] llvm-cas upstream review
Match upstream llvm-cas implementation and switching to OptTable.
1 parent 2a8460e commit ff8c093

File tree

7 files changed

+385
-233
lines changed

7 files changed

+385
-233
lines changed

clang/test/ClangScanDeps/modules-include-tree-prefix-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/System.casid | grep '<module-includes>' | sed 's|.* llvmcas|llvmcas|' > %t/system-module-includes.casid
4141
// RUN: echo "System module-includes" >> %t/result.txt
42-
// RUN: llvm-cas -cas %t/cas -cat-blob @%t/system-module-includes.casid >> %t/result.txt
42+
// RUN: llvm-cas -cas %t/cas -cat-node-data @%t/system-module-includes.casid >> %t/result.txt
4343

4444
// RUN: FileCheck %s -input-file %t/result.txt -DPREFIX=%/t -check-prefix=NO_PATHS
4545
// NO_PATHS-NOT: [[PREFIX]]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ CHECK: syml
2727
CHECK-SAME: sym_dir -> directory
2828

2929
RUN: llvm-cas --cas %t/cas --get-cas-id --data %S/Inputs/directory/file @%t/cas.id > %t/file.casid
30-
RUN: llvm-cas --cas %t/cas --cat-blob @%t/file.casid | FileCheck %s --check-prefix=CHECK-TEST-FILE
30+
RUN: llvm-cas --cas %t/cas --cat-node-data @%t/file.casid | FileCheck %s --check-prefix=CHECK-TEST-FILE
3131

3232
CHECK-TEST-FILE: test
3333

llvm/test/tools/llvm-cas/make-blob.test

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,24 @@ RUN: --data %S/Inputs/oneline >%t/oneline.casid
1414
RUN: llvm-cas --cas %t.cas --make-blob \
1515
RUN: --data %S/Inputs/oneline-nonewline >%t/oneline-nonewline.casid
1616

17-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/empty.casid |\
17+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/empty.casid |\
1818
RUN: FileCheck %s -check-prefix CHECK-EMPTY -allow-empty
19-
RUN: llvm-cas --cas %t.cas --print-kind @%t/empty.casid |\
20-
RUN: FileCheck %s -check-prefix CHECK-KIND
2119
CHECK-EMPTY-NOT: {{.}}
22-
CHECK-KIND: object
2320

24-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/abc.casid |\
21+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/abc.casid |\
2522
RUN: FileCheck %s -check-prefix CHECK-ABC
26-
RUN: llvm-cas --cas %t.cas --print-kind @%t/abc.casid |\
27-
RUN: FileCheck %s -check-prefix CHECK-KIND
2823
CHECK-ABC: abc
2924

30-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline-nonewline.casid |\
25+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/oneline-nonewline.casid |\
3126
RUN: FileCheck %s -check-prefix CHECK-ONELINE
32-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline.casid |\
27+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/oneline.casid |\
3328
RUN: FileCheck %s -check-prefix CHECK-ONELINE
3429
CHECK-ONELINE: content
3530

3631
# Double-check newlines.
37-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline-nonewline.casid \
32+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/oneline-nonewline.casid \
3833
RUN: >%t/oneline-nonewline
3934
RUN: diff %S/Inputs/oneline-nonewline %t/oneline-nonewline
40-
RUN: llvm-cas --cas %t.cas --cat-blob @%t/oneline.casid \
35+
RUN: llvm-cas --cas %t.cas --cat-node-data @%t/oneline.casid \
4136
RUN: >%t/oneline
4237
RUN: diff %S/Inputs/oneline %t/oneline

llvm/test/tools/llvm-cas/make-node.test

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ RUN: llvm-cas --cas %t/cas --ls-node-refs @%t/empty.casid |\
1111
RUN: FileCheck %s -check-prefix CHECK-EMPTY -allow-empty
1212
CHECK-EMPTY-NOT: {{.}}
1313

14-
RUN: llvm-cas --cas %t/cas --print-kind @%t/empty.casid |\
15-
RUN: FileCheck %s -check-prefix CHECK-NO-KIND
16-
### FIXME: Node ObjectKind with no reference is Blob kind in BuiltinCAS.
17-
CHECK-NO-KIND: object
18-
1914
# Make a complex object, which references existing ones. Reference a blob and
2015
# other objects, and reference one of them twice to be sure they don't get
2116
# deduped.
@@ -27,13 +22,10 @@ RUN: cat %t/complex.refs | sed -e 's,^.,CHECK: ,' > %t/complex.check
2722
RUN: llvm-cas --cas %t/cas --make-node \
2823
RUN: --data %S/Inputs/oneline @%t/complex.refs \
2924
RUN: >%t/complex.casid
30-
RUN: llvm-cas --cas %t/cas --print-kind \
31-
RUN: @%t/complex.casid | FileCheck %s -check-prefix COMPLEX-KIND
3225
RUN: llvm-cas --cas %t/cas --cat-node-data \
3326
RUN: @%t/complex.casid | FileCheck %s -check-prefix COMPLEX-DATA
3427
RUN: llvm-cas --cas %t/cas --ls-node-refs @%t/complex.casid |\
3528
RUN: FileCheck %t/complex.check
36-
COMPLEX-KIND: object
3729
COMPLEX-DATA: content
3830

3931
RUN: not llvm-cas --cas %t/cas --ls-tree @%t/complex.casid 2>&1 | FileCheck %s --check-prefix=CHECK-WRONG-TYPE

llvm/tools/llvm-cas/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
set(LLVM_TARGET_DEFINITIONS Options.td)
2+
tablegen(LLVM Options.inc -gen-opt-parser-defs)
3+
add_public_tablegen_target(LLVMCASToolTableGen)
4+
15
set(LLVM_LINK_COMPONENTS
26
Support
37
CAS
8+
Option
49
RemoteCachingService
510
CASUtil
611
)
712

813
add_llvm_tool(llvm-cas
914
llvm-cas.cpp
15+
16+
DEPENDS
17+
${tablegen_deps}
18+
LLVMCASToolTableGen
1019
)

llvm/tools/llvm-cas/Options.td

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
include "llvm/Option/OptParser.td"
2+
3+
class F<string name> : Flag<["--", "-"], name>;
4+
5+
def grp_action : OptionGroup<"Actions">, HelpText<"llvm-cas actions">;
6+
7+
def help : F<"help">, HelpText<"Prints this help output">;
8+
def : Flag<["-"], "h">, Alias<help>, HelpText<"Alias for --help">;
9+
10+
// Tool actions
11+
12+
def cas_dump : F<"dump">, HelpText<"Dump internal contents">, Group<grp_action>;
13+
def cat_node_data : F<"cat-node-data">,
14+
HelpText<"Cat node data">,
15+
Group<grp_action>;
16+
def diff_graph : F<"diff-graphs">, HelpText<"diff graphs">, Group<grp_action>;
17+
def traverse_graph : F<"traverse-graph">,
18+
HelpText<"traverse graph">,
19+
Group<grp_action>;
20+
def make_blob : F<"make-blob">, HelpText<"Make blob">, Group<grp_action>;
21+
def make_node : F<"make-node">, HelpText<"Make node">, Group<grp_action>;
22+
def ls_node_refs : F<"ls-node-refs">,
23+
HelpText<"List node refs">,
24+
Group<grp_action>;
25+
def ls_tree : F<"ls-tree">, HelpText<"list tree">, Group<grp_action>;
26+
def ls_tree_recursive : F<"ls-tree-recursive">,
27+
HelpText<"list tree recursive">,
28+
Group<grp_action>;
29+
def ingest : F<"ingest">, HelpText<"ingest file system">, Group<grp_action>;
30+
def merge_tree : F<"merge">, HelpText<"merge paths/cas-ids">, Group<grp_action>;
31+
def get_cas_id : F<"get-cas-id">,
32+
HelpText<"get cas id for file">,
33+
Group<grp_action>;
34+
def import : F<"import">,
35+
HelpText<"Import objects from another CAS">,
36+
Group<grp_action>;
37+
def put_cache_key : F<"put-cache-key">,
38+
HelpText<"Set a value for a cache key">,
39+
Group<grp_action>;
40+
def get_cache_result : F<"get-cache-result">,
41+
HelpText<"Get the result value from a cache key">,
42+
Group<grp_action>;
43+
def validate : F<"validate">,
44+
HelpText<"Validate ObjectStore">,
45+
Group<grp_action>;
46+
def validate_object : F<"validate-object">,
47+
HelpText<"Validate the object for CASID">,
48+
Group<grp_action>;
49+
def validate_if_needed : F<"validate-if-needed">,
50+
HelpText<"Validate cas contents if needed">,
51+
Group<grp_action>;
52+
def prune : F<"prune">, HelpText<"Prune local cas storage">, Group<grp_action>;
53+
54+
// Tool options
55+
56+
def cas_path : Separate<["-", "--"], "cas">,
57+
MetaVarName<"<path>">,
58+
HelpText<"Path to CAS on disk">;
59+
60+
def cas_plugin_path : Separate<["-", "--"], "fcas-plugin-path">,
61+
MetaVarName<"<path>">,
62+
HelpText<"Path to plugin CAS library">;
63+
64+
def cas_plugin_option : Separate<["-", "--"], "fcas-plugin-option">,
65+
MetaVarName<"<option>">,
66+
HelpText<"Plugin CAS Options">;
67+
68+
def upstream_cas : Separate<["-", "--"], "upstream-cas">,
69+
MetaVarName<"<path>">,
70+
HelpText<"Path to another upstream CAS">;
71+
72+
def data : Separate<["-", "--"], "data">,
73+
MetaVarName<"<path>">,
74+
HelpText<"Path to data or '-' for stdin">;
75+
76+
def check_hash : F<"check-hash">,
77+
HelpText<"Check all hashes during validation">;
78+
79+
def allow_recovery : F<"allow-recovery">,
80+
HelpText<"Allow recovery of CAS data">;
81+
82+
def force : F<"force">, HelpText<"Force validation even if unnecessary">;
83+
84+
def in_process : F<"in-process">, HelpText<"Validation in-process">;
85+
86+
def all_trees
87+
: F<"all-trees">,
88+
HelpText<"Print all trees, not just empty ones, for ls-tree-recursive">;
89+
90+
def prefix_map : Separate<["-", "--"], "prefix-map">,
91+
MetaVarName<"BEFORE=AFTER">,
92+
HelpText<"Prefix map for file system ingestion">;
93+
94+
def casid_file : F<"casid-file">,
95+
HelpText<"Input is CASID file, just ingest CASID">;

0 commit comments

Comments
 (0)