def test__plain_output(self): dirstructure = DirectoryStructure(path=self.rootpath()) # kind of bootstrap packages in order (just without writing # anything - just boil and install) first_local_package = LocalPackage( rootdirectory=dirstructure.first_source(), setups=[ConfixSetup(use_libtool=False)]) first_local_package.boil(external_nodes=[]) first_installed_package = first_local_package.install() second_local_package = LocalPackage( rootdirectory=dirstructure.second_source(), setups=[ConfixSetup(use_libtool=False)]) second_local_package.boil( external_nodes=first_installed_package.nodes()) second_installed_package = second_local_package.install() third_local_package = LocalPackage( rootdirectory=dirstructure.third_source(), setups=[ConfixSetup(use_libtool=False)]) third_local_package.boil( external_nodes=first_installed_package.nodes() + second_installed_package.nodes()) third_local_package.output() # so here, finally, go the tests ... exedir_builder = third_local_package.rootbuilder().find_entry_builder( ['exe']) self.failIf(exedir_builder is None) exedir_output_builder = find_automake_output_builder(exedir_builder) # see if we have the convenience item in makefile_am() convenience_deps = exedir_output_builder.makefile_am( ).compound_dependencies('ThirdPackage_exe_exe') self.failIf(convenience_deps is None) # see if the convenience item has all it should have self.failUnless('$(top_builddir)/library/libThirdPackage_library.a' in convenience_deps) self.failUnless('@installeddeplib_FirstPackage@' in convenience_deps) self.failUnless('@installeddeplib_SecondPackage@' in convenience_deps) # see if it got correctly written to the Makefile.am real_deps = makefile.find_list( elements=makefile.parse_makefile( exedir_output_builder.makefile_am().lines()), name='ThirdPackage_exe_exe_DEPENDENCIES') self.failIf(real_deps is None) self.failUnless( '$(top_builddir)/library/libThirdPackage_library.a' in real_deps) self.failUnless('@installeddeplib_FirstPackage@' in real_deps) self.failUnless('@installeddeplib_SecondPackage@' in real_deps) pass
def test(self): source = source_tree(testname=self.__class__.__name__) lo_dir = source.get('lo') hi_dir = source.get('hi') lo_pkg = LocalPackage(rootdirectory=lo_dir, setups=[ConfixSetup(use_libtool=False)]) lo_pkg.boil(external_nodes=[]) lo_pkg_inst = lo_pkg.install() hi_pkg = LocalPackage(rootdirectory=hi_dir, setups=[ConfixSetup(use_libtool=False)]) hi_pkg.boil(external_nodes=lo_pkg_inst.nodes()) hi_pkg.output() hi_pkg_rootdir_output_builder = find_automake_output_builder( hi_pkg.rootbuilder()) self.failIf(hi_pkg_rootdir_output_builder is None) makefile_am = hi_pkg_rootdir_output_builder.makefile_am() self.failUnless( '$(readonly_prefixes_incpath)' in makefile_am.includepath()) print hi_ldadd = makefile_am.compound_ldadd(self.__class__.__name__ + '-hi_main') self.failIf(hi_ldadd is None) self.failUnless('$(readonly_prefixes_libpath)' in hi_ldadd) pass
def test(self): common, lo, hi = inter_package.make_source(classname=self.__class__.__name__) common_package = LocalPackage(rootdirectory=common, setups=[ConfixSetup(use_libtool=False)]) common_package.boil(external_nodes=[]) common_installed = common_package.install() lo_package = LocalPackage(rootdirectory=lo, setups=[ConfixSetup(use_libtool=False)]) lo_package.boil(external_nodes=common_installed.nodes()) lo_installed = lo_package.install() hi_package = LocalPackage(rootdirectory=hi, setups=[ConfixSetup(use_libtool=False)]) hi_package.boil(external_nodes=common_installed.nodes() + lo_installed.nodes()) pass
def setUp(self): # hi -> mid -> lo # this is our fixture self.__hi_package_local = None source_tree = inter_package.make_source_tree() lo_source = source_tree.find(['lo']) lo_package_local = LocalPackage( rootdirectory=lo_source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) lo_package_local.boil(external_nodes=[]) lo_package_installed = lo_package_local.install() mid_source = source_tree.find(['mid']) mid_package_local = LocalPackage( rootdirectory=mid_source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) mid_package_local.boil(external_nodes=lo_package_installed.nodes()) mid_package_installed = mid_package_local.install() hi_source = source_tree.find(['hi']) self.__hi_package_local = LocalPackage( rootdirectory=hi_source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) self.__hi_package_local.boil( external_nodes=mid_package_installed.nodes() + lo_package_installed.nodes()) self.__hi_package_local.output() pass
def test__confix_module_propagate(self): fs = FileSystem(path=[]) source = fs.rootdirectory().add( name='source', entry=Directory()) distributor = source.add( name='distributor', entry=Directory()) distributor.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('distributor')", "PACKAGE_VERSION('1.2.3')"])) distributor.add( name=const.CONFIX2_DIR, entry=File(lines=["PROVIDE_SYMBOL('distributor')", "CMAKE_ADD_MODULE_FILE(", " name='TestModule.cmake'," " lines=['The-TestModule-Content'],", " flags=CMAKE_BUILDINFO_PROPAGATE)"])) distributor_package = LocalPackage(rootdirectory=distributor, setups=[ExplicitDirectorySetup(), CMakeSetup()]) distributor_package.boil(external_nodes=[]) receiver = source.add( name='receiver', entry=Directory()) receiver.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('receiver')", "PACKAGE_VERSION('1.2.3')"])) receiver.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('distributor', URGENCY_ERROR)"])) receiver_package = LocalPackage(rootdirectory=receiver, setups=[ExplicitDirectorySetup(), CMakeSetup()]) receiver_package.boil(external_nodes=distributor_package.install().nodes()) receiver_package.output() modfile = receiver.find(['confix-admin', 'cmake', 'Modules', 'TestModule.cmake']) self.failUnless(modfile) self.failUnlessEqual(modfile.lines()[0], 'The-TestModule-Content') pass
def test(self): fs = FileSystem(path=[]) source = fs.rootdirectory().add( name='source', entry=Directory()) # external definitions if True: externals = source.add( name='externals', entry=Directory()) externals.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('ext1')", "PACKAGE_VERSION('1.2.3')"])) externals.add( name=const.CONFIX2_DIR, entry=File(lines=["DIRECTORY(['ext1'])", "DIRECTORY(['ext2'])"])) ext1 = externals.add( name='ext1', entry=Directory()) ext1.add( name=const.CONFIX2_DIR, entry=File(lines=["PROVIDE_SYMBOL('ext1')", "CMAKE_EXTERNAL_LIBRARY(", " incpath=['ext1-incpath1', 'ext1-incpath2'],", " libpath=['ext1-libpath1', 'ext1-libpath2'],", " libs=['ext1-lib1', 'ext1-lib2'],", " cmdlinemacros={'ext1-macro1': 'ext1-value1', 'ext1-macro2': None})" ])) ext2 = externals.add( name='ext2', entry=Directory()) ext2.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('ext1', URGENCY_ERROR)", "PROVIDE_SYMBOL('ext2')", "CMAKE_EXTERNAL_LIBRARY(", " incpath=['ext2-incpath1', 'ext2-incpath2'],", " libpath=['ext2-libpath1', 'ext2-libpath2'],", " libs=['ext2-lib1', 'ext2-lib2'],", " cmdlinemacros={'ext2-macro1': 'ext2-value1', 'ext2-macro2': None})" ])) externals_package = LocalPackage(rootdirectory=externals, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) externals_package.boil(external_nodes=[]) externals_package.output() externals_installed = externals_package.install() pass # native package #1 if True: native1 = source.add( name='native1', entry=Directory()) native1.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('native1')", "PACKAGE_VERSION('1.2.3')"])) native1.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('ext2', URGENCY_ERROR)", "PROVIDE_SYMBOL('native1')", "LIBRARY(basename='native1', members=[H(filename='native1.h'), C(filename='native1.c')])"])) native1.add( name='native1.h', entry=File()) native1.add( name='native1.c', entry=File()) native1_package = LocalPackage(rootdirectory=native1, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) native1_package.boil(external_nodes=externals_installed.nodes()) native1_installed = native1_package.install() pass # native package #2 if True: native2 = source.add( name='native2', entry=Directory()) native2.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('native2')", "PACKAGE_VERSION('1.2.3')"])) native2.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('native1', URGENCY_ERROR)", "PROVIDE_SYMBOL('native2')", "LIBRARY(basename='native2', members=[H(filename='native2.h'), C(filename='native2.c')])"])) native2.add( name='native2.h', entry=File()) native2.add( name='native2.c', entry=File()) native2_package = LocalPackage(rootdirectory=native2, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) native2_package.boil(external_nodes=externals_installed.nodes()+native1_installed.nodes()) native2_installed = native2_package.install() pass # final package if True: final = source.add( name='final', entry=Directory()) final.add( name=const.CONFIX2_PKG, entry=File(lines=["PACKAGE_NAME('final')", "PACKAGE_VERSION('1.2.3')"])) final.add( name=const.CONFIX2_DIR, entry=File(lines=["DIRECTORY(['local1'])", "DIRECTORY(['local2'])", "DIRECTORY(['bin'])"])) local1 = final.add( name='local1', entry=Directory()) local1.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('native2', URGENCY_ERROR)", "PROVIDE_SYMBOL('local1')", "LIBRARY(basename='local1', members=[H(filename='local1.h'), C(filename='local1.c')])"])) local1.add( name='local1.h', entry=File()) local1.add( name='local1.c', entry=File()) local2 = final.add( name='local2', entry=Directory()) local2.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('local1', URGENCY_ERROR)", "PROVIDE_SYMBOL('local2')", "LIBRARY(basename='local2', members=[H(filename='local2.h'), C(filename='local2.c')])"])) local2.add( name='local2.h', entry=File()) local2.add( name='local2.c', entry=File()) bin = final.add( name='bin', entry=Directory()) bin.add( name=const.CONFIX2_DIR, entry=File(lines=["REQUIRE_SYMBOL('local2', URGENCY_ERROR)", "EXECUTABLE(exename='exe', center=C(filename='main.c'))"])) bin.add( name='main.c', entry=File()) final_package = LocalPackage(rootdirectory=final, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) final_package.boil(external_nodes=externals_installed.nodes()+native1_installed.nodes()+native2_installed.nodes()) final_package.output() pass cmake_output_builder = find_cmake_output_builder(final_package.rootbuilder().find_entry_builder(['bin'])) self.failUnlessEqual(cmake_output_builder.local_cmakelists().get_include_directories(), ['${CMAKE_CURRENT_BINARY_DIR}', '${final_BINARY_DIR}/local2', '${final_SOURCE_DIR}/local2', '${final_BINARY_DIR}/local1', '${final_SOURCE_DIR}/local1', '${CMAKE_INSTALL_PREFIX}/include', 'ext2-incpath1', 'ext2-incpath2', 'ext1-incpath1', 'ext1-incpath2']) self.failUnlessEqual(cmake_output_builder.local_cmakelists().get_link_directories(), ['${CMAKE_INSTALL_PREFIX}/lib', 'ext2-libpath1', 'ext2-libpath2', 'ext1-libpath1', 'ext1-libpath2']) self.failUnlessEqual(cmake_output_builder.local_cmakelists().get_target_link_libraries('exe'), ['local2', 'local1', 'native2', 'native1', 'ext2-lib1', 'ext2-lib2', 'ext1-lib1', 'ext1-lib2']) pass
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
def test(self): # boil and install lo if True: losource = Directory() losource.add(name=const.CONFIX2_PKG, entry=File(lines=['PACKAGE_NAME("lo")', 'PACKAGE_VERSION("6.6.6")'])) losource.add(name=const.CONFIX2_DIR, entry=File(lines=['LIBRARY(members=[H(filename="lo.h"), C(filename="lo.c")])'])) losource.add(name='lo.h', entry=File()) losource.add(name='lo.c', entry=File()) local_lopkg = LocalPackage(rootdirectory=losource, setups=[ExplicitDirectorySetup(), ExplicitCSetup()]) local_lopkg.boil(external_nodes=[]) installed_lopkg = local_lopkg.install() pass # boil hi, referencing things from lo. if True: hisource = Directory() hisource.add(name=const.CONFIX2_PKG, entry=File(lines=['PACKAGE_NAME("hi")', 'PACKAGE_VERSION("0.0.1")'])) hisource.add(name=const.CONFIX2_DIR, entry=File(lines=['LIBRARY(members=[C(filename="hi.c")])'])) hisource.add(name='hi.c', entry=File(lines=['#include <lo.h>'])) local_hipkg = LocalPackage(rootdirectory=hisource, setups=[ExplicitDirectorySetup(), ExplicitCSetup()]) local_hipkg.boil(external_nodes=installed_lopkg.nodes()) pass lo_h_builder = local_lopkg.rootbuilder().find_entry_builder(['lo.h']) lo_c_builder = local_lopkg.rootbuilder().find_entry_builder(['lo.c']) liblo_builder = None for b in local_lopkg.rootbuilder().iter_builders(): if isinstance(b, LibraryBuilder): liblo_builder = b break pass else: self.fail() pass hi_c_builder = local_hipkg.rootbuilder().find_entry_builder(['hi.c']) libhi_builder = None for b in local_hipkg.rootbuilder().iter_builders(): if isinstance(b, LibraryBuilder): libhi_builder = b break pass else: self.fail() pass # hi.c includes lo.h, so it must have a BuildInfo for # installed header files, but none for local header files. self.failUnless(hi_c_builder.using_native_installed() > 0) self.failUnless(len(hi_c_builder.native_local_include_dirs()) == 0) self.failUnless(len(libhi_builder.direct_libraries()) == 1) self.failUnless(len(libhi_builder.topo_libraries()) == 1) self.failUnless(isinstance(libhi_builder.direct_libraries()[0], BuildInfo_CLibrary_NativeInstalled)) self.failUnless(isinstance(libhi_builder.topo_libraries()[0], BuildInfo_CLibrary_NativeInstalled)) self.failUnless(libhi_builder.topo_libraries()[0] is \ libhi_builder.direct_libraries()[0]) self.failUnless(libhi_builder.direct_libraries()[0].basename() == 'lo') pass