def test(self): fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=intra_package.make_source_tree()) build = fs.rootdirectory().add(name='build', entry=Directory()) package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[]) commands.make(builddir=build.abspath(), args=[]) scan.rescan_dir(build) # I doubt that this will hold on Windows :-) if it becomes an # issue we will skip this check self.failUnless(build.find(['lo', 'liblo.a'])) self.failUnless(build.find(['hi', 'libhi.a'])) self.failUnless(build.find(['exe', 'exe'])) pass
def test__basic(self): fs = FileSystem(path=[]) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("HierarchyInMemoryTest.basic")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'DIRECTORY(["directory0"])', 'DIRECTORY(["directory1"])' ])) fs.rootdirectory().add(name='directory0', entry=Directory()) fs.rootdirectory().add(name='directory1', entry=Directory()) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() cmake_output_builder = find_cmake_output_builder(package.rootbuilder()) self.failUnlessEqual( len(cmake_output_builder.local_cmakelists().get_subdirectories()), 2 # plus the admin stuff, confix-admin/cmake/Modules + 4) self.failUnless('directory0' in cmake_output_builder.local_cmakelists( ).get_subdirectories()) self.failUnless('directory1' in cmake_output_builder.local_cmakelists( ).get_subdirectories()) pass
def test__CMAKE_CMAKELISTS_ADD_INCLUDE_local_only(self): fs = FileSystem(path=['']) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_CMAKELISTS_ADD_INCLUDE_local_only")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'CMAKE_CMAKELISTS_ADD_INCLUDE("include1", CMAKE_BUILDINFO_LOCAL)', 'CMAKE_CMAKELISTS_ADD_INCLUDE("include2", CMAKE_BUILDINFO_LOCAL)' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() self.failUnless('include1' in find_cmake_output_builder( package.rootbuilder()).top_cmakelists().get_includes()) self.failUnless('include2' in find_cmake_output_builder( package.rootbuilder()).top_cmakelists().get_includes()) for buildinfo in package.rootbuilder().iter_buildinfos(): self.failIf( isinstance(buildinfo, BuildInfo_Toplevel_CMakeLists_Include)) pass pass
def test__CMAKE_ADD_MODULE_FILE(self): fs = FileSystem(path=['']) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_ADD_MODULE_FILE")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'CMAKE_ADD_MODULE_FILE(', ' name="file1",', ' lines=["xxx"],' ' flags=CMAKE_BUILDINFO_LOCAL)', 'CMAKE_ADD_MODULE_FILE(', ' name="file2",', ' lines=["xxx"],', ' flags=CMAKE_BUILDINFO_LOCAL)' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() self.failUnless(fs.rootdirectory().find( ['confix-admin', 'cmake', 'Modules', 'file1'])) self.failUnless(fs.rootdirectory().find( ['confix-admin', 'cmake', 'Modules', 'file2'])) pass
def test__CMAKE_CMDLINE_MACROS_local_only(self): fs = FileSystem(path=[]) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_CMDLINE_MACROS_local_only")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'CMAKE_CMDLINE_MACROS(macros={"macro1": "value1", "macro2": "value2"}, flags=CMAKE_BUILDINFO_LOCAL)' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() self.failUnless("-Dmacro1=value1" in find_cmake_output_builder( package.rootbuilder()).local_cmakelists().get_definitions()) self.failUnless("-Dmacro2=value2" in find_cmake_output_builder( package.rootbuilder()).local_cmakelists().get_definitions()) for buildinfo in package.rootbuilder().iter_buildinfos(): self.failIf( isinstance(buildinfo, BuildInfo_CommandlineMacros_CMake)) pass pass
def test__CMAKE_CMAKELISTS_ADD_FIND_CALL_propagate_and_local(self): fs = FileSystem(path=['']) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_CMAKELISTS_ADD_FIND_CALL_propagate_and_local")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'CMAKE_CMAKELISTS_ADD_FIND_CALL("call", (CMAKE_BUILDINFO_PROPAGATE, CMAKE_BUILDINFO_LOCAL))' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() self.failUnless('call' in find_cmake_output_builder( package.rootbuilder()).top_cmakelists().get_find_calls()) for buildinfo in package.rootbuilder().iter_buildinfos(): if isinstance(buildinfo, BuildInfo_Toplevel_CMakeLists_FindCall): break pass else: self.fail() pass pass
def test__CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY_local(self): fs = FileSystem(path=['']) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY_local")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add(name=const.CONFIX2_DIR, entry=File(lines=['DIRECTORY(["subdir"])'])) subdir = fs.rootdirectory().add(name='subdir', entry=Directory()) subdir.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'CMAKE_CMAKELISTS_ADD_INCLUDE_DIRECTORY("include-directory", CMAKE_BUILDINFO_LOCAL)' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() cmake_output_builder = find_cmake_output_builder( package.rootbuilder().find_entry_builder(['subdir'])) self.failUnless('include-directory' in cmake_output_builder. local_cmakelists().get_include_directories()) pass
def test__live(self): fs = FileSystem(path=[]) fs.rootdirectory().add(name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("ModulesInMemoryTest")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ 'from libconfix.plugins.cmake.out_cmake import find_cmake_output_builder', 'from libconfix.core.machinery.builder import Builder', 'class ModuleAdder(Builder):', ' def output(self):', ' super(ModuleAdder, self).output()', ' cmake_out = find_cmake_output_builder(self.parentbuilder())', ' cmake_out.add_module_file(name="TestModule.cmake",', ' lines=["my content"])', ' pass', ' pass', ' def locally_unique_id(self):', ' return str(self.__class__)', 'ADD_BUILDER(ModuleAdder())' ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[CMakeSetup(), ExplicitDirectorySetup()]) package.boil(external_nodes=[]) package.output() modulefile = fs.rootdirectory().find( ['confix-admin', 'cmake', 'Modules', 'TestModule.cmake']) self.failIf(modulefile is None) self.failIf(modulefile.lines()[0] != 'my content') pass
def test__basic(self): linked_package = LocalPackage( rootdirectory=self.__linked_sourcedir, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) # read repo files along the cascade repo = AutomakeCascadedPackageRepository( prefix=self.__regular_installdir.abspath(), readonly_prefixes=[ self.__two_readonly_installdir.abspath(), self.__one_readonly_installdir.abspath() ]) linked_package.boil(external_nodes=repo.iter_nodes()) linked_package.output() self.__fs.sync() commands.cmake( packageroot=self.__linked_sourcedir.abspath(), builddir=self.__linked_builddir.abspath(), args=[ '-DCMAKE_INSTALL_PREFIX=' + '/'.join(self.__regular_installdir.abspath()), '-DREADONLY_PREFIXES=' + '/'.join(self.__one_readonly_installdir.abspath()) + ';' + '/'.join(self.__two_readonly_installdir.abspath()) ]) commands.make(builddir=self.__linked_builddir.abspath(), args=[]) self.failUnless( os.path.isfile( os.sep.join(self.__linked_builddir.abspath() + ['exe']))) 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__no_timestamp_clobber(self): fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=Directory()) build = fs.rootdirectory().add(name='build', entry=Directory()) source.add(name=const.CONFIX2_PKG, entry=File(lines=[ "PACKAGE_NAME('test_no_timestamp_clobber')", "PACKAGE_VERSION('1.2.3')" ])) source.add(name=const.CONFIX2_DIR, entry=File(lines=[ "for f in xrange(200):", " H(filename='%s.h' % str(f), install=['subdir'])", ])) for f in xrange(200): source.add(name='%s.h' % str(f), entry=File()) pass package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[]) commands.make(builddir=build.abspath(), args=[]) mtimes = {} for f in xrange(200): mtime = os.stat( os.sep.join(build.abspath() + ['confix-include', 'subdir', '%s.h' % str(f)])).st_mtime mtimes[f] = mtime pass # wait a bit and then call 'make' again time.sleep(1) commands.make(builddir=build.abspath(), args=[]) for f in xrange(200): mtime = os.stat( os.sep.join(build.abspath() + ['confix-include', 'subdir', '%s.h' % str(f)])).st_mtime self.failIf(mtime != mtimes[f], f) pass pass
def test__sourcefile_dependency(self): fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=Directory()) build = fs.rootdirectory().add(name='build', entry=Directory()) source.add(name=const.CONFIX2_PKG, entry=File(lines=[ "PACKAGE_NAME('test_sourcefile_dependency')", "PACKAGE_VERSION('1.2.3')" ])) source.add(name=const.CONFIX2_DIR, entry=File(lines=[ "H(filename='h.h', install=['subdir'])", ])) h = source.add(name='h.h', entry=File()) package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[]) commands.make(builddir=build.abspath(), args=[]) before_mtime = os.stat( os.sep.join(build.abspath() + ['confix-include', 'subdir', 'h.h'])).st_mtime # wait a bit. then touch the source file, call make again, and # check that the file was locally installed again. time.sleep(1) h.add_lines(['x']) fs.sync() commands.make(builddir=build.abspath(), args=[]) self.failUnless( os.stat( os.sep.join(build.abspath() + ['confix-include', 'subdir', 'h.h'])).st_mtime > before_mtime) pass
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(self): fs = FileSystem(path=[]) fs.rootdirectory().add(name=const.CONFIX2_PKG, entry=File(lines=[ "PACKAGE_NAME('ExternalLibraryTest')", "PACKAGE_VERSION('1.2.3')" ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File( lines=["DIRECTORY(['external'])", "DIRECTORY(['linked'])"])) external = fs.rootdirectory().add(name='external', entry=Directory()) external.add(name=const.CONFIX2_DIR, entry=File(lines=[ "PROVIDE_SYMBOL('the-external-library')", "CMAKE_EXTERNAL_LIBRARY(", " cflags=['my-cflag1', 'my-cflag2'],", " cxxflags=['my-cxxflag1', 'my-cxxflag2'])", ])) linked = fs.rootdirectory().add(name='linked', entry=Directory()) linked.add(name=const.CONFIX2_DIR, entry=File(lines=[ "REQUIRE_SYMBOL('the-external-library', URGENCY_ERROR)", "EXECUTABLE(center=C(filename='main.c'))" ])) linked.add(name='main.c', entry=File(lines=["int main(void) {}"])) package = LocalPackage( rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() linked_cmake_output_builder = find_cmake_output_builder( package.rootbuilder().find_entry_builder(['linked'])) self.failUnless('my-cflag1' in linked_cmake_output_builder. local_cmakelists().get_definitions()) self.failUnless('my-cflag2' in linked_cmake_output_builder. local_cmakelists().get_definitions()) self.failUnless('my-cxxflag1' in linked_cmake_output_builder. local_cmakelists().get_definitions()) self.failUnless('my-cxxflag2' in linked_cmake_output_builder. local_cmakelists().get_definitions()) pass
def setUp(self): rootdirectory = Directory() rootdirectory.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("package-name")', 'PACKAGE_VERSION("1.2.3")' ])) rootdirectory.add(name=const.CONFIX2_DIR, entry=File()) package = LocalPackage(rootdirectory=rootdirectory, setups=[CMakeSetup()]) package.boil(external_nodes=[]) package.output() self.__cmakelists = find_cmake_output_builder( package.rootbuilder()).top_cmakelists() pass
def setUp(self): fs = FileSystem(path=[], rootdirectory=intra_package.make_source_tree()) self.__package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) self.__package.boil(external_nodes=[]) self.__package.output() self.__lo_output_builder = find_cmake_output_builder(self.__package.rootbuilder().find_entry_builder(['lo'])) self.__hi_output_builder = find_cmake_output_builder(self.__package.rootbuilder().find_entry_builder(['hi'])) self.__exe_output_builder = find_cmake_output_builder(self.__package.rootbuilder().find_entry_builder(['exe'])) 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__CMAKE_EXTERNAL_LIBRARY(self): fs = FileSystem(path=['']) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("test_CMAKE_CMAKELISTS_ADD_INCLUDE")', 'PACKAGE_VERSION("1.2.3")' ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File(lines=[ "CMAKE_EXTERNAL_LIBRARY(", " incpath=['includedir1', 'includedir2'],", " libpath=['libdir1', 'libdir2'],", " libs=['lib1', 'lib2'],", " cmdlinemacros={'macro1': 'value1',", " 'macro2': 'value2'})" ])) package = LocalPackage(rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() external_library_builders = [] for external_library_builder in package.rootbuilder().iter_builders(): if isinstance(external_library_builder, ExternalLibraryBuilder): external_library_builders.append(external_library_builder) pass pass self.failUnlessEqual(len(external_library_builders), 1) incpath_infos = [] for incpath_info in external_library_builders[0].iter_buildinfos(): if isinstance(incpath_info, BuildInfo_IncludePath_External_CMake): incpath_infos.append(incpath_info) pass pass self.failUnlessEqual(len(incpath_infos), 1) self.failUnlessEqual(incpath_infos[0].incpath(), ['includedir1', 'includedir2']) libpath_infos = [] for libpath_info in external_library_builders[0].iter_buildinfos(): if isinstance(libpath_info, BuildInfo_LibraryPath_External_CMake): libpath_infos.append(libpath_info) pass pass self.failUnlessEqual(len(libpath_infos), 1) self.failUnlessEqual(libpath_infos[0].libpath(), ['libdir1', 'libdir2']) lib_infos = [] for lib_info in external_library_builders[0].iter_buildinfos(): if isinstance(lib_info, BuildInfo_Library_External_CMake): lib_infos.append(lib_info) pass pass self.failUnlessEqual(len(lib_infos), 1) self.failUnlessEqual(lib_infos[0].libs(), ['lib1', 'lib2']) macro_infos = [] for macro_info in external_library_builders[0].iter_buildinfos(): if isinstance(macro_info, BuildInfo_CommandlineMacros_CMake): macro_infos.append(macro_info) pass pass self.failUnlessEqual(len(macro_infos), 1) self.failUnlessEqual(macro_infos[0].macros(), { 'macro1': 'value1', 'macro2': 'value2' }) pass
def test__CMAKE_PKG_CONFIG_LIBRARY(self): fs = FileSystem(path=[]) fs.rootdirectory().add( name=const.CONFIX2_PKG, entry=File(lines=[ "PACKAGE_NAME('test_CMAKE_PKG_CONFIG_LIBRARY')", "PACKAGE_VERSION('1.2.3')" ])) fs.rootdirectory().add( name=const.CONFIX2_DIR, entry=File( lines=["DIRECTORY(['external'])", "DIRECTORY(['linked'])"])) external = fs.rootdirectory().add(name='external', entry=Directory()) external.add(name=const.CONFIX2_DIR, entry=File(lines=[ "PROVIDE_SYMBOL('xxx-glue')", "CMAKE_PKG_CONFIG_LIBRARY(packagename='xxx')" ])) linked = fs.rootdirectory().add(name='linked', entry=Directory()) linked.add(name=const.CONFIX2_DIR, entry=File(lines=[ "REQUIRE_SYMBOL('xxx-glue', URGENCY_ERROR)", "EXECUTABLE(exename='exe', center=C(filename='main.c'))" ])) linked.add(name='main.c', entry=File(lines=['int main(void() {}'])) package = LocalPackage( rootdirectory=fs.rootdirectory(), setups=[ExplicitDirectorySetup(), CMakeSetup(), ExplicitCSetup()]) package.boil(external_nodes=[]) package.output() linked_cmake_output_builder = find_cmake_output_builder( package.rootbuilder().find_entry_builder(['linked'])) self.failUnless( 'FIND_PACKAGE(PkgConfig)' in linked_cmake_output_builder.top_cmakelists().get_find_calls()) self.failUnless( 'PKG_CHECK_MODULES(CONFIX_CMAKE_PKG_CONFIG__xxx REQUIRED xxx)' in linked_cmake_output_builder.top_cmakelists().get_find_calls()) self.failUnless('${CONFIX_CMAKE_PKG_CONFIG__xxx_LIBRARIES}' in linked_cmake_output_builder.local_cmakelists( ).get_target_link_libraries('exe')) self.failUnless('${CONFIX_CMAKE_PKG_CONFIG__xxx_LIBRARY_DIRS}' in linked_cmake_output_builder.local_cmakelists( ).get_link_directories()) self.failUnless('${CONFIX_CMAKE_PKG_CONFIG__xxx_INCLUDE_DIRS}' in linked_cmake_output_builder.local_cmakelists( ).get_include_directories()) self.failUnless( '${CONFIX_CMAKE_PKG_CONFIG__xxx_CFLAGS}' in linked_cmake_output_builder.local_cmakelists().get_definitions()) self.failUnless( '${CONFIX_CMAKE_PKG_CONFIG__xxx_CFLAGS_OTHER}' in linked_cmake_output_builder.local_cmakelists().get_definitions()) pass
def __init__(self, library_dependencies): CompositeSetup.__init__(self, [CMakeSetup()]) if library_dependencies: self.add_setup(LibraryDependenciesSetup()) pass pass
def test_intra_package(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('LibraryDependencies-Intra-Package')", "PACKAGE_VERSION('1.2.3')" ])) source.add( name=const.CONFIX2_DIR, entry=File(lines=["DIRECTORY(['lib'])", "DIRECTORY(['exe'])"])) lib = source.add(name='lib', entry=Directory()) lib.add( name=const.CONFIX2_DIR, entry=File(lines=[ "LIBRARY(basename='lib', members=[H(filename='lib.h'), C(filename='lib.c')])" ])) lib.add(name='lib.h', entry=File(lines=[ '#ifndef lib_h', '#define lib_h', 'void lib();', '#endif' ])) lib.add(name='lib.c', entry=File(lines=['#include "lib.h"', 'void lib() {}'])) exe = source.add(name='exe', entry=Directory()) exe.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'EXECUTABLE(exename="exe", center=C(filename="main.c"))' ])) exe.add(name='main.c', entry=File(lines=[ '#include <lib.h>', '// CONFIX:REQUIRE_H("lib.h", URGENCY_ERROR)', 'int main(void) {', ' lib(); ', ' return 0;', '}' ])) package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[]) commands.make(builddir=build.abspath(), args=[]) # wait a bit and then touch liblo.a. (is there a better way # than sleeping?) time.sleep(1) lib_library = os.sep.join(build.abspath() + ['lib', 'liblib.a']) os.utime(lib_library, None) lib_library_stat = os.stat(lib_library) # exe is rebuilt as it depends on liblib.a if True: commands.make(builddir=build.abspath(), args=[]) self.failUnless( os.stat(os.sep.join(build.abspath() + ['exe', 'exe'])).st_mtime >= lib_library_stat.st_mtime) pass pass
def test(self): fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=inter_package.make_source_tree()) lo_source = source.find(['lo']) mid_source = source.find(['mid']) hi_source = source.find(['hi']) build = fs.rootdirectory().add(name='build', entry=Directory()) lo_build = build.add(name='lo', entry=Directory()) mid_build = build.add(name='mid', entry=Directory()) hi_build = build.add(name='hi', entry=Directory()) install = fs.rootdirectory().add(name='install', entry=Directory()) # build and install lo if True: lo_package = LocalPackage(rootdirectory=lo_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) lo_package.boil(external_nodes=[]) lo_package.output() fs.sync() commands.cmake( packageroot=lo_source.abspath(), builddir=lo_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=lo_build.abspath(), args=['install']) pass # build and install mid if True: repo = AutomakeCascadedPackageRepository(prefix=install.abspath(), readonly_prefixes=[]) mid_package = LocalPackage(rootdirectory=mid_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) mid_package.boil(external_nodes=repo.iter_nodes()) mid_package.output() fs.sync() commands.cmake( packageroot=mid_source.abspath(), builddir=mid_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=mid_build.abspath(), args=['install']) pass # build and install hi if True: repo = AutomakeCascadedPackageRepository(prefix=install.abspath(), readonly_prefixes=[]) hi_package = LocalPackage(rootdirectory=hi_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) hi_package.boil(external_nodes=repo.iter_nodes()) hi_package.output() fs.sync() commands.cmake( packageroot=hi_source.abspath(), builddir=hi_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=hi_build.abspath(), args=['install']) pass # call the program and see if everything's fine. pipe = subprocess.Popen( [os.sep.join(install.abspath() + ['bin', 'exe'])], stdout=subprocess.PIPE) self.failUnlessEqual(pipe.stdout.next(), 'main was here\n') pass
def test_inter_package(self): fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=inter_package.make_source_tree()) lo_source = source.find(['lo']) mid_source = source.find(['mid']) hi_source = source.find(['hi']) build = fs.rootdirectory().add(name='build', entry=Directory()) lo_build = build.add(name='lo', entry=Directory()) mid_build = build.add(name='mid', entry=Directory()) hi_build = build.add(name='hi', entry=Directory()) install = fs.rootdirectory().add(name='install', entry=Directory()) # build and install lo if True: lo_package = LocalPackage(rootdirectory=lo_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) lo_package.boil(external_nodes=[]) lo_package.output() fs.sync() commands.cmake( packageroot=lo_source.abspath(), builddir=lo_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=lo_build.abspath(), args=['install']) pass # build and install mid if True: repo = AutomakeCascadedPackageRepository(prefix=install.abspath(), readonly_prefixes=[]) mid_package = LocalPackage(rootdirectory=mid_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) mid_package.boil(external_nodes=repo.iter_nodes()) mid_package.output() fs.sync() commands.cmake( packageroot=mid_source.abspath(), builddir=mid_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=mid_build.abspath(), args=['install']) pass # build and install hi. declare that I want library # dependencies. if True: repo = AutomakeCascadedPackageRepository(prefix=install.abspath(), readonly_prefixes=[]) hi_package = LocalPackage(rootdirectory=hi_source, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup(), LibraryDependenciesSetup() ]) hi_package.boil(external_nodes=repo.iter_nodes()) hi_package.output() fs.sync() commands.cmake( packageroot=hi_source.abspath(), builddir=hi_build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + '/'.join(install.abspath())]) commands.make(builddir=hi_build.abspath(), args=['install']) pass # wait a bit and then touch liblo.a. (is there a better way # than sleeping?) time.sleep(1) lo_lib = os.sep.join(install.abspath() + ['lib', 'liblo.a']) os.utime(lo_lib, None) lo_stat = os.stat(lo_lib) # libmid.a is not rebuilt. if True: commands.make(builddir=mid_build.abspath(), args=['install']) self.failIf( os.stat(os.sep.join(install.abspath() + ['lib', 'libmid.a'])). st_mtime >= lo_stat.st_mtime) pass # exe is rebuilt as it has liblo.a linked in. if True: commands.make(builddir=hi_build.abspath(), args=['install']) self.failUnless( os.stat(os.sep.join(install.abspath() + ['bin', 'exe'])). st_mtime >= lo_stat.st_mtime) pass pass
def test__basic(self): source = Directory() source.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("Local-Install")', 'PACKAGE_VERSION("1.2.3")' ])) source.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'DIRECTORY(["headers-only"])', 'DIRECTORY(["headers-with-library"])', 'DIRECTORY(["exe"])' ])) headers_only = source.add(name='headers-only', entry=Directory()) headers_with_library = source.add(name='headers-with-library', entry=Directory()) exe = source.add(name='exe', entry=Directory()) headers_only.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'H(filename="header-1.h", install=["headers-only-install"])', 'H(filename="header-2.h", install=["headers-only-install"])' ])) headers_only.add(name='header-1.h', entry=File()) headers_only.add(name='header-2.h', entry=File()) headers_with_library.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'LIBRARY(members=[H(filename="library-1.h", install=["headers-with-library-install"]),' ' H(filename="library-2.h", install=["headers-with-library-install"]),' ' C(filename="library-1.c"),' ' C(filename="library-2.c")', ' ]', ' )' ])) headers_with_library.add(name='library-1.h', entry=File(lines=['void library1(void);'])) headers_with_library.add(name='library-2.h', entry=File(lines=['void library2(void);'])) headers_with_library.add( name='library-1.c', entry=File(lines=[ '#include <headers-only-install/header-1.h>', 'void library1(void) {}' ])) headers_with_library.add( name='library-2.c', entry=File(lines=[ '#include <headers-only-install/header-2.h>', 'void library2(void) {}' ])) exe.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'EXECUTABLE(exename="exe",', ' center=C(filename="main.c"))', ])) exe.add( name='main.c', entry=File(lines=[ '#include <headers-only-install/header-1.h>', '#include <headers-only-install/header-2.h>', '#include <headers-with-library-install/library-1.h>', '#include <headers-with-library-install/library-2.h>', 'int main(void) {', ' library1();', ' library2();', '}' ])) fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=source) build = fs.rootdirectory().add(name='build', entry=Directory()) package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake(packageroot=source.abspath(), builddir=build.abspath(), args=[]) commands.make(builddir=build.abspath(), args=[]) 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', 'exe'])) pass
def setUp(self): super(ReadonlyPrefixesBuildTest, self).setUp() # one-readonly, installed in prefix one-readonly # two-readonly, installed in prefix two-readonly # three-regular, installed on regular prefix # linked, using all three self.__fs = FileSystem(path=self.rootpath()) sourcedir = self.__fs.rootdirectory().add(name='source', entry=Directory()) builddir = self.__fs.rootdirectory().add(name='build', entry=Directory()) installdir = self.__fs.rootdirectory().add(name='install', entry=Directory()) self.__regular_installdir = self.__fs.rootdirectory().add( name='regular', entry=Directory()) self.__one_readonly_sourcedir = sourcedir.add(name='one-readonly', entry=Directory()) self.__one_readonly_builddir = builddir.add(name='one-readonly', entry=Directory()) self.__one_readonly_installdir = installdir.add(name='one-readonly', entry=Directory()) self.__two_readonly_sourcedir = sourcedir.add(name='two-readonly', entry=Directory()) self.__two_readonly_builddir = builddir.add(name='two-readonly', entry=Directory()) self.__two_readonly_installdir = installdir.add(name='two-readonly', entry=Directory()) self.__three_regular_sourcedir = sourcedir.add(name='three-regular', entry=Directory()) self.__three_regular_builddir = builddir.add(name='three-regular', entry=Directory()) self.__linked_sourcedir = sourcedir.add(name='linked', entry=Directory()) self.__linked_builddir = builddir.add(name='linked', entry=Directory()) # one_readonly source if True: self.__one_readonly_sourcedir.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("one-readonly")', 'PACKAGE_VERSION("1.2.3")' ])) self.__one_readonly_sourcedir.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'LIBRARY(basename="one", members=[H(filename="one_readonly.h"), C(filename="one_readonly.c")])' ])) self.__one_readonly_sourcedir.add(name='one_readonly.h', entry=File(lines=[ '#ifndef one_readonly_h', '#define one_readonly_h', 'void one_readonly();', '#endif', ])) self.__one_readonly_sourcedir.add( name='one_readonly.c', entry=File(lines=[ '#include "one_readonly.h"', 'void one_readonly() {}' ])) pass # two_readonly source if True: self.__two_readonly_sourcedir.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("two-readonly")', 'PACKAGE_VERSION("1.2.3")' ])) self.__two_readonly_sourcedir.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'LIBRARY(basename="two", members=[H(filename="two_readonly.h"), C(filename="two_readonly.c")])' ])) self.__two_readonly_sourcedir.add(name='two_readonly.h', entry=File(lines=[ '#ifndef two_readonly_h', '#define two_readonly_h', 'void two_readonly();', '#endif', ])) self.__two_readonly_sourcedir.add( name='two_readonly.c', entry=File(lines=[ '#include "two_readonly.h"', 'void two_readonly() {}' ])) pass # three_regular source if True: self.__three_regular_sourcedir.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("three-regular")', 'PACKAGE_VERSION("1.2.3")' ])) self.__three_regular_sourcedir.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'LIBRARY(basename="three", members=[H(filename="three_regular.h"), C(filename="three_regular.c")])' ])) self.__three_regular_sourcedir.add(name='three_regular.h', entry=File(lines=[ '#ifndef three_regular_h', '#define three_regular_h', 'void three_regular();', '#endif', ])) self.__three_regular_sourcedir.add( name='three_regular.c', entry=File(lines=[ '#include "three_regular.h"', 'void three_regular() {}' ])) pass # linked source if True: self.__linked_sourcedir.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("linked")', 'PACKAGE_VERSION("1.2.3")' ])) self.__linked_sourcedir.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'EXECUTABLE(exename="exe", center=C(filename="main.c"))' ])) self.__linked_sourcedir.add( name='main.c', entry=File(lines=[ '#include <one_readonly.h>', '#include <two_readonly.h>', '#include <three_regular.h>', '// CONFIX:REQUIRE_H("one_readonly.h", URGENCY_ERROR)', '// CONFIX:REQUIRE_H("two_readonly.h", URGENCY_ERROR)', '// CONFIX:REQUIRE_H("three_regular.h", URGENCY_ERROR)', 'int main(void) {', ' one_readonly();', ' two_readonly();', ' three_regular();', '}' ])) pass # build the three installed packages if True: one_readonly_package = LocalPackage( rootdirectory=self.__one_readonly_sourcedir, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) one_readonly_package.boil(external_nodes=[]) one_readonly_package.output() self.__fs.sync() commands.cmake( packageroot=self.__one_readonly_sourcedir.abspath(), builddir=self.__one_readonly_builddir.abspath(), args=[ '-DCMAKE_INSTALL_PREFIX=' + '/'.join(self.__one_readonly_installdir.abspath()) ]) commands.make(builddir=self.__one_readonly_builddir.abspath(), args=['install']) # paranoia self.failUnless( os.path.isdir( os.sep.join(self.__one_readonly_installdir.abspath() + ['lib']))) self.failUnless( os.path.isfile( os.sep.join(self.__one_readonly_installdir.abspath() + ['include', 'one_readonly.h']))) pass if True: two_readonly_package = LocalPackage( rootdirectory=self.__two_readonly_sourcedir, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) two_readonly_package.boil(external_nodes=[]) two_readonly_package.output() self.__fs.sync() commands.cmake( packageroot=self.__two_readonly_sourcedir.abspath(), builddir=self.__two_readonly_builddir.abspath(), args=[ '-DCMAKE_INSTALL_PREFIX=' + '/'.join(self.__two_readonly_installdir.abspath()) ]) commands.make(builddir=self.__two_readonly_builddir.abspath(), args=['install']) # paranoia self.failUnless( os.path.isdir( os.sep.join(self.__two_readonly_installdir.abspath() + ['lib']))) self.failUnless( os.path.isfile( os.sep.join(self.__two_readonly_installdir.abspath() + ['include', 'two_readonly.h']))) pass if True: three_regular_package = LocalPackage( rootdirectory=self.__three_regular_sourcedir, setups=[ ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) three_regular_package.boil(external_nodes=[]) three_regular_package.output() self.__fs.sync() commands.cmake( packageroot=self.__three_regular_sourcedir.abspath(), builddir=self.__three_regular_builddir.abspath(), args=[ '-DCMAKE_INSTALL_PREFIX=' + '/'.join(self.__regular_installdir.abspath()) ]) commands.make(builddir=self.__three_regular_builddir.abspath(), args=['install']) # paranoia self.failUnless( os.path.isdir( os.sep.join(self.__regular_installdir.abspath() + ['lib']))) self.failUnless( os.path.isfile( os.sep.join(self.__regular_installdir.abspath() + ['include', 'three_regular.h']))) pass pass
def test__library_dependencies_with_readonly_prefixes(self): # boil package with library dependencies enabled. linked_package = LocalPackage(rootdirectory=self.__linked_sourcedir, setups=[ LibraryDependenciesSetup(), ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup() ]) # read repo files along the cascade repo = AutomakeCascadedPackageRepository( prefix=self.__regular_installdir.abspath(), readonly_prefixes=[ self.__two_readonly_installdir.abspath(), self.__one_readonly_installdir.abspath() ]) linked_package.boil(external_nodes=repo.iter_nodes()) linked_package.output() self.__fs.sync() commands.cmake( packageroot=self.__linked_sourcedir.abspath(), builddir=self.__linked_builddir.abspath(), args=[ '-DCMAKE_INSTALL_PREFIX=' + '/'.join(self.__regular_installdir.abspath()), '-DREADONLY_PREFIXES=' + '/'.join(self.__one_readonly_installdir.abspath()) + ';' + '/'.join(self.__two_readonly_installdir.abspath()) ]) commands.make(builddir=self.__linked_builddir.abspath(), args=[]) # wait a bit and then touch libone.a. if True: time.sleep(1) libone = os.sep.join(self.__one_readonly_installdir.abspath() + ['lib', 'libone.a']) os.utime(libone, None) libone_stat = os.stat(libone) # exe is rebuilt as it depends on libone.a if True: commands.make(builddir=self.__linked_builddir.abspath(), args=[]) self.failUnless( os.stat( os.sep.join(self.__linked_builddir.abspath() + ['exe'])).st_mtime >= libone_stat.st_mtime) pass pass # wait a bit and then touch libtwo.a. if True: time.sleep(1) libtwo = os.sep.join(self.__two_readonly_installdir.abspath() + ['lib', 'libtwo.a']) os.utime(libtwo, None) libtwo_stat = os.stat(libtwo) # exe is rebuilt as it depends on libtwo.a if True: commands.make(builddir=self.__linked_builddir.abspath(), args=[]) self.failUnless( os.stat( os.sep.join(self.__linked_builddir.abspath() + ['exe'])).st_mtime >= libtwo_stat.st_mtime) pass pass # wait a bit and then touch libone.a. if True: time.sleep(1) libthree = os.sep.join(self.__regular_installdir.abspath() + ['lib', 'libthree.a']) os.utime(libthree, None) libthree_stat = os.stat(libthree) # exe is rebuilt as it depends on libthree.a if True: commands.make(builddir=self.__linked_builddir.abspath(), args=[]) self.failUnless( os.stat( os.sep.join(self.__linked_builddir.abspath() + ['exe']) ).st_mtime >= libthree_stat.st_mtime) pass pass pass
def test(self): source = Directory() source.add( name=const.CONFIX2_PKG, entry=File(lines=[ 'PACKAGE_NAME("Public-Install")', 'PACKAGE_VERSION("1.2.3")' ])) source.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'DIRECTORY(["headers"])', 'DIRECTORY(["library"])', 'DIRECTORY(["exe"])', 'DIRECTORY(["test"])' ])) headers = source.add(name='headers', entry=Directory()) library = source.add(name='library', entry=Directory()) exe = source.add(name='exe', entry=Directory()) test = source.add(name='test', entry=Directory()) headers.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'H(filename="flat-header.h")', 'H(filename="subdir-header.h", install=["subdir"])', ])) headers.add(name='flat-header.h', entry=File()) headers.add(name='subdir-header.h', entry=File()) library.add( name=const.CONFIX2_DIR, entry=File(lines=[ 'LIBRARY(basename="rary", members=[C(filename="library.c")])' ])) library.add(name='library.c', entry=File()) exe.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'EXECUTABLE(exename="exe",', ' center=C(filename="main.c"))', ])) exe.add(name='main.c', entry=File(lines=['int main(void) { return 0; }'])) test.add(name=const.CONFIX2_DIR, entry=File(lines=[ 'EXECUTABLE(exename="test",', ' center=C(filename="main.c"),', ' what=EXECUTABLE_CHECK)', ])) test.add(name='main.c', entry=File(lines=['int main(void) { return 0; }'])) fs = FileSystem(path=self.rootpath()) source = fs.rootdirectory().add(name='source', entry=source) build = fs.rootdirectory().add(name='build', entry=Directory()) install = fs.rootdirectory().add(name='install', entry=Directory()) package = LocalPackage( rootdirectory=source, setups=[ExplicitDirectorySetup(), ExplicitCSetup(), CMakeSetup()]) package.boil(external_nodes=[]) package.output() fs.sync() commands.cmake( packageroot=source.abspath(), builddir=build.abspath(), args=['-DCMAKE_INSTALL_PREFIX=' + os.sep.join(install.abspath())]) commands.make(builddir=build.abspath(), args=['install']) scan.rescan_dir(install) self.failUnless(install.find(['include', 'flat-header.h'])) self.failUnless(install.find(['include', 'subdir', 'subdir-header.h'])) # if this fails, then you probably are running on Windows. self.failUnless(install.find(['lib', 'library.a'])) self.failUnless(install.find(['bin', 'exe'])) self.failIf(install.find(['bin', 'test'])) self.failUnless( install.find([ 'share', 'confix-%s' % const.REPO_VERSION, 'repo', package.repofilename() ])) pass