Esempio n. 1
0
    def test_explicit_no_public_visibility(self):
        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(lines=["H(filename='header.h', public=False)"]))
        fs.rootdirectory().add(name='header.h', entry=File())

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[Boilerplate(), C()])
        package.boil(external_nodes=[])
        package.output()

        h = package.rootbuilder().find_entry_builder(['header.h'])

        # no explicit local visibility is given, so the namespace
        # recognizer sees no namespace - and the file can locally be
        # included directly.
        self.failUnlessEqual(h.package_visibility_action()[0],
                             HeaderBuilder.LOCALVISIBILITY_DIRECT_INCLUDE)
        self.failUnlessEqual(h.package_visibility_action()[1], [])

        # public visibility is explicitly not wanted.
        self.failIf(h.public())
        pass
Esempio n. 2
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. 3
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. 4
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. 5
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. 6
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. 7
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
    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
    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. 10
0
    def test__generated_headers_public_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_headers_public_install')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "LIBRARY(members=[H(filename='generated.h'), C(filename='generated.c')])",
                "CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(",
                "    outputs=['generated.h', 'generated.c'],",
                "    commands=[('touch', ['generated.h']),",
                "              ('touch', ['generated.c'])],",
                "    depends=[],",
                ")",
            ]))
        source.add(name='generated.h',
                   entry=File(state=FileState.VIRTUAL, lines=[]))
        source.add(name='generated.c',
                   entry=File(state=FileState.VIRTUAL, lines=[]))

        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.failUnless(install.find(['include', 'generated.h']))

        pass
Esempio n. 11
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=["DIRECTORY(['lo'])",
                              "DIRECTORY(['hi'])",
                              ]))

        lo = fs.rootdirectory().add(
            name='lo',
            entry=Directory())
        lo.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["from libconfix.core.hierarchy.tests.common_iface_suite import BUILDINFORMATION_propagates_Test",
                              "BUILDINFORMATION(BUILDINFORMATION_propagates_Test.TestBuildInformation())",
                              "PROVIDE_SYMBOL('test')"]))

        hi = fs.rootdirectory().add(
            name='hi',
            entry=Directory())
        hi.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["from libconfix.core.hierarchy.tests.common_iface_suite import BUILDINFORMATION_propagates_Test",
                              "REQUIRE_SYMBOL('test', URGENCY_ERROR)",
                              "ADD_BUILDER(BUILDINFORMATION_propagates_Test.TestBuildInformationReceiver())"
                              ]))

        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[Boilerplate(), C()])
        package.boil(external_nodes=[])

        for receiver in package.rootbuilder().find_entry_builder(['hi']).iter_builders():
            try:
                getattr(receiver, 'seen_buildinfo')
                break
            except: pass
            pass
        else:
            self.fail()
            pass

        self.failUnless(receiver.seen_buildinfo)
        pass
Esempio n. 12
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())

        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=[
                "CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(",
                "    outputs=['main.c'],", "    commands=[('cp', ",
                "               ['${PROJECT_SOURCE_DIR}/main.c.template', '${PROJECT_BINARY_DIR}/main.c'])],",
                "    depends=['${PROJECT_SOURCE_DIR}/main.c.template'],", ")",
                "EXECUTABLE(", "    exename='exe',",
                "    center=C(filename='main.c')", ")"
            ]))
        source.add(name='main.c.template',
                   entry=File(lines=['int main(void) { return 0; }']))
        source.add(name='main.c',
                   entry=File(state=FileState.VIRTUAL, lines=[]))

        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=[])

        scan.rescan_dir(build)

        # I doubt that this will hold under Windows :-) if it becomes
        # an issue we will skip this check
        self.failUnless(build.find(['exe']))

        pass
Esempio n. 13
0
 def test_explicit_fileiface_conflict(self):
     fs = FileSystem(path=[])
     fs.rootdirectory().add(
         name=const.CONFIX2_PKG,
         entry=File(['PACKAGE_NAME("argh")', 'PACKAGE_VERSION("1.2.3")']))
     fs.rootdirectory().add(
         name=const.CONFIX2_DIR,
         entry=File(lines=["H(filename='file.h', install=['xxx'])"]))
     file = fs.rootdirectory().add(
         name='file.h',
         entry=File(lines=["// CONFIX:INSTALLPATH(['yyy'])"]))
     package = LocalPackage(rootdirectory=fs.rootdirectory(),
                            setups=[Boilerplate(), C()])
     try:
         package.boil(external_nodes=[])
         package.output()
     except Error, e:
         return
Esempio n. 14
0
    def test__CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY_propagate(self):
        fs = FileSystem(path=[''])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                'PACKAGE_NAME("test_CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY_propagate")',
                'PACKAGE_VERSION("1.2.3")'
            ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(
                lines=['DIRECTORY(["sender"])', 'DIRECTORY(["receiver"])']))

        sender = fs.rootdirectory().add(name='sender', entry=Directory())
        sender.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'PROVIDE_SYMBOL("sender")',
                'CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY("include-directory", CMAKE_BUILDINFO_PROPAGATE)'
            ]))

        receiver = fs.rootdirectory().add(name='receiver', entry=Directory())
        receiver.add(name=const.CONFIX2_DIR,
                     entry=File(lines=[
                         'REQUIRE_SYMBOL("sender", URGENCY_ERROR)',
                         'C(filename="file.c")'
                     ]))
        # need a compiled file builder in order for the include path
        # to show up in the CMakeLists.txt.
        receiver.add(name='file.c', entry=File())

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

        cmake_output_builder = find_cmake_output_builder(
            package.rootbuilder().find_entry_builder(['receiver']))
        self.failUnless('include-directory' in cmake_output_builder.
                        local_cmakelists().get_include_directories())
        pass
Esempio n. 15
0
 def test_explicit_fileproperty_conflict(self):
     fs = FileSystem(path=[])
     fs.rootdirectory().add(
         name=const.CONFIX2_PKG,
         entry=File(['PACKAGE_NAME("argh")', 'PACKAGE_VERSION("1.2.3")']))
     fs.rootdirectory().add(
         name=const.CONFIX2_DIR,
         entry=File(lines=["H(filename='file.h', install=['xxx'])"]))
     file = fs.rootdirectory().add(name='file.h', entry=File())
     file.set_property(name='INSTALLPATH_CINCLUDE', value=['xxx'])
     package = LocalPackage(rootdirectory=fs.rootdirectory(),
                            setups=[Boilerplate(), C()])
     try:
         package.boil(external_nodes=[])
         package.output()
     except Error, e:
         self.failUnless(
             e.contains_error_of_type(
                 libconfix.plugins.c.h.AmbiguousVisibility))
         return
Esempio n. 16
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("Repo-Install")',
                              'PACKAGE_VERSION("1.2.3")']))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File())

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

        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=['-DCMAKE_INSTALL_PREFIX='+os.sep.join(install.abspath())])
        commands.make(
            builddir=build.abspath(),
            args=['repo-install'])

        scan.rescan_dir(install)

        self.failUnless(install.find(AutomakePackageRepository.REPO_FULL_PATH+['Repo-Install.repo']))
        pass
Esempio n. 17
0
    def test_explicit_diriface(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(['PACKAGE_NAME("argh")', 'PACKAGE_VERSION("1.2.3")']))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["H(filename='file.h', install=['xxx'])"]))
        file = fs.rootdirectory().add(name='file.h', entry=File())
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[Boilerplate(), C()])
        package.boil(external_nodes=[])
        package.output()

        file_h_builder = package.rootbuilder().find_entry_builder(['file.h'])

        self.failUnlessEqual(file_h_builder.visibility(), ['xxx'])
        self.failUnless(file_h_builder.public())
        self.failUnlessEqual(file_h_builder.package_visibility_action()[0],
                             HeaderBuilder.LOCALVISIBILITY_INSTALL)
        self.failUnlessEqual(file_h_builder.package_visibility_action()[1],
                             ['xxx'])
        pass
Esempio n. 18
0
    def test__executable_come_and_go(self):
        class TestGuide(Builder):
            """
            Removes executable as it sees it, and checks that the
            accompanying LibraryDependenciesFinder is also removed.
            """
            EXE_NOT_SEEN = 0
            EXE_SEEN = 1
            DEPFINDER_SEEN = 2
            DEPFINDER_DISAPPEARED = 3

            def __init__(self, exename):
                Builder.__init__(self)
                self.__exename = exename
                self.__state = self.EXE_NOT_SEEN
                self.__exe = None
                self.__depfinder = None
                pass

            def locally_unique_id(self):
                return str(self.__class__)

            def state(self):
                return self.__state

            def enlarge(self):
                if self.__state == self.EXE_NOT_SEEN:
                    for b in self.parentbuilder().iter_builders():
                        if isinstance(b, ExecutableBuilder) and b.exename(
                        ) == self.__exename:
                            self.__state = self.EXE_SEEN
                            self.__exe = b
                            self.force_enlarge()
                            return
                        pass
                    pass
                elif self.__state == self.EXE_SEEN:
                    for b in self.parentbuilder().iter_builders():
                        if isinstance(b, LibraryDependenciesFinder):
                            self.__state = self.DEPFINDER_SEEN
                            self.__depfinder = b
                            break
                        pass
                    if self.__state == self.DEPFINDER_SEEN:
                        self.parentbuilder().remove_builder(self.__exe)
                        self.__exe = None
                        pass
                    pass
                elif self.__state == self.DEPFINDER_SEEN:
                    # we removed the executable in the last
                    # round. wait for the depfinder to disappear.
                    for b in self.parentbuilder().iter_builders():
                        if b is self.__depfinder:
                            return  # still there; continue
                        pass
                    else:
                        self.__state = self.DEPFINDER_DISAPPEARED
                        self.__depfinder = None
                        pass
                    pass
                else:
                    self.fail()
                    pass
                pass

            pass

        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "PACKAGE_NAME('test_executable_come_and_go')",
                "PACKAGE_VERSION('1.2.3')"
            ]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "EXECUTABLE(exename='exe', center=C(filename='main.c'))"
            ]))
        fs.rootdirectory().add(name='main.c', entry=File())
        package = LocalPackage(rootdirectory=fs.rootdirectory(),
                               setups=[
                                   Boilerplate(),
                                   C(),
                                   Automake(use_libtool=False,
                                            library_dependencies=True)
                               ])
        guide = TestGuide(exename='exe')
        package.rootbuilder().add_builder(guide)
        package.boil(external_nodes=[])
        self.failUnlessEqual(guide.state(), guide.DEPFINDER_DISAPPEARED)
        pass
Esempio n. 19
0
    def test__copy_include_files_to_local_package(self):
        fs = FileSystem(path=self.rootpath())

        if True:
            # readonly_prefix1 has a file flatfile.h, flat in
            # prefix/include.
            readonly_prefix1_source = fs.rootdirectory().add(
                name='readonly_prefix1_source', entry=Directory())
            readonly_prefix1_source.add(name=const.CONFIX2_PKG,
                                        entry=File(lines=[
                                            "PACKAGE_NAME('readonly_prefix1')",
                                            "PACKAGE_VERSION('1.2.3')"
                                        ]))
            readonly_prefix1_source.add(
                name=const.CONFIX2_DIR,
                entry=File(lines=["H(filename='flatfile.h')"]))
            readonly_prefix1_source.add(name='flatfile.h', entry=File())
            readonly_prefix1_build = fs.rootdirectory().add(
                name='readonly_prefix1_build', entry=Directory())
            readonly_prefix1_install = fs.rootdirectory().add(
                name='readonly_prefix1_install', entry=Directory())

            readonly_prefix1_package = LocalPackage(
                rootdirectory=readonly_prefix1_source,
                setups=[Boilerplate(),
                        C(),
                        CMake(library_dependencies=False)])
            readonly_prefix1_package.boil(external_nodes=[])
            readonly_prefix1_package.output()
            fs.sync()

            commands.cmake(packageroot=readonly_prefix1_source.abspath(),
                           builddir=readonly_prefix1_build.abspath(),
                           prefix=readonly_prefix1_install.abspath())
            commands.make(builddir=readonly_prefix1_build.abspath(),
                          args=['install'])

            # readonly_prefix2 has a file subdirfile.h, in a subdir,
            # prefix/include/subdir.
            readonly_prefix2_source = fs.rootdirectory().add(
                name='readonly_prefix2_source', entry=Directory())
            readonly_prefix2_source.add(name=const.CONFIX2_PKG,
                                        entry=File(lines=[
                                            "PACKAGE_NAME('readonly_prefix2')",
                                            "PACKAGE_VERSION('1.2.3')"
                                        ]))
            readonly_prefix2_source.add(
                name=const.CONFIX2_DIR,
                entry=File(
                    lines=["H(filename='subdirfile.h', install=['subdir'])"]))
            readonly_prefix2_source.add(name='subdirfile.h', entry=File())
            readonly_prefix2_build = fs.rootdirectory().add(
                name='readonly_prefix2_build', entry=Directory())
            readonly_prefix2_install = fs.rootdirectory().add(
                name='readonly_prefix2_install', entry=Directory())

            readonly_prefix2_package = LocalPackage(
                rootdirectory=readonly_prefix2_source,
                setups=[Boilerplate(),
                        C(),
                        CMake(library_dependencies=False)])
            readonly_prefix2_package.boil(
                external_nodes=readonly_prefix1_package.install().nodes())
            readonly_prefix2_package.output()
            fs.sync()

            commands.cmake(packageroot=readonly_prefix2_source.abspath(),
                           builddir=readonly_prefix2_build.abspath(),
                           prefix=readonly_prefix2_install.abspath())
            commands.make(builddir=readonly_prefix2_build.abspath(),
                          args=['install'])

            # prefix has
            # prefix/include/prefixsubdir/prefixsubdirfile.h
            prefix_source = fs.rootdirectory().add(name='prefix_source',
                                                   entry=Directory())
            prefix_source.add(
                name=const.CONFIX2_PKG,
                entry=File(lines=[
                    "PACKAGE_NAME('prefix')", "PACKAGE_VERSION('1.2.3')"
                ]))
            prefix_source.add(
                name=const.CONFIX2_DIR,
                entry=File(lines=[
                    "H(filename='prefixsubdirfile.h', install=['prefixsubdir'])"
                ]))
            prefix_source.add(name='prefixsubdirfile.h', entry=File())
            prefix_build = fs.rootdirectory().add(name='prefix_build',
                                                  entry=Directory())
            prefix_install = fs.rootdirectory().add(name='prefix_install',
                                                    entry=Directory())

            prefix_package = LocalPackage(
                rootdirectory=prefix_source,
                setups=[Boilerplate(),
                        C(),
                        CMake(library_dependencies=False)])
            prefix_package.boil(
                external_nodes=readonly_prefix1_package.install().nodes() +
                readonly_prefix2_package.install().nodes())
            prefix_package.output()
            fs.sync()

            commands.cmake(packageroot=prefix_source.abspath(),
                           builddir=prefix_build.abspath(),
                           prefix=prefix_install.abspath())
            commands.make(builddir=prefix_build.abspath(), args=['install'])
            pass

        test_source = fs.rootdirectory().add(name='test_source',
                                             entry=Directory())
        test_source.add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "PACKAGE_NAME('test_source')", "PACKAGE_VERSION('1.2.3')"
            ]))
        test_source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                'CMAKE_CMAKELISTS_ADD_FIND_CALL([',
                '    "ConfixFindNativeInstalledFile(flatfile_dir flatfile.h include)",',
                '    "ConfixFindNativeInstalledFile(subdirfile_dir subdirfile.h include/subdir)",',
                '    "ConfixFindNativeInstalledFile(prefixsubdirfile_dir prefixsubdirfile.h include/prefixsubdir)",',
                '    "MESSAGE(STATUS flatfile: ${flatfile_dir})",',
                '    "MESSAGE(STATUS subdirfile: ${subdirfile_dir})",',
                '    "MESSAGE(STATUS prefixsubdirfile: ${prefixsubdirfile_dir})",',
                '    ],',
                '    flags=CMAKE_BUILDINFO_LOCAL,',
                ')',
                'CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(',
                '    outputs=["flatfile-copy.h"],',
                '    commands=[("cp ${flatfile_dir}/flatfile.h flatfile-copy.h", [])],',
                '    depends=["${flatfile_dir}/flatfile.h"],',
                ')',
                'CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(',
                '    outputs=["subdirfile-copy.h"],',
                '    commands=[("cp ${subdirfile_dir}/subdirfile.h subdirfile-copy.h", [])],',
                '    depends=["${subdirfile_dir}/subdirfile.h"],',
                ')',
                'CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(',
                '    outputs=["prefixsubdirfile-copy.h"],',
                '    commands=[("cp ${prefixsubdirfile_dir}/prefixsubdirfile.h prefixsubdirfile-copy.h", [])],',
                '    depends=["${prefixsubdirfile_dir}/prefixsubdirfile.h"],',
                ')',
                'CMAKE_CMAKELISTS_ADD_CUSTOM_TARGET(',
                '    name="we-make-them-with-all-target",',
                '    all=True,',
                '    depends=["flatfile-copy.h", "subdirfile-copy.h", "prefixsubdirfile-copy.h"])',
            ]))
        test_build = fs.rootdirectory().add(name='test_build',
                                            entry=Directory())

        test_package = LocalPackage(
            rootdirectory=test_source,
            setups=[Boilerplate(),
                    C(), CMake(library_dependencies=False)])
        test_package.boil(external_nodes=readonly_prefix1_package.install().nodes() + \
                          readonly_prefix2_package.install().nodes() + \
                          prefix_package.install().nodes())
        test_package.output()
        fs.sync()

        commands.cmake(
            packageroot=test_source.abspath(),
            builddir=test_build.abspath(),
            args=['-DREADONLY_PREFIXES='+\
                  '/'.join(prefix_install.abspath())+';'+ \
                  '/'.join(readonly_prefix2_install.abspath())+';'+ \
                  '/'.join(readonly_prefix1_install.abspath())])
        commands.make(builddir=test_build.abspath())

        scan.rescan_dir(test_build)
        self.failUnless(test_build.get('flatfile-copy.h'))
        self.failUnless(test_build.get('subdirfile-copy.h'))
        self.failUnless(test_build.get('prefixsubdirfile-copy.h'))

        pass
Esempio n. 20
0
    def test__quoting(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_quoting')", "PACKAGE_VERSION('1.2.3')"
            ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(",
                "    outputs=['greater_file'],",
                "    commands=[('touch greater_file > greater_sideeffect', [])],",
                "    depends=[],",
                ")",
                "CMAKE_CMAKELISTS_ADD_CUSTOM_COMMAND__OUTPUT(",
                "    outputs=['less_file'],",
                "    commands=[('echo xxx > tmp_file', []),",
                "              ('cat < tmp_file > less_file', [])],",
                "    depends=[],",
                ")",
                "",
                "CMAKE_CMAKELISTS_ADD_CUSTOM_TARGET(",
                "    name='beitl',",
                "    all=True,",
                "    depends=['greater_file',",
                "             'less_file',",
                "            ]",
                ")",
                "",
            ]))

        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=[])

        scan.rescan_dir(build)

        self.failUnless(build.find(['greater_file']))
        self.failUnless(build.find(['greater_sideeffect']))
        self.failIf(build.find(['>']))

        less_file = build.find(['less_file'])
        self.failUnless(less_file)
        self.failUnlessEqual(len(less_file.lines()), 1)
        self.failUnlessEqual(less_file.lines()[0], 'xxx')

        pass
Esempio n. 21
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('SimplePlainFileTest')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[
                "ADD_PLAINFILE(filename='plainfile_data', ",
                "              datadir=['subdir', 'data'])",  # list of path components
                "ADD_PLAINFILE(filename='plainfile_prefix',",
                "              prefixdir='subdir/prefix')",  # string
            ]))
        source.add(name='plainfile_data', entry=File())
        source.add(name='plainfile_prefix', entry=File())

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

        automake_output_builder = find_automake_output_builder(
            package.rootbuilder())
        self.failUnless('plainfile_data' in
                        automake_output_builder.makefile_am().extra_dist())
        self.failUnless('plainfile_prefix' in
                        automake_output_builder.makefile_am().extra_dist())

        fs.sync()

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

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

        pass
Esempio n. 22
0
    def test__true(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('AutomakeTestScriptTest')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR,
                   entry=File(lines=[
                       "ADD_SCRIPT(filename='test-true', what=SCRIPT_CHECK)",
                       "ADD_SCRIPT(filename='install-dummy', what=SCRIPT_BIN)",
                   ]))
        source.add(name='test-true',
                   entry=File(lines=[
                       '#!/bin/sh',
                       'touch I-was-here',
                       'exit 0',
                   ],
                              mode=stat.S_IRUSR | stat.S_IXUSR))
        source.add(name='install-dummy',
                   entry=File(mode=stat.S_IRUSR | stat.S_IXUSR))

        package = LocalPackage(rootdirectory=source,
                               setups=[
                                   Boilerplate(),
                                   Script(),
                                   Automake(use_libtool=False,
                                            library_dependencies=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=['check'])
        make.make(builddir=build.abspath(), args=['install'])

        # verify that the script was executed.
        scan.rescan_dir(build)
        self.failUnless(build.find(['I-was-here']))

        scan.rescan_dir(install)

        # verify that the script hasn't been installed.
        self.failIf(install.find(['bin', 'I-was-here']))

        # for completeness (and paranoia), check if scripts are
        # installed at all.
        self.failUnless(install.find(['bin', 'install-dummy']))

        pass
Esempio n. 23
0
    def test(self):
        fs = FileSystem(path=[])
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                "PACKAGE_NAME('PseudoHandwritten')", "PACKAGE_VERSION('1.2.3')"
            ]))
        fs.rootdirectory().add(name=const.CONFIX2_DIR, entry=File())

        package1 = LocalPackage(rootdirectory=fs.rootdirectory(),
                                setups=[Boilerplate()])
        pseudo_output_builder1 = pseudo_handwritten.find_pseudo_handwritten_builder(
            package1.rootbuilder())
        file1 = pseudo_output_builder1.create_file('file1')
        file1.add_lines(['line1'])

        package1.boil(external_nodes=[])
        package1.output()

        self.failUnless(fs.rootdirectory().get(
            pseudo_handwritten.PseudoHandWrittenFileManager.
            PSEUDO_HANDWRITTEN_LIST_FILENAME))
        self.failUnless(fs.rootdirectory().get('file1').lines() == ['line1'])

        package1 = None

        package2 = LocalPackage(rootdirectory=fs.rootdirectory(),
                                setups=[Boilerplate()])

        pseudo_output_builder2 = pseudo_handwritten.find_pseudo_handwritten_builder(
            package2.rootbuilder())
        file2 = pseudo_output_builder2.create_file('file2')
        file2.add_lines(['line2'])
        package2.boil(external_nodes=[])
        package2.output()

        self.failUnless(fs.rootdirectory().get(
            pseudo_handwritten.PseudoHandWrittenFileManager.
            PSEUDO_HANDWRITTEN_LIST_FILENAME))

        # note that we ought to remove the file, but we can only
        # truncate it.

        #self.failIf(fs.rootdirectory().get('file1'))
        self.failUnless(len(fs.rootdirectory().get('file1').lines()) == 0)

        self.failUnless(fs.rootdirectory().get('file2').lines() == ['line2'])

        package2 = None

        package3 = LocalPackage(rootdirectory=fs.rootdirectory(),
                                setups=[Boilerplate()])
        package3.boil(external_nodes=[])
        package3.output()

        # note that we ought to remove the file, but we can only
        # truncate it.

        #self.failIf(fs.rootdirectory().get(pseudo_handwritten.PseudoHandWrittenFileManager.PSEUDO_HANDWRITTEN_LIST_FILENAME))

        self.failUnless(
            len(
                helper_pickle.load_object_from_lines(fs.rootdirectory().get(
                    pseudo_handwritten.PseudoHandWrittenFileManager.
                    PSEUDO_HANDWRITTEN_LIST_FILENAME).lines())) == 0)
        pass