def package(self): self.copy("COPYING-*", src=self._source_subfolder, dst="licenses") with self._build_context(): autotools = self._configure_autotools() autotools.install() pc_data = {} for fn in glob.glob( os.path.join(self.package_folder, "share", "pkgconfig", "*.pc")): pc_text = load(self, fn) filename = os.path.basename(fn)[:-3] name = next( re.finditer("^Name: ([^\n$]+)[$\n]", pc_text, flags=re.MULTILINE)).group(1) version = next( re.finditer("^Version: ([^\n$]+)[$\n]", pc_text, flags=re.MULTILINE)).group(1) pc_data[filename] = { "version": version, "name": name, } mkdir(self, os.path.dirname(self._pc_data_path)) save(self, self._pc_data_path, yaml.dump(pc_data)) rmdir(self, os.path.join(self.package_folder, "share"))
def configure(self, build_script_folder=None): cmakelist_folder = self._conanfile.source_folder if build_script_folder: cmakelist_folder = os.path.join(self._conanfile.source_folder, build_script_folder) build_folder = self._conanfile.build_folder generator_folder = self._conanfile.generators_folder mkdir(self._conanfile, build_folder) arg_list = [self._cmake_program] if self._generator: arg_list.append('-G "{}"'.format(self._generator)) if self._toolchain_file: if os.path.isabs(self._toolchain_file): toolpath = self._toolchain_file else: toolpath = os.path.join(generator_folder, self._toolchain_file) arg_list.append('-DCMAKE_TOOLCHAIN_FILE="{}"'.format( toolpath.replace("\\", "/"))) if self._conanfile.package_folder: pkg_folder = self._conanfile.package_folder.replace("\\", "/") arg_list.append('-DCMAKE_INSTALL_PREFIX="{}"'.format(pkg_folder)) if platform.system( ) == "Windows" and self._generator == "MinGW Makefiles": arg_list.append('-DCMAKE_SH="CMAKE_SH-NOTFOUND"') arg_list.append('"{}"'.format(cmakelist_folder)) command = " ".join(arg_list) self._conanfile.output.info("CMake command: %s" % command) with chdir(self, build_folder): self._conanfile.run(command)
def folders(): tmp = temp_folder() files = ["foo/var/file.txt"] outside_folder = temp_folder() symlinks = [ (os.path.join(tmp, "foo/var/file.txt"), "foo/var/other/absolute.txt"), # Absolute link (os.path.join(tmp, "foo/var"), "foo/var/other/other/myfolder"), # Absolute link folder (os.path.join(tmp, "foo/var/file.txt"), "foo/absolute.txt"), # Absolute link ("foo/var/file.txt", "foo/var/other/relative.txt"), # Relative link ("missing.txt", "foo/var/other/broken.txt"), # Broken link (outside_folder, "foo/var/other/absolute_outside" ), # Absolute folder outside the folder ("../../../../../outside", "foo/absolute_outside"), # Relative folder outside the folder ] # Create the files and symlinks for path in files: mkdir(None, os.path.dirname(os.path.join(tmp, path))) with open(os.path.join(tmp, path), "w") as fl: fl.write("foo") for link_dst, linked_file in symlinks: mkdir(None, os.path.dirname(os.path.join(tmp, linked_file))) os.symlink(link_dst, os.path.join(tmp, linked_file)) return tmp, outside_folder
def configure(self, variables=None, build_script_folder=None): cmakelist_folder = self._conanfile.source_folder if build_script_folder: cmakelist_folder = os.path.join(self._conanfile.source_folder, build_script_folder) build_folder = self._conanfile.build_folder generator_folder = self._conanfile.generators_folder mkdir(self._conanfile, build_folder) arg_list = [self._cmake_program] if self._generator: arg_list.append('-G "{}"'.format(self._generator)) if self._toolchain_file: if os.path.isabs(self._toolchain_file): toolpath = self._toolchain_file else: toolpath = os.path.join(generator_folder, self._toolchain_file) arg_list.append('-DCMAKE_TOOLCHAIN_FILE="{}"'.format( toolpath.replace("\\", "/"))) if self._conanfile.package_folder: pkg_folder = self._conanfile.package_folder.replace("\\", "/") arg_list.append('-DCMAKE_INSTALL_PREFIX="{}"'.format(pkg_folder)) if platform.system( ) == "Windows" and self._generator == "MinGW Makefiles": # It seems these don't work in the toolchain file, they need to be here in command line arg_list.append('-DCMAKE_SH="CMAKE_SH-NOTFOUND"') cmake_make_program = self._conanfile.conf.get( "tools.gnu:make_program", default=None) if cmake_make_program: cmake_make_program = cmake_make_program.replace("\\", "/") arg_list.append( '-DCMAKE_MAKE_PROGRAM="{}"'.format(cmake_make_program)) if variables: arg_list.extend( ["-D{}={}".format(k, v) for k, v in variables.items()]) arg_list.append('"{}"'.format(cmakelist_folder)) command = " ".join(arg_list) self._conanfile.output.info("CMake command: %s" % command) with chdir(self, build_folder): self._conanfile.run(command)
def install(self, build_type=None): mkdir(self._conanfile, self._conanfile.package_folder) bt = build_type or self._conanfile.settings.get_safe("build_type") if not bt: raise ConanException("build_type setting should be defined.") is_multi = is_multi_configuration(self._generator) build_config = "--config {}".format(bt) if bt and is_multi else "" pkg_folder = args_to_string( [self._conanfile.package_folder.replace("\\", "/")]) build_folder = args_to_string([self._conanfile.build_folder]) arg_list = [ "--install", build_folder, build_config, "--prefix", pkg_folder ] arg_list = " ".join(filter(None, arg_list)) command = "%s %s" % (self._cmake_program, arg_list) self._conanfile.output.info("CMake command: %s" % command) self._conanfile.run(command)
def package(self): self.copy(pattern="COPYING", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() rmdir(self, os.path.join(self.package_folder, "share", "doc")) mkdir(self, os.path.join(self.package_folder, "res")) for i in ["var", "share", "etc"]: rename(self, os.path.join(self.package_folder, i), os.path.join(self.package_folder, "res", i)) rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) rmdir(self, os.path.join(self.package_folder, "lib", "systemd")) remove_files_by_mask(self.package_folder, "*.la") # TODO: to remove in conan v2 once cmake_find_package_* generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"dbus-1": "dbus-1::dbus-1"})
def configure(self, variables=None, build_script_folder=None): cmakelist_folder = self._conanfile.source_folder if build_script_folder: cmakelist_folder = os.path.join(self._conanfile.source_folder, build_script_folder) build_folder = self._conanfile.build_folder generator_folder = self._conanfile.generators_folder mkdir(self._conanfile, build_folder) arg_list = [self._cmake_program] if self._generator: arg_list.append('-G "{}"'.format(self._generator)) if self._toolchain_file: if os.path.isabs(self._toolchain_file): toolpath = self._toolchain_file else: toolpath = os.path.join(generator_folder, self._toolchain_file) arg_list.append('-DCMAKE_TOOLCHAIN_FILE="{}"'.format( toolpath.replace("\\", "/"))) if self._conanfile.package_folder: pkg_folder = self._conanfile.package_folder.replace("\\", "/") arg_list.append('-DCMAKE_INSTALL_PREFIX="{}"'.format(pkg_folder)) if not variables: variables = {} self._cache_variables.update(variables) arg_list.extend([ '-D{}="{}"'.format(k, v) for k, v in self._cache_variables.items() ]) arg_list.append('"{}"'.format(cmakelist_folder)) command = " ".join(arg_list) self._conanfile.output.info("CMake command: %s" % command) with chdir(self, build_folder): self._conanfile.run(command)
def generate(self): tc = MesonToolchain(self) tc.project_options["libdir"] = "lib" tc.project_options["datadir"] = "res" tc.project_options["libraries"] = self.options.enable_libraries tc.project_options[ "dtd_validation"] = self.options.enable_dtd_validation tc.project_options["documentation"] = False if Version(self.version) >= "1.18.91": tc.project_options["scanner"] = True # Generate PC files for the tool_requires wayland package to ensure wayland-scanner is found for build machine. if cross_building(self): native_generators_folder = os.path.join( self.generators_folder, "native") mkdir(self, native_generators_folder) for pc_name, pc_content in get_pc_files_and_content( self, self.dependencies.build["wayland"]).items(): save(self, os.path.join(native_generators_folder, pc_name), pc_content) tc.project_options[ "build.pkg_config_path"] = native_generators_folder tc.generate()
def install(self, build_type=None): if not self._conanfile.should_install: return mkdir(self._conanfile, self._conanfile.package_folder) self._build(build_type=build_type, target="install")