summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/contrib/bbvars.py52
1 files changed, 2 insertions, 50 deletions
diff --git a/scripts/contrib/bbvars.py b/scripts/contrib/bbvars.py
index 556f6529f8..286b5a9405 100755
--- a/scripts/contrib/bbvars.py
+++ b/scripts/contrib/bbvars.py
@@ -32,48 +32,12 @@ scriptpath.add_bitbake_lib_path()
32import bb.tinfoil 32import bb.tinfoil
33 33
34def usage(): 34def usage():
35 print('Usage: %s -d FILENAME [-d FILENAME]* -m METADIR [-m MATADIR]*' % os.path.basename(sys.argv[0])) 35 print('Usage: %s -d FILENAME [-d FILENAME]*' % os.path.basename(sys.argv[0]))
36 print(' -d FILENAME documentation file to search') 36 print(' -d FILENAME documentation file to search')
37 print(' -h, --help display this help and exit') 37 print(' -h, --help display this help and exit')
38 print(' -m METADIR meta directory to search for recipes')
39 print(' -t FILENAME documentation config file (for doc tags)') 38 print(' -t FILENAME documentation config file (for doc tags)')
40 print(' -T Only display variables with doc tags (requires -t)') 39 print(' -T Only display variables with doc tags (requires -t)')
41 40
42def recipe_bbvars(recipe):
43 ''' Return a unique set of every bbvar encountered in the recipe '''
44 prog = re.compile("[A-Z_]+")
45 vset = set()
46 try:
47 r = open(recipe)
48 except IOError as err:
49 print('WARNING: Failed to open recipe ', recipe)
50 print(err.args[1])
51
52 for line in r:
53 # Strip any comments from the line
54 line = line.rsplit('#')[0]
55 vset = vset.union(set(prog.findall(line)))
56 r.close()
57
58 bbvars = {}
59 for v in vset:
60 bbvars[v] = 1
61
62 return bbvars
63
64def collect_bbvars(metadir):
65 ''' Walk the metadir and collect the bbvars from each recipe found '''
66 bbvars = {}
67 for root,dirs,files in os.walk(metadir):
68 for name in files:
69 if name.find(".bb") >= 0:
70 for key in recipe_bbvars(os.path.join(root,name)).keys():
71 if key in bbvars:
72 bbvars[key] = bbvars[key] + 1
73 else:
74 bbvars[key] = 1
75 return bbvars
76
77def bbvar_is_documented(var, documented_vars): 41def bbvar_is_documented(var, documented_vars):
78 ''' Check if variable (var) is in the list of documented variables(documented_vars) ''' 42 ''' Check if variable (var) is in the list of documented variables(documented_vars) '''
79 if var in documented_vars: 43 if var in documented_vars:
@@ -112,7 +76,6 @@ def bbvar_doctag(var, docconf):
112 76
113def main(): 77def main():
114 docfiles = [] 78 docfiles = []
115 metadirs = []
116 bbvars = set() 79 bbvars = set()
117 undocumented = [] 80 undocumented = []
118 docconf = "" 81 docconf = ""
@@ -136,12 +99,6 @@ def main():
136 else: 99 else:
137 print('ERROR: documentation file %s is not a regular file' % a) 100 print('ERROR: documentation file %s is not a regular file' % a)
138 sys.exit(3) 101 sys.exit(3)
139 elif o == '-m':
140 if os.path.isdir(a):
141 metadirs.append(a)
142 else:
143 print('ERROR: meta directory %s is not a directory' % a)
144 sys.exit(4)
145 elif o == "-t": 102 elif o == "-t":
146 if os.path.isfile(a): 103 if os.path.isfile(a):
147 docconf = a 104 docconf = a
@@ -155,11 +112,6 @@ def main():
155 usage() 112 usage()
156 sys.exit(5) 113 sys.exit(5)
157 114
158 if len(metadirs) == 0:
159 print('ERROR: no metadir specified')
160 usage()
161 sys.exit(6)
162
163 if onlydoctags and docconf == "": 115 if onlydoctags and docconf == "":
164 print('ERROR: no docconf specified') 116 print('ERROR: no docconf specified')
165 usage() 117 usage()
@@ -196,7 +148,7 @@ def main():
196 bbvars_update(data) 148 bbvars_update(data)
197 149
198 # Collect variables from all recipes 150 # Collect variables from all recipes
199 for recipe in tinfoil.all_recipe_files(): 151 for recipe in tinfoil.all_recipe_files(variants=False):
200 print("Checking %s" % recipe) 152 print("Checking %s" % recipe)
201 for data in tinfoil.parse_recipe_file(recipe): 153 for data in tinfoil.parse_recipe_file(recipe):
202 bbvars_update(data) 154 bbvars_update(data)