def conan_profile_unscaped_env_var_test(self): client = TestClient() conanfile = ''' from conans import ConanFile class HelloConan(ConanFile): name = "Hello" version = "0.1" ''' files = {"conanfile.py": conanfile} client.save(files) client.run("export lasote/stable") reuse = ''' [requires] Hello/0.1@lasote/stable [generators] virtualenv ''' profile = ''' [env] CXXFLAGS=-fPIC -DPIC ''' files = {"conanfile.txt": reuse, "myprofile": profile} client.save(files, clean_first=True) client.run("install --profile ./myprofile --build missing") with tools.chdir(client.current_folder): if platform.system() != "Windows": ret = os.system("chmod +x activate.sh && ./activate.sh") else: ret = os.system("activate.bat") self.assertEquals(ret, 0)
def test(self): with tools.chdir("bin"): if tools.os_info.is_windows: self.run("example") else: prefix = "DYLD_LIBRARY_PATH=." if tools.os_info.is_macos else "" self.run("%s ./example" % prefix)
def build(self): if self.settings.os == "Linux" or self.settings.os == "Macos": autotools = AutoToolsBuildEnvironment(self) env_vars = autotools.vars.copy() # required to correctly find static libssl on Linux if self.options.with_openssl and self.settings.os == "Linux": env_vars['OPENSSL_LIBADD'] = '-ldl' # disable rpath build tools.replace_in_file(os.path.join(self._source_subfolder, "configure"), r"-install_name \$rpath/", "-install_name ") # compose configure options configure_args = [] if not self.options.shared: configure_args.append("--disable-shared") configure_args.append("--enable-openssl" if self.options.with_openssl else "--disable-openssl") if self.options.disable_threads: configure_args.append("--disable-thread-support") with tools.environment_append(env_vars): with tools.chdir(self._source_subfolder): # set LD_LIBRARY_PATH with tools.environment_append(RunEnvironment(self).vars): autotools.configure(args=configure_args) autotools.make() elif self.settings.os == "Windows": vcvars = tools.vcvars_command(self.settings) suffix = '' if self.options.with_openssl: suffix = "OPENSSL_DIR=" + self.deps_cpp_info['OpenSSL'].rootpath # add runtime directives to runtime-unaware nmakefile tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile.nmake"), 'LIBFLAGS=/nologo', 'LIBFLAGS=/nologo\n' 'CFLAGS=$(CFLAGS) /%s' % str(self.settings.compiler.runtime)) # do not build tests. static_libs is the only target, no shared libs at all make_command = "nmake %s -f Makefile.nmake static_libs" % suffix with tools.chdir(self._source_subfolder): self.run("%s && %s" % (vcvars, make_command))
def _process_git_repo(repo_url, client_cache, output, tmp_folder, verify_ssl): output.info("Trying to clone repo %s" % repo_url) with tools.chdir(tmp_folder): try: subprocess.check_output('git -c http.sslVerify=%s clone "%s" config' % (verify_ssl, repo_url), shell=True) output.info("Repo cloned") except Exception as e: raise ConanException("config install error. Can't clone repo: %s" % str(e)) tmp_folder = os.path.join(tmp_folder, "config") _process_folder(tmp_folder, client_cache, output)
def run_imports(conanfile, dest_folder, output): if not hasattr(conanfile, "imports"): return [] file_importer = _FileImporter(conanfile, dest_folder) conanfile.copy = file_importer conanfile.imports_folder = dest_folder with get_env_context_manager(conanfile): with tools.chdir(dest_folder): conanfile.imports() copied_files = file_importer.copied_files _make_files_writable(copied_files) import_output = ScopedOutput("%s imports()" % output.scope, output) _report_save_manifest(copied_files, import_output, dest_folder, IMPORTS_MANIFESTS) return copied_files
def install_repo_test(self): """ should install from a git repo """ folder = self._create_profile_folder() with tools.chdir(folder): self.client.runner('git init .') self.client.runner('git add .') self.client.runner('git config user.name myname') self.client.runner('git config user.email [email protected]') self.client.runner('git commit -m "mymsg"') self.client.run('config install "%s/.git"' % folder) self._check("%s/.git" % folder)
def launch_tests(self): """Conan will remove rpaths from shared libs to be able to reuse the shared libs, we need to tell the tests where to find the shared libs""" test_args = "-VV" if tools.os_info.is_windows else "" with tools.chdir("build"): outdir = os.path.join(self.build_folder, "build", "blosc") if tools.os_info.is_macos: prefix = "DYLD_LIBRARY_PATH=%s" % outdir elif tools.os_info.is_windows: prefix = "PATH=%s;%%PATH%%" % outdir elif tools.os_info.is_linux: prefix = "LD_LIBRARY_PATH=%s" % outdir else: return self.run("%s ctest %s" % (prefix, test_args))
def config_source_local(dest_dir, conan_file, output): output.info('Configuring sources in %s' % dest_dir) conan_file.source_folder = dest_dir with tools.chdir(dest_dir): try: with conanfile_exception_formatter(str(conan_file), "source"): with get_env_context_manager(conan_file): conan_file.build_folder = None conan_file.package_folder = None conan_file.source() except ConanExceptionInUserConanfileMethod: raise except Exception as e: raise ConanException(e)
def _link_folders(src, dst, linked_folders): for linked_folder in linked_folders: link = os.readlink(os.path.join(src, linked_folder)) # The link is relative to the directory of the "linker_folder" dest_dir = os.path.join(os.path.dirname(linked_folder), link) if os.path.exists(os.path.join(dst, dest_dir)): with tools.chdir(dst): try: # Remove the previous symlink os.remove(linked_folder) except OSError: pass # link is a string relative to linked_folder # e.j: os.symlink("test/bar", "./foo/test_link") will create a link to foo/test/bar in ./foo/test_link os.symlink(link, linked_folder)
def _parse_file(conan_file_path): """ From a given path, obtain the in memory python import module """ if not os.path.exists(conan_file_path): raise NotFoundException("%s not found!" % conan_file_path) filename = os.path.splitext(os.path.basename(conan_file_path))[0] try: current_dir = os.path.dirname(conan_file_path) sys.path.append(current_dir) old_modules = list(sys.modules.keys()) with chdir(current_dir): sys.dont_write_bytecode = True loaded = imp.load_source(filename, conan_file_path) sys.dont_write_bytecode = False # Put all imported files under a new package name module_id = uuid.uuid1() added_modules = set(sys.modules).difference(old_modules) for added in added_modules: module = sys.modules[added] if module: try: folder = os.path.dirname(module.__file__) except AttributeError: # some module doesn't have __file__ pass else: if folder.startswith(current_dir): module = sys.modules.pop(added) sys.modules["%s.%s" % (module_id, added)] = module except Exception: import traceback trace = traceback.format_exc().split('\n') raise ConanException("Unable to load conanfile in %s\n%s" % (conan_file_path, '\n'.join(trace[3:]))) finally: sys.path.pop() return loaded, filename
def run_deploy(conanfile, install_folder, output): deploy_output = ScopedOutput("%s deploy()" % output.scope, output) file_importer = _FileImporter(conanfile, install_folder) package_copied = set() # This is necessary to capture FileCopier full destination paths # Maybe could be improved in FileCopier def file_copier(*args, **kwargs): file_copy = FileCopier(conanfile.package_folder, install_folder) copied = file_copy(*args, **kwargs) _make_files_writable(copied) package_copied.update(copied) conanfile.copy_deps = file_importer conanfile.copy = file_copier conanfile.install_folder = install_folder with get_env_context_manager(conanfile): with tools.chdir(install_folder): conanfile.deploy() copied_files = file_importer.copied_files copied_files.update(package_copied) _report_save_manifest(copied_files, deploy_output, install_folder, "deploy_manifest.txt")
import os from conan.packager import ConanMultiPackager from conans import tools if __name__ == "__main__": runtimes = ["MD", "MDd"] for subdir in ["sasl2", "sasldb", "gssapiv2"]: ref = os.environ.get("CONAN_REFERENCE", "") if ref: name, ver = ref.split("/", 1) os.environ["CONAN_REFERENCE"] = "cyrus-sasl-" + subdir + "/" + ver with tools.chdir(os.path.join("win32", "conan", subdir)): builder = ConanMultiPackager(visual_runtimes=runtimes) builder.add_common_builds(shared_option_name=False, pure_c=True) builder.run()
def build(self): with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() autotools.make()
def _msvc_build_environment(self): with tools.chdir(self._source_subfolder): with tools.vcvars(self.settings): with tools.environment_append(VisualStudioBuildEnvironment(self).vars): yield
def build(self): print("Building...") with tools.chdir("src"): atools = AutoToolsBuildEnvironment(self) atools.make()
def package(self): if tools.os_info.is_linux: with tools.chdir(self.source_subfolder): self.copy("*", src="%s/builddir" % (os.getcwd()))
def source(self): self.run( "git clone https://github.com/greenplum-db/gpbackup.git src/github.com/greenplum-db/gpbackup" ) with tools.chdir('src/github.com/greenplum-db/gpbackup'): self.run("git checkout GIT_VERSION")
def cmake_build_debug_release(cmake, build_subfolder, run): for config in ("Debug", "Release"): configure_cmake(cmake, build_subfolder) cmake.build(args=["--config", config, "--verbose"]) with tools.chdir(build_subfolder): run(f"ctest -C {config} --output-on-failure")
def build(self): def add_flag(name, value): if name in os.environ: os.environ[name] += " " + value else: os.environ[name] = value if self.version != "2019_u9" and self.settings.build_type == "Debug": tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile"), "release", "debug") if self._is_msvc: tools.save(os.path.join(self._source_subfolder, "build", "big_iron_msvc.inc"), # copy of big_iron.inc adapted for MSVC """ LIB_LINK_CMD = lib.exe LIB_OUTPUT_KEY = /OUT: LIB_LINK_FLAGS = LIB_LINK_LIBS = DYLIB_KEY = override CXXFLAGS += -D__TBB_DYNAMIC_LOAD_ENABLED=0 -D__TBB_SOURCE_DIRECTLY_INCLUDED=1 ITT_NOTIFY = DLL = lib LIBEXT = lib LIBPREF = LIBDL = TBB.DLL = $(LIBPREF)tbb$(DEBUG_SUFFIX).$(LIBEXT) LINK_TBB.LIB = $(TBB.DLL) TBB.DEF = TBB_NO_VERSION.DLL = MALLOC.DLL = $(LIBPREF)tbbmalloc$(DEBUG_SUFFIX).$(LIBEXT) LINK_MALLOC.LIB = $(MALLOC.DLL) MALLOC.DEF = MALLOC_NO_VERSION.DLL = MALLOCPROXY.DLL = MALLOCPROXY.DEF = """) extra = "" if self.options.shared else "extra_inc=big_iron_msvc.inc" else: extra = "" if self.options.shared else "extra_inc=big_iron.inc" arch = {"x86": "ia32", "x86_64": "intel64", "armv7": "armv7", "armv8": "aarch64"}.get(str(self.settings.arch)) if self.settings.compiler in ["gcc", "clang", "apple-clang"]: if str(self.settings.compiler.libcxx) in ["libstdc++", "libstdc++11"]: extra += " stdlib=libstdc++" elif str(self.settings.compiler.libcxx) == "libc++": extra += " stdlib=libc++" extra += " compiler=gcc" if self.settings.compiler == "gcc" else " compiler=clang" extra += " gcc_version={}".format(str(self.settings.compiler.version)) make = tools.get_env("CONAN_MAKE_PROGRAM", tools.which("make") or tools.which("mingw32-make")) if not make: raise ConanInvalidConfiguration("This package needs 'make' in the path to build") with tools.chdir(self._source_subfolder): # intentionally not using AutoToolsBuildEnvironment for now - it's broken for clang-cl if self._is_clanglc: add_flag("CFLAGS", "-mrtm") add_flag("CXXFLAGS", "-mrtm") targets = ["tbb", "tbbmalloc", "tbbproxy"] if self._is_msvc: # intentionally not using vcvars for clang-cl yet with tools.vcvars(self.settings): if self.settings.get_safe("compiler.runtime") in ["MT", "MTd"]: runtime = "vc_mt" else: runtime = {"8": "vc8", "9": "vc9", "10": "vc10", "11": "vc11", "12": "vc12", "14": "vc14", "15": "vc14.1", "16": "vc14.2"}.get(str(self.settings.compiler.version), "vc14.2") self.run("%s arch=%s runtime=%s %s %s" % (make, arch, runtime, extra, " ".join(targets))) elif self._is_mingw: self.run("%s arch=%s compiler=gcc %s %s" % (make, arch, extra, " ".join(targets))) else: self.run("%s arch=%s %s %s" % (make, arch, extra, " ".join(targets)))
def build(self): with tools.chdir(self.name): self.run(f'python setup.py install --prefix={self.package_folder}')
def build(self): with tools.chdir(self._source_subfolder): env_build = self._configure_autotools() env_build.make()
def test(self): img_path = os.path.join(self.source_folder, "lena.jpg") shutil.copy(img_path, 'bin') with tools.chdir('bin'): self.run('lena.exe' if self.settings.os == 'Windows' else './lena', run_environment=True)
def _mingw_build_environment(self): with tools.chdir(os.path.join(self._source_subfolder, "win32")): with tools.environment_append( AutoToolsBuildEnvironment(self).vars): yield
def _msvc_build_environment(self): with tools.chdir(os.path.join(self._source_subfolder, "win32")): with tools.vcvars(self): with tools.environment_append( VisualStudioBuildEnvironment(self).vars): yield
def build(self): self._patch_sources() with tools.vcvars(self) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.chdir(self._source_subfolder): env_build = AutoToolsBuildEnvironment(self) env_build.make(args=self._make_args, target=self._library_filename)
def package(self): self.copy('LICENSE.TXT', dst='licenses', src=self._source_subfolder) lib_path = os.path.join(self.package_folder, 'lib') cmake = self._configure_cmake() cmake.install() if not self.options.shared: for ext in ['.a', '.lib']: lib = '*LLVMTableGenGlobalISel{}'.format(ext) self.copy(lib, dst='lib', src='lib') self.run('cmake --graphviz=graph/llvm.dot .') with tools.chdir('graph'): dot_text = tools.load('llvm.dot').replace('\r\n', '\n') dep_regex = re.compile(r'//\s(.+)\s->\s(.+)$', re.MULTILINE) deps = re.findall(dep_regex, dot_text) dummy_targets = defaultdict(list) for target, dep in deps: if not target.startswith('LLVM'): dummy_targets[target].append(dep) cmake_targets = { 'libffi::libffi': 'ffi', 'ZLIB::ZLIB': 'z', 'Iconv::Iconv': 'iconv', 'LibXml2::LibXml2': 'xml2' } components = defaultdict(list) for lib, dep in deps: if not lib.startswith('LLVM'): continue elif dep.startswith('-delayload:'): continue elif dep.startswith('LLVM'): components[dep] elif dep in cmake_targets: dep = cmake_targets[dep] elif os.path.exists(dep): dep = os.path.splitext(os.path.basename(dep))[0] dep = dep.replace('lib', '') dep = dep.replace('-l', '') if dep in dummy_targets.keys(): components[lib].extend(dummy_targets[dep]) components[lib] = list(set(components[lib])) else: components[lib].append(dep) tools.rmdir(os.path.join(self.package_folder, 'bin')) tools.rmdir(os.path.join(self.package_folder, 'lib', 'cmake')) tools.rmdir(os.path.join(self.package_folder, 'share')) for name in os.listdir(lib_path): if 'LLVM' not in name: os.remove(os.path.join(lib_path, name)) if not self.options.shared: components_path = \ os.path.join(self.package_folder, 'lib', 'components.json') with open(components_path, 'w') as components_file: json.dump(components, components_file, indent=4) else: suffixes = ['.dylib', '.so'] for name in os.listdir(lib_path): if not any(suffix in name for suffix in suffixes): os.remove(os.path.join(lib_path, name))
def _build_autotools(self): with tools.chdir(self._source_subfolder): tools.save(path="VERSION", content="%s" % self.version) self.run("{} -fiv".format(tools.get_env("AUTORECONF"))) autotools = self._configure_autotools() autotools.make()
def build(self): # Source should be downloaded in the build step since it depends on specific options self._download_source() target_tag = self._target_tag host_tag = "x86_64-linux-gnu" # We currently cannot build with multilib and threads=posix. Otherwise we get the gcc compile error: # checking for ld that supports -Wl,--gc-sections... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES. # Makefile:11275: recipe for target 'configure-target-libstdc++-v3' failed build_multilib = False # Instructions see: # https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-doc/howto-build/mingw-w64-howto-build.txt # and # https://sourceforge.net/p/mingw-w64/code/HEAD/tree/trunk/mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt # also good to see specific commands: # https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/+/lollipop-dev/build-mingw64-toolchain.sh # add binutils to path. Required for gcc build env = { "PATH": os.environ["PATH"] + ":" + os.path.join(self.package_folder, "bin") } with tools.environment_append(env): self.output.info("Building gmp ...") os.mkdir(os.path.join(self.build_folder, "gmp")) with tools.chdir(os.path.join(self.build_folder, "gmp")): autotools = AutoToolsBuildEnvironment(self) conf_args = ["--enable-silent-rules", "--disable-shared"] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "gmp"), args=conf_args, target=False, host=False, build=False) autotools.make() autotools.install() self.output.info("Building mpfr ...") os.mkdir(os.path.join(self.build_folder, "mpfr")) with tools.chdir(os.path.join(self.build_folder, "mpfr")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--disable-shared", "--with-gmp={}".format(self.package_folder) ] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mpfr"), args=conf_args, target=False, host=False, build=False) autotools.make() autotools.install() self.output.info("Building mpc ...") os.mkdir(os.path.join(self.build_folder, "mpc")) with tools.chdir(os.path.join(self.build_folder, "mpc")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--disable-shared", "--with-gmp={}".format(self.package_folder), "--with-mpfr={}".format(self.package_folder) ] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mpc"), args=conf_args, target=False, host=False, build=False) autotools.make() autotools.install() with_gmp_mpfc_mpc = [ "--with-gmp={}".format(self.package_folder), "--with-mpfr={}".format(self.package_folder), "--with-mpc={}".format(self.package_folder) ] self.output.info("Building binutils ...") os.mkdir(os.path.join(self.build_folder, "binutils")) with tools.chdir(os.path.join(self.build_folder, "binutils")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--with-sysroot={}".format(self.package_folder), "--disable-nls", "--disable-shared" ] if build_multilib: conf_args.append( "--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32") conf_args.extend(with_gmp_mpfc_mpc) autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "binutils"), args=conf_args, target=target_tag, host=False, build=False) autotools.make() autotools.install() self.output.info("Building mingw-w64-tools ...") os.mkdir(os.path.join(self.build_folder, "mingw-w64-tools")) with tools.chdir(os.path.join(self.build_folder, "mingw-w64-tools")): autotools = AutoToolsBuildEnvironment(self) conf_args = [] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mingw-w64", "mingw-w64-tools", "widl"), args=conf_args, target=target_tag, host=False, build=False) autotools.make() autotools.install() self.output.info("Building mingw-w64-headers ...") os.mkdir(os.path.join(self.build_folder, "mingw-w64-headers")) with tools.chdir( os.path.join(self.build_folder, "mingw-w64-headers")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--with-widl={}".format( os.path.join(self.package_folder, "bin")), "--enable-sdk=all", "--prefix={}".format( os.path.join(self.package_folder, target_tag)) ] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mingw-w64", "mingw-w64-headers"), args=conf_args, target=False, host=target_tag, build=host_tag) autotools.make() autotools.install() # Step 3) GCC requires the x86_64-w64-mingw32 directory be mirrored as a # directory 'mingw' in the same root. So, if using configure default # /usr/local, type: # ln -s /usr/local/x86_64-w64-mingw32 /usr/local/mingw # or, for sysroot, type: # ln -s /mypath/x86_64-w64-mingw32 /mypath/mingw self.run("ln -s {} {}".format( os.path.join(self.package_folder, target_tag), os.path.join(self.package_folder, 'mingw'))) # Step 5) Symlink x86_64-w64-mingw32/lib directory as x86_64-w64-mingw32/lib64: # ln -s /usr/local/x86_64-w64-mingw32/lib /usr/local/x86_64-w64-mingw32/lib64 # or, for sysroot: # ln -s /mypath/x86_64-w64-mingw32/lib /mypath/x86_64-w64-mingw32/lib64 self.run("ln -s {} {}".format( os.path.join(self.package_folder, target_tag, 'lib'), os.path.join(self.package_folder, target_tag, 'lib64'))) self.output.info("Building core gcc ...") os.mkdir(os.path.join(self.build_folder, "gcc")) with tools.chdir(os.path.join(self.build_folder, "gcc")): autotools_gcc = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--enable-languages=c,c++", "--with-sysroot={}".format(self.package_folder), "--disable-shared" ] if build_multilib: conf_args.append("--enable-targets=all") conf_args.append("--enable-multilib") else: conf_args.append("--disable-multilib") conf_args.extend(with_gmp_mpfc_mpc) if self.options.exception == "sjlj": conf_args.append("--enable-sjlj-exceptions") if self.options.threads == "posix": # Some specific options which need to be set for posix thread. Otherwise it fails compiling. conf_args.extend([ "--enable-silent-rules", "--enable-threads=posix", # Not 100% sure why, but the following options are required, otherwise # gcc fails to build with posix threads ]) autotools_gcc.configure(configure_dir=os.path.join( self.build_folder, "sources", "gcc"), args=conf_args, target=target_tag, host=False, build=False) autotools_gcc.make(target="all-gcc") autotools_gcc.make(target="install-gcc") env_compiler = dict(env) # The CC and CXX compiler must be set to the mingw compiler. Conan already sets CC and CXX, therefore we need to overwrite it. # If the wrong compiler is used for mingw-w64-crt, then you will get the error # configure: Please check if the mingw-w64 header set and the build/host option are set properly. env_compiler["CC"] = target_tag + "-gcc" env_compiler["CXX"] = target_tag + "-g++" with tools.environment_append(env_compiler): self.output.info("Building mingw-w64-crt ...") os.mkdir(os.path.join(self.build_folder, "mingw-w64-crt")) with tools.chdir( os.path.join(self.build_folder, "mingw-w64-crt")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--prefix={}".format( os.path.join(self.package_folder, target_tag)), "--with-sysroot={}".format(self.package_folder) ] if build_multilib: conf_args.append("--enable-lib32") autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mingw-w64", "mingw-w64-crt"), args=conf_args, target=False, host=target_tag, build=False, use_default_install_dirs=False) autotools.make() autotools.install() if self.options.threads == "posix": self.output.info( "Building mingw-w64-libraries-winpthreads ...") os.mkdir( os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")) with tools.chdir( os.path.join(self.build_folder, "mingw-w64-libraries-winpthreads")): autotools = AutoToolsBuildEnvironment(self) conf_args = [ "--enable-silent-rules", "--disable-shared", "--prefix={}".format( os.path.join(self.package_folder, target_tag)) ] autotools.configure(configure_dir=os.path.join( self.build_folder, "sources", "mingw-w64", "mingw-w64-libraries", "winpthreads"), args=conf_args, target=False, host=target_tag, build=False) autotools.make() autotools.install() self.output.info("Building libgcc ...") with tools.chdir(os.path.join(self.build_folder, "gcc")): autotools_gcc.make() autotools_gcc.install() self.output.info("Building done!")
def build(self): with tools.chdir("src"): env_build = AutoToolsBuildEnvironment(self) env_build.make()
def package(self): with tools.chdir("streamvbyte"): cmake = CMake(self) cmake.install()
def build_configure(self): # FIXME : once component feature is out, should be unnecessary if self.options.webp: self._copy_pkg_config('libwebp') # components: libwebpmux if self.options.vorbis: shutil.copyfile('vorbis.pc', 'vorbisenc.pc') # components: vorbisenc, vorbisfile if self.settings.os == "Linux": if self.options.xcb: self._copy_pkg_config('libxcb') with tools.chdir(self._source_subfolder): prefix = tools.unix_path(self.package_folder) if self.settings.os == 'Windows' else self.package_folder args = ['--prefix=%s' % prefix, '--disable-doc', '--disable-programs'] if self.options.shared: args.extend(['--disable-static', '--enable-shared']) else: args.extend(['--disable-shared', '--enable-static']) args.append('--pkg-config-flags=--static') if self.settings.build_type == 'Debug': args.extend(['--disable-optimizations', '--disable-mmx', '--disable-stripping', '--enable-debug']) # since ffmpeg's build system ignores CC and CXX if 'CC' in os.environ: args.append('--cc=%s' % os.environ['CC']) if 'CXX' in os.environ: args.append('--cxx=%s' % os.environ['CXX']) if self._is_msvc: args.append('--toolchain=msvc') args.append('--extra-cflags=-%s' % self.settings.compiler.runtime) if int(str(self.settings.compiler.version)) <= 12: # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++) args.append('--extra-cflags=-Dinline=__inline' % self.settings.compiler.runtime) if self.settings.arch == 'x86': args.append('--arch=x86') if self.settings.os != "Windows": args.append('--enable-pic' if self.options.fPIC else '--disable-pic') args.append('--enable-postproc' if self.options.postproc else '--disable-postproc') args.append('--enable-zlib' if self.options.zlib else '--disable-zlib') args.append('--enable-bzlib' if self.options.bzlib else '--disable-bzlib') args.append('--enable-lzma' if self.options.lzma else '--disable-lzma') args.append('--enable-iconv' if self.options.iconv else '--disable-iconv') args.append('--enable-libfreetype' if self.options.freetype else '--disable-libfreetype') args.append('--enable-libopenjpeg' if self.options.openjpeg else '--disable-libopenjpeg') args.append('--enable-libopenh264' if self.options.openh264 else '--disable-libopenh264') args.append('--enable-libvorbis' if self.options.vorbis else '--disable-libvorbis') args.append('--enable-libopus' if self.options.opus else '--disable-libopus') args.append('--enable-libzmq' if self.options.zmq else '--disable-libzmq') args.append('--enable-sdl2' if self.options.sdl2 else '--disable-sdl2') args.append('--enable-libx264' if self.options.x264 else '--disable-libx264') args.append('--enable-libx265' if self.options.x265 else '--disable-libx265') args.append('--enable-libvpx' if self.options.vpx else '--disable-libvpx') args.append('--enable-libmp3lame' if self.options.mp3lame else '--disable-libmp3lame') args.append('--enable-libfdk-aac' if self.options.fdk_aac else '--disable-libfdk-aac') args.append('--enable-libwebp' if self.options.webp else '--disable-libwebp') args.append('--enable-openssl' if self.options.openssl else '--disable-openssl') if self.options.x264 or self.options.x265 or self.options.postproc: args.append('--enable-gpl') if self.options.fdk_aac: args.append('--enable-nonfree') if self.settings.os == "Linux": args.append('--enable-alsa' if self.options.alsa else '--disable-alsa') args.append('--enable-libpulse' if self.options.pulse else '--disable-libpulse') args.append('--enable-vaapi' if self.options.vaapi else '--disable-vaapi') args.append('--enable-vdpau' if self.options.vdpau else '--disable-vdpau') if self.options.xcb: args.extend(['--enable-libxcb', '--enable-libxcb-shm', '--enable-libxcb-shape', '--enable-libxcb-xfixes']) else: args.extend(['--disable-libxcb', '--disable-libxcb-shm', '--disable-libxcb-shape', '--disable-libxcb-xfixes']) if self.settings.os == "Macos": args.append('--enable-appkit' if self.options.appkit else '--disable-appkit') args.append('--enable-avfoundation' if self.options.avfoundation else '--disable-avfoundation') args.append('--enable-coreimage' if self.options.avfoundation else '--disable-coreimage') args.append('--enable-audiotoolbox' if self.options.audiotoolbox else '--disable-audiotoolbox') args.append('--enable-videotoolbox' if self.options.videotoolbox else '--disable-videotoolbox') args.append('--enable-securetransport' if self.options.securetransport else '--disable-securetransport') if self.settings.os == "Windows": args.append('--enable-libmfx' if self.options.qsv else '--disable-libmfx') # FIXME disable CUDA and CUVID by default, revisit later args.extend(['--disable-cuda', '--disable-cuvid']) env_build = AutoToolsBuildEnvironment(self, win_bash=self._is_mingw_windows or self._is_msvc) # ffmpeg's configure is not actually from autotools, so it doesn't understand standard options like # --host, --build, --target env_build.configure(args=args, build=False, host=False, target=False) env_build.make() env_build.make(args=['install'])
def build(self): with tools.chdir("libsndfile"): autotools = AutoToolsBuildEnvironment(self) autotools.configure() autotools.make()
def build(self): os.environ["PATH"] = os.environ["PATH"] + ":" + os.path.join( os.getcwd(), "bin") with tools.environment_append({'GOPATH': os.getcwd()}): with tools.chdir('src/github.com/greenplum-db/gpbackup'): self.run('make depend && make build_linux')
def source(self): source_url = "https://github.com/boostorg" for lib_short_name in self.lib_short_names: self.run("git clone --branch=master {0}/{1}.git".format(source_url, lib_short_name)) with tools.chdir(lib_short_name): self.run("git checkout {0}".format(self.commit_id))
def _autotools_build_environment(self): with tools.chdir(self._source_subfolder): with tools.run_environment(self): with tools.environment_append({"PKG_CONFIG_PATH": tools.unix_path(self.build_folder)}): yield
def test(self): with tools.environment_append(RunEnvironment(self).vars): with tools.chdir('bin'): self.run("pkg_test")
def _build_msvc(self): for patch in self.conan_data.get("patches", {}).get(self.version, {}): tools.patch(**patch) # FIXME: package LiquidRescale aka liblqr tools.replace_in_file( os.path.join("VisualMagick", "lqr", "Config.txt"), "#define MAGICKCORE_LQR_DELEGATE", "", ) # FIXME: package LibRaw tools.replace_in_file( os.path.join("VisualMagick", "libraw", "Config.txt"), "#define MAGICKCORE_RAW_R_DELEGATE", "", ) # FIXME: package FLIF (FLIF: Free Lossless Image Format) tools.replace_in_file( os.path.join("VisualMagick", "flif", "Config.txt"), "#define MAGICKCORE_FLIF_DELEGATE", "", ) # FIXME: package librsvg tools.replace_in_file( os.path.join("VisualMagick", "librsvg", "Config.txt"), "#define MAGICKCORE_RSVG_DELEGATE", "", ) if not self.options.shared: for module in self._modules: tools.replace_in_file( os.path.join("VisualMagick", module, "Config.txt"), "[DLL]", "[STATIC]", ) tools.replace_in_file( os.path.join("VisualMagick", "coders", "Config.txt"), "[DLLMODULE]", "[STATIC]\n[DEFINES]\n_MAGICKLIB_", ) if self.settings.arch == "x86_64": project = os.path.join("VisualMagick", "configure", "configure.vcxproj") tools.replace_in_file(project, "Win32", "x64") tools.replace_in_file(project, "/MACHINE:I386", "/MACHINE:x64") with tools.chdir(os.path.join("VisualMagick", "configure")): toolset = tools.msvs_toolset(self) tools.replace_in_file( "configure.vcxproj", "<PlatformToolset>v120</PlatformToolset>", "<PlatformToolset>%s</PlatformToolset>" % toolset, ) msbuild = MSBuild(self) # fatal error C1189: #error: Please use the /MD switch for _AFXDLL builds msbuild.build_env.flags = ["/MD"] msbuild.build( project_file="configure.vcxproj", platforms={"x86": "Win32"}, force_vcvars=True, ) # https://github.com/ImageMagick/ImageMagick-Windows/blob/master/AppVeyor/Build.ps1 command = ["configure.exe", "/noWizard"] msvc_version = { 9: "/VS2002", 10: "/VS2010", 11: "/VS2012", 12: "/VS2013", 14: "/VS2015", 15: "/VS2017", 16: "/VS2019", 17: "/VS2022", }.get(int(str(self.settings.compiler.version))) runtime = { "MT": "/smt", "MTd": "/smtd", "MD": "/dmt", "MDd": "/mdt" }.get(str(self.settings.compiler.runtime)) command.append(runtime) command.append(msvc_version) command.append("/hdri" if self.options.hdri else "/noHdri") command.append("/Q%s" % self.options.quantum_depth) if self.settings.arch == "x86_64": command.append("/x64") command = " ".join(command) self.output.info(command) self.run(command, run_environment=True) # disable incorrectly detected OpenCL baseconfig = os.path.join(self._source_subfolder, "MagickCore", "magick-baseconfig.h") tools.replace_in_file( baseconfig, "#define MAGICKCORE__OPENCL", "#undef MAGICKCORE__OPENCL", strict=False, ) tools.replace_in_file( baseconfig, "#define MAGICKCORE_HAVE_CL_CL_H", "#undef MAGICKCORE_HAVE_CL_CL_H", strict=False, ) suffix = { "MT": "StaticMT", "MTd": "StaticMTD", "MD": "DynamicMT", "MDd": "DynamicMT", }.get(str(self.settings.compiler.runtime)) # GdiPlus requires C++, but ImageMagick has *.c files project = ("IM_MOD_emf_%s.vcxproj" % suffix if self.options.shared else "CORE_coders_%s.vcxproj" % suffix) tools.replace_in_file( os.path.join("VisualMagick", "coders", project), '<ClCompile Include="..\\..\\ImageMagick\\coders\\emf.c">', '<ClCompile Include="..\\..\\ImageMagick\\coders\\emf.c">\n' "<CompileAs>CompileAsCpp</CompileAs>", ) for module in self._modules: with tools.chdir(os.path.join("VisualMagick", module)): msbuild = MSBuild(self) msbuild.build( project_file="CORE_%s_%s.vcxproj" % (module, suffix), upgrade_project=False, platforms={ "x86": "Win32", "x86_64": "x64" }, ) with tools.chdir(os.path.join("VisualMagick", "coders")): pattern = ("IM_MOD_*_%s.vcxproj" % suffix if self.options.shared else "CORE_coders_%s.vcxproj" % suffix) projects = glob.glob(pattern) for project in projects: msbuild = MSBuild(self) msbuild.build( project_file=project, upgrade_project=False, platforms={ "x86": "Win32", "x86_64": "x64" }, )
def build(self): self.output.info("cwd=%s" % (os.getcwd())) # put conan inclusion into CMakeLists.txt file or fail (strict=True) self.output.info('Patching CMakeLists.txt') tools.replace_in_file(os.sep.join([self.folder_name, "CMakeLists.txt"]), "project(RdKafka)", '''project(RdKafka) include(${CMAKE_BINARY_DIR}/../../conanbuildinfo.cmake) conan_basic_setup()''') # Some situations like using a bad passphrase causes rk to never be initialized # so calling this function would cause a segfault. Input validation would be helpful. tools.replace_in_file(os.sep.join([self.folder_name, "src", "rdkafka.c"]), '''static void rd_kafka_destroy_app (rd_kafka_t *rk, int blocking) { thrd_t thrd; #ifndef _MSC_VER int term_sig = rk->rk_conf.term_sig; #endif''', '''static void rd_kafka_destroy_app (rd_kafka_t *rk, int blocking) { if (rk == NULL) { return; } thrd_t thrd; #ifndef _MSC_VER int term_sig = rk->rk_conf.term_sig; #endif''') if tools.os_info.is_windows: # rdkafka C++ library does not export the special partition and offset constants/values # variables from the DLL, and looks like the library is switching to a preprocessor define # instead. This change includes the C-header file just to get the macro values, and then # changes the constants from being used as imported values to read from the macros. tools.replace_in_file(os.sep.join([self.folder_name, "examples", "rdkafka_example.cpp"]), '#include "rdkafkacpp.h"', '''#include "rdkafkacpp.h" #include "rdkafka.h"''') tools.replace_in_file(os.sep.join([self.folder_name, "examples", "rdkafka_example.cpp"]), 'RdKafka::Topic::PARTITION_UA', 'RD_KAFKA_PARTITION_UA') tools.replace_in_file(os.sep.join([self.folder_name, "examples", "rdkafka_example.cpp"]), 'RdKafka::Topic::OFFSET_BEGINNING', 'RD_KAFKA_OFFSET_BEGINNING') tools.replace_in_file(os.sep.join([self.folder_name, "examples", "rdkafka_example.cpp"]), 'RdKafka::Topic::OFFSET_END', 'RD_KAFKA_OFFSET_END') tools.replace_in_file(os.sep.join([self.folder_name, "examples", "rdkafka_example.cpp"]), 'RdKafka::Topic::OFFSET_STORED', 'RD_KAFKA_OFFSET_STORED') # src/rd.h includes win32_config.h which is not generated by CMake/Conan # so it builds librdkafka with fixed settings (!!!). # This change removes that choice, and both platforms use the generated config.h file self.output.info('Patching src/rd.h file') tools.replace_in_file(os.sep.join([self.folder_name, 'src', 'rd.h']), ''' #ifdef _MSC_VER /* Visual Studio */ #include "win32_config.h" #else /* POSIX / UNIX based systems */ #include "../config.h" /* mklove output */ #endif ''', '#include "../config.h"') files.mkdir("./{}/build".format(self.folder_name)) with tools.chdir("./{}/build".format(self.folder_name)): cmake = CMake(self) cmake.definitions['RDKAFKA_BUILD_STATIC'] = "OFF" if self.options.shared else "ON" cmake.definitions['ENABLE_DEVEL'] = "ON" if self.options.with_devel_asserts else "OFF" cmake.definitions['ENABLE_REFCNT_DEBUG'] = 'ON' if self.options.with_refcount_debug else "OFF" cmake.definitions['ENABLE_SHAREDPTR_DEBUG'] = 'ON' if self.options.with_sharedptr_debug else "OFF" cmake.definitions["RDKAFKA_BUILD_EXAMPLES"] = "ON" if self.options.build_examples else "OFF" cmake.definitions["RDKAFKA_BUILD_TESTS"] = "ON" if self.options.build_tests else "OFF" cmake.definitions["WITH_LIBDL"] = "OFF" cmake.definitions["WITH_PLUGINS"] = "OFF" cmake.definitions["WITH_SASL"] = "OFF" cmake.definitions["WITH_SSL"] = "ON" if self.options.with_openssl else "OFF" cmake.definitions["WITH_ZLIB"] = "ON" if self.options.with_zlib else "OFF" if self.settings.build_type == "Debug": cmake.definitions["WITHOUT_OPTIMIZATION"] = "ON" if self.options.shared: cmake.definitions["BUILD_SHARED_LIBS"] = "ON" # Enables overridding of default window build settings cmake.definitions["WITHOUT_WIN32_CONFIG"] = "ON" cmake.configure(source_dir="..", build_dir=".") cmake.build(build_dir=".") else: configure_args = [ "--prefix=", "--disable-sasl" ] if not self.options.with_openssl: configure_args.append('--disable-ssl') if not self.options.with_zlib: configure_args.append('--disable-lz4') if self.options.shared: ldflags = os.environ.get("LDFLAGS", "") if tools.os_info.is_linux: os.environ["LDFLAGS"] = ldflags + " -Wl,-rpath=\\$$ORIGIN" elif tools.os_info.is_macos: os.environ["LDFLAGS"] = ldflags + " -headerpad_max_install_names" else: configure_args.append("--enable-static") if self.settings.build_type == "Debug": configure_args.append("--disable-optimization") destdir = os.path.join(os.getcwd(), "install") with tools.chdir(self.folder_name): if tools.os_info.is_macos and self.options.shared: path = os.path.join(os.getcwd(), "mklove", "modules", "configure.lib") tools.replace_in_file( path, '-dynamiclib -Wl,-install_name,$(DESTDIR)$(libdir)/$(LIBFILENAME)', '-dynamiclib -Wl,-install_name,@rpath/$(LIBFILENAME)', ) env_build = AutoToolsBuildEnvironment(self) env_build.configure(args=configure_args) env_build.make() env_build.make(args=["install", "DESTDIR="+destdir]) with tools.chdir(self.folder_name): os.rename("LICENSE", "LICENSE.librdkafka")
def test(self): with tools.chdir("bin"): self.run(".%stest_package" % os.sep)
def build_make(self): with tools.chdir(self.source_subfolder): autotools = AutoToolsBuildEnvironment(self) autotools.configure() autotools.make()
def shared_in_current_directory_test(self): """ - There is a package building a shared library - There is a consumer project importing the shared library (and the executable) - The consumer tries to execute the imported shared library and executable in the same directory, and it fails in Linux, but works on OSX and WIndows. - Then I move the shared library to a different directory, and it fails, I'm making sure that there is no harcoded rpaths messing. - Finally I use the virtualrunenvironment that declares de LD_LIBRARY_PATH, PATH and DYLD_LIBRARY_PATH to run the executable, and.. magic! it's running agains the shared in the local cache. """ conanfile = """ from conans import ConanFile, CMake, tools class LibConan(ConanFile): name = "lib" version = "1.0" settings = "os", "compiler", "build_type", "arch" options = {"shared": [True, False]} default_options = "shared=True" generators = "cmake" exports_sources = "*" def build(self): cmake = CMake(self) self.run('cmake %s' % cmake.command_line) self.run("cmake --build . %s" % cmake.build_config) def package(self): self.copy("*.h", dst="include", src="hello") self.copy("*.lib", dst="lib", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False) self.copy("*.so", dst="lib", keep_path=False) self.copy("*.dylib", dst="lib", keep_path=False) self.copy("*main*", dst="bin", keep_path=False) """ cmakelists = """ project(mytest) set(CMAKE_CXX_COMPILER_WORKS 1) set(CMAKE_CXX_ABI_COMPILED 1) SET(CMAKE_SKIP_RPATH 1) ADD_LIBRARY(hello SHARED hello.c) ADD_EXECUTABLE(main main.c) TARGET_LINK_LIBRARIES(main hello) """ hello_h = """#pragma once #ifdef WIN32 #define HELLO_EXPORT __declspec(dllexport) #else #define HELLO_EXPORT #endif HELLO_EXPORT void hello(); """ client = TestClient() files = {CONANFILE: conanfile, "CMakeLists.txt": cmakelists, "hello.c": '#include "hello.h"\nvoid hello(){\nreturn;}', "hello.h": hello_h, "main.c": '#include "hello.h"\nint main(){\nhello();\nreturn 0;\n}'} client.save(files) client.run("export . conan/stable") client.run("install lib/1.0@conan/stable -o lib:shared=True --build missing") client.save({"conanfile.txt": ''' [requires] lib/1.0@conan/stable [generators] virtualrunenv [imports] bin, * -> ./bin lib, * -> ./bin '''}, clean_first=True) client.run("install .") # Break possible rpaths built in the exe with absolute paths os.rename(os.path.join(client.current_folder, "bin"), os.path.join(client.current_folder, "bin2")) with tools.chdir(os.path.join(client.current_folder, "bin2")): if platform.system() == "Windows": self.assertEqual(os.system("main.exe"), 0) elif platform.system() == "Darwin": self.assertEqual(os.system("./main"), 0) else: self.assertNotEqual(os.system("./main"), 0) self.assertEqual(os.system("LD_LIBRARY_PATH=$(pwd) ./main"), 0) self.assertEqual(os.system("LD_LIBRARY_PATH=. ./main"), 0) # If we move the shared library it won't work, at least we use the virtualrunenv os.mkdir(os.path.join(client.current_folder, "bin2", "subdir")) name = {"Darwin": "libhello.dylib", "Windows": "hello.dll"}.get(platform.system(), "libhello.so") os.rename(os.path.join(client.current_folder, "bin2", name), os.path.join(client.current_folder, "bin2", "subdir", name)) if platform.system() == "Windows": self.assertNotEqual(os.system("main.exe"), 0) elif platform.system() == "Darwin": self.assertNotEqual(os.system("./main"), 0) else: self.assertNotEqual(os.system("LD_LIBRARY_PATH=$(pwd) ./main"), 0) # Will use the shared from the local cache if platform.system() != "Windows": command = "bash -c 'source ../activate_run.sh && ./main'" else: command = "cd .. && activate_run.bat && cd bin2 && main.exe" self.assertEqual(os.system(command), 0)
def _install_autotools(self): with tools.chdir(self._source_subfolder): autotools = self._configure_autotools() autotools.install() tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) tools.remove_files_by_mask(self.package_folder, "*.la")
def build(self): def add_flag(name, value): if name in os.environ: os.environ[name] += " " + value else: os.environ[name] = value # Get the version of the current compiler instead of gcc linux_include = os.path.join(self._source_subfolder, "build", "linux.inc") tools.replace_in_file(linux_include, "shell gcc", "shell $(CC)") tools.replace_in_file(linux_include, "= gcc", "= $(CC)") if self.version != "2019_u9" and self.settings.build_type == "Debug": tools.replace_in_file( os.path.join(self._source_subfolder, "Makefile"), "release", "debug") if self._base_compiler == "Visual Studio": tools.save( os.path.join(self._source_subfolder, "build", "big_iron_msvc.inc"), # copy of big_iron.inc adapted for MSVC """ LIB_LINK_CMD = {}.exe LIB_OUTPUT_KEY = /OUT: LIB_LINK_FLAGS = LIB_LINK_LIBS = DYLIB_KEY = override CXXFLAGS += -D__TBB_DYNAMIC_LOAD_ENABLED=0 -D__TBB_SOURCE_DIRECTLY_INCLUDED=1 ITT_NOTIFY = DLL = lib LIBEXT = lib LIBPREF = LIBDL = TBB.DLL = $(LIBPREF)tbb$(DEBUG_SUFFIX).$(LIBEXT) LINK_TBB.LIB = $(TBB.DLL) TBB.DEF = TBB_NO_VERSION.DLL = MALLOC.DLL = $(LIBPREF)tbbmalloc$(DEBUG_SUFFIX).$(LIBEXT) LINK_MALLOC.LIB = $(MALLOC.DLL) MALLOC.DEF = MALLOC_NO_VERSION.DLL = MALLOCPROXY.DLL = MALLOCPROXY.DEF = """.format("xilib" if self.settings.compiler == "intel" else "lib")) extra = "" if self.options.shared else "extra_inc=big_iron_msvc.inc" else: extra = "" if self.options.shared else "extra_inc=big_iron.inc" arch = { "x86": "ia32", "x86_64": "intel64", "armv7": "armv7", "armv8": "aarch64", }[str(self.settings.arch)] extra += " arch=%s" % arch if str(self._base_compiler) in ("gcc", "clang", "apple-clang"): if str(self._base_compiler.libcxx) in ("libstdc++", "libstdc++11"): extra += " stdlib=libstdc++" elif str(self._base_compiler.libcxx) == "libc++": extra += " stdlib=libc++" if str(self.settings.compiler) == "intel": extra += " compiler=icc" elif str(self.settings.compiler) in ("clang", "apple-clang"): extra += " compiler=clang" else: extra += " compiler=gcc" if self.settings.os == "Linux": # runtime is supposed to track the version of the c++ stdlib, # the version of glibc, and the version of the linux kernel. # However, it isn't actually used anywhere other than for # logging and build directory names. # TBB computes the value of this variable using gcc, which we # don't necessarily want to require when building this recipe. # Setting it to a dummy value prevents TBB from calling gcc. extra += " runtime=gnu" elif str(self._base_compiler) == "Visual Studio": if str(self._base_compiler.runtime) in ("MT", "MTd"): runtime = "vc_mt" else: runtime = { "8": "vc8", "9": "vc9", "10": "vc10", "11": "vc11", "12": "vc12", "14": "vc14", "15": "vc14.1", "16": "vc14.2" }[str(self._base_compiler.version)] extra += " runtime=%s" % runtime if self.settings.compiler == "intel": extra += " compiler=icl" else: extra += " compiler=cl" make = tools.get_env( "CONAN_MAKE_PROGRAM", tools.which("make") or tools.which("mingw32-make")) if not make: raise ConanInvalidConfiguration( "This package needs 'make' in the path to build") with tools.chdir(self._source_subfolder): # intentionally not using AutoToolsBuildEnvironment for now - it's broken for clang-cl if self._is_clanglc: add_flag("CFLAGS", "-mrtm") add_flag("CXXFLAGS", "-mrtm") targets = ["tbb", "tbbmalloc", "tbbproxy"] context = tools.no_op() if self.settings.compiler == "intel": context = tools.intel_compilervars(self) elif self._is_msvc: # intentionally not using vcvars for clang-cl yet context = tools.vcvars(self) with context: self.run("%s %s %s" % (make, extra, " ".join(targets)))
def _configure_autotools(self): if self._autotools: return self._autotools configure_dir = self._source_subfolder with tools.chdir(configure_dir): self.run("autoconf -i", win_bash=tools.os_info.is_windows) self._autotools = AutoToolsBuildEnvironment( self, win_bash=tools.os_info.is_windows) args = [] # Shared/Static if self.options.shared: args.extend(["--disable-static", "--enable-shared"]) else: args.extend(["--disable-shared", "--enable-static"]) # Enable C++14 if requested in conan profile if self.settings.compiler.cppstd and tools.valid_min_cppstd(self, 14): args.append("--with-cpp14") # Debug if self.settings.build_type == "Debug": args.append("--enable-debug") # SIMD Intrinsics simd_intrinsics = self.options.get_safe("simd_intrinsics", False) if not simd_intrinsics: args.extend(["--without-sse", "--without-ssse3", "--without-avx"]) elif simd_intrinsics == "sse": args.extend(["--with-sse", "--without-ssse3", "--without-avx"]) elif simd_intrinsics == "ssse3": args.extend(["--with-sse", "--with-ssse3", "--without-avx"]) elif simd_intrinsics == "avx": args.extend(["--with-sse", "--with-ssse3", "--with-avx"]) # LTO (disabled) args.append("--disable-lto") # Symbols args.append("--with-hide_internal_symbols") # Do not add /usr/local/lib and /usr/local/include args.append("--without-local") # Threadsafe args.append("--with-threads={}".format( "yes" if self.options.threadsafe else "no")) # Depencencies: args.append("--with-proj=yes") # always required ! args.append( "--with-libz={}".format("yes" if self.options.with_zlib else "no")) args.append("--with-libiconv-prefix={}".format( self._unix_path(self.deps_cpp_info["libiconv"].rootpath))) args.append( "--with-liblzma=no" ) # always disabled: liblzma is an optional transitive dependency of gdal (through libtiff). args.append("--with-zstd={}".format( "yes" if self.options.get_safe("with_zstd") else "no" )) # Optional direct dependency of gdal only if lerc lib enabled # Drivers: if not (self.options.with_zlib and self.options.with_png and bool(self.options.with_jpeg)): # MRF raster driver always depends on zlib, libpng and libjpeg: https://github.com/OSGeo/gdal/issues/2581 if tools.Version(self.version) < "3.0.0": args.append("--without-mrf") else: args.append("--disable-driver-mrf") args.append( "--with-pg={}".format("yes" if self.options.with_pg else "no")) args.extend(["--without-grass", "--without-libgrass" ]) # TODO: to implement when libgrass lib available args.append("--with-cfitsio={}".format( self._unix_path(self.deps_cpp_info["cfitsio"].rootpath) if self. options.with_cfitsio else "no")) args.append("--with-pcraster={}".format( "internal" if self.options.with_pcraster else "no" )) # TODO: use conan recipe when available instead of internal one args.append("--with-png={}".format( self._unix_path(self.deps_cpp_info["libpng"].rootpath) if self. options.with_png else "no")) args.append( "--without-dds") # TODO: to implement when crunch lib available args.append("--with-gta={}".format( self._unix_path(self.deps_cpp_info["libgta"].rootpath) if self. options.with_gta else "no")) args.append("--with-pcidsk={}".format( "internal" if self.options.with_pcidsk else "no" )) # TODO: use conan recipe when available instead of internal one args.append("--with-libtiff={}".format( self._unix_path( self.deps_cpp_info["libtiff"].rootpath))) # always required ! args.append("--with-geotiff={}".format( self._unix_path(self.deps_cpp_info["libgeotiff"].rootpath)) ) # always required ! if self.options.with_jpeg == "libjpeg": args.append("--with-jpeg={}".format( self._unix_path(self.deps_cpp_info["libjpeg"].rootpath))) elif self.options.with_jpeg == "libjpeg-turbo": args.append("--with-jpeg={}".format( self._unix_path(self.deps_cpp_info["libjpeg-turbo"].rootpath))) else: args.append("--without-jpeg") args.append("--without-jpeg12" ) # disabled: it requires internal libjpeg and libgeotiff args.append("--with-charls={}".format( "yes" if self.options.with_charls else "no")) args.append("--with-gif={}".format( self._unix_path(self.deps_cpp_info["giflib"].rootpath) if self. options.with_gif else "no")) args.append( "--without-ogdi" ) # TODO: to implement when ogdi lib available (https://sourceforge.net/projects/ogdi/) args.append("--without-fme") # commercial library args.append( "--without-sosi") # TODO: to implement when fyba lib available args.append("--without-mongocxx" ) # TODO: to implement when mongocxx lib available args.append( "--with-hdf4={}".format("yes" if self.options.with_hdf4 else "no")) args.append( "--with-hdf5={}".format("yes" if self.options.with_hdf5 else "no")) args.append( "--without-kea") # TODO: to implement when kealib available args.append("--without-netcdf" ) # TODO: to implement when netcdf-c lib available args.append("--with-jasper={}".format( self._unix_path(self.deps_cpp_info["jasper"].rootpath) if self. options.with_jasper else "no")) args.append("--with-openjpeg={}".format( "yes" if self.options.with_openjpeg else "no")) args.append( "--without-fgdb" ) # TODO: to implement when file-geodatabase-api lib available args.append("--without-ecw") # commercial library args.append("--without-kakadu") # commercial library args.extend( ["--without-mrsid", "--without-jp2mrsid", "--without-mrsid_lidar"]) # commercial library args.append("--without-jp2lura") # commercial library args.append("--without-msg") # commercial library args.append("--without-oci") # TODO args.append( "--with-gnm={}".format("yes" if self.options.with_gnm else "no")) args.append("--with-mysql={}".format( "yes" if bool(self.options.with_mysql) else "no")) args.append("--without-ingres") # commercial library args.append("--with-xerces={}".format( self._unix_path(self.deps_cpp_info["xerces-c"].rootpath) if self. options.with_xerces else "no")) args.append("--with-expat={}".format( "yes" if self.options.with_expat else "no")) args.append("--with-libkml={}".format( self._unix_path(self.deps_cpp_info["libkml"].rootpath) if self. options.with_libkml else "no")) args.append("--with-odbc={}".format( self._unix_path(self.deps_cpp_info["odbc"].rootpath) if self. options.with_odbc else "no")) args.append("--without-dods-root" ) # TODO: to implement when libdap lib available args.append( "--with-curl={}".format("yes" if self.options.with_curl else "no")) args.append( "--with-xml2={}".format("yes" if self.options.with_xml2 else "no")) args.append("--without-spatialite" ) # TODO: to implement when libspatialite lib available args.append("--with-sqlite3={}".format( "yes" if self.options.get_safe("with_sqlite3") else "no")) args.append("--without-rasterlite2" ) # TODO: to implement when rasterlite2 lib available args.append("--with-pcre={}".format( "yes" if self.options.get_safe("with_pcre") else "no")) args.append("--without-teigha") # commercial library args.append("--without-idb") # commercial library args.append("--without-sde") # commercial library args.append("--without-epsilon" ) # TODO: to implement when epsilon lib available args.append("--with-webp={}".format( self._unix_path(self.deps_cpp_info["libwebp"].rootpath) if self. options.with_webp else "no")) args.append( "--with-geos={}".format("yes" if self.options.with_geos else "no")) args.append( "--without-sfcgal") # TODO: to implement when sfcgal lib available args.append("--with-qhull={}".format( "yes" if self.options.with_qhull else "no")) args.append( "--without-opencl" ) # TODO: to implement when opencl-headers available (and also OpenCL lib?) args.append("--with-freexl={}".format( "yes" if self.options.with_freexl else "no")) args.append("--with-libjson-c={}".format( self._unix_path( self.deps_cpp_info["json-c"].rootpath))) # always required ! if self.options.without_pam: args.append("--without-pam") args.append("--without-poppler" ) # TODO: to implement when poppler lib available args.append( "--without-podofo") # TODO: to implement when podofo lib available args.append( "--without-pdfium") # TODO: to implement when pdfium lib available args.append("--without-perl") args.append("--without-python") args.append("--without-java") args.append("--without-hdfs") if tools.Version(self.version) >= "3.0.0": args.append("--without-tiledb" ) # TODO: to implement when tiledb lib available args.append("--without-mdb") args.append("--without-rasdaman" ) # TODO: to implement when rasdaman lib available if tools.Version(self.version) >= "3.1.0": args.append("--without-rdb") # commercial library args.append("--without-armadillo" ) # TODO: to implement when armadillo lib available args.append("--without-cryptopp" ) # TODO: to implement when cryptopp lib available args.append("--with-crypto={}".format( "yes" if self.options.with_crypto else "no")) args.append("--with-lerc={}".format( "no" if self.options.without_lerc else "yes")) if self.options.with_null: args.append("--with-null") if self.options.get_safe("with_exr") is not None: args.append("--with-exr={}".format( "yes" if self.options.with_exr else "no")) # Inject -stdlib=libc++ for clang with libc++ env_build_vars = self._autotools.vars if self.settings.compiler == "clang" and \ self.settings.os == "Linux" and self._stdcpp_library == "c++": env_build_vars["LDFLAGS"] = "-stdlib=libc++ {}".format( env_build_vars["LDFLAGS"]) with tools.chdir(configure_dir): self._autotools.configure(args=args, vars=env_build_vars) return self._autotools
def valid_xml_test(self, use_toolset): tempdir = temp_folder() with chdir(tempdir): settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.compiler = "Visual Studio" settings.compiler.version = "11" settings.compiler.runtime = "MD" if use_toolset: settings.compiler.toolset = "v110" conanfile = ConanFile(None, None, Settings({}), None) ref = ConanFileReference.loads("MyPkg/0.1@user/testing") cpp_info = CppInfo("dummy_root_folder1") conanfile.deps_cpp_info.update(cpp_info, ref.name) ref = ConanFileReference.loads("My.Fancy-Pkg_2/0.1@user/testing") cpp_info = CppInfo("dummy_root_folder2") conanfile.deps_cpp_info.update(cpp_info, ref.name) settings.arch = "x86" settings.build_type = "Debug" conanfile.settings = settings generator = VisualStudioMultiGenerator(conanfile) generator.output_path = "" content = generator.content self.assertEqual(2, len(content)) self.assertIn('conanbuildinfo_multi.props', content.keys()) self.assertIn('conanbuildinfo_debug_win32_v110.props', content.keys()) content_multi = content['conanbuildinfo_multi.props'] self.assertIn("<Import Condition=\"'$(Configuration)' == 'Debug' " "And '$(Platform)' == 'Win32' " "And '$(PlatformToolset)' == 'v110'\" " "Project=\"conanbuildinfo_debug_win32_v110.props\"/>", content_multi) with open('conanbuildinfo_multi.props', 'w') as f: f.write(content_multi) settings.arch = "x86_64" settings.build_type = "Release" settings.compiler.version = "15" settings.compiler.toolset = "v141" conanfile.settings = settings generator = VisualStudioMultiGenerator(conanfile) generator.output_path = "" content = generator.content self.assertEqual(2, len(content)) self.assertIn('conanbuildinfo_multi.props', content.keys()) self.assertIn('conanbuildinfo_release_x64_v141.props', content.keys()) content_multi = content['conanbuildinfo_multi.props'] self.assertIn("<Import Condition=\"'$(Configuration)' == 'Debug' " "And '$(Platform)' == 'Win32' " "And '$(PlatformToolset)' == 'v110'\" " "Project=\"conanbuildinfo_debug_win32_v110.props\"/>", content_multi) self.assertIn("<Import Condition=\"'$(Configuration)' == 'Release' " "And '$(Platform)' == 'x64' " "And '$(PlatformToolset)' == 'v141'\" " "Project=\"conanbuildinfo_release_x64_v141.props\"/>", content_multi) os.unlink('conanbuildinfo_multi.props')
def _extract_license(self): with tools.chdir(os.path.join(self.source_folder, self._source_subfolder)): tmp = tools.load("zlib.h") license_contents = tmp[2:tmp.find("*/", 1)] tools.save("LICENSE", license_contents)