Esempio n. 1
0
    def test__basic(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=make_package())
        build = fs.rootdirectory().add(name='build', entry=Directory())
        install = fs.rootdirectory().add(name='install', entry=Directory())

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   Boilerplate(),
                                   Plainfile(),
                                   CMake(library_dependencies=False)
                               ])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        commands.cmake(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())])
        commands.make(builddir=build.abspath(), args=['install'])

        self.failUnless(
            os.path.isfile(
                os.sep.join(
                    self.rootpath() +
                    ['install', 'share', 'subdir', 'data', 'plainfile_data'])))
        self.failUnless(
            os.path.isfile(
                os.sep.join(
                    self.rootpath() +
                    ['install', 'subdir', 'prefix', 'plainfile_prefix'])))

        pass
Esempio n. 2
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())
        lo1 = fs.rootdirectory().add(
            name='lo1',
            entry=Directory())
        lo2 = fs.rootdirectory().add(
            name='lo2',
            entry=Directory())
        hi = fs.rootdirectory().add(
            name='hi',
            entry=Directory())
        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[NullSetup()])

        lo1_builder = DirectoryBuilder(directory=lo1)
        lo1_builder.add_provide(Provide_Symbol(symbol='the_ambiguous_symbol'))
        package.rootbuilder().add_builder(lo1_builder)

        lo2_builder = DirectoryBuilder(directory=lo2)
        lo2_builder.add_provide(Provide_Symbol(symbol='the_ambiguous_symbol'))
        package.rootbuilder().add_builder(lo2_builder)

        hi_builder = DirectoryBuilder(directory=hi)
        hi_builder.add_require(Require_Symbol(symbol='the_ambiguous_symbol', found_in=[]))
        package.rootbuilder().add_builder(hi_builder)

        self.failUnlessRaises(Error, package.boil, external_nodes=[])
        pass
Esempio n. 3
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())

        lo = fs.rootdirectory().add(
            name='lo',
            entry=Directory())

        hi = fs.rootdirectory().add(
            name='hi',
            entry=Directory())

        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[NullSetup()])

        lodir_builder = DirectoryBuilder(directory=lo)
        lodir_builder.add_builder(DeferredProvider(provide=Provide_Symbol(symbol='the_deferred_provided_symbol')))
        package.rootbuilder().add_builder(lodir_builder)

        hidir_builder = DirectoryBuilder(directory=hi)
        hidir_builder.add_require(Require_Symbol(symbol='the_deferred_provided_symbol',
                                                 found_in=[],
                                                 urgency=Require.URGENCY_ERROR))
        package.rootbuilder().add_builder(hidir_builder)

        package.boil(external_nodes=[])

        self.failUnless(lodir_builder in package.digraph().successors(hidir_builder))
        pass
Esempio n. 4
0
    def test(self):
        fs = FileSystem(path=['', 'path', 'to', 'it'])
        fs.rootdirectory().add(name=const.CONFIX2_PKG,
                               entry=File(lines=[
                                   "PACKAGE_NAME('ProvideRequireInclude')",
                                   "PACKAGE_VERSION('1.2.3')"
                               ]))
        fs.rootdirectory().add(name=const.CONFIX2_DIR, entry=File())

        lo = fs.rootdirectory().add(name='lo', entry=Directory())
        lo.add(name=const.CONFIX2_DIR, entry=File(lines=["PROVIDE_H('lo.h')"]))

        hi = fs.rootdirectory().add(name='hi', entry=Directory())
        hi.add(name=const.CONFIX2_DIR,
               entry=File(lines=["REQUIRE_H('lo.h', URGENCY_ERROR)"]))

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

        lo_builder = package.rootbuilder().find_entry_builder(['lo'])
        hi_builder = package.rootbuilder().find_entry_builder(['hi'])

        self.failUnless(lo_builder in package.digraph().successors(hi_builder))
        pass
Esempio n. 5
0
    def test__publicinstall_flat(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=Directory())
        build = fs.rootdirectory().add(name='build', entry=Directory())
        install = fs.rootdirectory().add(name='install', entry=Directory())

        source.add(name=const.CONFIX2_PKG,
                   entry=File(lines=[
                       "PACKAGE_NAME('test_publicinstall_flat')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR, entry=File())
        source.add(name='file.idl', entry=File())

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   AutoBoilerplate(),
                                   CMake(library_dependencies=False),
                                   IDLSetup()
                               ])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        commands.cmake(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())])
        commands.make(builddir=build.abspath(), args=['install'])

        scan.rescan_dir(install)

        self.failUnless(install.find(['include', 'file.idl']))

        pass
Esempio n. 6
0
    def test(self):
        fs = FileSystem(path=['don\'t', 'care'])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "PACKAGE_NAME('" + self.__class__.__name__ +
                "')", "PACKAGE_VERSION('1.2.3')",
                "from libconfix.setups.explicit_setup import ExplicitSetup",
                "SETUP([ExplicitSetup(use_libtool=True)])"
            ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["DIRECTORY(['dir1'])", "DIRECTORY(['dir2'])"]))
        dir1 = fs.rootdirectory().add(name='dir1', entry=Directory())
        dir2 = fs.rootdirectory().add(name='dir2', entry=Directory())
        dir1.add(name=const.CONFIX2_DIR,
                 entry=File(lines=["PROVIDE_SYMBOL('x')"]))
        dir2.add(name=const.CONFIX2_DIR,
                 entry=File(lines=["PROVIDE_SYMBOL('x')"]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=None)
        try:
            package.boil(external_nodes=[])
            self.fail()
        except Error:
            pass
        pass
Esempio n. 7
0
    def test__basic(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=Directory())
        build = fs.rootdirectory().add(name='build', entry=Directory())
        install = fs.rootdirectory().add(name='install', entry=Directory())

        source.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "from libconfix.setups.boilerplate import Boilerplate",
                "from libconfix.setups.cmake import CMake",
                "from libconfix.setups.script import Script",
                "PACKAGE_NAME('cmake-script-build')",
                "PACKAGE_VERSION('1.2.3')",
                "SETUP([Boilerplate(), CMake(library_dependencies=False), Script()])",
            ]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=['ADD_SCRIPT(filename="script")']))
        source.add(name='script', entry=File())

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

        commands.cmake(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())])
        commands.make(builddir=build.abspath(), args=['install'])

        stat = os.stat(os.sep.join(install.abspath() + ['bin', 'script']))
        pass
Esempio n. 8
0
    def test__explicit_no_public_visibility(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=Directory())
        build = fs.rootdirectory().add(name='build', entry=Directory())
        install = fs.rootdirectory().add(name='install', entry=Directory())

        source.add(
            name=const.CONFIX2_PKG,
            entry=File(
                lines=["PACKAGE_NAME('blah')", "PACKAGE_VERSION('1.2.3')"]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=["H(filename='header.h', public=False)"]))
        source.add(name='header.h', entry=File())

        package = LocalPackage(
            rootdirectory=source,
            setups=[Boilerplate(),
                    C(), CMake(library_dependencies=False)])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())])
        commands.make(builddir=build.abspath(), args=['install'])

        scan.rescan_dir(install)

        self.failIf(install.find(['include', 'header.h']))

        pass
Esempio n. 9
0
    def test__localinstall_not_absolutely_necessary(self):
        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('test_localinstall_not_absolutely_necessary')",
                "PACKAGE_VERSION('1.2.3')"
            ]))
        source.add(name=const.CONFIX2_DIR, entry=File())
        source.add(name='file.idl', entry=File())

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   AutoBoilerplate(),
                                   CMake(library_dependencies=False),
                                   IDLSetup()
                               ])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        commands.cmake(packageroot=source.abspath(),
                       builddir=build.abspath(),
                       args=[])
        commands.make(builddir=build.abspath(), args=[])

        scan.rescan_dir(build)

        self.failUnless(build.find(['confix-include', 'file.idl']))

        pass
Esempio n. 10
0
    def test__basic(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                'PACKAGE_NAME("HierarchyInMemoryTest.basic")',
                'PACKAGE_VERSION("1.2.3")'
            ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'DIRECTORY(["directory0"])', 'DIRECTORY(["directory1"])'
            ]))
        fs.rootdirectory().add(name='directory0', entry=Directory())
        fs.rootdirectory().add(name='directory1', entry=Directory())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ExplicitDirectorySetup(),
                                       CMakeSetup()])
        package.boil(external_nodes=[])
        package.output()

        cmake_output_builder = find_cmake_output_builder(package.rootbuilder())

        self.failUnlessEqual(
            len(cmake_output_builder.local_cmakelists().get_subdirectories()),
            2
            # plus the admin stuff, confix-admin/cmake/Modules
            + 4)
        self.failUnless('directory0' in cmake_output_builder.local_cmakelists(
        ).get_subdirectories())
        self.failUnless('directory1' in cmake_output_builder.local_cmakelists(
        ).get_subdirectories())

        pass
Esempio n. 11
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
Esempio n. 12
0
    def test__generated_plainfile_install(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=Directory())
        build = fs.rootdirectory().add(name='build', entry=Directory())
        install = fs.rootdirectory().add(name='install', entry=Directory())

        source.add(name=const.CONFIX2_PKG,
                   entry=File(lines=[
                       "PACKAGE_NAME('generated_plainfile_install')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "ADD_PLAINFILE(filename='prefixfile', prefixdir='prefixdir')",
                "ADD_PLAINFILE(filename='datafile', datadir='datadir')",
                "CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(",
                "    outputs=['prefixfile', 'datafile'],",
                "    commands=[('touch', ['prefixfile']),",
                "              ('touch', ['datafile'])],",
                "    depends=[],",
                ")",
                # without doing anything, nothing will be built. hook
                # it to the 'all' target.
                "CMAKE_CMAKELISTS_ADD_CUSTOM_TARGET(",
                "    name='generate_those_bloody_files_when_I_say_make',",
                "    all=True,",
                "    depends=['prefixfile', 'datafile'],",
                ")",
            ]))
        source.add(name='prefixfile',
                   entry=File(state=FileState.VIRTUAL, lines=[]))
        source.add(name='datafile',
                   entry=File(state=FileState.VIRTUAL, lines=[]))

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   Boilerplate(),
                                   Plainfile(),
                                   CMake(library_dependencies=False)
                               ])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(
            packageroot=source.abspath(),
            builddir=build.abspath(),
            args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())])
        commands.make(builddir=build.abspath(), args=['install'])

        scan.rescan_dir(install)

        self.failUnless(install.find(['prefixdir', 'prefixfile']))
        self.failUnless(install.find(['share', 'datadir', 'datafile']))

        pass
Esempio n. 13
0
    def test__relative_path(self):
        fs = FileSystem(path=['a', 'b'])
        subdir = fs.rootdirectory().add(name='subdir', entry=Directory())
        subsubdir = subdir.add(name='subsubdir', entry=Directory())
        file = subsubdir.add(name='file', entry=File())

        self.failUnless(
            subsubdir.relpath(fs.rootdirectory()) == ['subdir', 'subsubdir'])
        self.failUnless(file.relpath(subdir) == ['subsubdir', 'file'])
        pass
Esempio n. 14
0
    def test__two_directories_with_generator_same_outputfilename(self):
        """
        The artificial custom target that we generate for every custom
        command has a name that is derived from the command's
        output(s). This leads to clashes when two directories have
        commands that generate outputs with the same name.
        """

        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('two_directories_with_generator_same_outputfilename')",
                "PACKAGE_VERSION('1.2.3')"
            ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=['DIRECTORY(["dira"])', 'DIRECTORY(["dirb"])']))

        dira = source.add(name='dira', entry=Directory())
        dira.add(name=const.CONFIX2_DIR,
                 entry=File(lines=[
                     'CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(',
                     '    outputs=["output"],',
                     '    commands=[("touch", ["output"])],', '    depends=[])'
                 ]))

        dirb = source.add(name='dirb', entry=Directory())
        dirb.add(name=const.CONFIX2_DIR,
                 entry=File(lines=[
                     'CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(',
                     '    outputs=["output"],',
                     '    commands=[("touch", ["output"])],', '    depends=[])'
                 ]))

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   Boilerplate(),
                                   Plainfile(),
                                   CMake(library_dependencies=False)
                               ])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(),
                       builddir=build.abspath(),
                       args=[])
        commands.make(builddir=build.abspath(), args=[])

        pass
Esempio n. 15
0
    def test__library_depends_on_generated_header__from_a_header_only_directory(
            self):
        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('library_depends_on_generated_header__from_a_header_only_directory')",
                "PACKAGE_VERSION('1.2.3')"
            ]))
        generated_header = source.add(name='generated-header',
                                      entry=Directory())

        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       "DIRECTORY(['generated-header'])",
                       "DIRECTORY(['library1'])",
                       "DIRECTORY(['library2'])",
                   ]))

        library1 = source.add(name='library1', entry=Directory())
        library1.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "LIBRARY(members=[C(filename='using-generated-header.c')])"
            ]))
        library1.add(name='using-generated-header.c',
                     entry=File(lines=['#include <generated-header.h>']))

        library2 = source.add(name='library2', entry=Directory())
        library2.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "LIBRARY(members=[C(filename='using-generated-header.c')])"
            ]))
        library2.add(name='using-generated-header.c',
                     entry=File(lines=['#include <generated-header.h>']))

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   Boilerplate(),
                                   C(),
                                   CMake(library_dependencies=False),
                                   GeneratedHeaderSetup()
                               ])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(), builddir=build.abspath())
        commands.make(builddir=build.abspath(), args=['-j', 'VERBOSE=1'])
        pass
Esempio n. 16
0
    def test__no_timestamp_clobber(self):
        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('test_no_timestamp_clobber')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       "for f in xrange(200):",
                       "    H(filename='%s.h' % str(f), install=['subdir'])",
                   ]))
        for f in xrange(200):
            source.add(name='%s.h' % str(f), entry=File())
            pass

        package = LocalPackage(
            rootdirectory=source,
            setups=[ExplicitDirectorySetup(),
                    ExplicitCSetup(),
                    CMakeSetup()])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(),
                       builddir=build.abspath(),
                       args=[])

        commands.make(builddir=build.abspath(), args=[])
        mtimes = {}
        for f in xrange(200):
            mtime = os.stat(
                os.sep.join(build.abspath() +
                            ['confix-include', 'subdir',
                             '%s.h' % str(f)])).st_mtime
            mtimes[f] = mtime
            pass

        # wait a bit and then call 'make' again
        time.sleep(1)

        commands.make(builddir=build.abspath(), args=[])
        for f in xrange(200):
            mtime = os.stat(
                os.sep.join(build.abspath() +
                            ['confix-include', 'subdir',
                             '%s.h' % str(f)])).st_mtime
            self.failIf(mtime != mtimes[f], f)
            pass
        pass
Esempio n. 17
0
 def setUp(self):
     self.fs_ = dirhier.packageroot()
     dir1 = self.fs_.rootdirectory().add(name='dir1', entry=Directory())
     dir1.add(name=const.CONFIX2_DIR, entry=File(lines=[]))
     dir2 = dir1.add(name='dir2', entry=Directory())
     dir2.add(name=const.CONFIX2_DIR, entry=File(lines=[]))
     dir3 = dir2.add(name='dir3', entry=Directory())
     dir3.add(name=const.CONFIX2_DIR, entry=File(lines=[]))
     dir3.add(name='file.c', entry=File(lines=[]))
     self.dir3_ = dir3
     pass
Esempio n. 18
0
    def test__parallel_build(self):
        num_dirs = 50

        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('test_basic')", "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       'DIRECTORY(["dir_' + str(i) + '"])' for i in xrange(50)
                   ] + ['DIRECTORY(["user"])']))

        for i in xrange(num_dirs):
            dir_i = source.add(name='dir_' + str(i), entry=Directory())
            dir_i.add(
                name=const.CONFIX2_DIR,
                entry=File(lines=[
                    "LIBRARY(members=[H(filename='file_" + str(i) +
                    ".h', ", "                   install=['prefix', 'subdir_" +
                    str(i) + "']), ", "                 C(filename='file_" +
                    str(i) + ".c')])"
                ]))
            dir_i.add(name='file_' + str(i) + '.h', entry=File())
            dir_i.add(name='file_' + str(i) + '.c', entry=File())
            pass

        user = source.add(name='user', entry=Directory())
        user.add(name=const.CONFIX2_DIR,
                 entry=File(lines=["LIBRARY(members=[C(filename='user.c')])"]))
        user.add(name='user.c',
                 entry=File(lines=[
                     '#include <prefix/subdir_' + str(i) + '/file_' + str(i) +
                     '.h>' for i in xrange(num_dirs)
                 ]))

        package = LocalPackage(
            rootdirectory=source,
            setups=[Boilerplate(),
                    C(), CMake(library_dependencies=False)])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(),
                       builddir=build.abspath(),
                       args=[])
        commands.make(builddir=build.abspath(), args=['-j'])

        pass
Esempio n. 19
0
    def test__reproduce_two_custom_targets(self):
        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('test_reproduce_two_custom_targets')",
                              "PACKAGE_VERSION('1.2.3')"]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'CMAKE_CMAKELISTS_ADD_FIND_CALL(',
                '    find_call=["ADD_CUSTOM_COMMAND(",',
                '               "    OUTPUT generated",',
                '               "    COMMAND sleep 1",',
                '               "    COMMAND echo custom command running",',
                '               "    COMMAND echo I was here >> generated",',
                '               "    COMMAND touch generated",',
                '               ")",',
                '               "ADD_CUSTOM_TARGET(",',
                '               "    my-all-1",',
                '               "    ALL",',
                '               "    DEPENDS generated",',
                '               ")",',
                '               "ADD_CUSTOM_TARGET(",',
                '               "    my-all-2",',
                '               "    ALL",',
                '               "    DEPENDS generated",',
                '               ")",',
                '               ],',
                '    flags=CMAKE_BUILDINFO_LOCAL)',
                ]))

        package = LocalPackage(rootdirectory=source,
                               setups=[Boilerplate(), CMake(library_dependencies=False)])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[])
        commands.make(builddir=build.abspath(), args=['-j2'])

        scan.rescan_dir(build)

        self.failUnlessEqual(build.get('generated').lines(), ['I was here', 'I was here'])
        
        pass
Esempio n. 20
0
    def test(self):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(
            name='source',
            entry=Directory())
        build = fs.rootdirectory().add(
            name='build',
            entry=Directory())
        install=fs.rootdirectory().add(
            name='install',
            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())
        source.add(
            name='main.cc',
            entry=File(lines=['// CONFIX:EXENAME("explicit-name")',
                              'int main() { return 0; }']))

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

        fs.sync()

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

        # we have written the fs to disk, but unfortunately we cannot
        # see what the build contributed to it (we don't implement
        # re-reading the fs that has changed under the hood)

        exe_path = install.abspath() + ['bin', 'explicit-name']
        self.failUnless(os.path.isfile(os.sep.join(exe_path)))
        
        pass
Esempio n. 21
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
Esempio n. 22
0
    def test(self):
        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=['CALL_MAKE_AND_RESCAN()']))
        source.add(
            name='Makefile',
            entry=File(lines=[
                'all:',
                '\tif test -e main.c; then echo "make being called twice"; exit 1; fi',
                '\techo "// CONFIX:EXENAME(\'the_executable_generated_by_a_call_to_make\')" > main.cc',
                '\techo "int main(void) {return 0;}" >> main.cc'
            ]))

        # during enlarge() we will call 'make' which expects the
        # Makefile being physically available in the physically
        # available directory, so flush it once ...
        fs.sync()

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

        # ... and, for the rest of it, we need the automake input
        # files as well.
        fs.sync()

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

        self.failUnless(
            os.path.isfile(
                os.sep.join(build.abspath() +
                            ['the_executable_generated_by_a_call_to_make'])))

        pass
Esempio n. 23
0
    def test__sourcefile_dependency(self):
        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('test_sourcefile_dependency')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       "H(filename='h.h', install=['subdir'])",
                   ]))
        h = source.add(name='h.h', entry=File())

        package = LocalPackage(
            rootdirectory=source,
            setups=[ExplicitDirectorySetup(),
                    ExplicitCSetup(),
                    CMakeSetup()])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(),
                       builddir=build.abspath(),
                       args=[])

        commands.make(builddir=build.abspath(), args=[])
        before_mtime = os.stat(
            os.sep.join(build.abspath() +
                        ['confix-include', 'subdir', 'h.h'])).st_mtime

        # wait a bit. then touch the source file, call make again, and
        # check that the file was locally installed again.
        time.sleep(1)

        h.add_lines(['x'])
        fs.sync()

        commands.make(builddir=build.abspath(), args=[])

        self.failUnless(
            os.stat(
                os.sep.join(build.abspath() +
                            ['confix-include', 'subdir', 'h.h'])).st_mtime >
            before_mtime)

        pass
Esempio n. 24
0
    def test__CONFIGURE_AC_ACINCLUDE_M4_propagate(self):
        """ We pass flags=[PROPAGATE] explicitly, to both
        ACINCLUDE_M4() and CONFIGURE_AC(), propagate it to a dependent
        node,"hi", and check if both go into acinclude.m4 and configure.ac."""

        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(
                lines=['PACKAGE_NAME("blah")', 'PACKAGE_VERSION("1.2.3")']))
        fs.rootdirectory().add(name=const.CONFIX2_DIR, entry=File())
        lo = fs.rootdirectory().add(name='lo', entry=Directory())
        lo.add(name=const.CONFIX2_DIR,
               entry=File(lines=[
                   'PROVIDE_SYMBOL("lo")',
                   'CONFIGURE_AC(lines=["the_token_for_configure_ac"],',
                   '             order=AC_PROGRAMS,',
                   '             flags=[PROPAGATE])',
                   'ACINCLUDE_M4(lines=["the_token_for_acinclude_m4"],',
                   '             flags=[PROPAGATE])'
               ]))
        hi = fs.rootdirectory().add(name='hi', entry=Directory())
        hi.add(name=const.CONFIX2_DIR,
               entry=File(lines=['REQUIRE_SYMBOL("lo", URGENCY_ERROR)']))

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

        configure_ac = fs.rootdirectory().find(['configure.ac'])
        acinclude_m4 = fs.rootdirectory().find(['acinclude.m4'])
        self.failIf(configure_ac is None)
        self.failIf(acinclude_m4 is None)

        for line in configure_ac.lines():
            if line == 'the_token_for_configure_ac':
                break
            pass
        else:
            self.fail()
            pass

        for line in acinclude_m4.lines():
            if line == 'the_token_for_acinclude_m4':
                break
            pass
        else:
            self.fail()
            pass
        pass
Esempio n. 25
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
    def test(self):
        fs = FileSystem(path=[])

        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(['external'])", "DIRECTORY(['linked'])"]))

        external = fs.rootdirectory().add(name='external', entry=Directory())
        external.add(name=const.CONFIX2_DIR,
                     entry=File(lines=[
                         "PROVIDE_SYMBOL('the-external-library')",
                         "CMAKE_EXTERNAL_LIBRARY(",
                         "    cflags=['my-cflag1', 'my-cflag2'],",
                         "    cxxflags=['my-cxxflag1', 'my-cxxflag2'])",
                     ]))

        linked = fs.rootdirectory().add(name='linked', entry=Directory())
        linked.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       "REQUIRE_SYMBOL('the-external-library', URGENCY_ERROR)",
                       "EXECUTABLE(center=C(filename='main.c'))"
                   ]))
        linked.add(name='main.c', entry=File(lines=["int main(void) {}"]))

        package = LocalPackage(
            rootdirectory=fs.rootdirectory(),
            setups=[ExplicitDirectorySetup(),
                    ExplicitCSetup(),
                    CMakeSetup()])
        package.boil(external_nodes=[])
        package.output()

        linked_cmake_output_builder = find_cmake_output_builder(
            package.rootbuilder().find_entry_builder(['linked']))
        self.failUnless('my-cflag1' in linked_cmake_output_builder.
                        local_cmakelists().get_definitions())
        self.failUnless('my-cflag2' in linked_cmake_output_builder.
                        local_cmakelists().get_definitions())
        self.failUnless('my-cxxflag1' in linked_cmake_output_builder.
                        local_cmakelists().get_definitions())
        self.failUnless('my-cxxflag2' in linked_cmake_output_builder.
                        local_cmakelists().get_definitions())
        pass
Esempio n. 27
0
    def test__relocated_header_requires_relocated_header(self):
        fs = FileSystem(path=['dont\'t', '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())

        include = fs.rootdirectory().add(name='include', entry=Directory())
        include.add(name=const.CONFIX2_DIR,
                    entry=File(lines=[
                        "RELOCATE_HEADER(filename='a.h',",
                        "                directory=['src'])",
                        "RELOCATE_HEADER(filename='b.h',",
                        "                directory=['src'])"
                    ]))
        include.add(name='a.h',
                    entry=File(lines=[
                        '#ifndef A_H', '#define A_H',
                        '// CONFIX:REQUIRE_H("b.h", REQUIRED)',
                        '#include "b.h"', 'void a(void);'
                        '#endif'
                    ]))
        include.add(
            name='b.h',
            entry=File(
                lines=['#ifndef B_H', '#define B_H', 'void b(void);'
                       '#endif']))

        src = fs.rootdirectory().add(name='src', entry=Directory())
        src.add(name=const.CONFIX2_DIR, entry=File())
        src.add(name='a.c',
                entry=File(lines=[
                    '#include <a.h>', '// CONFIX:REQUIRE_H("a.h", REQUIRED)',
                    'void a(void) {}'
                ]))
        src.add(name='b.c',
                entry=File(lines=[
                    '#include <b.h>', '// CONFIX:REQUIRE_H("b.h", REQUIRED)',
                    'void b(void) {}'
                ]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[ConfixSetup(use_libtool=False)])

        package.boil(external_nodes=[])

        pass
Esempio n. 28
0
    def test(self):
        root = Directory()
        root.add(name=const.CONFIX2_PKG,
                 entry=File(lines=[
                     'PACKAGE_NAME("' + self.__class__.__name__ +
                     '")', 'PACKAGE_VERSION("1.2.3")'
                 ]))
        root.add(name=const.CONFIX2_DIR, entry=File())

        ext_lib = root.add(name='ext-lib', entry=Directory())
        ext_lib.add(name=const.CONFIX2_DIR,
                    entry=File(lines=[
                        'PROVIDE_H("ext_lib.h")',
                        'PKG_CONFIG_LIBRARY(packagename="ext_lib")'
                    ]))

        main = root.add(name='main', entry=Directory())
        main.add(name='main.cc',
                 entry=File(lines=[
                     '#include <ext_lib.h>',
                     '// CONFIX:REQUIRE_H("ext_lib.h", REQUIRED)',
                     '// CONFIX:EXENAME("the_exe")', 'int main() { return 0; }'
                 ]))
        main.add(name=const.CONFIX2_DIR, entry=File())

        package = LocalPackage(
            rootdirectory=root,
            setups=[ConfixSetup(use_libtool=False),
                    PkgConfigSetup()])
        package.boil(external_nodes=[])
        package.output()

        maindir_builder = package.rootbuilder().find_entry_builder(['main'])
        self.failIf(maindir_builder is None)

        maindir_output_builder = find_automake_output_builder(maindir_builder)
        self.failIf(maindir_output_builder is None)

        self.failUnless('$(ext_lib_PKG_CONFIG_CFLAGS)' in
                        maindir_output_builder.makefile_am().am_cflags())
        self.failUnless('$(ext_lib_PKG_CONFIG_CFLAGS)' in
                        maindir_output_builder.makefile_am().am_cxxflags())

        main_ldadd = maindir_output_builder.makefile_am().compound_ldadd(
            compound_name='the_exe')
        self.failIf(main_ldadd is None)

        self.failUnless('$(ext_lib_PKG_CONFIG_LIBS)' in main_ldadd)
        pass
Esempio n. 29
0
    def test__workaround_library_and_custom_target(self):
        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('test_workaround_library_and_custom_target')",
                              "PACKAGE_VERSION('1.2.3')"]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'from libconfix.core.filesys.file import File, FileState',
                'from libconfix.plugins.cmake.out_cmake import find_cmake_output_builder',
                'cmake_output_builder = find_cmake_output_builder(CURRENT_BUILDER())',
                'cmake_output_builder.local_cmakelists().add_find_call(',
                '    find_call=["ADD_CUSTOM_COMMAND(",',
                '               "    OUTPUT generated.c file",',
                '               "    COMMAND sleep 1",',
                '               "    COMMAND echo custom command running",',
                '               "    COMMAND echo I was here >> generated",',
                '               "    COMMAND touch generated.c file",',
                '               ")",',
                '               ]),',
                'CURRENT_BUILDER().directory().add(name="generated.c", entry=File(lines=[], state=FileState.VIRTUAL))',
                'LIBRARY([C(filename="generated.c")])',
                'cmake_output_builder.local_cmakelists().add_custom_target(name="my-all-target", all=True, depends=["file"])',
                ]))

        package = LocalPackage(rootdirectory=source,
                               setups=[Boilerplate(),
                                       CMake(library_dependencies=False),
                                       C()])
        package.boil(external_nodes=[])
        package.output()

        fs.sync()

        commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[])
        commands.make(builddir=build.abspath(), args=['-j2'])

        scan.rescan_dir(build)

        self.failUnlessEqual(build.get('generated').lines(), ['I was here'])
        pass
Esempio n. 30
0
    def test(self):
        fs = FileSystem(path=self.rootpath())

        source = fs.rootdirectory().add(name='source', entry=Directory())
        source.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "PACKAGE_NAME('KDEHackTest')", "PACKAGE_VERSION('1.2.3')"
            ]))
        source.add(name=const.CONFIX2_DIR, entry=File())

        subdir = source.add(name='subdir', entry=Directory())
        subdir.add(name=const.CONFIX2_DIR, entry=File())

        build = fs.rootdirectory().add(name='build', entry=Directory())

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   AutomakeSetup(use_libtool=False),
                                   KDEHackSetup(),
                                   ImplicitDirectorySetup()
                               ])
        package.boil(external_nodes=[])
        package.output()

        autoconf_dir_builder = package.rootbuilder().find_entry_builder(
            [const.ADMIN_DIR, 'automake'])
        self.failIf(autoconf_dir_builder is None)
        self.failUnless(isinstance(autoconf_dir_builder,
                                   AutoconfAuxDirBuilder))

        self.failUnless(
            source.find([const.ADMIN_DIR, 'automake', 'conf.change.pl']))
        self.failUnless(source.find([const.ADMIN_DIR, 'automake',
                                     'config.pl']))

        fs.sync()

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