DT compatibles : Add a separate database for documentation
Idxes needs to be sorted in RefLists but documentation idxes are lower than others and we added them latter in the RefList so there was a problem. The easiest solution to solve that is to create a separate database for documentations. Signed-off-by: Maxime Chretien <maxime.chretien@bootlin.com>
This commit is contained in:
parent
6bb9d5f848
commit
76c68265d3
3 changed files with 31 additions and 10 deletions
1
data.py
1
data.py
|
|
@ -196,4 +196,5 @@ class DB:
|
|||
self.docs = BsdDB(dir + '/doccomments.db', ro, RefList)
|
||||
if dtscomp:
|
||||
self.comps = BsdDB(dir + '/compatibledts.db', ro, RefList)
|
||||
self.comps_docs = BsdDB(dir + '/compatibledts_docs.db', ro, RefList)
|
||||
# Use a RefList in case there are multiple doc comments for an identifier
|
||||
|
|
|
|||
13
query.py
13
query.py
|
|
@ -216,8 +216,10 @@ def query(cmd, *args):
|
|||
|
||||
files_this_version = db.vers.get(version).iter()
|
||||
comps = db.comps.get(ident).iter(dummy=True)
|
||||
comps_docs = db.comps_docs.get(ident).iter(dummy=True)
|
||||
|
||||
comps_idx, comps_lines, comps_family = next(comps)
|
||||
comps_docs_idx, comps_docs_lines, comps_docs_family = next(comps_docs)
|
||||
compsCBuf = [] # C/CPP/ASM files
|
||||
compsDBuf = [] # DT files
|
||||
compsBBuf = [] # DT bindings docs files
|
||||
|
|
@ -225,16 +227,21 @@ def query(cmd, *args):
|
|||
for file_idx, file_path in files_this_version:
|
||||
while comps_idx < file_idx:
|
||||
comps_idx, comps_lines, comps_family = next(comps)
|
||||
|
||||
while comps_docs_idx < file_idx:
|
||||
comps_docs_idx, comps_docs_lines, comps_docs_family = next(comps_docs)
|
||||
|
||||
while comps_idx == file_idx:
|
||||
if comps_family == 'C':
|
||||
compsCBuf.append((file_path, comps_lines))
|
||||
elif comps_family == 'D':
|
||||
compsDBuf.append((file_path, comps_lines))
|
||||
elif comps_family == 'B':
|
||||
compsBBuf.append((file_path, comps_lines))
|
||||
|
||||
comps_idx, comps_lines, comps_family = next(comps)
|
||||
|
||||
while comps_docs_idx == file_idx:
|
||||
compsBBuf.append((file_path, comps_docs_lines))
|
||||
comps_docs_idx, comps_docs_lines, comps_docs_family = next(comps_docs)
|
||||
|
||||
for path, cline in sorted(compsCBuf):
|
||||
symbol_definitions.append(SymbolInstance(path, cline, 'compatible'))
|
||||
|
||||
|
|
|
|||
27
update.py
27
update.py
|
|
@ -45,6 +45,7 @@ defs_lock = Lock() # Lock for db.defs
|
|||
refs_lock = Lock() # Lock for db.refs
|
||||
docs_lock = Lock() # Lock for db.docs
|
||||
comps_lock = Lock() # Lock for db.comps
|
||||
comps_docs_lock = Lock() # Lock for db.comps_docs
|
||||
tag_ready = Condition() # Waiting for new tags
|
||||
|
||||
new_idxes = [] # (new idxes, Event idxes ready, Event defs ready)
|
||||
|
|
@ -367,7 +368,7 @@ class UpdateComps(Thread):
|
|||
global hash_file_lock, comps_lock, tags_comps
|
||||
|
||||
for idx in idxes:
|
||||
if (idx % 1000 == 0): progress('comps: ' + str(idx) + ' 1/2', tags_comps)
|
||||
if (idx % 1000 == 0): progress('comps: ' + str(idx), tags_comps)
|
||||
|
||||
with hash_file_lock:
|
||||
hash = db.hash.get(idx)
|
||||
|
|
@ -403,7 +404,7 @@ class UpdateComps(Thread):
|
|||
global hash_file_lock, comps_lock, tags_comps, bindings_idxes
|
||||
|
||||
for idx in idxes:
|
||||
if (idx % 1000 == 0): progress('comps: ' + str(idx) + ' 2/2', tags_comps)
|
||||
if (idx % 1000 == 0): progress('comps_docs: ' + str(idx), tags_comps)
|
||||
|
||||
if not idx in bindings_idxes: # Parse only bindings doc files
|
||||
continue
|
||||
|
|
@ -414,17 +415,29 @@ class UpdateComps(Thread):
|
|||
|
||||
family = 'B'
|
||||
lines = scriptLines('parse-comps', hash, filename, family)
|
||||
comps_docs = {}
|
||||
with comps_lock:
|
||||
for l in lines:
|
||||
ident, line = l.split(b' ')
|
||||
line = int(line.decode())
|
||||
|
||||
if db.comps.exists(ident):
|
||||
obj = db.comps.get(ident)
|
||||
obj.append(idx, str(line), family)
|
||||
if verbose:
|
||||
print(f"comps: {ident} in #{idx} @ {line}")
|
||||
db.comps.put(ident, obj)
|
||||
if ident in comps_docs:
|
||||
comps_docs[ident] += ',' + str(line)
|
||||
else:
|
||||
comps_docs[ident] = str(line)
|
||||
|
||||
with comps_docs_lock:
|
||||
for ident, lines in comps_docs.items():
|
||||
if db.comps_docs.exists(ident):
|
||||
obj = db.comps_docs.get(ident)
|
||||
else:
|
||||
obj = data.RefList()
|
||||
|
||||
obj.append(idx, lines, family)
|
||||
if verbose:
|
||||
print(f"comps_docs: {ident} in #{idx} @ {line}")
|
||||
db.comps_docs.put(ident, obj)
|
||||
|
||||
|
||||
def progress(msg, current):
|
||||
|
|
|
|||
Loading…
Reference in a new issue