summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-06-30 23:02:52 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-01 17:17:35 +0100
commit6c36f4a6aa76dbbca4f8c0623955058db34bd1e5 (patch)
tree66aba473c08e3d195fc0cf8c2e86b9d06e805608 /bitbake
parent9fe29fd7db125d8f1295086b003d925c255303f4 (diff)
downloadpoky-6c36f4a6aa76dbbca4f8c0623955058db34bd1e5.tar.gz
cooker|command|event: add new command findFilesMatchingInDir
This command can be used to search each BBPATH for files in the passed directory which have a filename matching the supplied pattern. This is implemented for use from the GUI (to determine the available PACKAGE_CLASSES) but has been written so as to be generically useful and reusable. (Bitbake rev: 2a599812a57cb0b964880a6a2b7548423497ea92) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/command.py12
-rw-r--r--bitbake/lib/bb/cooker.py23
-rw-r--r--bitbake/lib/bb/event.py10
3 files changed, 45 insertions, 0 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 2f37938cee..a902da2ce8 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -251,6 +251,18 @@ class CommandsAsync:
251 command.finishAsyncCommand() 251 command.finishAsyncCommand()
252 findConfigFiles.needcache = True 252 findConfigFiles.needcache = True
253 253
254 def findFilesMatchingInDir(self, command, params):
255 """
256 Find implementation files matching the specified pattern
257 in the requested subdirectory of a BBPATH
258 """
259 pattern = params[0]
260 directory = params[1]
261
262 command.cooker.findFilesMatchingInDir(pattern, directory)
263 command.finishAsyncCommand()
264 findFilesMatchingInDir.needcache = True
265
254 def findConfigFilePath(self, command, params): 266 def findConfigFilePath(self, command, params):
255 """ 267 """
256 Find the path of the requested configuration file 268 Find the path of the requested configuration file
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index e537634df8..9874f664b5 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -520,6 +520,29 @@ class BBCooker:
520 path = self._findConfigFile(configfile) 520 path = self._findConfigFile(configfile)
521 bb.event.fire(bb.event.ConfigFilePathFound(path), self.configuration.data) 521 bb.event.fire(bb.event.ConfigFilePathFound(path), self.configuration.data)
522 522
523 def findFilesMatchingInDir(self, filepattern, directory):
524 """
525 Searches for files matching the regex 'pattern' which are children of
526 'directory' in each BBPATH. i.e. to find all rootfs package classes available
527 to BitBake one could call findFilesMatchingInDir(self, 'rootfs_', 'classes')
528 or to find all machine configuration files on could call
529 findFilesMatchingInDir(self, 'conf/machines', 'conf')
530 """
531 import re
532
533 matches = []
534 p = re.compile(re.escape(filepattern))
535 bbpaths = bb.data.getVar('BBPATH', self.configuration.data, True).split(':')
536 for path in bbpaths:
537 dirpath = os.path.join(path, directory)
538 if os.path.exists(dirpath):
539 for root, dirs, files in os.walk(dirpath):
540 for f in files:
541 if p.search(f):
542 matches.append(f)
543
544 bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.configuration.data)
545
523 def findConfigFiles(self, varname): 546 def findConfigFiles(self, varname):
524 """ 547 """
525 Find config files which are appropriate values for varname. 548 Find config files which are appropriate values for varname.
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 7c49d464dd..c7252dd330 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -390,6 +390,16 @@ class TargetsTreeGenerated(Event):
390 Event.__init__(self) 390 Event.__init__(self)
391 self._model = model 391 self._model = model
392 392
393class FilesMatchingFound(Event):
394 """
395 Event when a list of files matching the supplied pattern has
396 been generated
397 """
398 def __init__(self, pattern, matches):
399 Event.__init__(self)
400 self._pattern = pattern
401 self._matches = matches
402
393class ConfigFilesFound(Event): 403class ConfigFilesFound(Event):
394 """ 404 """
395 Event when a list of appropriate config files has been generated 405 Event when a list of appropriate config files has been generated