1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
from cmakelang.parse.argument_nodes import (
PositionalParser,
StandardArgTree,
)
from cmakelang.parse.util import (
get_nth_semantic_token
)
def parse_build_name(ctx, tokens, breakstack):
"""
::
build_name(variable)
:see: https://cmake.org/cmake/help/latest/command/build_name.html
"""
return StandardArgTree.parse(ctx, tokens, 1, {}, [], breakstack)
def parse_exec_program(ctx, tokens, breakstack):
"""
::
exec_program(Executable [directory in which to run]
[ARGS <arguments to executable>]
[OUTPUT_VARIABLE <var>]
[RETURN_VALUE <var>])
:see: https://cmake.org/cmake/help/latest/command/exec_program.html
"""
kwargs = {
"ARGS": PositionalParser("+"),
"OUTPUT_VARIABLE": PositionalParser(1),
"RETURN_VALUE": PositionalParser(1)
}
return StandardArgTree.parse(ctx, tokens, 2, kwargs, [], breakstack)
def parse_install_files(ctx, tokens, breakstack):
"""
::
install_files(<dir> extension file file ...)
install_files(<dir> regexp)
install_files(<dir> FILES file file ...)
:see: https://cmake.org/cmake/help/latest/command/install_files.html
"""
second_token = get_nth_semantic_token(tokens, 1)
third_token = get_nth_semantic_token(tokens, 2)
if second_token is not None and second_token.spelling.upper() == "FILES":
return StandardArgTree.parse(ctx, tokens, "3+", {}, ["FILES"], breakstack)
if third_token is None:
return StandardArgTree.parse(ctx, tokens, 2, {}, [], breakstack)
return StandardArgTree.parse(ctx, tokens, "3+", {}, [], breakstack)
def parse_install_programs(ctx, tokens, breakstack):
"""
::
install_programs(<dir> file1 file2 [file3 ...])
install_programs(<dir> FILES file1 [file2 ...])
install_programs(<dir> regexp)
:see: https://cmake.org/cmake/help/latest/command/install_programs.html
"""
second_token = get_nth_semantic_token(tokens, 1)
third_token = get_nth_semantic_token(tokens, 2)
if second_token is not None and second_token.spelling.upper() == "FILES":
return StandardArgTree.parse(ctx, tokens, "3+", {}, ["FILES"], breakstack)
if third_token is None:
return StandardArgTree.parse(ctx, tokens, 2, {}, [], breakstack)
return StandardArgTree.parse(ctx, tokens, "3+", {}, [], breakstack)
def parse_install_targets(ctx, tokens, breakstack):
"""
::
install_targets(<dir> [RUNTIME_DIRECTORY dir] target target)
:see: https://cmake.org/cmake/help/latest/command/install_targets.html
"""
kwargs = {
"RUNTIME_DIRECTORY": PositionalParser(1)
}
return StandardArgTree.parse(ctx, tokens, "2+", kwargs, [], breakstack)
def parse_make_directory(ctx, tokens, breakstack):
"""
::
make_directory(directory)
:see: https://cmake.org/cmake/help/latest/command/make_directory.html
"""
return StandardArgTree.parse(ctx, tokens, 1, {}, [], breakstack)
def parse_remove(ctx, tokens, breakstack):
"""
::
remove(VAR VALUE VALUE ...)
:see: https://cmake.org/cmake/help/latest/command/remove.html
"""
return StandardArgTree.parse(ctx, tokens, "2+", {}, [], breakstack)
def parse_subdir_depends(ctx, tokens, breakstack):
"""
::
subdir_depends(subdir dep1 dep2 ...)
:see: https://cmake.org/cmake/help/latest/command/subdir_depends.html
"""
return StandardArgTree.parse(ctx, tokens, "2+", {}, [], breakstack)
def parse_subdirs(ctx, tokens, breakstack):
"""
::
subdirs(dir1 dir2 ...[EXCLUDE_FROM_ALL exclude_dir1 exclude_dir2 ...]
[PREORDER] )
:see: https://cmake.org/cmake/help/latest/command/subdirs.html
"""
kwargs = {
"EXCLUDE_FROM_ALL": PositionalParser("+"),
}
flags = ["PREORDER"]
return StandardArgTree.parse(ctx, tokens, "+", kwargs, flags, breakstack)
def parse_use_mangled_mesa(ctx, tokens, breakstack):
"""
::
use_mangled_mesa(PATH_TO_MESA OUTPUT_DIRECTORY)
:see: https://cmake.org/cmake/help/latest/command/use_mangled_mesa.html
"""
return StandardArgTree.parse(ctx, tokens, 2, {}, [], breakstack)
def parse_utility_source(ctx, tokens, breakstack):
"""
::
utility_source(cache_entry executable_name
path_to_source [file1 file2 ...])
:see: https://cmake.org/cmake/help/latest/command/utility_source.html
"""
return StandardArgTree.parse(ctx, tokens, "3+", {}, [], breakstack)
def parse_variable_requires(ctx, tokens, breakstack):
"""
::
variable_requires(TEST_VARIABLE RESULT_VARIABLE
REQUIRED_VARIABLE1
REQUIRED_VARIABLE2 ...)
:see: https://cmake.org/cmake/help/latest/command/variable_requires.html
"""
return StandardArgTree.parse(ctx, tokens, "3+", {}, [], breakstack)
def parse_write_file(ctx, tokens, breakstack):
"""
::
write_file(filename "message to write"... [APPEND])
:see: https://cmake.org/cmake/help/latest/command/write_file.html
"""
return StandardArgTree.parse(ctx, tokens, "2+", {}, ["APPEND"], breakstack)
def populate_db(parse_db):
parse_db["build_name"] = parse_build_name
parse_db["exec_program"] = parse_exec_program
parse_db["install_files"] = parse_install_files
parse_db["install_programs"] = parse_install_programs
parse_db["install_targets"] = parse_install_targets
parse_db["make_directory"] = parse_make_directory
parse_db["remove"] = parse_remove
parse_db["subdir_depends"] = parse_subdir_depends
parse_db["subdirs"] = parse_subdirs
parse_db["use_mangled_mesa"] = parse_use_mangled_mesa
parse_db["utility_source"] = parse_utility_source
parse_db["variable_requires"] = parse_variable_requires
parse_db["write_file"] = parse_write_file
|