source: rtems-libbsd/builder.py @ f7a09b5

5-freebsd-12
Last change on this file since f7a09b5 was f7a09b5, checked in by Chris Johns <chrisj@…>, on Mar 26, 2018 at 4:14:52 AM

waf: Support building from libbsd.py directly from waf.

Remove the need to generate a waf script.

Move various pieces of data from the builder code to libbsd.py and make
it configuration data.

Update #3351

  • Property mode set to 100755
File size: 24.1 KB
Line 
1#
2#  Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
3#
4#  Copyright (c) 2009, 2017 embedded brains GmbH.  All rights reserved.
5#
6#   embedded brains GmbH
7#   Dornierstr. 4
8#   82178 Puchheim
9#   Germany
10#   <info@embedded-brains.de>
11#
12#  Copyright (c) 2012 OAR Corporation. All rights reserved.
13#
14#  Redistribution and use in source and binary forms, with or without
15#  modification, are permitted provided that the following conditions
16#  are met:
17#  1. Redistributions of source code must retain the above copyright
18#     notice, this list of conditions and the following disclaimer.
19#  2. Redistributions in binary form must reproduce the above copyright
20#     notice, this list of conditions and the following disclaimer in the
21#     documentation and/or other materials provided with the distribution.
22#
23#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35# FreeBSD: http://svn.freebsd.org/base/releng/8.2/sys (revision 222485)
36
37from __future__ import print_function
38
39import shutil
40import os
41import re
42import sys
43import getopt
44import filecmp
45import difflib
46import codecs
47
48#
49# Global controls.
50#
51LIBBSD_DIR = "."
52FreeBSD_DIR = "freebsd-org"
53verboseLevel = 0
54isDryRun = False
55isDiffMode = False
56filesProcessedCount = 0
57filesProcessed = []
58filesTotal = 0
59filesTotalLines = 0
60filesTotalInserts = 0
61filesTotalDeletes = 0
62diffDetails = { }
63
64verboseInfo = 1
65verboseDetail = 2
66verboseMoreDetail = 3
67verboseDebug = 4
68
69def verbose(level = verboseInfo):
70    return verboseLevel >= level
71
72def changedFileSummary(statsReport = False):
73
74    global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes
75
76    if isDiffMode == False:
77        if verbose():
78            print('%d file(s) were changed:' % (filesProcessedCount))
79            for f in sorted(filesProcessed):
80                print(' %s' % (f))
81        else:
82            print('%d file(s) were changed.' % (filesProcessedCount))
83    if statsReport:
84        print('Stats Report:')
85        transparent = filesTotal - len(diffDetails)
86        changes = filesTotalInserts + filesTotalDeletes
87        opacity = (float(changes) / (filesTotalLines + changes)) * 100.0
88        print(' Total File(s):%d  Unchanged:%d (%.1f%%)  Changed:%d' \
89              '   Opacity:%5.1f%% Lines:%d Edits:%d (+):%d (-):%d'  % \
90              (filesTotal, transparent, (float(transparent) / filesTotal) * 100.0, len(diffDetails), \
91               opacity, filesTotalLines, changes, filesTotalInserts, filesTotalDeletes))
92        #
93        # Sort by opacity.
94        #
95        ordered_diffs = sorted(diffDetails.items(), key = lambda diff: diff[1].opacity, reverse = True)
96        for f in ordered_diffs:
97            print(%s' % (diffDetails[f[0]].status()))
98
99def readFile(name):
100    try:
101        contents = codecs.open(name, mode = 'r', encoding = 'utf-8', errors = 'ignore').read()
102    except UnicodeDecodeError as ude:
103        print('error: reading: %s: %s' % (name, ude))
104        sys.exit(1)
105    return contents
106
107def writeFile(name, contents):
108    path = os.path.dirname(name)
109    if not os.path.exists(path):
110        try:
111            os.makedirs(path)
112        except OSError as oe:
113            print('error: cannot create directory: %s: %s' % (path, oe))
114            sys.exit(1)
115    try:
116        codecs.open(name, mode = 'w',  encoding = 'utf-8', errors = 'ignore').write(contents)
117    except UnicodeDecodeError as ude:
118        print('error: write: %s: %s' % (name, ude))
119        sys.exit(1)
120
121#
122# A builder error.
123#
124class error(Exception):
125    """Base class for exceptions."""
126    def __init__(self, msg):
127        self.msg = 'error: %s' % (msg)
128    def set_output(self, msg):
129        self.msg = msg
130    def __str__(self):
131        return self.msg
132
133#
134# Diff Record
135#
136class diffRecord:
137    def __init__(self, src, dst, orig, diff, inserts, deletes):
138        self.src = src
139        self.dst = dst
140        self.orig = orig
141        self.diff = diff
142        self.lines = len(orig)
143        self.inserts = inserts
144        self.deletes = deletes
145        self.changes = inserts + deletes
146        self.opacity = (float(self.changes) / (self.lines + self.changes)) * 100.0
147
148    def __repr__(self):
149        return self.src
150
151    def status(self):
152        return 'opacity:%5.1f%% edits:%4d (+):%-4d (-):%-4d %s' % \
153            (self.opacity, self.changes, self.inserts, self.deletes, self.src)
154
155#
156# This stuff needs to move to libbsd.py.
157#
158
159# Move target dependent files under a machine directory
160def mapCPUDependentPath(path):
161  return path.replace("include/", "include/machine/")
162
163def fixIncludes(data):
164    data = re.sub('#include <sys/resource.h>', '#include <rtems/bsd/sys/resource.h>', data)
165    data = re.sub('#include <sys/unistd.h>',   '#include <rtems/bsd/sys/unistd.h>', data)
166    return data
167
168# revert fixing the include paths inside a C or .h file
169def revertFixIncludes(data):
170    data = re.sub('#include <rtems/bsd/',  '#include <', data)
171    data = re.sub('#include <util.h>',     '#include <rtems/bsd/util.h>', data)
172    data = re.sub('#include <bsd.h>',      '#include <rtems/bsd/bsd.h>', data)
173    data = re.sub('#include <zerocopy.h>', '#include <rtems/bsd/zerocopy.h>', data)
174    return data
175
176# fix include paths inside a C or .h file
177def fixLocalIncludes(data):
178    data = re.sub('#include "opt_([^"]*)"',    '#include <rtems/bsd/local/opt_\\1>', data)
179    data = re.sub('#include "([^"]*)_if.h"',   '#include <rtems/bsd/local/\\1_if.h>', data)
180    data = re.sub('#include "miidevs([^"]*)"', '#include <rtems/bsd/local/miidevs\\1>', data)
181    data = re.sub('#include "usbdevs([^"]*)"', '#include <rtems/bsd/local/usbdevs\\1>', data)
182    return data
183
184# revert fixing the include paths inside a C or .h file
185def revertFixLocalIncludes(data):
186    data = re.sub('#include <rtems/bsd/local/([^>]*)>', '#include "\\1"', data)
187    return data
188
189def assertHeaderFile(path):
190    if path[-2] != '.' or path[-1] != 'h':
191        print("*** " + path + " does not end in .h")
192        print("*** Move it to a C source file list")
193        sys.exit(2)
194
195def assertSourceFile(path):
196    if path[-2] != '.' or (path[-1] != 'c' and path[-1] != 'S'):
197        print("*** " + path + " does not end in .c")
198        print("*** Move it to a header file list")
199        sys.exit(2)
200
201def diffSource(dstLines, srcLines, src, dst):
202    global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes
203    #
204    # Diff, note there is no line termination on each string.  Expand the
205    # generator to list because the generator is not reusable.
206    #
207    diff = list(difflib.unified_diff(dstLines,
208                                     srcLines,
209                                     fromfile = src,
210                                     tofile = dst,
211                                     n = 5,
212                                     lineterm = ''))
213    inserts = 0
214    deletes = 0
215    if len(diff) > 0:
216        if src in diffDetails and \
217           diffDetails[src].dst != dst and diffDetails[src].diff != diff:
218            raise error('repeated diff of file different: src:%s dst:%s' % (src, dst))
219        for l in diff:
220            if l[0] == '-':
221                deletes += 1
222            elif l[0] == '+':
223                inserts += 1
224        diffDetails[src] = diffRecord(src, dst, srcLines, diff, inserts, deletes)
225
226    #
227    # Count the total files, lines and the level of changes.
228    #
229    filesTotal += 1
230    filesTotalLines += len(srcLines)
231    filesTotalInserts += inserts
232    filesTotalDeletes += deletes
233
234    return diff
235
236#
237# Converters provide a way to alter the various types of code. The conversion
238# process filters a file as it is copies from the source path to the
239# destination path. Specialised versions are provided for different types of
240# source.
241#
242class Converter(object):
243
244    def convert(self, src, dst, hasSource = True, sourceFilter = None, srcContents = None):
245
246        global filesProcessed, filesProcessedCount
247
248        if verbose(verboseDebug):
249            print("convert: filter:%s: %s -> %s" % \
250                  (['yes', 'no'][sourceFilter is None], src, dst))
251
252        #
253        # If there is no source raise an error if we expect source else print a
254        # warning and do not try and convert.
255        #
256        if srcContents is None:
257            if not os.path.exists(src):
258                if hasSource:
259                    raise error('source not found: %s' % (src))
260                else:
261                    print('warning: no source: %s' % (src))
262                    return
263
264            #
265            # Files read as a single string if not passed in.
266            #
267            srcContents = readFile(src)
268
269        if os.path.exists(dst):
270            dstContents = readFile(dst)
271        else:
272            print('warning: no destination: %s' % (dst))
273            dstContents = ''
274
275        #
276        # Filter the source.
277        #
278        if sourceFilter is not None:
279            srcContents = sourceFilter(srcContents)
280
281        #
282        # Split into a list of lines.
283        #
284        srcLines = srcContents.split(os.linesep)
285        dstLines = dstContents.split(os.linesep)
286
287        if verbose(verboseDebug):
288            print('Unified diff: %s (lines:%d)' % (src, len(srcLines)))
289
290        #
291        # Diff, note there is no line termination on each string.
292        #
293        diff = diffSource(dstLines, srcLines, src, dst)
294
295        #
296        # The diff list is empty if the files are the same.
297        #
298        if len(diff) > 0:
299
300            if verbose(verboseDebug):
301                print('Unified diff length: %d' % len(diff))
302
303            filesProcessed += [dst]
304            filesProcessedCount += 1
305            if isDiffMode == False:
306                if verbose(verboseDetail):
307                    print("UPDATE: %s -> %s" % (src, dst))
308                if isDryRun == False:
309                    writeFile(dst, srcContents)
310            else:
311                print("diff -u %s %s" % (src, dst))
312                for l in diff:
313                    print(l)
314
315class NoConverter(Converter):
316    def convert(self, src, dst, hasSource = True, sourceFilter = None):
317        return '/* EMPTY */\n'
318
319class FromFreeBSDToRTEMSHeaderConverter(Converter):
320    def sourceFilter(self, data):
321        data = fixLocalIncludes(data)
322        data = fixIncludes(data)
323        return data
324
325    def convert(self, src, dst):
326        sconverter = super(FromFreeBSDToRTEMSHeaderConverter, self)
327        sconverter.convert(src, dst, sourceFilter = self.sourceFilter)
328
329class FromFreeBSDToRTEMSUserSpaceHeaderConverter(Converter):
330    def sourceFilter(self, data):
331        data = fixIncludes(data)
332        return data
333
334    def convert(self, src, dst):
335        sconverter = super(FromFreeBSDToRTEMSUserSpaceHeaderConverter, self)
336        sconverter.convert(src, dst, sourceFilter = self.sourceFilter)
337
338class FromFreeBSDToRTEMSSourceConverter(Converter):
339    def sourceFilter(self, data):
340        data = fixLocalIncludes(data)
341        data = fixIncludes(data)
342        data = '#include <machine/rtems-bsd-kernel-space.h>\n\n' + data
343        return data
344
345    def convert(self, src, dst):
346        sconverter = super(FromFreeBSDToRTEMSSourceConverter, self)
347        sconverter.convert(src, dst, sourceFilter = self.sourceFilter)
348
349class FromFreeBSDToRTEMSUserSpaceSourceConverter(Converter):
350    def sourceFilter(self, data):
351        data = fixIncludes(data)
352        data = '#include <machine/rtems-bsd-user-space.h>\n\n' + data
353        return data
354
355    def convert(self, src, dst):
356        sconverter = super(FromFreeBSDToRTEMSUserSpaceSourceConverter, self)
357        sconverter.convert(src, dst, sourceFilter = self.sourceFilter)
358
359class FromRTEMSToFreeBSDHeaderConverter(Converter):
360    def sourceFilter(self, data):
361        data = revertFixLocalIncludes(data)
362        data = revertFixIncludes(data)
363        return data
364
365    def convert(self, src, dst):
366        sconverter = super(FromRTEMSToFreeBSDHeaderConverter, self)
367        sconverter.convert(src, dst, hasSource = False,  sourceFilter = self.sourceFilter)
368
369class FromRTEMSToFreeBSDSourceConverter(Converter):
370    def sourceFilter(self, data):
371        data = re.sub('#include <machine/rtems-bsd-kernel-space.h>\n\n', '', data)
372        data = re.sub('#include <machine/rtems-bsd-user-space.h>\n\n', '', data)
373        data = revertFixLocalIncludes(data)
374        data = revertFixIncludes(data)
375        return data
376
377    def convert(self, src, dst):
378        sconverter = super(FromRTEMSToFreeBSDSourceConverter, self)
379        sconverter.convert(src, dst, hasSource = False, sourceFilter = self.sourceFilter)
380
381#
382# Compose a path based for the various parts of the source tree.
383#
384class PathComposer(object):
385    def composeOriginPath(self, path):
386        return path
387
388    def composeLibBSDPath(self, path, prefix):
389        return os.path.join(prefix, path)
390
391class FreeBSDPathComposer(PathComposer):
392    def composeOriginPath(self, path):
393        return os.path.join(FreeBSD_DIR, path)
394
395    def composeLibBSDPath(self, path, prefix):
396        return os.path.join(prefix, 'freebsd', path)
397
398class RTEMSPathComposer(PathComposer):
399    def composeOriginPath(self, path):
400        return path
401
402    def composeLibBSDPath(self, path, prefix):
403        return os.path.join(prefix, 'rtemsbsd', path)
404
405class LinuxPathComposer(PathComposer):
406    def composeOriginPath(self, path):
407        return path
408
409    def composeLibBSDPath(self, path, prefix):
410        return os.path.join(prefix, 'linux', path)
411
412class CPUDependentFreeBSDPathComposer(FreeBSDPathComposer):
413    def composeLibBSDPath(self, path, prefix):
414        path = super(CPUDependentFreeBSDPathComposer, self).composeLibBSDPath(path, prefix)
415        path = mapCPUDependentPath(path)
416        return path
417
418class CPUDependentRTEMSPathComposer(RTEMSPathComposer):
419    def composeLibBSDPath(self, path, prefix):
420        path = super(CPUDependentRTEMSPathComposer, self).composeLibBSDPath(path, prefix)
421        path = mapCPUDependentPath(path)
422        return path
423
424class CPUDependentLinuxPathComposer(LinuxPathComposer):
425    def composeLibBSDPath(self, path, prefix):
426        path = super(CPUDependentLinuxPathComposer, self).composeLibBSDPath(path, prefix)
427        path = mapCPUDependentPath(path)
428        return path
429
430class TargetSourceCPUDependentPathComposer(CPUDependentFreeBSDPathComposer):
431    def __init__(self, targetCPU, sourceCPU):
432        self.targetCPU = targetCPU
433        self.sourceCPU = sourceCPU
434
435    def composeLibBSDPath(self, path, prefix):
436        path = super(TargetSourceCPUDependentPathComposer, self).composeLibBSDPath(path, prefix)
437        path = path.replace(self.sourceCPU, self.targetCPU)
438        return path
439
440class BuildSystemFragmentComposer(object):
441    def __init__(self, includes = None):
442        if type(includes) is not list:
443            self.includes = [includes]
444        else:
445            self.includes = includes
446
447    def compose(self, path):
448        return ''
449
450#
451# File - a file in the source we move backwards and forwards.
452#
453class File(object):
454    def __init__(self, path, pathComposer,
455                 forwardConverter, reverseConverter, buildSystemComposer):
456        if verbose(verboseMoreDetail):
457            print("FILE: %-50s F:%-45s R:%-45s" % \
458                  (path,
459                   forwardConverter.__class__.__name__,
460                   reverseConverter.__class__.__name__))
461        self.path = path
462        self.pathComposer = pathComposer
463        self.originPath = self.pathComposer.composeOriginPath(self.path)
464        self.libbsdPath = self.pathComposer.composeLibBSDPath(self.path, LIBBSD_DIR)
465        self.forwardConverter = forwardConverter
466        self.reverseConverter = reverseConverter
467        self.buildSystemComposer = buildSystemComposer
468
469    def processSource(self, forward):
470        if forward:
471            if verbose(verboseDetail):
472                print("process source: %s => %s" % (self.originPath, self.libbsdPath))
473            self.forwardConverter.convert(self.originPath, self.libbsdPath)
474        else:
475            if verbose(verboseDetail):
476                print("process source: %s => %s converter:%s" % \
477                      (self.libbsdPath, self.originPath, self.reverseConverter.__class__.__name__))
478            self.reverseConverter.convert(self.libbsdPath, self.originPath)
479
480    def getFragment(self):
481        return self.buildSystemComposer.compose(self.pathComposer.composeLibBSDPath(self.path, ''))
482
483#
484# Module - logical group of related files we can perform actions on
485#
486class Module(object):
487    def __init__(self, name):
488        self.name = name
489        self.conditionalOn = "none"
490        self.files = []
491        self.cpuDependentSourceFiles = {}
492        self.dependencies = []
493
494    def initCPUDependencies(self, cpu):
495        if cpu not in self.cpuDependentSourceFiles:
496            self.cpuDependentSourceFiles[cpu] = []
497
498    def processSource(self, direction):
499        if verbose(verboseDetail):
500            print("process module: %s" % (self.name))
501        for f in self.files:
502            f.processSource(direction)
503        for cpu, files in self.cpuDependentSourceFiles.items():
504            for f in files:
505                f.processSource(direction)
506
507    def addFiles(self, newFiles, buildSystemComposer = BuildSystemFragmentComposer()):
508        files = []
509        for newFile in newFiles:
510            assertFile(newFile)
511            files += [File(newFile, composers, buildSystemComposer)]
512        return files
513
514    def addFile(self, f):
515        self.files += [f]
516
517    def addFiles(self, newFiles,
518                 pathComposer, forwardConverter, reverseConverter,
519                 assertFile, buildSystemComposer = BuildSystemFragmentComposer()):
520        files = []
521        for newFile in newFiles:
522            assertFile(newFile)
523            files += [File(newFile, pathComposer, forwardConverter,
524                           reverseConverter, buildSystemComposer)]
525        return files
526
527    def addKernelSpaceHeaderFiles(self, files):
528        self.files += self.addFiles(files,
529                                    FreeBSDPathComposer(), FromFreeBSDToRTEMSHeaderConverter(),
530                                    FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile)
531
532    def addUserSpaceHeaderFiles(self, files):
533        self.files += self.addFiles(files,
534                                    FreeBSDPathComposer(), FromFreeBSDToRTEMSUserSpaceHeaderConverter(),
535                                    FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile)
536
537    def addRTEMSHeaderFiles(self, files):
538        self.files += self.addFiles(files, RTEMSPathComposer(),
539                                    NoConverter(), NoConverter(), assertHeaderFile)
540
541    def addLinuxHeaderFiles(self, files):
542        self.files += self.addFiles(files,
543                                    PathComposer(), NoConverter(),
544                                    NoConverter(), assertHeaderFile)
545
546    def addCPUDependentFreeBSDHeaderFiles(self, files):
547        self.files += self.addFiles(files,
548                                    CPUDependentFreeBSDPathComposer(), FromFreeBSDToRTEMSHeaderConverter(),
549                                    FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile)
550
551    def addCPUDependentLinuxHeaderFiles(self, files):
552        self.files += self.addFiles(files,
553                                    CPUDependentLinuxPathComposer(), NoConverter(),
554                                    NoConverter(), assertHeaderFile)
555
556    def addTargetSourceCPUDependentHeaderFiles(self, targetCPUs, sourceCPU, files):
557        for cpu in targetCPUs:
558            self.files += self.addFiles(files,
559                                        TargetSourceCPUDependentPathComposer(cpu, sourceCPU),
560                                        FromFreeBSDToRTEMSHeaderConverter(),
561                                        NoConverter(), assertHeaderFile)
562
563    def addSourceFiles(self, files, sourceFileFragmentComposer):
564        self.files += self.addFiles(files,
565                                    PathComposer(), NoConverter(), NoConverter(), assertSourceFile,
566                                    sourceFileFragmentComposer)
567
568    def addKernelSpaceSourceFiles(self, files, sourceFileFragmentComposer):
569        self.files += self.addFiles(files,
570                                    FreeBSDPathComposer(), FromFreeBSDToRTEMSSourceConverter(),
571                                    FromRTEMSToFreeBSDSourceConverter(), assertSourceFile,
572                                    sourceFileFragmentComposer)
573
574    def addUserSpaceSourceFiles(self, files, sourceFileFragmentComposer):
575        self.files += self.addFiles(files,
576                                    FreeBSDPathComposer(),
577                                    FromFreeBSDToRTEMSUserSpaceSourceConverter(),
578                                    FromRTEMSToFreeBSDSourceConverter(), assertSourceFile,
579                                    sourceFileFragmentComposer)
580
581    def addRTEMSSourceFiles(self, files, sourceFileFragmentComposer):
582        self.files += self.addFiles(files,
583                                    RTEMSPathComposer(), NoConverter(), NoConverter(),
584                                    assertSourceFile, sourceFileFragmentComposer)
585
586    def addLinuxSourceFiles(self, files, sourceFileFragmentComposer):
587        self.files += self.addFiles(files,
588                                    PathComposer(), NoConverter(),
589                                    NoConverter(), assertSourceFile,
590                                    sourceFileFragmentComposer)
591
592    def addCPUDependentFreeBSDSourceFiles(self, cpus, files, sourceFileFragmentComposer):
593        for cpu in cpus:
594            self.initCPUDependencies(cpu)
595            self.cpuDependentSourceFiles[cpu] += \
596                self.addFiles(files,
597                              CPUDependentFreeBSDPathComposer(), FromFreeBSDToRTEMSSourceConverter(),
598                              FromRTEMSToFreeBSDSourceConverter(), assertSourceFile,
599                              sourceFileFragmentComposer)
600
601    def addCPUDependentRTEMSSourceFiles(self, cpus, files, sourceFileFragmentComposer):
602        for cpu in cpus:
603            self.initCPUDependencies(cpu)
604            self.cpuDependentSourceFiles[cpu] += \
605                self.addFiles(files,
606                              CPUDependentRTEMSPathComposer(), NoConverter(),
607                              NoConverter(), assertSourceFile,
608                              sourceFileFragmentComposer)
609
610    def addCPUDependentLinuxSourceFiles(self, cpus, files, sourceFileFragmentComposer):
611        for cpu in cpus:
612            self.initCPUDependencies(cpu)
613            self.cpuDependentSourceFiles[cpu] += \
614                self.addFiles(files,
615                              CPUDependentLinuxPathComposer(), NoConverter(),
616                              NoConverter(), assertSourceFile,
617                              sourceFileFragmentComposer)
618
619    def addTest(self, testFragementComposer):
620        self.files += [File(testFragementComposer.testName,
621                            PathComposer(), NoConverter(), NoConverter(),
622                            testFragementComposer)]
623
624    def addDependency(self, dep):
625        self.dependencies += [dep]
626
627#
628# Manager - a collection of modules.
629#
630class ModuleManager(object):
631    def __init__(self):
632        self.modules = {}
633        self.generator = {}
634        self.configuration = {}
635        self.setGenerators()
636
637    def __getitem__(self, key):
638        if key not in self.modules:
639            raise KeyError('module %s not found' % (key))
640        return self.modules[key]
641
642    def getModules(self):
643        return sorted(self.modules.keys())
644
645    def addModule(self, module):
646        self.modules[module.name] = module
647
648    def processSource(self, direction):
649        if verbose(verboseDetail):
650            print("process modules:")
651        for m in sorted(self.modules):
652            self.modules[m].processSource(direction)
653
654    def setConfiguration(self, config):
655        self.configuration = config
656
657    def getConfiguration(self):
658        return self.configuration
Note: See TracBrowser for help on using the repository browser.