Exemplo n.º 1
0
    def test__implicit_name(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('ExecutableInMemoryTest')",
                                   "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(
                lines=["EXECUTABLE(center=C(filename='main.c'), members=[])"]))
        fs.rootdirectory().add(name='main.c', entry=File())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])

        found_exe_builder = None
        for b in package.rootbuilder().iter_builders():
            if isinstance(b, ExecutableBuilder):
                self.failUnless(found_exe_builder is None)
                found_exe_builder = b
                continue
            pass
        self.failIf(found_exe_builder is None)
        self.failUnless(
            found_exe_builder.exename() == 'ExecutableInMemoryTest_main')
        pass
Exemplo n.º 2
0
    def test__library(self):
        rootdir = Directory()
        rootdir.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('LibtoolInMemoryTest.testLibrary')",
                              "PACKAGE_VERSION('1.2.3')"]))
        rootdir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["LIBRARY(members=[C(filename='file.c')])"]))
        rootdir.add(
            name='file.c',
            entry=File())

        package = LocalPackage(rootdirectory=rootdir,
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])
        package.output()

        library_builder = None
        for b in package.rootbuilder().iter_builders():
            if isinstance(b, LibraryBuilder):
                self.failUnless(library_builder is None)
                library_builder = b
                pass
            pass
        self.failIf(library_builder is None)

        automake_output_builder = find_automake_output_builder(package.rootbuilder())
        self.failUnless('lib'+library_builder.basename()+'.la' in automake_output_builder.makefile_am().ltlibraries())
        pass
Exemplo n.º 3
0
    def test__with_explicit_setup(self):
        filesys = FileSystem(path=[])
        filesys.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                'PACKAGE_NAME("CheckProgramTest")', 'PACKAGE_VERSION("1.2.3")'
            ]))
        filesys.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "TESTS_ENVIRONMENT('name', 'value')",
                "EXECUTABLE(center=C(filename='main.c'),",
                "           exename='the-test-program',",
                "           what=EXECUTABLE_CHECK)"
            ]))
        filesys.rootdirectory().add(name='main.c',
                                    entry=File(lines=['int main(void) {}']))

        package = LocalPackage(rootdirectory=filesys.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()

        rootdir_output_builder = find_automake_output_builder(
            package.rootbuilder())
        self.failIf(rootdir_output_builder is None)

        self.failUnless('the-test-program' in
                        rootdir_output_builder.makefile_am().check_programs())
        self.failUnlessEqual(
            len(rootdir_output_builder.makefile_am().tests_environment()), 1)
        self.failUnlessEqual(
            rootdir_output_builder.makefile_am().tests_environment()['name'],
            'value')
Exemplo n.º 4
0
    def test(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["from libconfix.core.machinery.builder import Builder",
                              "class MyBuilder(Builder):",
                              "    def locally_unique_id(self): return 'my_builder_id'",
                              "ADD_BUILDER(builder=MyBuilder())"]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        for b in package.rootbuilder().iter_builders():
            if b.locally_unique_id() == 'my_builder_id':
                break
            pass
        else:
            self.fail()
            pass
        pass
Exemplo n.º 5
0
    def setUp(self):
        fs = FileSystem(path=['', 'path', 'to', 'it'])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('ExternalLibraryTest')",
                                   "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(name=const.CONFIX2_DIR,
                               entry=File(lines=[
                                   'DIRECTORY(["lolo"])',
                                   'DIRECTORY(["lo"])',
                                   'DIRECTORY(["hi"])',
                               ]))
        lolo = fs.rootdirectory().add(name='lolo', entry=Directory())
        lolo.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "PROVIDE_SYMBOL('lolo')", "EXTERNAL_LIBRARY(",
                "    incpath=['-I/the/include/path/of/lolo'],",
                "    libpath=['-L/the/first/library/path/of/lolo', '-L/the/second/library/path/of/lolo'],",
                "    cflags=['lolo_cflags'],",
                "    cxxflags=['lolo_cxxflags'],",
                "    cmdlinemacros={'cmdlinemacro_lolo': 'value_lolo'},",
                "    libs=['-llolo'])"
            ]))

        lo = fs.rootdirectory().add(name='lo', entry=Directory())
        lo.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "REQUIRE_SYMBOL('lolo', URGENCY_ERROR)",
                "PROVIDE_SYMBOL('lo')", "EXTERNAL_LIBRARY(",
                "    incpath=['-I/the/include/path/of/lo'],",
                "    libpath=['-L/the/first/library/path/of/lo', '-L/the/second/library/path/of/lo'],",
                "    cflags=['lo_cflags'],", "    cxxflags=['lo_cxxflags'],",
                "    cmdlinemacros={'cmdlinemacro_lo': 'value_lo'},",
                "    libs=['-llo'])"
            ]))

        hi = fs.rootdirectory().add(name='hi', entry=Directory())
        hi.add(name=const.CONFIX2_DIR,
               entry=File(lines=[
                   'hi_c = C(filename="hi_c.c")',
                   'hi_cc = CXX(filename="hi_cc.cc")',
                   'LIBRARY(basename="hi", members=[hi_c, hi_cc])'
               ]))
        hi.add(name='hi_c.c',
               entry=File(
                   lines=["// CONFIX:REQUIRE_SYMBOL('lo', URGENCY_ERROR)"]))
        hi.add(name='hi_cc.cc',
               entry=File(
                   lines=["// CONFIX:REQUIRE_SYMBOL('lo', URGENCY_ERROR)"]))

        self.__package = LocalPackage(rootdirectory=fs.rootdirectory(),
                                      setups=[ExplicitSetup(use_libtool=True)])
        self.__package.boil(external_nodes=[])
        self.__package.output()

        pass
Exemplo n.º 6
0
def _generate(source, use_libtool, explicit):
    if explicit:
        setup = ExplicitSetup(use_libtool=use_libtool)
    else:
        setup = ConfixSetup(use_libtool=use_libtool)
        pass
    package = LocalPackage(rootdirectory=source, setups=[setup])
    package.boil(external_nodes=[])
    package.output()
    pass
Exemplo n.º 7
0
    def test(self):
        rootdirectory = Directory()
        rootdirectory.add(name=const.CONFIX2_PKG,
                          entry=File(lines=[
                              "PACKAGE_NAME('" + self.__class__.__name__ +
                              "')", "PACKAGE_VERSION('1.2.3')"
                          ]))
        rootdirectory.add(
            name=const.CONFIX2_DIR,
            entry=File(
                lines=["DIRECTORY(['include'])", "DIRECTORY(['source'])"]))

        include = rootdirectory.add(name='include', entry=Directory())
        include.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["H(filename='file.h', relocate_to=['source'])"]))
        include.add(name='file.h',
                    entry=File(lines=['#include <another_file.h>']))

        source = rootdirectory.add(name='source', entry=Directory())
        source.add(name=const.CONFIX2_DIR, entry=File(lines=[]))

        package = LocalPackage(rootdirectory=rootdirectory,
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])

        include_builder = package.rootbuilder().find_entry_builder(
            path=['include'])
        source_builder = package.rootbuilder().find_entry_builder(
            path=['source'])

        self.failIf(include_builder is None)
        self.failIf(source_builder is None)

        # the include directory must not require anything - the only
        # builder was relocated to the source directory.
        for r in include_builder.requires():
            self.failIf(isinstance(r, Require_CInclude), r)
            pass

        # whereas the source directory must require the header that
        # file.h includes.
        for r in source_builder.requires():
            if isinstance(
                    r, Require_CInclude) and r.filename() == 'another_file.h':
                break
            pass
        else:
            self.fail()
            pass

        pass
Exemplo n.º 8
0
    def test(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["ADD_DIRECTORY('dir')"]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        self.failIf(package.rootdirectory().get('dir') is None)
        self.failUnless(type(package.rootdirectory().get('dir')) is Directory)
        pass
Exemplo n.º 9
0
    def test(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["from libconfix.core.filesys.file import File",
                              "if '"+str(fs.rootdirectory())+"' == str(CURRENT_DIRECTORY()):",
                              "  CURRENT_DIRECTORY().add(name='ok', entry=File())"]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        self.failUnless(package.rootdirectory().get('ok'))
        pass
Exemplo n.º 10
0
    def testIface(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File([
                'PACKAGE_NAME("Provide_CInclude_and_Require_CInclude.testIface")',
                'PACKAGE_VERSION("1.2.3")'
            ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "PROVIDE_H(filename='file*')", "PROVIDE_H(filename='file')",
                "PROVIDE_H(filename='file?')",
                "PROVIDE_H(filename='fileblah', match=AUTO_MATCH)"
            ]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])

        found = 0
        for p in package.rootbuilder().provides():
            self.failUnless(isinstance(p, Provide_CInclude))
            if p.string() == 'file*':
                self.failUnless(p.match() == Provide_CInclude.GLOB_MATCH)
                found += 1
                continue
            if p.string() == 'file':
                self.failUnless(p.match() == Provide_CInclude.EXACT_MATCH)
                found += 1
                continue
            if p.string() == 'file?':
                self.failUnless(p.match() == Provide_CInclude.GLOB_MATCH)
                found += 1
                continue
            if p.string() == 'fileblah':
                self.failUnless(p.match() == Provide_CInclude.EXACT_MATCH)
                found += 1
                continue
            pass
        self.failUnlessEqual(found, 4)
        pass
Exemplo n.º 11
0
    def test(self):
        fs = FileSystem(path=self.rootpath())
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('AutoConfArchiveTest')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["CONFIGURE_AC(lines=['AC_CXX_NAMESPACES'],",
                              "             order=AC_PROGRAMS)"]))
        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=fs.rootdirectory().abspath(),
                            path=None,
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        pass
Exemplo n.º 12
0
    def test__no_files(self):
        fs = FileSystem(path=['dont', 'care'])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File())
        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()

        rootdir_automake_builder = find_automake_output_builder(package.rootbuilder())
        self.failIf(rootdir_automake_builder is None)

        self.failIf(rootdir_automake_builder.configure_ac().unique_file_in_srcdir() is None)
        self.failUnless(rootdir_automake_builder.configure_ac().unique_file_in_srcdir() in ('Confix2.dir', 'Confix2.pkg'))

        pass
Exemplo n.º 13
0
    def test(self):
        fs = FileSystem(path=['don\'t', 'care'])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('ScriptPluginTest')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["ADD_SCRIPT(filename='script')"]))
        fs.rootdirectory().add(
            name='script',
            entry=File())
        
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()

        script = package.rootbuilder().find_entry_builder(['script'])
        self.failIf(script is None)
        pass
Exemplo n.º 14
0
    def test(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["SET_FILE_PROPERTY(filename='file', name='a', value=1)"]))
        fs.rootdirectory().add(
            name='file',
            entry=File())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        f = fs.rootdirectory().get('file')
        self.failIf(f is None)
        self.failUnless(f.get_property('a') == 1)
        pass
Exemplo n.º 15
0
    def test__basic(self):
        package = LocalPackage(
            rootdirectory=relocated_header.make_package_source(
                package_name=self.__class__.__name__),
            setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])

        exe_builder = package.rootbuilder().find_entry_builder(['exe'])
        lib_implementation_builder = package.rootbuilder().find_entry_builder(
            ['lib_implementation'])
        include_builder = package.rootbuilder().find_entry_builder(['include'])
        self.failIf(exe_builder is None)
        self.failIf(lib_implementation_builder is None)
        self.failIf(include_builder is None)

        self.failUnless(lib_implementation_builder in
                        package.digraph().successors(exe_builder))
        self.failUnless(include_builder in package.digraph().successors(
            lib_implementation_builder))

        pass
Exemplo n.º 16
0
    def test__ADD_EXTRA_DIST(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["ADD_EXTRA_DIST(filename='file')"]))
        fs.rootdirectory().add(name='file', entry=File())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        rootdir_automake_builder = find_automake_output_builder(
            package.rootbuilder())
        self.failUnless(
            'file' in rootdir_automake_builder.makefile_am().extra_dist())
        pass
Exemplo n.º 17
0
    def test__MAKEFILE_AM(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["MAKEFILE_AM(line='" + token + "')"]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        rootdir_automake_builder = find_automake_output_builder(
            package.rootbuilder())
        self.failUnless(
            token in rootdir_automake_builder.makefile_am().lines())
        pass
Exemplo n.º 18
0
    def test__CALL_MAKE_AND_RESCAN(self):
        fs = FileSystem(self.rootpath())
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(name=const.CONFIX2_DIR,
                               entry=File(lines=['CALL_MAKE_AND_RESCAN()']))
        fs.rootdirectory().add(
            name='Makefile',
            entry=File(lines=['all:', '\t@touch the_file', '']))

        fs.sync()  # the make program needs something to hold on to
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])

        package.boil(external_nodes=[])

        self.failUnless(fs.rootdirectory().find(['the_file']))
        pass
Exemplo n.º 19
0
    def setUp(self):
        PersistentTestCase.setUp(self)
        self.fs_ = FileSystem(path=self.rootpath())

        self.build_ = self.fs_.rootdirectory().add(name='build',
                                                   entry=Directory())

        self.source_ = self.fs_.rootdirectory().add(name='source',
                                                    entry=Directory())
        self.source_.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                'PACKAGE_NAME("CheckProgramTest")', 'PACKAGE_VERSION("1.2.3")'
            ]))
        self.source_.add(name=const.CONFIX2_DIR,
                         entry=File(lines=[
                             "TESTS_ENVIRONMENT('name', 'value')",
                             "EXECUTABLE(center=C(filename='main.c'),",
                             "           exename='the-test-program',",
                             "           what=EXECUTABLE_CHECK)"
                         ]))
        self.source_.add(
            name='main.c',
            entry=File(lines=[
                '#include <sys/types.h>', '#include <sys/stat.h>',
                '#include <fcntl.h>', '#include <stdlib.h>',
                '#include <string.h>', 'int main(void) {',
                '    const char* name = getenv("name");', '    if (!name)',
                '        return 1;', '    if (strcmp(name, "value"))',
                '        return 1;', '    return open("' +
                os.sep.join(self.build_.abspath() + ['my-check-was-here']) +
                '",', '                O_CREAT|O_RDWR, 0644) >=0?0:1;', '}'
            ]))

        self.package_ = LocalPackage(
            rootdirectory=self.source_,
            setups=[ExplicitSetup(use_libtool=self.use_libtool())])
        self.package_.boil(external_nodes=[])
        self.package_.output()
        pass
Exemplo n.º 20
0
    def test__with_confix2_dir(self):

        # Explicitly adding 'subdir' as subdirectory to be built, we
        # check that an eventual Confix2.dir file is recognized an
        # executed.

        # This is done by adding a file to the subdirectory, and then
        # adding a file property to it from the subdir's Confix2.dir
        # file.

        fs = FileSystem(path=[])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["DIRECTORY(path=['subdir'])"]))
        subdir = fs.rootdirectory().add(name='subdir', entry=Directory())
        dummy_property_receiver_file = subdir.add(
            name='dummy_property_receiver_file', entry=File())
        subdir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "SET_FILE_PROPERTY(filename='dummy_property_receiver_file',",
                "                  name='the_property',",
                "                  value='the_value')"
            ]))
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        self.failIf(
            package.rootbuilder().find_entry_builder(['subdir']) is None)
        self.failUnlessEqual(
            dummy_property_receiver_file.get_property('the_property'),
            'the_value')
        pass
Exemplo n.º 21
0
    def do_test(self, use_libtool):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(
            name='source',
            entry=relocated_header.make_package_source(
                package_name=self.__class__.__name__))
        build = fs.rootdirectory().add(name='build', entry=Directory())

        package = LocalPackage(rootdirectory=source,
                               setups=[ExplicitSetup(use_libtool=use_libtool)])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=source.abspath(),
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=source.abspath(),
                            builddir=build.abspath(),
                            prefix=None)
        make.make(builddir=build.abspath(), args=[])

        pass
Exemplo n.º 22
0
    def test__without_confix2_dir(self):

        # See if 'subdir' is built when we explicitly say that it
        # should. We do not add a Confix2.dir file to 'subdir'.

        fs = FileSystem(path=[])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["DIRECTORY(path=['subdir'])"]))
        fs.rootdirectory().add(name='subdir', entry=Directory())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=True)])
        package.boil(external_nodes=[])

        self.failIf(
            package.rootbuilder().find_entry_builder(['subdir']) is None)
        pass
Exemplo n.º 23
0
    def test__CALL_MAKE_AND_RESCAN_SYNC(self):

        # CALL_MAKE_AND_RESCAN_SYNC() is supposed to make files that
        # were created by the call to make immediately available to the
        # further code in Confix2.dir. We check this in the Confix2.dir,
        # and if we found the created file, we set a file property on
        # the Makefile which we evaluate later in the test routine. (We
        # could raise an exception in Confix2.dir as well, but that
        # makes the test result less obvious.

        fs = FileSystem(self.rootpath())
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('" + self.__class__.__name__ +
                                   "')", "PACKAGE_VERSION('1.2.3')"
                               ]))
        makefile = fs.rootdirectory().add(
            name='Makefile',
            entry=File(lines=['all:', '\t@touch the_file_created_by_make']))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'CALL_MAKE_AND_RESCAN_SYNC()',
                'if FIND_ENTRY("the_file_created_by_make"):',
                '    SET_FILE_PROPERTY("Makefile", "saw_the_file_created_by_make", True)',
            ]))

        fs.sync()  # the make program needs something to hold on to
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitSetup(use_libtool=False)])

        package.boil(external_nodes=[])

        self.failUnless(
            makefile.get_property('saw_the_file_created_by_make') is True)
        pass
Exemplo n.º 24
0
    def test__basic(self):
        sourcedir = Directory()
        sourcedir.add(name=const.CONFIX2_PKG,
                      entry=File(lines=[
                          "PACKAGE_NAME('" + self.__class__.__name__ +
                          "')", "PACKAGE_VERSION('1.2.3')"
                      ]))
        sourcedir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "DIRECTORY(['lolibrary'])", "DIRECTORY(['hilibrary'])",
                "DIRECTORY(['executable'])"
            ]))

        lolibrary_dir = sourcedir.add(name='lolibrary', entry=Directory())
        hilibrary_dir = sourcedir.add(name='hilibrary', entry=Directory())
        executable_dir = sourcedir.add(name='executable', entry=Directory())

        lolibrary_dir.add(name=const.CONFIX2_DIR,
                          entry=File(lines=[
                              "LIBRARY(members=[H(filename='lo.h'),",
                              "                 C(filename='lo1.c'),",
                              "                 C(filename='lo2.c')],",
                              "        basename='hansi')"
                          ]))
        lolibrary_dir.add(
            name='lo.h',
            entry=File(lines=[
                '#ifndef LO_H', '#define LO_H', '#ifdef __cplusplus',
                'extern "C" {', '#endif', 'void lo1(void);', 'void lo2(void);',
                '#ifdef __cplusplus', '}', '#endif', '#endif'
            ]))
        lolibrary_dir.add(
            name='lo1.c',
            entry=File(lines=['#include "lo.h"', 'void lo1(void) { lo2(); }']))
        lolibrary_dir.add(
            name='lo2.c',
            entry=File(lines=['#include "lo.h"', 'void lo2(void) {}']))

        hilibrary_dir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "LIBRARY(members=[H(filename='hi.h', install=['hi']),",
                "                 CXX(filename='hi.cc')])"
            ]))
        hilibrary_dir.add(
            name='hi.h',
            entry=File(lines=[
                "#ifndef HI_HI_H", "#define HI_HI_H", "void hi();", "#endif"
            ]))
        hilibrary_dir.add(
            name='hi.cc',
            entry=File(lines=[
                '#include "hi.h"', '#include <lo.h>', 'void hi() { lo1(); }'
            ]))

        executable_dir.add(name=const.CONFIX2_DIR,
                           entry=File(lines=[
                               "EXECUTABLE(exename='the_executable',",
                               "           center=CXX(filename='main.cc'))"
                           ]))
        executable_dir.add(name='main.cc',
                           entry=File(lines=[
                               '#include <hi/hi.h>', 'int main() {',
                               '    hi();', '    return 0;', '}'
                           ]))

        package = LocalPackage(rootdirectory=sourcedir,
                               setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])

        # see if we have got the directories right
        found_lodir_builder = package.rootbuilder().find_entry_builder(
            ['lolibrary'])
        self.failIf(found_lodir_builder is None)
        found_hidir_builder = package.rootbuilder().find_entry_builder(
            ['hilibrary'])
        self.failIf(found_hidir_builder is None)
        found_exedir_builder = package.rootbuilder().find_entry_builder(
            ['executable'])
        self.failIf(found_exedir_builder is None)

        # lodirectory has lolibrary has H(lo.h), C(lo1.c), C(lo2.c)
        # ---------------------------------------------------------

        # we called H() and C() in the directory's Confix2.dir, as
        # arguments of LIBRARY(). the side effect of this must have
        # been to add the corresponding source files to the directory.
        found_lo_lo_h = None
        found_lo_lo1_c = None
        found_lo_lo2_c = None
        for b in found_lodir_builder.iter_builders():
            if type(b) is HeaderBuilder and b.file().name() == 'lo.h':
                found_lo_lo_h = b
                pass
            if type(b) is CBuilder and b.file().name() == 'lo1.c':
                found_lo_lo1_c = b
                pass
            if type(b) is CBuilder and b.file().name() == 'lo2.c':
                found_lo_lo2_c = b
                pass
            pass
        self.failIf(found_lo_lo_h is None)
        self.failIf(found_lo_lo1_c is None)
        self.failIf(found_lo_lo2_c is None)

        # find the library itself and see if it has the right
        # properties.
        found_lolib_builder = None
        for b in found_lodir_builder.iter_builders():
            if type(b) is LibraryBuilder:
                self.failUnless(found_lolib_builder is None,
                                str(b))  # we build only one library
                found_lolib_builder = b
                pass
            pass
        self.failIf(found_lolib_builder is None)
        self.failUnless(found_lolib_builder.basename() == 'hansi')

        # see if it has the right members
        found_lo_lo_h = None
        found_lo_lo1_c = None
        found_lo_lo2_c = None
        for b in found_lolib_builder.members():
            if type(b) is HeaderBuilder and b.file().name() == 'lo.h':
                found_lo_lo_h = b
                continue
            if type(b) is CBuilder and b.file().name() == 'lo1.c':
                found_lo_lo1_c = b
                continue
            if type(b) is CBuilder and b.file().name() == 'lo2.c':
                found_lo_lo2_c = b
                continue
            pass
        self.failIf(found_lo_lo_h is None)
        self.failIf(found_lo_lo1_c is None)
        self.failIf(found_lo_lo2_c is None)

        pass
Exemplo n.º 25
0
    def do_test(self, use_libtool):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(
            name='source',
            entry=Directory())
        build = fs.rootdirectory().add(
            name='build',
            entry=Directory())

        source.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('"+self.__class__.__name__+"')",
                              "PACKAGE_VERSION('1.2.3')"]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["DIRECTORY(['lolibrary'])",
                              "DIRECTORY(['hilibrary'])",
                              "DIRECTORY(['executable'])"]))

        lolibrary_dir = source.add(
            name='lolibrary',
            entry=Directory())
        hilibrary_dir = source.add(
            name='hilibrary',
            entry=Directory())
        executable_dir = source.add(
            name='executable',
            entry=Directory())

        lolibrary_dir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["LIBRARY(members=[H(filename='lo.h'),",
                              "                 C(filename='lo1.c'),",
                              "                 C(filename='lo2.c')],",
                              "        basename='hansi')"]))
        lolibrary_dir.add(
            name='lo.h',
            entry=File(lines=['#ifndef LO_H',
                              '#define LO_H',
                              '#ifdef __cplusplus',
                              'extern "C" {',
                              '#endif',
                              'void lo1(void);',
                              'void lo2(void);',
                              '#ifdef __cplusplus',
                              '}',
                              '#endif',
                              '#endif']))
        lolibrary_dir.add(
            name='lo1.c',
            entry=File(lines=['#include "lo.h"',
                              'void lo1(void) { lo2(); }']))
        lolibrary_dir.add(
            name='lo2.c',
            entry=File(lines=['#include "lo.h"',
                              'void lo2(void) {}']))

        hilibrary_dir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["LIBRARY(members=[H(filename='hi.h', install=['hi']),",
                              "                 CXX(filename='hi.cc')])"]))
        hilibrary_dir.add(
            name='hi.h',
            entry=File(lines=["#ifndef HI_HI_H",
                              "#define HI_HI_H",
                              "void hi();",
                              "#endif"]))
        hilibrary_dir.add(
            name='hi.cc',
            entry=File(lines=['#include "hi.h"',
                              '#include <lo.h>',
                              'void hi() { lo1(); }']))

        executable_dir.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["EXECUTABLE(exename='the_executable',",
                              "           center=CXX(filename='main.cc'))"]))
        executable_dir.add(
            name='main.cc',
            entry=File(lines=['#include <hi/hi.h>',
                              'int main() {',
                              '    hi();',
                              '    return 0;',
                              '}']))

        package = LocalPackage(rootdirectory=source,
                               setups=[ExplicitSetup(use_libtool=use_libtool)])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        bootstrap.bootstrap(
            packageroot=source.abspath(),
            use_kde_hack=False,
            argv0=sys.argv[0])
        configure.configure(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            prefix=None)
        make.make(
            builddir=build.abspath(),
            args=[])

        pass