Exemple #1
0
def _build_and_check(source, build):
    bootstrap.bootstrap(packageroot=source.abspath(),
                        path=None,
                        use_kde_hack=False,
                        argv0=sys.argv[0])
    configure.configure(packageroot=source.abspath(),
                        builddir=build.abspath(),
                        prefix='/dev/null'.split(os.sep),
                        readonly_prefixes=[])
    make.make(builddir=build.abspath(), args=['check'])
    pass
Exemple #2
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
    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
Exemple #4
0
    def test(self):
        try:
            # confixize, bootstrap, and install package 'lo'

            self.lo_package_.boil(external_nodes=[])
            self.lo_package_.output()
            self.lo_fs_.sync()

            # once I suspected the error to be of that root.
            lo_dir_output_builder = find_automake_output_builder(
                self.lo_package_.rootbuilder())
            self.failUnless('confixrepo' in lo_dir_output_builder.makefile_am(
            ).install_directories())

            bootstrap.bootstrap(packageroot=self.lo_sourcedir_,
                                use_kde_hack=False,
                                path=None,
                                argv0=sys.argv[0])
            os.makedirs(os.sep.join(self.lo_builddir_))
            configure.configure(packageroot=self.lo_sourcedir_,
                                builddir=self.lo_builddir_,
                                prefix=self.installdir_,
                                readonly_prefixes=[])
            make.make(builddir=self.lo_builddir_, args=['install'])

            # read repo from prefix

            repo = AutomakeCascadedPackageRepository(prefix=self.installdir_,
                                                     readonly_prefixes=[])

            # confixize, bootstrap, and install package 'hi'

            self.hi_package_.boil(external_nodes=repo.iter_nodes())
            self.hi_package_.output()
            self.hi_fs_.sync()

            bootstrap.bootstrap(packageroot=self.hi_sourcedir_,
                                use_kde_hack=False,
                                path=None,
                                argv0=sys.argv[0])
            os.makedirs(os.sep.join(self.hi_builddir_))
            configure.configure(packageroot=self.hi_sourcedir_,
                                builddir=self.hi_builddir_,
                                prefix=self.installdir_,
                                readonly_prefixes=[])
            make.make(builddir=self.hi_builddir_, args=['install'])

        except Error, e:
            sys.stderr.write( ` e ` + '\n')
            raise
Exemple #5
0
 def test(self):
     try:
         bootstrap.bootstrap(packageroot=self.sourcerootpath_,
                             path=None,
                             use_kde_hack=False,
                             argv0=sys.argv[0])
         os.makedirs(os.sep.join(self.buildrootpath_))
         configure.configure(packageroot=self.sourcerootpath_,
                             builddir=self.buildrootpath_,
                             prefix='/dev/null'.split(os.sep),
                             readonly_prefixes=[])
         make.make(builddir=self.buildrootpath_, args=[])
     except Error, e:
         sys.stderr.write( ` e ` + '\n')
         raise
Exemple #6
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
Exemple #7
0
def BOOTSTRAP():
    global DONE_BOOTSTRAP
    global ARGS

    if DONE_BOOTSTRAP: return 0

    SETTINGS()
    if OUTPUT(): return -1

    bootstrap.bootstrap(packageroot=CONFIG.packageroot().split(os.sep),
                        use_kde_hack=CONFIG.use_kde_hack(),
                        path=None,
                        argv0=sys.argv[0])

    DONE_BOOTSTRAP = 1
    return 0
Exemple #8
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('InterixLink')", "PACKAGE_VERSION('1.2.3')"
            ]))
        source.add(name=const.CONFIX2_DIR, entry=File())

        lolo = source.add(name='lolo', entry=Directory())
        lolo.add(name=const.CONFIX2_DIR, entry=File())
        lolo.add(name='lolo.h', entry=File(lines=["void lolo(void);"]))
        lolo.add(name='lolo.c', entry=File(lines=["void lolo(void) {}"]))

        lo = source.add(name='lo', entry=Directory())
        lo.add(name=const.CONFIX2_DIR, entry=File())
        lo.add(name='lo.h', entry=File(lines=["void lo(void);"]))
        lo.add(
            name='lo.c',
            entry=File(lines=["#include <lolo.h>", "void lo(void) {lolo();}"]))

        hi = source.add(name='hi', entry=Directory())
        hi.add(name=const.CONFIX2_DIR, entry=File())
        hi.add(name='hi.c',
               entry=File(lines=["#include <lo.h>", "void hi(void) {lo();}"]))

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

        package = LocalPackage(rootdirectory=source,
                               setups=[ConfixSetup(use_libtool=True)])
        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=None,
                            readonly_prefixes=None)
        make.make(builddir=build.abspath(), args=[])

        pass
Exemple #9
0
    def test(self):
        self.fs_.sync()
        bootstrap.bootstrap(packageroot=self.source_.abspath(),
                            path=None,
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=self.source_.abspath(),
                            builddir=self.build_.abspath(),
                            prefix='/dev/null'.split(os.sep),
                            readonly_prefixes=[])
        make.make(builddir=self.build_.abspath(), args=['check'])

        # as a side effect, the test program creates a file for us.
        self.failUnless(
            os.path.isfile(
                os.sep.join(self.build_.abspath() + ['my-check-was-here'])))
        pass
Exemple #10
0
    def test__publicinstall_subdir(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_subdir')",
                       "PACKAGE_VERSION('1.2.3')"
                   ]))
        source.add(name=const.CONFIX2_DIR, entry=File())
        source.add(name='file.idl',
                   entry=File(lines=[
                       'module A {',
                       'module B {',
                       '}; // /module',
                       '}; // /module',
                   ]))

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

        scan.rescan_dir(install)

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

        pass
Exemple #11
0
    def test(self):
        fs = FileSystem(path=self.rootpath())
        fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=["PACKAGE_NAME('AutoConfArchiveTest')",
                              "PACKAGE_VERSION('1.2.3')"]))
        fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["CONFIGURE_AC(lines=['AC_CXX_NAMESPACES'],",
                              "             order=AC_PROGRAMS)"]))
        package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=fs.rootdirectory().abspath(),
                            path=None,
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        pass
Exemple #12
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(),
                                   Automake(use_libtool=False,
                                            library_dependencies=False),
                                   IDLSetup()
                               ])
        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='/dev/null'.split(os.sep),
                            readonly_prefixes=[])
        make.make(builddir=build.abspath(), args=[])

        scan.rescan_dir(build)

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

        pass
    def do_test(self, use_libtool):
        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(
            name='source',
            entry=relocated_header.make_package_source(
                package_name=self.__class__.__name__))
        build = fs.rootdirectory().add(name='build', entry=Directory())

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

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

        pass
Exemple #14
0
    def do_implicit_interpackage(self, use_libtool):
        common_source, lo_source, hi_source = inter_package.make_source(
            classname=helper.automake_name(self.__class__.__name__))

        fs = FileSystem(path=self.rootpath())
        source = fs.rootdirectory().add(name='source', entry=Directory())
        source.add(name='common', entry=common_source)
        source.add(name='lo', entry=lo_source)
        source.add(name='hi', entry=hi_source)

        build = fs.rootdirectory().add(name='build', entry=Directory())
        common_build = build.add(name='common', entry=Directory())
        lo_build = build.add(name='lo', entry=Directory())
        hi_build = build.add(name='hi', entry=Directory())

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

        # massage common

        common_package = LocalPackage(
            rootdirectory=common_source,
            setups=[ConfixSetup(use_libtool=use_libtool)])
        common_package.boil(external_nodes=[])
        common_package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=common_source.abspath(),
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=common_source.abspath(),
                            builddir=common_build.abspath(),
                            prefix=install.abspath())
        make.make(builddir=common_build.abspath(), args=['install'])

        # massage lo

        lo_package = LocalPackage(
            rootdirectory=lo_source,
            setups=[ConfixSetup(use_libtool=use_libtool)])
        lo_package.boil(external_nodes=AutomakePackageRepository(
            prefix=install.abspath()).iter_nodes())
        lo_package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=lo_source.abspath(),
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=lo_source.abspath(),
                            builddir=lo_build.abspath(),
                            prefix=install.abspath())
        make.make(builddir=lo_build.abspath(), args=['install'])
        repo = AutomakePackageRepository(prefix=install.abspath())

        # massage hi

        hi_package = LocalPackage(
            rootdirectory=hi_source,
            setups=[ConfixSetup(use_libtool=use_libtool)])
        hi_package.boil(external_nodes=AutomakePackageRepository(
            prefix=install.abspath()).iter_nodes())
        hi_package.output()
        fs.sync()

        bootstrap.bootstrap(packageroot=hi_source.abspath(),
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=hi_source.abspath(),
                            builddir=hi_build.abspath(),
                            prefix=install.abspath())
        make.make(builddir=hi_build.abspath(), args=[])

        pass
Exemple #15
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())
        lo_build = build.add(name='lo', entry=Directory())
        hi_build = build.add(name='hi', entry=Directory())
        prefix = fs.rootdirectory().add(name='prefix', entry=Directory())

        # package lo contains 2 header files. one is installed flat
        # into #(includedir), the other onto a subdirectory thereof.
        lo_source = source.add(name='lo', entry=Directory())
        lo_source.add(name=const.CONFIX2_PKG,
                      entry=File(lines=[
                          "PACKAGE_NAME('InstalledIncludeDirTest-LO')",
                          "PACKAGE_VERSION('1.2.3')"
                      ]))
        lo_source.add(name=const.CONFIX2_DIR, entry=File())
        lo_source.add(name='flat.h', entry=File())
        lo_source.add(
            name='deep.h',
            entry=File(
                lines=["// CONFIX:INSTALLPATH(['path', 'to', 'deep'])"]))

        # hi contains one file that includes both.
        hi_source = source.add(name='hi', entry=Directory())

        hi_source.add(name=const.CONFIX2_PKG,
                      entry=File(lines=[
                          "PACKAGE_NAME('InstalledIncludeDirTest-HI')",
                          "PACKAGE_VERSION('1.2.3')"
                      ]))
        hi_source.add(name=const.CONFIX2_DIR, entry=File())
        hi_source.add(
            name='hi.c',
            entry=File(
                lines=["#include <flat.h>", "#include <path/to/deep/deep.h>"]))

        # bootstrap ... install lo
        package = LocalPackage(rootdirectory=lo_source,
                               setups=[ConfixSetup(use_libtool=False)])
        package.boil(external_nodes=[])
        package.output()
        fs.sync()

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

        # read repo that we need for hi

        repo = AutomakeCascadedPackageRepository(prefix=prefix.abspath(),
                                                 readonly_prefixes=[])

        # bootstrap ... make hi

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

        bootstrap.bootstrap(packageroot=hi_source.abspath(),
                            path=None,
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=hi_source.abspath(),
                            builddir=hi_build.abspath(),
                            prefix=prefix.abspath(),
                            readonly_prefixes=[])
        make.make(builddir=hi_build.abspath(), args=[])
        pass
Exemple #16
0
    def test(self):
        sourcedir = self.rootpath() + ['source']
        builddir = self.rootpath() + ['build']
        installdir = self.rootpath() + ['install']

        lo_sourcedir = sourcedir + ['lo']
        lo_builddir = builddir + ['lo']
        lo_installdir = installdir + ['lo']

        hi_sourcedir = sourcedir + ['hi']
        hi_builddir = builddir + ['hi']
        hi_installdir = installdir + ['hi']

        # create, sync, build, install package lo
        # ---------------------------------------
        lo_fs = FileSystem(path=lo_sourcedir)

        lo_fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=['PACKAGE_NAME("lo")',
                              'PACKAGE_VERSION("1.2.3")']))
        lo_fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File(lines=[]))
        lo_fs.rootdirectory().add(
            name='lo.h',
            entry=File(lines=['#ifndef lo_lo_h',
                              '#define lo_lo_h',
                              'void lo();',
                              '#endif',
                              ]))
        lo_fs.rootdirectory().add(
            name='lo.c',
            entry=File(lines=['#include "lo.h"',
                              'void lo() {}']))

        lo_package = LocalPackage(rootdirectory=lo_fs.rootdirectory(),
                                  setups=[ConfixSetup(use_libtool=self.use_libtool())])
        lo_package.boil(external_nodes=[])
        lo_package.output()
        lo_fs.sync()

        bootstrap.bootstrap(
            packageroot=lo_sourcedir,
            path=None,
            use_kde_hack=False,
            argv0=sys.argv[0])
        os.makedirs(os.sep.join(lo_builddir))
        configure.configure(
            packageroot=lo_sourcedir,
            builddir=lo_builddir,
            prefix=lo_installdir,
            readonly_prefixes=[])
        make.make(
            builddir=lo_builddir,
            args=['install'])


        # get external view (repo-packages from prefix and readonly-prefixes)
        # -------------------------------------------------------------------

        repo = AutomakeCascadedPackageRepository(
            prefix=hi_installdir, # we don't actually read aything
                                  # from there because we have nothing
                                  # installed there (yet)
            readonly_prefixes=[lo_installdir])

        # create, sync, build package lo
        # ------------------------------

        hi_fs = FileSystem(path=hi_sourcedir)
        
        hi_fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=['PACKAGE_NAME("hi")',
                              'PACKAGE_VERSION("4.5.6")']))
        hi_fs.rootdirectory().add(
            name=const.CONFIX2_DIR,
            entry=File())
        lib = hi_fs.rootdirectory().add(
            name='lib',
            entry=Directory())
        lib.add(
            name=const.CONFIX2_DIR,
            entry=File())
        lib.add(
            name='hilib.h',
            entry=File(lines=['#ifndef hi_hilib_h',
                              '#define hi_hilib_h',
                              'void hilib();',
                              '#endif']))
        lib.add(
            name='hilib.c',
            entry=File(lines=['#include "hilib.h"',
                              '#include <stdio.h>',
                              'void hilib() {',
                              r'    printf("hilib();\n");',
                              '}']))
        bin = hi_fs.rootdirectory().add(
            name='bin',
            entry=Directory())
        bin.add(
            name=const.CONFIX2_DIR,
            entry=File())
        bin.add(
            name='main.c',
            entry=File(lines=['#include <lo.h>',
                              '#include <hilib.h>',
                              '// URGENCY_ERROR: detect errors as early as possible ',
                              '// (keeping test-and-fix cycles low)',
                              '// CONFIX:REQUIRE_H("lo.h", URGENCY_ERROR)',
                              '// CONFIX:REQUIRE_H("hilib.h", URGENCY_ERROR)',
                              '',
                              'int main() {',
                              '  lo();',
                              '  hilib();',
                              '  return 0;',
                              '}']))

        hi_package = LocalPackage(rootdirectory=hi_fs.rootdirectory(),
                                  setups=[ConfixSetup(use_libtool=self.use_libtool())])
        hi_package.boil(external_nodes=repo.iter_nodes())
        hi_package.output()
        hi_fs.sync()

        bootstrap.bootstrap(
            packageroot=hi_sourcedir,
            path=None,
            use_kde_hack=False,
            argv0=sys.argv[0])
        os.makedirs(os.sep.join(hi_builddir))
        configure.configure(
            packageroot=hi_sourcedir,
            builddir=hi_builddir,
            prefix=hi_installdir,
            readonly_prefixes=[lo_installdir])
        make.make(
            builddir=hi_builddir,
            args=['install'])

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

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

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

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

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

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

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

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

        pass
Exemple #18
0
    def test(self):
        source = self.rootpath() + ['source']
        build = self.rootpath() + ['build']
        install = self.rootpath() + ['install']
        overlay = self.rootpath() + ['overlay']

        # compose the source tree,

        # source
        # |-- exe
        # |   `-- main.c
        # `-- library
        #     |-- library.c
        #     `-- library.h

        source_fs = FileSystem(path=source)
        source_library = source_fs.rootdirectory().add(name='library',
                                                       entry=Directory())
        source_library.add(name='library.h',
                           entry=File(lines=[
                               '#ifndef LIBRARY_H', '#define LIBRARY_H',
                               'extern void f(void);', '#endif'
                           ]))
        source_library.add(
            name='library.c',
            entry=File(lines=['#include "library.h"', 'void f(void) {}']))
        source_exe = source_fs.rootdirectory().add(name='exe',
                                                   entry=Directory())
        source_exe.add(
            name='main.c',
            entry=File(lines=[
                '// CONFIX:EXENAME("the_exe")', '#include <library.h>',
                'int main(void) {', '    f();', '    return 0;', '}'
            ]))

        # compose the build instructions, separate from the source
        # tree,

        # overlay
        # |-- Confix2.dir
        # |-- Confix2.pkg
        # |-- exe
        # |   `-- Confix2.dir
        # `-- library
        #     `-- Confix2.dir

        overlay_fs = FileSystem(path=overlay)
        overlay_fs.rootdirectory().add(
            name=const.CONFIX2_PKG,
            entry=File(lines=[
                'PACKAGE_NAME("' + self.__class__.__name__ +
                '")', 'PACKAGE_VERSION("1.2.3")'
            ]))
        overlay_fs.rootdirectory().add(name=const.CONFIX2_DIR, entry=File())
        overlay_library = overlay_fs.rootdirectory().add(name='library',
                                                         entry=Directory())
        overlay_library.add(name=const.CONFIX2_DIR, entry=File())
        overlay_exe = overlay_fs.rootdirectory().add(name='exe',
                                                     entry=Directory())
        overlay_exe.add(name=const.CONFIX2_DIR, entry=File())

        # union of both, and boil-build-install

        overlay_fs = OverlayFileSystem(original=source_fs, overlay=overlay_fs)

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

        # should have checked such thing elsewhwere, but it won't hurt
        # repeating.
        self.failUnless(
            source_fs.rootdirectory().find([const.CONFIX2_PKG]) is None)
        self.failUnless(
            source_fs.rootdirectory().find([const.CONFIX2_DIR]) is None)
        self.failUnless(
            source_fs.rootdirectory().find(['exe', const.CONFIX2_DIR]) is None)
        self.failUnless(source_fs.rootdirectory().find(
            ['library', const.CONFIX2_DIR]) is None)

        overlay_fs.sync()

        os.makedirs(os.sep.join(build))
        bootstrap.bootstrap(packageroot=overlay_fs.rootdirectory().abspath(),
                            use_kde_hack=False,
                            argv0=sys.argv[0])
        configure.configure(packageroot=overlay_fs.rootdirectory().abspath(),
                            builddir=build,
                            prefix=install)
        make.make(builddir=build, args=['install'])

        self.failUnless(
            os.path.exists(os.sep.join(install + ['bin', 'the_exe'])))

        make.make(builddir=build, args=['dist'])

        pass
Exemple #19
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
Exemple #20
0
    def test__basic(self):
        dirstructure = DirectoryStructure(path=self.rootpath())

        # bootstrap&&configure&&build&&install packages in order
        first_local_package = LocalPackage(rootdirectory=dirstructure.first_source(),
                                           setups=[ConfixSetup(use_libtool=False)])
        first_local_package.boil(external_nodes=[])
        first_local_package.output()
        dirstructure.sync()
        bootstrap.bootstrap(
            packageroot=dirstructure.first_source().abspath(),
            path=None,
            use_kde_hack=False,
            argv0=sys.argv[0])
        configure.configure(
            packageroot=dirstructure.first_source().abspath(),
            builddir=dirstructure.first_build().abspath(),
            prefix=dirstructure.first_install().abspath(),
            readonly_prefixes=None)
        make.make(
            builddir=dirstructure.first_build().abspath(),
            args=['install'])


        second_local_package = LocalPackage(rootdirectory=dirstructure.second_source(),
                                            setups=[ConfixSetup(use_libtool=False)])
        second_local_package.boil(external_nodes=AutomakePackageRepository(prefix=dirstructure.first_install().abspath()).iter_nodes())
        second_local_package.output()
        dirstructure.sync()
        bootstrap.bootstrap(
            packageroot=dirstructure.second_source().abspath(),
            path=None,
            use_kde_hack=False,
            argv0=sys.argv[0])
        configure.configure(
            packageroot=dirstructure.second_source().abspath(),
            builddir=dirstructure.second_build().abspath(),
            prefix=dirstructure.second_install().abspath(),
            readonly_prefixes=[dirstructure.first_install().abspath()])
        make.make(
            builddir=dirstructure.second_build().abspath(),
            args=['install'])


        third_local_package = LocalPackage(rootdirectory=dirstructure.third_source(),
                                           setups=[ConfixSetup(use_libtool=False)])
        third_local_package.boil(external_nodes=itertools.chain(
            AutomakePackageRepository(prefix=dirstructure.first_install().abspath()).iter_nodes(),
            AutomakePackageRepository(prefix=dirstructure.second_install().abspath()).iter_nodes()))
        third_local_package.output()
        dirstructure.sync()
        bootstrap.bootstrap(
            packageroot=dirstructure.third_source().abspath(),
            path=None,
            use_kde_hack=False,
            argv0=sys.argv[0])
        configure.configure(
            packageroot=dirstructure.third_source().abspath(),
            builddir=dirstructure.third_build().abspath(),
            prefix=None,
            readonly_prefixes=[dirstructure.first_install().abspath(),
                               dirstructure.second_install().abspath()])
        make.make(
            builddir=dirstructure.third_build().abspath(),
            args=None)

        # so here, finally, go the tests.

        fs = scan.scan_filesystem(path=self.rootpath())

        first_library = fs.rootdirectory().find(dirstructure.first_install().relpath(self.rootpath())+['lib', 'libFirstPackage.a'])
        second_library = fs.rootdirectory().find(dirstructure.second_install().relpath(self.rootpath())+['lib', 'libSecondPackage.a'])
        third_library = fs.rootdirectory().find(dirstructure.third_build().relpath(self.rootpath())+['library', 'libThirdPackage_library.a'])
        third_exe_Makefile = fs.rootdirectory().find(dirstructure.third_build().relpath(self.rootpath())+['exe', 'Makefile'])
        self.failIf(first_library is None)
        self.failIf(second_library is None)
        self.failIf(third_library is None)
        self.failIf(third_exe_Makefile is None)

        elements = makefile.parse_makefile(third_exe_Makefile.lines())
        deps = makefile.find_list(name='ThirdPackage_exe_exe_DEPENDENCIES',
                                  elements=elements)
        self.failIf(deps is None)

        self.failUnless(os.sep.join(first_library.abspath()) in deps)
        self.failUnless(os.sep.join(second_library.abspath()) in deps)
        self.failUnless('$(top_builddir)/library/libThirdPackage_library.a' in deps)
        
        pass
Exemple #21
0
    def test__implicit_with_explicit_libname(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_implicit_with_explicit_libname')",
                              "PACKAGE_VERSION('1.2.3')",

                              "from libconfix.setups.boilerplate import AutoBoilerplate",
                              "from libconfix.setups.c import AutoC",
                              "from libconfix.setups.automake import Automake",

                              "SETUP([AutoBoilerplate(),",
                              "       AutoC(),",
                              "       Automake(use_libtool=False, library_dependencies=True)])"
                              ]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File())
        
        library = source.add(
            name='library',
            entry=Directory())
        library.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["PROVIDE_SYMBOL('my-library')",
                              "LIBNAME('my-library')"]))
        library.add(
            name='library.c',
            entry=File(lines=['void f() {}']))

        exe = source.add(
            name='exe',
            entry=Directory())
        exe.add(
            name=const.CONFIX2_DIR,
            entry=File(lines=["REQUIRE_SYMBOL('my-library', URGENCY_ERROR)"]))
        exe.add(
            name='main.c',
            entry=File(lines=['int main(void) { return 0; }']))

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

        exe_Makefile_am = source.find(['exe', 'Makefile.am'])
        elements = makefile.parse_makefile(exe_Makefile_am.lines())
        deps = makefile.find_list(name='test_implicit_with_explicit_libname_exe_main_DEPENDENCIES',
                                  elements=elements)
        self.failUnless('$(top_builddir)/library/libmy-library.a' in deps)

        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=[]
            )
        make.make(
            builddir=build.abspath(),
            args=[])

        self.failUnless(os.path.isfile(
            os.sep.join(itertools.chain(build.abspath(), ['exe', 'test_implicit_with_explicit_libname_exe_main']))))
        pass
Exemple #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
Exemple #23
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('LocalIncludeDirTest')",
                              "PACKAGE_VERSION('1.2.3')"]))
        source.add(
            name=const.CONFIX2_DIR,
            entry=File())

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

        deep = source.add(
            name='deep',
            entry=Directory())
        deep.add(
            name=const.CONFIX2_DIR,
            entry=File())
        deep.add(
            name='deep.h',
            entry=File(lines=["// CONFIX:INSTALLPATH(['path', 'to', 'deep'])"]))

        user = source.add(
            name='user',
            entry=Directory())
        user.add(
            name=const.CONFIX2_DIR,
            entry=File())
        user.add(
            name='user.c',
            entry=File(lines=["#include <flat.h>",
                              "#include <path/to/deep/deep.h>"]))

        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='/dev/null'.split(os.sep),
            readonly_prefixes=[])
        make.make(
            builddir=build.abspath(),
            args=[])
        pass