示例#1
0
 def testNoSources(self):
     s = module_sources.SourcesSet()
     self.assertEqual(s.all(), [])
     self.assertEqual(s.nopch(), [])
     self.assertEqual(s.pch(), [])
     self.assertEqual(s.pch_system_includes(), [])
     self.assertEqual(s.pch_jumbo(), [])
示例#2
0
 def testGenerateSourcesListFilesEmpty(self):
     s = module_sources.SourcesSet()
     s.generateSourcesListFiles(self.tmpdir())
     empty = StringIO.StringIO()
     for f in ('sources.all', 'sources.nopch', 'sources.pch',
               'sources.pch_system_includes', 'sources.pch_jumbo'):
         filename = os.path.join(self.tmpdir(), f)
         self.assertTrue(util.compareWithFile(empty, filename))
         os.remove(filename)
示例#3
0
    def generateSourcesSetup(self, verify_sources=True):
        """
        Generates the files sources.all, sources.nopch, sources.pch,
        sources.pch_system_includes and sources.pch_jumbo in both
        modules/hardcore/setup/plain/sources and
        modules/hardcore/setup/jumbo/sources. It also generates the
        jumbo compile units of all modules.
        @return True if any of the generated files has changed and
          False if none has changed.
        """
        changed = False
        self.__plain_sources = module_sources.SourcesSet()
        self.__jumbo_sources = module_sources.SourcesSet()
        for module in self.__modules:
            if util.fileTracker.addInput(module.getSourcesFile()):
                sources = module.getModuleSources()
                changed = sources.generateJumboCompileUnits(self.__sourceRoot, self.__outputRoot) or changed
                self.__plain_sources.extend(sources.plain_sources(),
                                            module.type(), module.name())
                self.__jumbo_sources.extend(sources.jumbo_sources(),
                                            module.type(), module.name())

        # verify that all files exist:
        if verify_sources:
            for filename in set(self.__plain_sources.all()) | set(self.__jumbo_sources.all()):
                if not os.path.exists(os.path.join(self.__sourceRoot, filename)) and not os.path.exists(os.path.join(self.__outputRoot, filename)):
                    self.addError(util.Line("", 0), "file '%s' not found" % filename)

        hardcoreDir = os.path.join(self.__outputRoot, 'modules', 'hardcore')
        plainDir = os.path.join(hardcoreDir, 'setup', 'plain', 'sources')
        jumboDir = os.path.join(hardcoreDir, 'setup', 'jumbo', 'sources')
        sources = ['all', 'nocph', 'pch', 'pch_system_includes', 'pch_jumbo']
        changed = self.__plain_sources.generateSourcesListFiles(plainDir) or changed
        util.updateModuleGenerated(hardcoreDir,
                                   map(lambda s: '/'.join(['setup', 'plain', 'sources', "sources.%s" % s]), sources))
        changed = self.__jumbo_sources.generateSourcesListFiles(jumboDir) or changed
        util.updateModuleGenerated(hardcoreDir,
                                   map(lambda s: '/'.join(['setup', 'jumbo', 'sources', "sources.%s" % s]), sources))

        return changed
示例#4
0
    def testExtend(self):
        s1 = module_sources.SourcesSet()
        s1.addSourceFile("a000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s1.addSourceFile("a010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s1.addSourceFile("a011.c", pch=False, jumbo=True, system_includes=True)
        s1.addSourceFile("a100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a101.c", pch=True, jumbo=False, system_includes=True)
        s1.addSourceFile("a110.c", pch=True, jumbo=True, system_includes=False)
        s1.addSourceFile("a111.c", pch=True, jumbo=True, system_includes=True)

        s = module_sources.SourcesSet()
        # extend an empty set with specifying type and module, so
        # both type and module are prepended to the source files:
        s.extend(s1, type='foo', module='bar')
        self.assertEqual(s.all(), [
            "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
            "foo/bar/a011.c", "foo/bar/a100.c", "foo/bar/a101.c",
            "foo/bar/a110.c", "foo/bar/a111.c"
        ])
        self.assertEqual(s.nopch(), [
            "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
            "foo/bar/a011.c", "foo/bar/a111.c"
        ])
        self.assertEqual(s.pch(), ["foo/bar/a100.c"])
        self.assertEqual(s.pch_system_includes(), ["foo/bar/a101.c"])
        self.assertEqual(s.pch_jumbo(), ["foo/bar/a110.c"])
示例#5
0
    def testExtendModule(self):
        s1 = module_sources.SourcesSet()
        s1.addSourceFile("a000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s1.addSourceFile("a010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s1.addSourceFile("a011.c", pch=False, jumbo=True, system_includes=True)
        s1.addSourceFile("a100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a101.c", pch=True, jumbo=False, system_includes=True)
        s1.addSourceFile("a110.c", pch=True, jumbo=True, system_includes=False)
        s1.addSourceFile("a111.c", pch=True, jumbo=True, system_includes=True)

        s = module_sources.SourcesSet()
        # extend an empty set with specifying a module but no type, so
        # only the module is prepended to the source file's paths:
        s.extend(s1, module='foo')
        self.assertEqual(s.all(), [
            "foo/a000.c", "foo/a001.c", "foo/a010.c", "foo/a011.c",
            "foo/a100.c", "foo/a101.c", "foo/a110.c", "foo/a111.c"
        ])
        self.assertEqual(s.nopch(), [
            "foo/a000.c", "foo/a001.c", "foo/a010.c", "foo/a011.c",
            "foo/a111.c"
        ])
        self.assertEqual(s.pch(), ["foo/a100.c"])
        self.assertEqual(s.pch_system_includes(), ["foo/a101.c"])
        self.assertEqual(s.pch_jumbo(), ["foo/a110.c"])
示例#6
0
    def testExtendNoTypeModule(self):
        s1 = module_sources.SourcesSet()
        s1.addSourceFile("a000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s1.addSourceFile("a010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s1.addSourceFile("a011.c", pch=False, jumbo=True, system_includes=True)
        s1.addSourceFile("a100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a101.c", pch=True, jumbo=False, system_includes=True)
        s1.addSourceFile("a110.c", pch=True, jumbo=True, system_includes=False)
        s1.addSourceFile("a111.c", pch=True, jumbo=True, system_includes=True)

        s = module_sources.SourcesSet()
        # extend an empty set without specifying type and module, so
        # no path is prepended to the source files:
        s.extend(s1)
        self.assertEqual(s.all(), [
            "a000.c", "a001.c", "a010.c", "a011.c", "a100.c", "a101.c",
            "a110.c", "a111.c"
        ])
        self.assertEqual(s.nopch(),
                         ["a000.c", "a001.c", "a010.c", "a011.c", "a111.c"])
        self.assertEqual(s.pch(), ["a100.c"])
        self.assertEqual(s.pch_system_includes(), ["a101.c"])
        self.assertEqual(s.pch_jumbo(), ["a110.c"])
示例#7
0
 def testAddSources(self):
     s = module_sources.SourcesSet()
     s.addSourceFile("000.c", pch=False, jumbo=False, system_includes=False)
     s.addSourceFile("001.c", pch=False, jumbo=False, system_includes=True)
     s.addSourceFile("010.c", pch=False, jumbo=True, system_includes=False)
     s.addSourceFile("011.c", pch=False, jumbo=True, system_includes=True)
     s.addSourceFile("100.c", pch=True, jumbo=False, system_includes=False)
     s.addSourceFile("101.c", pch=True, jumbo=False, system_includes=True)
     s.addSourceFile("110.c", pch=True, jumbo=True, system_includes=False)
     s.addSourceFile("111.c", pch=True, jumbo=True, system_includes=True)
     self.assertEqual(s.all(), [
         "000.c", "001.c", "010.c", "011.c", "100.c", "101.c", "110.c",
         "111.c"
     ])
     self.assertEqual(s.nopch(),
                      ["000.c", "001.c", "010.c", "011.c", "111.c"])
     self.assertEqual(s.pch(), ["100.c"])
     self.assertEqual(s.pch_system_includes(), ["101.c"])
     self.assertEqual(s.pch_jumbo(), ["110.c"])
示例#8
0
    def testGenerateSourcesListFiles(self):
        s1 = module_sources.SourcesSet()
        s1.addSourceFile("a000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s1.addSourceFile("a010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s1.addSourceFile("a011.c", pch=False, jumbo=True, system_includes=True)
        s1.addSourceFile("a100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a101.c", pch=True, jumbo=False, system_includes=True)
        s1.addSourceFile("a110.c", pch=True, jumbo=True, system_includes=False)
        s1.addSourceFile("a111.c", pch=True, jumbo=True, system_includes=True)
        s2 = module_sources.SourcesSet()
        s2.addSourceFile("b000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s2.addSourceFile("b001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s2.addSourceFile("b010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s2.addSourceFile("b011.c", pch=False, jumbo=True, system_includes=True)
        s2.addSourceFile("b100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s2.addSourceFile("b101.c", pch=True, jumbo=False, system_includes=True)
        s2.addSourceFile("b110.c", pch=True, jumbo=True, system_includes=False)
        s2.addSourceFile("b111.c", pch=True, jumbo=True, system_includes=True)

        # test extending the set with two different sets which have a
        # different module name
        s = module_sources.SourcesSet()
        s.extend(s1, 'foo', 'bar')
        s.extend(s2, 'foo', 'baz')
        expected_result = {
            'sources.all': [
                "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
                "foo/bar/a011.c", "foo/bar/a100.c", "foo/bar/a101.c",
                "foo/bar/a110.c", "foo/bar/a111.c", "foo/baz/b000.c",
                "foo/baz/b001.c", "foo/baz/b010.c", "foo/baz/b011.c",
                "foo/baz/b100.c", "foo/baz/b101.c", "foo/baz/b110.c",
                "foo/baz/b111.c"
            ],
            'sources.nopch': [
                "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
                "foo/bar/a011.c", "foo/bar/a111.c", "foo/baz/b000.c",
                "foo/baz/b001.c", "foo/baz/b010.c", "foo/baz/b011.c",
                "foo/baz/b111.c"
            ],
            'sources.pch': ["foo/bar/a100.c", "foo/baz/b100.c"],
            'sources.pch_system_includes':
            ["foo/bar/a101.c", "foo/baz/b101.c"],
            'sources.pch_jumbo': ["foo/bar/a110.c", "foo/baz/b110.c"]
        }
        s.generateSourcesListFiles(self.tmpdir())
        for f in expected_result.keys():
            content = StringIO.StringIO()
            for file in expected_result[f]:
                print >> content, file
            filename = os.path.join(self.tmpdir(), f)
            self.assertTrue(util.compareWithFile(content, filename))
            os.remove(filename)
示例#9
0
    def testExtend2(self):
        s1 = module_sources.SourcesSet()
        s1.addSourceFile("a000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s1.addSourceFile("a010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s1.addSourceFile("a011.c", pch=False, jumbo=True, system_includes=True)
        s1.addSourceFile("a100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s1.addSourceFile("a101.c", pch=True, jumbo=False, system_includes=True)
        s1.addSourceFile("a110.c", pch=True, jumbo=True, system_includes=False)
        s1.addSourceFile("a111.c", pch=True, jumbo=True, system_includes=True)
        s2 = module_sources.SourcesSet()
        s2.addSourceFile("b000.c",
                         pch=False,
                         jumbo=False,
                         system_includes=False)
        s2.addSourceFile("b001.c",
                         pch=False,
                         jumbo=False,
                         system_includes=True)
        s2.addSourceFile("b010.c",
                         pch=False,
                         jumbo=True,
                         system_includes=False)
        s2.addSourceFile("b011.c", pch=False, jumbo=True, system_includes=True)
        s2.addSourceFile("b100.c",
                         pch=True,
                         jumbo=False,
                         system_includes=False)
        s2.addSourceFile("b101.c", pch=True, jumbo=False, system_includes=True)
        s2.addSourceFile("b110.c", pch=True, jumbo=True, system_includes=False)
        s2.addSourceFile("b111.c", pch=True, jumbo=True, system_includes=True)

        # test extending the set with two different sets which have a
        # different module name
        s = module_sources.SourcesSet()
        s.extend(s1, 'foo', 'bar')
        s.extend(s2, 'foo', 'baz')
        self.assertEqual(s.all(), [
            "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
            "foo/bar/a011.c", "foo/bar/a100.c", "foo/bar/a101.c",
            "foo/bar/a110.c", "foo/bar/a111.c", "foo/baz/b000.c",
            "foo/baz/b001.c", "foo/baz/b010.c", "foo/baz/b011.c",
            "foo/baz/b100.c", "foo/baz/b101.c", "foo/baz/b110.c",
            "foo/baz/b111.c"
        ])
        self.assertEqual(s.nopch(), [
            "foo/bar/a000.c", "foo/bar/a001.c", "foo/bar/a010.c",
            "foo/bar/a011.c", "foo/bar/a111.c", "foo/baz/b000.c",
            "foo/baz/b001.c", "foo/baz/b010.c", "foo/baz/b011.c",
            "foo/baz/b111.c"
        ])
        self.assertEqual(s.pch(), ["foo/bar/a100.c", "foo/baz/b100.c"])
        self.assertEqual(s.pch_system_includes(),
                         ["foo/bar/a101.c", "foo/baz/b101.c"])
        self.assertEqual(s.pch_jumbo(), ["foo/bar/a110.c", "foo/baz/b110.c"])