Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts/kernel-doc.py: move file lists to the parser function

Instead of setting file lists at __init__ time, move it to
the actual parsing function. This allows adding more files
to be parsed in real time, by calling parse function multiple
times.

With the new way, the export_files logic was rewritten to
avoid parsing twice EXPORT_SYMBOL for partial matches.

Please notice that, with this logic, it can still read the
same file twice when export_file is used.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/ab10bc94050406ce6536d4944b5d718ecd70812f.1744106242.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
799b0d2a 4fa5e411

+21 -25
+3 -4
scripts/kernel-doc.py
··· 274 274 else: 275 275 out_style = RestFormat() 276 276 277 - kfiles = KernelFiles(files=args.files, verbose=args.verbose, 277 + kfiles = KernelFiles(verbose=args.verbose, 278 278 out_style=out_style, werror=args.werror, 279 279 wreturn=args.wreturn, wshort_desc=args.wshort_desc, 280 280 wcontents_before_sections=args.wcontents_before_sections, 281 - modulename=args.modulename, 282 - export_file=args.export_file) 281 + modulename=args.modulename) 283 282 284 - kfiles.parse() 283 + kfiles.parse(args.files, export_file=args.export_file) 285 284 286 285 for t in kfiles.msg(enable_lineno=args.enable_lineno, export=args.export, 287 286 internal=args.internal, symbol=args.symbol,
+18 -21
scripts/lib/kdoc/kdoc_files.py
··· 124 124 self.config.log.error("Cannot find file %s", fname) 125 125 self.config.errors += 1 126 126 127 - def __init__(self, files=None, verbose=False, out_style=None, 127 + def __init__(self, verbose=False, out_style=None, 128 128 werror=False, wreturn=False, wshort_desc=False, 129 129 wcontents_before_sections=False, 130 130 logger=None, modulename=None, export_file=None): ··· 181 181 self.config.src_tree = os.environ.get("SRCTREE", None) 182 182 183 183 self.out_style = out_style 184 - self.export_file = export_file 185 184 186 185 # Initialize internal variables 187 186 188 187 self.config.errors = 0 189 188 self.results = [] 190 189 191 - self.file_list = files 192 190 self.files = set() 191 + self.export_files = set() 193 192 194 - def parse(self): 193 + def parse(self, file_list, export_file=None): 195 194 """ 196 195 Parse all files 197 196 """ 198 197 199 198 glob = GlobSourceFiles(srctree=self.config.src_tree) 200 199 201 - # Let's use a set here to avoid duplicating files 200 + # Prevent parsing the same file twice to speedup parsing and 201 + # avoid reporting errors multiple times 202 202 203 - for fname in glob.parse_files(self.file_list, self.file_not_found_cb): 203 + for fname in glob.parse_files(file_list, self.file_not_found_cb): 204 204 if fname in self.files: 205 205 continue 206 206 207 + res = self.parse_file(fname) 208 + 209 + self.results.append((res.fname, res.entries)) 207 210 self.files.add(fname) 208 211 209 - res = self.parse_file(fname) 210 - self.results.append((res.fname, res.entries)) 211 - 212 - if not self.files: 213 - sys.exit(1) 214 - 215 212 # If a list of export files was provided, parse EXPORT_SYMBOL* 216 - # from the ones not already parsed 213 + # from files that weren't fully parsed 217 214 218 - if self.export_file: 219 - files = self.files 215 + if not export_file: 216 + return 220 217 221 - glob = GlobSourceFiles(srctree=self.config.src_tree) 218 + self.export_files |= self.files 222 219 223 - for fname in glob.parse_files(self.export_file, 224 - self.file_not_found_cb): 225 - if fname not in files: 226 - files.add(fname) 220 + glob = GlobSourceFiles(srctree=self.config.src_tree) 227 221 228 - self.process_export_file(fname) 222 + for fname in glob.parse_files(export_file, self.file_not_found_cb): 223 + if fname not in self.export_files: 224 + self.process_export_file(fname) 225 + self.export_files.add(fname) 229 226 230 227 def out_msg(self, fname, name, arg): 231 228 """