def _build(make): for package in ['xkbcommon', 'glib']: if package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, dirnames, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile( os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file( filename, lib_path) with tools.environment_append({ "MAKEFLAGS": "j%d" % tools.cpu_count(), "PKG_CONFIG_PATH": os.getcwd() }): try: self.run("%s/qt5/configure %s" % (self.source_folder, " ".join(args))) finally: self.output.info(open('config.log', 'r').read()) self.run(make, run_environment=True) self.run("%s install" % make)
def _patch_files(self): # - fontconfig requires libtool version number, change it for the corresponding freetype one tools.replace_in_file(os.path.join(self._source_subfolder, 'configure'), '21.0.15', '2.8.1') # Patch freetype2 freetype_path = self.deps_cpp_info["freetype"].rootpath shutil.copyfile(os.path.join(freetype_path, "lib", "pkgconfig", "freetype2.pc"), "freetype2.pc") tools.replace_prefix_in_pc_file("freetype2.pc", freetype_path)
def _patch_pc_files(self): # Patch freetype2 freetype_path = self.deps_cpp_info["freetype"].rootpath shutil.copyfile( os.path.join(freetype_path, "lib", "pkgconfig", "freetype2.pc"), "freetype2.pc") tools.replace_prefix_in_pc_file("freetype2.pc", freetype_path)
def build(self): if "mesa" in self.deps_cpp_info.deps: mesa_path = self.deps_cpp_info["mesa"].rootpath shutil.copyfile(os.path.join(mesa_path, "lib", "pkgconfig", "gl.pc"), "gl.pc") tools.replace_prefix_in_pc_file("gl.pc", mesa_path) with tools.environment_append({"PKG_CONFIG_PATH": os.getcwd()}): cmake = self._get_cmake() cmake.build()
def import_pkg_config_files(self, pkg, pkgconfig_path): for root, dirs, files in os.walk(self.deps_cpp_info[pkg].rootpath): for file in files: if file.endswith("pc"): source_path = os.path.join(root, file) target_path = os.path.join(pkgconfig_path, file) print("Importing pkg_config file: %s" % target_path) copyfile(source_path, target_path) tools.replace_prefix_in_pc_file(target_path, self.deps_cpp_info[pkg].rootpath)
def copy_pkg_config(self, name): root = self.deps_cpp_info[name].rootpath pc_dir = os.path.join(root, 'lib', 'pkgconfig') pc_files = glob.glob('%s/*.pc' % pc_dir) for pc_name in pc_files: new_pc = os.path.join('pkgconfig', os.path.basename(pc_name)) self.output.warn('copy .pc file %s' % os.path.basename(pc_name)) shutil.copy(pc_name, new_pc) tools.replace_prefix_in_pc_file(new_pc, root)
def build(self): args = ["--enable-shared", "--enable-namespaceversioning", ] autotools = AutoToolsBuildEnvironment(self) # LD_LIBRARY_PATH is needed by the configure script to find libHalf and numpy with tools.environment_append(RunEnvironment(self).vars): autotools.configure(configure_dir='pyilmbase-{}'.format(self.version), args=args) autotools.make() tools.replace_prefix_in_pc_file("PyIlmBase.pc", "${package_root_path_pyilmbase}")
def _gather_pc_files(package): if package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) for dep in self.deps_cpp_info[package].public_deps: _gather_pc_files(dep)
def build(self): for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) meson = self._configure_meson() meson.build()
def _copy_pkg_config(self, name): root = self.deps_cpp_info[name].rootpath pc_dir = os.path.join(root, 'lib', 'pkgconfig') pc_files = glob.glob('%s/*.pc' % pc_dir) for pc_name in pc_files: new_pc = os.path.basename(pc_name) self.output.warn('copy .pc file %s' % os.path.basename(pc_name)) shutil.copy(pc_name, new_pc) prefix = tools.unix_path( root) if self.settings.os == 'Windows' else root tools.replace_prefix_in_pc_file(new_pc, prefix)
def build(self): for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() autotools.make()
def build(self): args = [ "--enable-shared", "--enable-namespaceversioning", ] autotools = AutoToolsBuildEnvironment(self) autotools.configure(configure_dir='ilmbase-{}'.format(self.version), args=args) autotools.make() tools.replace_prefix_in_pc_file("IlmBase.pc", "${package_root_path_ilmbase}")
def copy_pkg_config(self, name): root = self.deps_cpp_info[name].rootpath self.output.info('prefix in pc file will be replaced with %s'%root) pc_dir = os.path.join(root, 'lib', 'pkgconfig') pc_files = glob.glob('%s/*.pc' % pc_dir) if not pc_files: # zlib store .pc in root pc_files = glob.glob('%s/*.pc' % root) for pc_name in pc_files: new_pc = os.path.basename(pc_name) self.output.warn('copy and modify .pc file %s' %pc_name) shutil.copy(pc_name, new_pc) prefix = root tools.replace_prefix_in_pc_file(new_pc, prefix)
def build(self): cmake = CMake(self) cmake.definitions['BUILD_TRAINING_TOOLS'] = self.options.with_training cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared cmake.definitions["STATIC"] = not self.options.shared # provide patched lept.pc shutil.copy( os.path.join(self.deps_cpp_info['leptonica'].rootpath, 'lib', 'pkgconfig', 'lept.pc'), 'lept.pc') tools.replace_prefix_in_pc_file( "lept.pc", self.deps_cpp_info['leptonica'].rootpath) # VS build uses cmake to locate leptonica use_pkg_config = self.settings.compiler != "Visual Studio" # use cmake-based configure even for unix use_pkg_config = False # if static leptonica used with pkg-config, tesseract must use Leptonica_STATIC_LIBRARIES # which use static dependencies like jpeg, png etc provided by lept.pc if not self.options['leptonica'].shared and use_pkg_config: tools.replace_in_file( os.path.join(self._source_subfolder, "CMakeListsOriginal.txt"), "target_link_libraries (libtesseract ${Leptonica_LIBRARIES})", "target_link_libraries (libtesseract ${Leptonica_STATIC_LIBRARIES})" ) if self.version == "3.05.01": # upstream bug: output name is not substituted for tesseract.pc # fixed in master but still an issue for stable tools.replace_in_file( os.path.join(self._source_subfolder, "CMakeListsOriginal.txt"), "set_target_properties (libtesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)", "set_target_properties (libtesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)\n" "else()\n" "set_target_properties (libtesseract PROPERTIES OUTPUT_NAME tesseract)\n" ) if not use_pkg_config: cmake.definitions['Leptonica_DIR'] = self.deps_cpp_info[ 'leptonica'].rootpath with tools.environment_append({'PKG_CONFIG_PATH': self.build_folder }) if use_pkg_config else tools.no_op(): cmake.configure(source_folder=self._source_subfolder) cmake.build() cmake.install() cmake.patch_config_paths() self._fix_absolute_paths()
def build(self): yes_no = {True: "enable", False: "disable"} args = [ "--{}-shared".format(yes_no.get(bool(self.options.shared))), "--{}-static".format(yes_no.get(not bool(self.options.shared))), "--{}-namespaceversioning".format( yes_no.get(bool(self.options.namespace_versioning))), ] autotools = AutoToolsBuildEnvironment(self) autotools.configure(configure_dir='ilmbase-{}'.format(self.version), args=args) autotools.make() tools.replace_prefix_in_pc_file("IlmBase.pc", "${package_root_path_ilmbase}")
def build(self): args = [ "--enable-shared", "--enable-namespaceversioning", ] autotools = AutoToolsBuildEnvironment(self) # LD_LIBRARY_PATH is needed by the configure script to find libHalf with tools.environment_append(RunEnvironment(self).vars): # To fix another configure error when checking for libz with tools.environment_append({'LDFLAGS': '-lpthread'}): autotools.configure(configure_dir='openexr-{}'.format( self.version), args=args) autotools.make() tools.replace_prefix_in_pc_file("OpenEXR.pc", "${package_root_path_openexr}")
def pkgconfig_adaption(conanfile,pkgconfig_folder='~pkgconfig'): pkgconfigd=os.path.abspath(pkgconfig_folder) requires = conanfile.requires for (name,reference) in requires.items(): rootd = conanfile.deps_cpp_info[name].rootpath pcd = os.path.join(rootd,'lib/pkgconfig') for name in os.listdir(pcd): pcfile=os.path.join(pcd,name) if name.endswith('.pc') and os.path.isfile(pcfile) : filename = os.path.join(pkgconfigd,name) if not os.path.isdir(pkgconfigd): os.makedirs(pkgconfigd) shutil.copy(pcfile, filename) tools.replace_prefix_in_pc_file(filename,rootd) tools.out.info('%s ->%s'%(name,filename))
def build(self): for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) with tools.chdir(self._source_subfolder): args = ["--disable-dependency-tracking"] args.extend(self._configure_args) env_build = AutoToolsBuildEnvironment(self) env_build.configure(args=args, pkg_config_paths=self.build_folder) env_build.make() env_build.install(args=["-j1"])
def _patch_files(self): # - fontconfig requires libtool version number, change it for the corresponding freetype one tools.replace_in_file( os.path.join(self._source_subfolder, 'configure'), '21.0.15', '2.8.1') # Patch freetype2 freetype_path = self.deps_cpp_info["freetype"].rootpath shutil.copyfile( os.path.join(freetype_path, "lib", "pkgconfig", "freetype2.pc"), "freetype2.pc") tools.replace_prefix_in_pc_file("freetype2.pc", freetype_path) if self.settings.build_type == "Debug": content = tools.load("freetype2.pc") content = re.sub("-lfreetype(?!d)", "-lfreetyped", content) content = content.encode("utf-8") with open("freetype2.pc", "wb") as handle: handle.write(content)
def copy_pkg_config(self, name): root = self.deps_cpp_info[name].rootpath pc_dir = os.path.join(root, 'lib', 'pkgconfig') pc_files = glob.glob('{}/*.pc'.format(pc_dir)) self.output.warn('Copy .pc files from {} to {}'.format( root, os.getcwd())) if not pc_files: # maybe it's stored in .pc at root pc_files = glob.glob('{}/**/*.pc'.format(root), recursive=True) for pc_name in pc_files: new_pc = os.path.basename(pc_name) self.output.warn('\tcopy {}'.format(os.path.basename(pc_name))) shutil.copy(pc_name, new_pc) if tools.os_info.is_windows: prefix = root.replace('\\', '/') else: prefix = root tools.replace_prefix_in_pc_file(new_pc, prefix)
def build(self): for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith(".pc"): if filename in [ "cairo.pc", "fontconfig.pc", "xext.pc", "xi.pc", "x11.pc", "xcb.pc" ]: continue shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) with tools.environment_append(tools.RunEnvironment(self).vars): meson = self._configure_meson() meson.build()
def _configure_autotools(self): if not self._autotools: for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) args = ["--enable-shared", "--disable-static" ] if self.options.shared else [ "--enable-static", "--disable-shared" ] self._autotools = AutoToolsBuildEnvironment(self) self._autotools.configure(configure_dir=self._source_subfolder, pkg_config_paths=self.build_folder, args=args) return self._autotools
def build(self): for filename in sorted(glob.glob("patches/*.patch")): self.output.info('applying patch "%s"' % filename) tools.patch(base_path=self._source_subfolder, patch_file=filename) for package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): if filename in ["cairo.pc", "fontconfig.pc"]: continue shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, tools.unix_path(lib_path) if self.settings.os == 'Windows' else lib_path) meson_build = os.path.join(self._source_subfolder, "meson.build") tools.replace_in_file(meson_build, "subdir('tests')", "") tools.replace_in_file(meson_build, "subdir('tools')", "") tools.replace_in_file(meson_build, "subdir('utils')", "") tools.replace_in_file(meson_build, "subdir('examples')", "") with tools.environment_append(VisualStudioBuildEnvironment(self).vars) if self._is_msvc else tools.no_op(): meson = self._configure_meson() meson.build()
def package_info(self): self.cpp_info.includedirs = ['include' ] # Ordered list of include paths self.cpp_info.libs = ['flann'] # The libs to link against self.cpp_info.libdirs = ['lib' ] # Directories where libraries can be found self.cpp_info.resdirs = [ 'res' ] # Directories where resources, data, etc can be found self.cpp_info.bindirs = [ ] # Directories where executables and shared libs can be found self.cpp_info.defines = [] # preprocessor definitions self.cpp_info.cflags = [] # pure C flags self.cpp_info.cppflags = [] # C++ compilation flags self.cpp_info.sharedlinkflags = [] # linker flags self.cpp_info.exelinkflags = [] # linker flags self.env_info.FLANN_ROOT = self.package_folder self.env_info.PKG_CONFIG_PATH.append( os.path.join(self.package_folder, "lib", "pkgconfig")) tools.replace_prefix_in_pc_file( os.path.join(self.package_folder, "lib", "pkgconfig", "flann.pc"), self.package_folder)
def build(self): emcc = self.is_emscripten() if self.options.with_openjpeg: # patch prefix for openjpeg pc file. # note the difference between pc name and package name shutil.copy( os.path.join(self.deps_cpp_info['openjpeg'].rootpath, 'lib', 'pkgconfig', 'libopenjp2.pc'), 'libopenjp2.pc') tools.replace_prefix_in_pc_file( "libopenjp2.pc", self.deps_cpp_info['openjpeg'].rootpath) # leptonica finds openjpeg.h in a wrong directory. just patch a pc file tools.replace_in_file("libopenjp2.pc", 'includedir=${prefix}/include/openjpeg-2.3', 'includedir=${prefix}/include') with tools.environment_append({'PKG_CONFIG_PATH': self.build_folder}): cmake = CMake(self) cmake.definitions[ 'STATIC'] = False if emcc else not self.options.shared cmake.definitions['BUILD_PROG'] = False # avoid finding system libs cmake.definitions[ 'CMAKE_DISABLE_FIND_PACKAGE_GIF'] = not self.options.with_gif cmake.definitions[ 'CMAKE_DISABLE_FIND_PACKAGE_PNG'] = not self.options.with_png cmake.definitions[ 'CMAKE_DISABLE_FIND_PACKAGE_TIFF'] = not self.options.with_tiff cmake.definitions[ 'CMAKE_DISABLE_FIND_PACKAGE_JPEG'] = not self.options.with_jpeg # avoid finding system libs by pkg-config by removing finders because they have no off switch if self.options.with_openjpeg: # check_include_files need to know where openjp2k resides tools.replace_in_file( os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "pkg_check_modules(JP2K libopenjp2)", 'pkg_check_modules(JP2K libopenjp2)\n' 'list(APPEND CMAKE_REQUIRED_INCLUDES "${JP2K_INCLUDE_DIRS}")' ) else: tools.replace_in_file( os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "pkg_check_modules(JP2K libopenjp2)", "") # webp does not provide .pc file but provide cmake configs. so use find_package instead if self.options.with_webp: tools.replace_in_file( os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "pkg_check_modules(WEBP libwebp)", "find_package(WEBP REQUIRED NAMES WEBP WebP NO_SYSTEM_ENVIRONMENT_PATH)" ) else: tools.replace_in_file( os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "pkg_check_modules(WEBP libwebp)", "") cmake.configure(source_folder=self.source_subfolder) cmake.build() cmake.install() self._fix_absolute_paths()
def build(self): tools.replace_prefix_in_pc_file("stm32f4stdperiph.pc", VARNAME_STM32STDPERIPH)
def build(self): emcc = self.is_emscripten() cmake = CMake(self) cmake.definitions['BUILD_TRAINING_TOOLS'] = False cmake.definitions["BUILD_SHARED_LIBS"] = True if emcc else self.options.shared cmake.definitions["STATIC"] = False if emcc else not self.options.shared if emcc: shutil.copy("helpers.js", os.path.join(self.source_subfolder, "helpers.js")) tools.replace_in_file(os.path.join(self.source_subfolder, "src/viewer/svpaint.cpp"), 'int main(int argc, char** argv) {', 'static int svpaint_main(int argc, char** argv) {') tools.replace_in_file(os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), 'PROPERTIES COMPILE_FLAGS "-msse4.1")', 'PROPERTIES COMPILE_FLAGS "")') tools.replace_in_file(os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), 'PROPERTIES COMPILE_FLAGS "-mavx")', 'PROPERTIES COMPILE_FLAGS "")') tools.replace_in_file(os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), 'PROPERTIES COMPILE_FLAGS "-mavx2")', 'PROPERTIES COMPILE_FLAGS "")') tools.replace_in_file(os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), 'target_link_libraries (tesseract libtesseract)', 'target_link_libraries (tesseract libtesseract)\n' + 'set(JS_HELPER "${CMAKE_CURRENT_SOURCE_DIR}/helpers.js")\n' + 'set(EMSCRIPTEN_LINK_FLAGS "--memory-init-file 0 -s TOTAL_MEMORY=134217728 ' + '-s ALLOW_MEMORY_GROWTH=1 -s DEMANGLE_SUPPORT=1")\n' + 'set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -Wno-missing-prototypes")\n' + 'set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} --pre-js ${JS_HELPER}")\n' + 'set_target_properties(tesseract PROPERTIES LINK_FLAGS ${EMSCRIPTEN_LINK_FLAGS})') tools.replace_in_file(os.path.join(self.source_subfolder, "src/api/baseapi.cpp"), 'locale = std::setlocale(LC_ALL, nullptr);', 'locale = std::setlocale(LC_ALL, nullptr);\n' + ' #ifdef __emscripten__\n' + " if (locale[0]=='C')\n" + ' locale="C"; // workaround for emscripten \n' + '#endif\n' ) # provide patched lept.pc shutil.copy(os.path.join(self.deps_cpp_info['leptonica'].rootpath, 'lib', 'pkgconfig', 'lept.pc'), 'lept.pc') tools.replace_prefix_in_pc_file("lept.pc", self.deps_cpp_info['leptonica'].rootpath) # VS build uses cmake to locate leptonica use_pkg_config = self.settings.compiler != "Visual Studio" # use cmake-based configure even for unix use_pkg_config = False # if static leptonica used with pkg-config, tesseract must use Leptonica_STATIC_LIBRARIES # which use static dependencies like jpeg, png etc provided by lept.pc if not emcc and not self.options['leptonica'].shared and use_pkg_config: tools.replace_in_file(os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "target_link_libraries (libtesseract ${Leptonica_LIBRARIES})", "target_link_libraries (libtesseract ${Leptonica_STATIC_LIBRARIES})") if self.version == "3.05.01": # upstream bug: output name is not substituted for tesseract.pc # fixed in master but still an issue for stable tools.replace_in_file( os.path.join(self.source_subfolder, "CMakeListsOriginal.txt"), "set_target_properties (libtesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)", "set_target_properties (libtesseract PROPERTIES DEBUG_OUTPUT_NAME tesseract${VERSION_MAJOR}${VERSION_MINOR}d)\n" "else()\n" "set_target_properties (libtesseract PROPERTIES OUTPUT_NAME tesseract)\n") if not use_pkg_config: cmake.definitions['Leptonica_DIR'] = self.deps_cpp_info['leptonica'].rootpath with tools.environment_append({'PKG_CONFIG_PATH': self.build_folder}) if use_pkg_config else tools.no_op(): cmake.configure(source_folder=self.source_subfolder) cmake.build() cmake.install() self._fix_absolute_paths()
def build(self): args = [ "-confirm-license", "-silent", "-nomake examples", "-nomake tests", "-prefix %s" % self.package_folder ] if self.options.commercial: args.append("-commercial") else: args.append("-opensource") if not self.options.GUI: args.append("-no-gui") if not self.options.widgets: args.append("-no-widgets") if not self.options.shared: args.insert(0, "-static") if self.settings.compiler == "Visual Studio": if self.settings.compiler.runtime == "MT" or self.settings.compiler.runtime == "MTd": args.append("-static-runtime") else: args.insert(0, "-shared") if self.options.multiconfiguration: args.append("-debug-and-release") elif self.settings.build_type == "Debug": args.append("-debug") elif self.settings.build_type == "Release": args.append("-release") elif self.settings.build_type == "RelWithDebInfo": args.append("-release") args.append("-force-debug-info") elif self.settings.build_type == "MinSizeRel": args.append("-release") args.append("-optimize-size") for module in self._submodules: if module != 'qtbase' and not getattr(self.options, module) \ and os.path.isdir(os.path.join(self.source_folder, 'qt5', self._submodules[module]['path'])): args.append("-skip " + module) args.append("--zlib=system") # openGL if self.options.opengl == "no": args += ["-no-opengl"] elif self.options.opengl == "es2": args += ["-opengl es2"] elif self.options.opengl == "desktop": args += ["-opengl desktop"] elif self.options.opengl == "dynamic": args += ["-opengl dynamic"] # openSSL if not self.options.openssl: args += ["-no-openssl"] else: if self.options["openssl"].shared: args += ["-openssl-runtime"] else: args += ["-openssl-linked"] # args.append("--iconv=" + ("gnu" if self.options.with_libiconv else "no")) args.append("--glib=" + ("yes" if self.options.with_glib else "no")) args.append("--pcre=" + ("system" if self.options.with_pcre2 else "qt")) args.append("--fontconfig=" + ("yes" if self.options.with_fontconfig else "no")) args.append("--icu=" + ("yes" if self.options.with_icu else "no")) args.append("--sql-mysql=" + ("yes" if self.options.with_mysql else "no")) args.append("--sql-psql=" + ("yes" if self.options.with_pq else "no")) args.append("--sql-odbc=" + ("yes" if self.options.with_odbc else "no")) if self.options.qtmultimedia: args.append("--alsa=" + ("yes" if self.options.with_libalsa else "no")) for opt, conf_arg in [("with_doubleconversion", "doubleconversion"), ("with_freetype", "freetype"), ("with_harfbuzz", "harfbuzz"), ("with_libjpeg", "libjpeg"), ("with_libpng", "libpng"), ("with_sqlite3", "sqlite")]: if getattr(self.options, opt): if self.options.multiconfiguration: args += ["-qt-" + conf_arg] else: args += ["-system-" + conf_arg] else: args += ["-no-" + conf_arg] libmap = [ ("zlib", "ZLIB"), ("openssl", "OPENSSL"), ("pcre2", "PCRE2"), ("glib", "GLIB"), # ("libiconv", "ICONV"), ("double-conversion", "DOUBLECONVERSION"), ("freetype", "FREETYPE"), ("fontconfig", "FONTCONFIG"), ("icu", "ICU"), ("harfbuzz", "HARFBUZZ"), ("libjpeg-turbo", "LIBJPEG"), ("libpng", "LIBPNG"), ("sqlite3", "SQLITE"), ("libmysqlclient", "MYSQL"), ("libpq", "PSQL"), ("odbc", "ODBC"), ("sdl2", "SDL2"), ("openal", "OPENAL"), ("libalsa", "ALSA") ] libPaths = [] for package, var in libmap: if package in self.deps_cpp_info.deps: if package == 'freetype': args.append( "\"%s_INCDIR=%s\"" % (var, self.deps_cpp_info[package].include_paths[-1])) #else: # MercsEng: no else, we DO want freetype included like other packages. args += [ "-I " + s for s in self.deps_cpp_info[package].include_paths ] args += [ "-D " + s for s in self.deps_cpp_info[package].defines ] def _remove_duplicate(l): seen = set() seen_add = seen.add for element in itertools.filterfalse(seen.__contains__, l): seen_add(element) yield element def _gather_libs(p): libs = ["-l" + i for i in self.deps_cpp_info[p].libs] if self.settings.os in ["Macos", "iOS", "watchOS", "tvOS"]: libs += [ "-framework " + i for i in self.deps_cpp_info[p].frameworks ] libs += self.deps_cpp_info[p].sharedlinkflags for dep in self.deps_cpp_info[p].public_deps: libs += _gather_libs(dep) return _remove_duplicate(libs) args.append("\"%s_LIBS=%s\"" % (var, " ".join(_gather_libs(package)))) def _gather_lib_paths(p): lib_paths = self.deps_cpp_info[p].lib_paths for dep in self.deps_cpp_info[p].public_deps: lib_paths += _gather_lib_paths(dep) return _remove_duplicate(lib_paths) libPaths += _gather_lib_paths(package) args += ["-L " + s for s in _remove_duplicate(libPaths)] if 'libmysqlclient' in self.deps_cpp_info.deps: args.append( "-mysql_config " + os.path.join(self.deps_cpp_info['libmysqlclient'].rootpath, "bin", "mysql_config")) if 'libpq' in self.deps_cpp_info.deps: args.append("-psql_config " + os.path.join( self.deps_cpp_info['libpq'].rootpath, "bin", "pg_config")) if self.settings.os == "Linux": if self.options.GUI: args.append("-qt-xcb") elif self.settings.os == "Macos": args += ["-no-framework"] elif self.settings.os == "Android": args += [ "-android-ndk-platform android-%s" % self.settings.os.api_level ] args += [ "-android-arch %s" % { "armv6": "armeabi", "armv7": "armeabi-v7a", "armv8": "arm64-v8a", "x86": "x86", "x86_64": "x86_64", "mips": "mips", "mips64": "mips64" }.get(str(self.settings.arch)) ] # args += ["-android-toolchain-version %s" % self.settings.compiler.version] if self.options.sysroot: args += ["-sysroot %s" % self.options.sysroot] if self.options.device: args += ["-device %s" % self.options.device] if self.options.cross_compile: args += [ "-device-option CROSS_COMPILE=%s" % self.options.cross_compile ] else: xplatform_val = self._xplatform() if xplatform_val: if not tools.cross_building(self.settings, skip_x64_x86=True): args += ["-platform %s" % xplatform_val] else: args += ["-xplatform %s" % xplatform_val] else: self.output.warn( "host not supported: %s %s %s %s" % (self.settings.os, self.settings.compiler, self.settings.compiler.version, self.settings.arch)) def _getenvpath(var): val = os.getenv(var) if val and tools.os_info.is_windows: val = val.replace("\\", "/") os.environ[var] = val return val value = _getenvpath('CC') if value: args += [ 'QMAKE_CC="' + value + '"', 'QMAKE_LINK_C="' + value + '"', 'QMAKE_LINK_C_SHLIB="' + value + '"' ] value = _getenvpath('CXX') if value: args += [ 'QMAKE_CXX="' + value + '"', 'QMAKE_LINK="' + value + '"', 'QMAKE_LINK_SHLIB="' + value + '"' ] if tools.os_info.is_linux and self.settings.compiler == "clang": args += ['QMAKE_CXXFLAGS+="-ftemplate-depth=1024"'] if self.settings.os != "Windows": args += ["-no-d3d12"] if self.options.config: args.append(str(self.options.config)) for package in ['xkbcommon', 'glib']: if package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) with tools.vcvars( self.settings ) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.environment_append({ "MAKEFLAGS": "j%d" % tools.cpu_count(), "PKG_CONFIG_PATH": os.getcwd() }): try: self.run("%s/qt5/configure %s" % (self.source_folder, " ".join(args))) finally: self.output.info( open('config.log', errors='backslashreplace').read()) if self.settings.compiler == "Visual Studio": make = "jom" elif tools.os_info.is_windows: make = "mingw32-make" else: make = "make" self.run(make, run_environment=True) self.run("%s install" % make) with open('qtbase/bin/qt.conf', 'w') as f: f.write('[Paths]\nPrefix = ..')
def build(self): args = [ "-confirm-license", "-silent", "-nomake examples", "-nomake tests", "-prefix %s" % self.package_folder ] if self.options.commercial: args.append("-commercial") else: args.append("-opensource") if not self.options.GUI: args.append("-no-gui") if not self.options.widgets: args.append("-no-widgets") if not self.options.shared: args.insert(0, "-static") if self.settings.compiler == "Visual Studio": if self.settings.compiler.runtime == "MT" or self.settings.compiler.runtime == "MTd": args.append("-static-runtime") else: args.insert(0, "-shared") if self.options.multiconfiguration: args.append("-debug-and-release") elif self.settings.build_type == "Debug": args.append("-debug") elif self.settings.build_type == "Release": args.append("-release") elif self.settings.build_type == "RelWithDebInfo": args.append("-release") args.append("-force-debug-info") elif self.settings.build_type == "MinSizeRel": args.append("-release") args.append("-optimize-size") for module in QtConan._submodules: if module != 'qtbase' and not getattr(self.options, module) \ and os.path.isdir(os.path.join(self.source_folder, 'qt5', QtConan._submodules[module]['path'])): args.append("-skip " + module) # openGL if self.options.opengl == "no": args += ["-no-opengl"] elif self.options.opengl == "es2": args += ["-opengl es2"] elif self.options.opengl == "desktop": args += ["-opengl desktop"] if self.settings.os == "Windows": if self.options.opengl == "dynamic": args += ["-opengl dynamic"] # openSSL if not self.options.openssl: args += ["-no-openssl"] else: if self.options["OpenSSL"].shared: args += ["-openssl-runtime"] else: args += ["-openssl-linked"] # args.append("--iconv=" + ("gnu" if self.options.with_libiconv else "no")) args.append("--glib=" + ("yes" if self.options.with_glib else "no")) args.append("--pcre=" + ("system" if self.options.with_pcre2 else "qt")) # args.append("--icu=" + ("yes" if self.options.with_icu else "no")) args.append("--sql-mysql=" + ("yes" if self.options.with_mysql else "no")) args.append("--sql-psql=" + ("yes" if self.options.with_pq else "no")) args.append("--sql-odbc=" + ("yes" if self.options.with_odbc else "no")) for opt, conf_arg in [("with_doubleconversion", "doubleconversion"), ("with_freetype", "freetype"), ("with_harfbuzz", "harfbuzz"), ("with_libjpeg", "libjpeg"), ("with_libpng", "libpng"), ("with_sqlite3", "sqlite")]: if getattr(self.options, opt): if self.options.multiconfiguration: args += ["-qt-" + conf_arg] else: args += ["-system-" + conf_arg] else: args += ["-no-" + conf_arg] libmap = [ ("zlib", "ZLIB"), ("OpenSSL", "OPENSSL"), ("pcre2", "PCRE2"), ("glib", "GLIB"), # ("libiconv", "ICONV"), ("double-conversion", "DOUBLECONVERSION"), ("freetype", "FREETYPE"), # ("icu", "ICU"), ("harfbuzz", "HARFBUZZ"), ("libjpeg", "LIBJPEG"), ("libpng", "LIBPNG"), ("sqlite3", "SQLITE"), ("mysql-connector-c", "MYSQL"), ("libpq", "PSQL"), ("odbc", "ODBC"), ("sdl2", "SDL2"), ("openal", "OPENAL"), ("libalsa", "ALSA") ] for package, var in libmap: if package in self.deps_cpp_info.deps: if package == 'odbc' and self.settings.os == "Windows": continue args.append("\"%s_PREFIX=%s\"" % (var, self.deps_cpp_info[package].rootpath)) if package == 'freetype': args.append( "\"%s_INCDIR=%s\"" % (var, self.deps_cpp_info[package].include_paths[-1])) args += [ "-D " + s for s in self.deps_cpp_info[package].defines ] def _gather_libs(p): libs = ["-l" + i for i in self.deps_cpp_info[p].libs] libs += self.deps_cpp_info[p].sharedlinkflags for dep in self.deps_cpp_info[p].public_deps: libs += [ "-L" + lpath for lpath in self.deps_cpp_info[dep].lib_paths ] libs += _gather_libs(dep) return libs args.append("\"%s_LIBS=%s\"" % (var, " ".join(_gather_libs(package)))) if 'mysql-connector-c' in self.deps_cpp_info.deps: args.append( "-mysql_config " + os.path.join(self.deps_cpp_info['mysql-connector-c'].rootpath, "bin", "mysql_config")) if 'libpq' in self.deps_cpp_info.deps: args.append("-psql_config " + os.path.join( self.deps_cpp_info['libpq'].rootpath, "bin", "pg_config")) if self.settings.os == "Linux": if self.options.GUI: args.append("-qt-xcb") elif self.settings.os == "Macos": args += ["-no-framework"] elif self.settings.os == "Android": args += [ "-android-ndk-platform android-%s" % self.settings.os.api_level ] args += [ "-android-arch %s" % { "armv6": "armeabi", "armv7": "armeabi-v7a", "armv8": "arm64-v8a", "x86": "x86", "x86_64": "x86_64", "mips": "mips", "mips64": "mips64" }.get(str(self.settings.arch)) ] # args += ["-android-toolchain-version %s" % self.settings.compiler.version] if self.options.sysroot: args += ["-sysroot %s" % self.options.sysroot] if self.options.device: args += ["-device %s" % self.options.device] if self.options.cross_compile: args += [ "-device-option CROSS_COMPILE=%s" % self.options.cross_compile ] else: xplatform_val = self._xplatform() if xplatform_val: if (not tools.cross_building(self.settings)) or\ (self.settings.os == self.settings.os_build and\ self.settings.arch_build == "x86_64" and self.settings.arch == "x86"): args += ["-platform %s" % xplatform_val] else: args += ["-xplatform %s" % xplatform_val] else: self.output.warn( "host not supported: %s %s %s %s" % (self.settings.os, self.settings.compiler, self.settings.compiler.version, self.settings.arch)) def _getenvpath(var): val = os.getenv(var) if val and tools.os_info.is_windows: val = val.replace("\\", "/") os.environ[var] = val return val value = _getenvpath('CC') if value: args += [ 'QMAKE_CC="' + value + '"', 'QMAKE_LINK_C="' + value + '"', 'QMAKE_LINK_C_SHLIB="' + value + '"' ] value = _getenvpath('CXX') if value: args += [ 'QMAKE_CXX="' + value + '"', 'QMAKE_LINK="' + value + '"', 'QMAKE_LINK_SHLIB="' + value + '"' ] if tools.os_info.is_linux and self.settings.compiler == "clang": args += ['QMAKE_CXXFLAGS+="-ftemplate-depth=1024"'] if self.options.config: args.append(str(self.options.config)) for package in ['xkbcommon', 'glib']: if package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, dirnames, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) # args += ['-no-pch'] if 'glib' in self.deps_cpp_info.deps: shutil.move("pcre.pc", "libpcre.pc") with tools.vcvars( self.settings ) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.environment_append({ "MAKEFLAGS": "j%d" % tools.cpu_count(), "PKG_CONFIG_PATH": os.getcwd() }): try: print("Run configure") self.run("%s/qt5/configure %s" % (self.source_folder, " ".join(args))) except Exception as e: print("Unexpected exception") print(e.message) print(e.__doc__) finally: print("Patch log") # python 3 , errors='backslashreplace' self.output.info(open('config.log').read()) print("Patch done - compiler settings") if self.settings.compiler == "Visual Studio": print("VS using jom") # If we had the Incredibuild make tools license could do this # make = 'BuildConsole /command="jom" /openmonitor /title="conan-qt"' make = "jom" elif tools.os_info.is_windows: make = "mingw32-make" else: make = "make" print("Run make with {0}".format(make)) self.run(make, run_environment=True) print("Run install") self.run("%s install" % make) with open('qtbase/bin/qt.conf', 'w') as f: f.write('[Paths]\nPrefix = ..')