Exemplo n.º 1
0
def adjust_path(path, win_bash=False, subsystem=None, compiler=None):
    """
    adjusts path to be safely passed to the compiler command line
    for Windows bash, ensures path is in format according to the subsystem
    for path with spaces, places double quotes around it
    converts slashes to backslashes, or vice versa
    """
    if str(compiler) == 'Visual Studio':
        path = path.replace('/', '\\')
    else:
        path = path.replace('\\', '/')
    if win_bash:
        path = unix_path(path, subsystem)
    return '"%s"' % path if ' ' in path else path
Exemplo n.º 2
0
    def run_in_windows_bash_test(self):
        if platform.system() != "Windows":
            return
        conanfile = '''
from conans import ConanFile, tools

class ConanBash(ConanFile):
    name = "bash"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    def build(self):
        tools.run_in_windows_bash(self, "pwd")

        '''
        client = TestClient()
        client.save({CONANFILE: conanfile})
        client.run("export lasote/stable")
        client.run("install bash/0.1@lasote/stable --build")
        expected_curdir_base = unix_path(client.client_cache.conan(ConanFileReference.loads("bash/0.1@lasote/stable")))
        self.assertIn(expected_curdir_base, client.user_io.out)
Exemplo n.º 3
0
 def test_wsl_path(self):
     self.assertEqual('/mnt/c/Windows/System32', tools.unix_path('C:\\Windows\\System32',
                                                                 path_flavor=tools.WSL))
Exemplo n.º 4
0
    def _configure_args(self):
        openssldir = self.options.openssldir if self.options.openssldir else os.path.join(
            self.package_folder, "res")
        prefix = tools.unix_path(
            self.package_folder) if self._win_bash else self.package_folder
        openssldir = tools.unix_path(
            openssldir) if self._win_bash else openssldir
        args = [
            '"%s"' % (self._target if self._full_version >= "1.1.0" else
                      self._ancestor_target),
            "shared" if self.options.shared else "no-shared",
            "--prefix=%s" % prefix,
            "--openssldir=%s" % openssldir, "no-unit-test"
        ]
        if self._full_version >= "1.1.1":
            args.append("PERL=%s" % self._perl)
        if self._full_version < "1.1.0" or self._full_version >= "1.1.1":
            args.append("no-tests")
        if self._full_version >= "1.1.0":
            args.append("--debug" if self.settings.build_type ==
                        "Debug" else "--release")

        if str(self.settings.os) == "Android":
            args.append(" -D__ANDROID_API__=%s" %
                        str(self.settings.os.api_level))  # see NOTES.ANDROID
        if str(self.settings.os) == "Emscripten":
            args.append("-D__STDC_NO_ATOMICS__=1")
        if self.settings.os == "Windows":
            if self.options.capieng_dialog:
                args.append("-DOPENSSL_CAPIENG_DIALOG=1")
        else:
            args.append("-fPIC" if self.options.fPIC else "")
        if self.settings.os == "Neutrino":
            args.append("-lsocket no-asm")

        if "zlib" in self.deps_cpp_info.deps:
            zlib_info = self.deps_cpp_info["zlib"]
            include_path = zlib_info.include_paths[0]
            if self.settings.os == "Windows":
                lib_path = "%s/%s.lib" % (zlib_info.lib_paths[0],
                                          zlib_info.libs[0])
            else:
                lib_path = zlib_info.lib_paths[
                    0]  # Just path, linux will find the right file
            if tools.os_info.is_windows:
                # clang-cl doesn't like backslashes in #define CFLAGS (builldinf.h -> cversion.c)
                include_path = include_path.replace('\\', '/')
                lib_path = lib_path.replace('\\', '/')
            args.extend([
                '--with-zlib-include="%s"' % include_path,
                '--with-zlib-lib="%s"' % lib_path
            ])

        for option_name in self.options.values.fields:
            activated = getattr(self.options, option_name)
            if activated and option_name not in [
                    "fPIC", "openssldir", "capieng_dialog"
            ]:
                self.output.info("activated option: %s" % option_name)
                args.append(option_name.replace("_", "-"))
        return args
Exemplo n.º 5
0
    def _get_configure_command_args(self):
        yes_no = lambda v: "yes" if v else "no"
        params = [
            "--with-libidn2={}".format(yes_no(self.options.with_libidn)),
            "--with-librtmp={}".format(yes_no(self.options.with_librtmp)),
            "--with-libmetalink={}".format(
                yes_no(self.options.with_libmetalink)),
            "--with-libpsl={}".format(yes_no(self.options.with_libpsl)),
            "--with-schannel={}".format(
                yes_no(self.options.with_ssl == "schannel")),
            "--with-secure-transport={}".format(
                yes_no(self.options.with_ssl == "darwinssl")),
            "--with-brotli={}".format(yes_no(self.options.with_brotli)),
            "--enable-shared={}".format(yes_no(self.options.shared)),
            "--enable-static={}".format(yes_no(not self.options.shared)),
            "--enable-ldap={}".format(yes_no(self.options.with_ldap)),
            "--enable-debug={}".format(
                yes_no(self.settings.build_type == "Debug")),
            "--enable-ares={}".format(yes_no(self.options.with_c_ares)),
            "--enable-threaded-resolver={}".format(
                yes_no(self.options.with_c_ares)),
        ]
        if self.options.with_ssl == "openssl":
            params.append("--with-ssl={}".format(
                tools.unix_path(self.deps_cpp_info["openssl"].rootpath)))
        else:
            params.append("--without-ssl")
        if self.options.with_ssl == "wolfssl":
            params.append("--with-wolfssl={}".format(
                tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath)))
        else:
            params.append("--without-wolfssl")

        if self.options.with_libssh2:
            params.append("--with-libssh2={}".format(
                tools.unix_path(self.deps_cpp_info["libssh2"].rootpath)))
        else:
            params.append("--without-libssh2")

        if self.options.with_nghttp2:
            params.append("--with-nghttp2={}".format(
                tools.unix_path(self.deps_cpp_info["libnghttp2"].rootpath)))
        else:
            params.append("--without-nghttp2")

        if self.options.with_zlib:
            params.append("--with-zlib={}".format(
                tools.unix_path(self.deps_cpp_info["zlib"].rootpath)))
        else:
            params.append("--without-zlib")

        if self._has_zstd_option:
            params.append("--with-zstd={}".format(
                yes_no(self.options.with_zstd)))

        # Cross building flags
        if tools.cross_building(self.settings):
            if self.settings.os == "Linux" and "arm" in self.settings.arch:
                params.append("--host=%s" % self._get_linux_arm_host())
            elif self.settings.os == "iOS":
                params.append("--enable-threaded-resolver")
                params.append("--disable-verbose")
            elif self.settings.os == "Android":
                pass  # this just works, conan is great!

        return params
Exemplo n.º 6
0
    def package_info(self):
        # library components
        self.cpp_info.components["libelf"].libs = ["elf"]
        self.cpp_info.components["libelf"].requires = ["zlib::zlib"]

        self.cpp_info.components["libdw"].libs = ["dw"]
        self.cpp_info.components["libdw"].requires = ["libelf", "zlib::zlib"]
        if self.options.with_bzlib:
            self.cpp_info.components["libdw"].requires.append("bzip2::bzip2")
        if self.options.with_lzma:
            self.cpp_info.components["libdw"].requires.append(
                "xz_utils::xz_utils")

        self.cpp_info.components["libasm"].includedirs = ["include/elfutils"]
        self.cpp_info.components["libasm"].libs = ["asm"]
        self.cpp_info.components["libasm"].requires = ["libelf", "libdw"]

        # utilities
        bin_path = os.path.join(self.package_folder, "bin")
        self.output.info("Appending PATH env var with : {}".format(bin_path))
        self.env_info.PATH.append(bin_path)

        bin_ext = ".exe" if self.settings.os == "Windows" else ""

        addr2line = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-addr2line" + bin_ext))
        self.output.info("Setting ADDR2LINE to {}".format(addr2line))
        self.env_info.ADDR2LINE = addr2line

        ar = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-ar" + bin_ext))
        self.output.info("Setting AR to {}".format(ar))
        self.env_info.AR = ar

        elfclassify = tools.unix_path(
            os.path.join(self.package_folder, "bin",
                         "eu-elfclassify" + bin_ext))
        self.output.info("Setting ELFCLASSIFY to {}".format(elfclassify))
        self.env_info.ELFCLASSIFY = elfclassify

        elfcmp = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-elfcmp" + bin_ext))
        self.output.info("Setting ELFCMP to {}".format(elfcmp))
        self.env_info.ELFCMP = elfcmp

        elfcompress = tools.unix_path(
            os.path.join(self.package_folder, "bin",
                         "eu-elfcompress" + bin_ext))
        self.output.info("Setting ELFCOMPRESS to {}".format(elfcompress))
        self.env_info.ELFCOMPRESS = elfcompress

        elflint = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-elflint" + bin_ext))
        self.output.info("Setting ELFLINT to {}".format(elflint))
        self.env_info.ELFLINT = elflint

        findtextrel = tools.unix_path(
            os.path.join(self.package_folder, "bin",
                         "eu-findtextrel" + bin_ext))
        self.output.info("Setting FINDTEXTREL to {}".format(findtextrel))
        self.env_info.FINDTEXTREL = findtextrel

        make_debug_archive = tools.unix_path(
            os.path.join(self.package_folder, "bin",
                         "eu-make-debug-archive" + bin_ext))
        self.output.info(
            "Setting MAKE_DEBUG_ARCHIVE to {}".format(make_debug_archive))
        self.env_info.MAKE_DEBUG_ARCHIVE = make_debug_archive

        nm = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-nm" + bin_ext))
        self.output.info("Setting NM to {}".format(nm))
        self.env_info.NM = nm

        objdump = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-objdump" + bin_ext))
        self.output.info("Setting OBJDUMP to {}".format(objdump))
        self.env_info.OBJDUMP = objdump

        ranlib = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-ranlib" + bin_ext))
        self.output.info("Setting RANLIB to {}".format(ranlib))
        self.env_info.RANLIB = ranlib

        readelf = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-readelf" + bin_ext))
        self.output.info("Setting READELF to {}".format(readelf))
        self.env_info.READELF = readelf

        size = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-size" + bin_ext))
        self.output.info("Setting SIZE to {}".format(size))
        self.env_info.SIZE = size

        stack = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-stack" + bin_ext))
        self.output.info("Setting STACK to {}".format(stack))
        self.env_info.STACK = stack

        strings = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-strings" + bin_ext))
        self.output.info("Setting STRINGS to {}".format(strings))
        self.env_info.STRINGS = strings

        strip = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-strip" + bin_ext))
        self.output.info("Setting STRIP to {}".format(strip))
        self.env_info.STRIP = strip

        unstrip = tools.unix_path(
            os.path.join(self.package_folder, "bin", "eu-unstrip" + bin_ext))
        self.output.info("Setting UNSTRIP to {}".format(unstrip))
        self.env_info.UNSTRIP = unstrip
 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
Exemplo n.º 8
0
 def _configure_autotools(self):
     if self._autotools:
         return self._autotools
     self._autotools = AutoToolsBuildEnvironment(
         self, win_bash=tools.os_info.is_windows)
     build = None
     host = None
     conf_args = [
         "--enable-widec" if self.options.with_widec else "--disable-widec",
         "--enable-ext-colors" if self.options.get_safe(
             "with_extended_colors", False) else "--disable-ext-colors",
         "--enable-reentrant"
         if self.options.with_reentrant else "--disable-reentrant",
         "--with-pcre2" if self.options.with_pcre2 else "--without-pcre2",
         "--with-cxx-binding"
         if self.options.with_cxx else "--without-cxx-binding",
         "--with-progs" if self.options.with_progs else "--without-progs",
         "--without-libtool",
         "--without-ada",
         "--without-manpages",
         "--without-tests",
         "--disable-echo",
         "--without-debug",
         "--without-profile",
         "--with-sp-funcs",
         "--disable-rpath",
         "--datarootdir={}".format(
             tools.unix_path(
                 os.path.join(self.package_folder, "bin", "share"))),
         "--disable-pc-files",
     ]
     if self.options.shared:
         conf_args.extend([
             "--with-shared",
             "--without-normal",
             "--with-cxx-shared",
         ])
     else:
         conf_args.extend(
             ["--without-shared", "--with-normal", "--without-cxx-shared"])
     if self.settings.os == "Windows":
         conf_args.extend([
             "--disable-macros",
             "--disable-termcap",
             "--enable-database",
             "--enable-sp-funcs",
             "--enable-term-driver",
             "--enable-interop",
         ])
     if self.settings.compiler == "Visual Studio":
         conf_args.extend([
             "ac_cv_func_getopt=yes",
         ])
         build = host = "{}-w64-mingw32-msvc7".format(self.settings.arch)
         self._autotools.flags.append("-FS")
         self._autotools.cxx_flags.append("-EHsc")
     self._autotools.configure(args=conf_args,
                               configure_dir=self._source_subfolder,
                               host=host,
                               build=build)
     return self._autotools
Exemplo n.º 9
0
 def test_sfu_path(self):
     self.assertEqual(
         '/dev/fs/C/windows/system32',
         tools.unix_path('C:\\Windows\\System32', path_flavor=tools.SFU))
Exemplo n.º 10
0
    def _configure_args(self):
        openssldir = self.options.openssldir or self._get_default_openssl_dir()
        prefix = tools.unix_path(
            self.package_folder) if self._win_bash else self.package_folder
        openssldir = tools.unix_path(
            openssldir) if self._win_bash else openssldir
        args = [
            '"%s"' % (self._target if self._full_version >= "1.1.0" else
                      self._ancestor_target),
            "shared" if self.options.shared else "no-shared",
            "--prefix=\"%s\"" % prefix,
            "--openssldir=\"%s\"" % openssldir, "no-unit-test",
            "no-threads" if self.options.no_threads else "threads"
        ]
        if self._full_version >= "1.1.1":
            args.append("PERL=%s" % self._perl)
        if self._full_version < "1.1.0" or self._full_version >= "1.1.1":
            args.append("no-tests")
        if self._full_version >= "1.1.0":
            args.append("--debug" if self.settings.build_type ==
                        "Debug" else "--release")

        if self.settings.os in ["tvOS", "watchOS"]:
            args.append(
                " -DNO_FORK")  # fork is not available on tvOS and watchOS
        if self.settings.os == "Android":
            args.append(" -D__ANDROID_API__=%s" %
                        str(self.settings.os.api_level))  # see NOTES.ANDROID
        if self.settings.os == "Emscripten":
            args.append("-D__STDC_NO_ATOMICS__=1")
        if self.settings.os == "Windows":
            if self.options.enable_capieng:
                args.append("enable-capieng")
            if self.options.capieng_dialog:
                args.append("-DOPENSSL_CAPIENG_DIALOG=1")
        else:
            args.append(
                "-fPIC" if self.options.get_safe("fPIC", True) else "no-pic")
        if self.settings.os == "Neutrino":
            args.append("no-asm -lsocket -latomic")
        if self._full_version < "1.1.0":
            if self.options.get_safe("no_zlib"):
                args.append("no-zlib")
            else:
                zlib_info = self.deps_cpp_info["zlib"]
                include_path = zlib_info.include_paths[0]
                if self.settings.os == "Windows":
                    lib_path = "%s/%s.lib" % (zlib_info.lib_paths[0],
                                              zlib_info.libs[0])
                else:
                    lib_path = zlib_info.lib_paths[
                        0]  # Just path, linux will find the right file
                # clang-cl doesn't like backslashes in #define CFLAGS (builldinf.h -> cversion.c)
                include_path = self._adjust_path(include_path)
                lib_path = self._adjust_path(lib_path)

                if zlib_info.shared:
                    args.append("zlib-dynamic")
                else:
                    args.append("zlib")

                args.extend([
                    '--with-zlib-include="%s"' % include_path,
                    '--with-zlib-lib="%s"' % lib_path
                ])

        for option_name in self.options.values.fields:
            activated = getattr(self.options, option_name)
            if activated and option_name not in [
                    "fPIC", "openssldir", "capieng_dialog", "enable_capieng"
            ]:
                self.output.info("activated option: %s" % option_name)
                args.append(option_name.replace("_", "-"))
        return args
Exemplo n.º 11
0
    def _configure_autotools(self):
        if self._autotools:
            return self._autotools
        self._autotools = AutoToolsBuildEnvironment(
            self, win_bash=tools.os_info.is_windows)
        self._autotools.libs = []
        args = [
            "--bit-depth=%s" % str(self.options.bit_depth),
            "--disable-cli",
            "--prefix={}".format(tools.unix_path(self.package_folder)),
        ]
        if self.options.shared:
            args.append("--enable-shared")
        else:
            args.append("--enable-static")
        if self.options.get_safe("fPIC", self.settings.os != "Windows"):
            args.append("--enable-pic")
        if self.settings.build_type == "Debug":
            args.append("--enable-debug")
        if self.settings.os == "Macos" and self.settings.arch == "armv8":
            # bitstream-a.S:29:18: error: unknown token in expression
            args.append("--extra-asflags=-arch arm64")
            args.append("--extra-ldflags=-arch arm64")
            args.append("--host=aarch64-apple-darwin")

        if self._with_nasm:
            # FIXME: get using user_build_info
            self._override_env["AS"] = os.path.join(
                self.dependencies.build["nasm"].package_folder, "bin",
                "nasm{}".format(
                    ".exe" if tools.os_info.is_windows else "")).replace(
                        "\\", "/")
        if tools.cross_building(self):
            if self.settings.os == "Android":
                # the as of ndk does not work well for building libx264
                self._override_env["AS"] = os.environ["CC"]
                ndk_root = tools.unix_path(os.environ["NDK_ROOT"])
                arch = {
                    "armv7": "arm",
                    "armv8": "aarch64",
                    "x86": "i686",
                    "x86_64": "x86_64",
                }.get(str(self.settings.arch))
                abi = "androideabi" if self.settings.arch == "armv7" else "android"
                args.append("--cross-prefix={}".format(
                    "{}/bin/{}-linux-{}-".format(ndk_root, arch, abi)))
        if self._is_msvc:
            self._override_env["CC"] = "cl -nologo"
            self._autotools.flags.append("-{}".format(msvc_runtime_flag(self)))
            if not (self.settings.compiler == "Visual Studio"
                    and tools.Version(self.settings.compiler.version) < "12"):
                self._autotools.flags.append("-FS")
        build_canonical_name = None
        host_canonical_name = None
        if self._is_msvc:
            # autotools does not know about the msvc canonical name(s)
            build_canonical_name = False
            host_canonical_name = False
        self._autotools.configure(args=args,
                                  vars=self._override_env,
                                  configure_dir=self._source_subfolder,
                                  build=build_canonical_name,
                                  host=host_canonical_name)
        return self._autotools
Exemplo n.º 12
0
    def build_configure(self):
        with tools.chdir('sources'):
            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', '--pkg-config-flags=--static'])
            if self.settings.build_type == 'Debug':
                args.extend(['--disable-optimizations', '--disable-mmx', '--disable-stripping', '--enable-debug'])
            if self.settings.compiler == 'Visual Studio':
                args.append('--toolchain=msvc')
            if self.settings.arch == 'x86':
                args.append('--arch=x86')

            args.append('--enable-postproc' if self.options.postproc else '--disable-postproc')
            args.append('--enable-pic' if self.options.fPIC else '--disable-pic')
            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')

            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-jack' if self.options.jack else '--disable-jack')
                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-vda' if self.options.vda else '--disable-vda')
                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'])

            os.makedirs('pkgconfig')
            if self.options.freetype:
                self.copy_pkg_config('freetype')
                self.copy_pkg_config('libpng')
            if self.options.opus:
                self.copy_pkg_config('opus')
            if self.options.vorbis:
                self.copy_pkg_config('ogg')
                self.copy_pkg_config('vorbis')
            if self.options.zmq:
                self.copy_pkg_config('zmq')
            if self.options.sdl2:
                self.copy_pkg_config('sdl2')
            if self.options.x264:
                self.copy_pkg_config('libx264')
            if self.options.x265:
                self.copy_pkg_config('libx265')
            if self.options.vpx:
                self.copy_pkg_config('libvpx')
            if self.options.fdk_aac:
                self.copy_pkg_config('libfdk_aac')
            if self.options.openh264:
                self.copy_pkg_config('openh264')

            env_vars = {'PKG_CONFIG_PATH': os.path.abspath('pkgconfig')}

            if self.settings.compiler == 'Visual Studio':
                args.append('--extra-cflags=-%s' % self.settings.compiler.runtime)
                if int(str(self.settings.compiler.version)) <= 12:
                    args.append('--extra-cflags=-Dsnprintf=_snprintf')

            with tools.environment_append(env_vars):
                env_build = AutoToolsBuildEnvironment(self, win_bash=self.is_mingw 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()
Exemplo n.º 13
0
    def build_configure(self):
        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')
                enable_gpl = True

            if self.options.fdk_aac or (enable_gpl and self.options.openssl):
                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"])
Exemplo n.º 14
0
    def _configure_autotools(self):
        args = [
            "--prefix={}".format(tools.unix_path(self.package_folder)),
            "--disable-examples",
            "--disable-unit-tests",
            "--disable-tools",
            "--disable-docs",
            "--enable-vp9-highbitdepth",
            "--as=yasm",
        ]
        if self.options.shared:
            args.extend(['--disable-static', '--enable-shared'])
        else:
            args.extend(['--disable-shared', '--enable-static'])
        if self.settings.os != 'Windows' and self.options.get_safe(
                "fPIC", True):
            args.append('--enable-pic')
        if self.settings.build_type == "Debug":
            args.append('--enable-debug')
        if self._is_msvc and "MT" in msvc_runtime_flag(self):
            args.append('--enable-static-msvcrt')

        arch = {
            'x86': 'x86',
            'x86_64': 'x86_64',
            'armv7': 'armv7',
            'armv8': 'arm64',
            'mips': 'mips32',
            'mips64': 'mips64',
            'sparc': 'sparc'
        }.get(str(self.settings.arch))
        if self._is_msvc:
            if self.settings.compiler == "Visual Studio":
                vc_version = self.settings.compiler.version
            else:
                vc_version = msvc_version_to_vs_ide_version(
                    self.settings.compiler.version)
            compiler = "vs{}".format(vc_version)
        elif self.settings.compiler in ["gcc", "clang", "apple-clang"]:
            compiler = 'gcc'

        host_os = str(self.settings.os)
        if host_os == 'Windows':
            os_name = 'win32' if self.settings.arch == 'x86' else 'win64'
        elif tools.is_apple_os(host_os):
            if self.settings.arch in ["x86", "x86_64"]:
                os_name = 'darwin11'
            elif self.settings.arch == "armv8" and self.settings.os == "Macos":
                os_name = 'darwin20'
            else:
                # Unrecognized toolchain 'arm64-darwin11-gcc', see list of toolchains in ./configure --help
                os_name = 'darwin'
        elif host_os == 'Linux':
            os_name = 'linux'
        elif host_os == 'Solaris':
            os_name = 'solaris'
        elif host_os == 'Android':
            os_name = 'android'
        target = "%s-%s-%s" % (arch, os_name, compiler)
        args.append('--target=%s' % target)
        if str(self.settings.arch) in ["x86", "x86_64"]:
            for name in self._arch_options:
                if not self.options.get_safe(name):
                    args.append('--disable-%s' % name)
        autotools = AutoToolsBuildEnvironment(
            self, win_bash=tools.os_info.is_windows)
        if self._is_msvc:
            # gen_msvs_vcxproj.sh doesn't like custom flags
            autotools.cxxflags = []
            autotools.flags = []
        if tools.is_apple_os(self.settings.os) and self.settings.get_safe(
                "compiler.libcxx") == "libc++":
            # special case, as gcc/g++ is hard-coded in makefile, it implicitly assumes -lstdc++
            autotools.link_flags.append("-stdlib=libc++")
        autotools.configure(args=args,
                            configure_dir=self._source_subfolder,
                            host=False,
                            build=False,
                            target=False)
        return autotools
Exemplo n.º 15
0
 def test_msys_path(self):
     self.assertEqual('/c/windows/system32', tools.unix_path('C:\\Windows\\System32',
                                                             path_flavor=tools.MSYS2))
Exemplo n.º 16
0
 def _make_program(self):
     return tools.unix_path(
         tools.get_env("CONAN_MAKE_PROGRAM",
                       tools.which("make") or tools.which("mingw32-make")))
Exemplo n.º 17
0
    def _configure_cmd(self):
        if self.settings.compiler in ('clang', 'apple-clang'):
            botan_compiler = 'clang'
        elif self.settings.compiler == 'gcc':
            botan_compiler = 'gcc'
        else:
            botan_compiler = 'msvc'

        botan_abi_flags = []
        botan_extra_cxx_flags = []
        build_flags = []

        if self._is_linux_clang_libcxx:
            botan_abi_flags.extend(["-stdlib=libc++", "-lc++abi"])

        if botan_compiler in ['clang', 'apple-clang', 'gcc']:
            if self.settings.arch == "x86":
                botan_abi_flags.append('-m32')
            elif self.settings.arch == "x86_64":
                botan_abi_flags.append('-m64')

        if self.settings.os != "Windows" and self.options.fPIC:
            botan_extra_cxx_flags.append('-fPIC')

        if tools.is_apple_os(self.settings.os):
            if self.settings.get_safe("os.version"):
                macos_min_version = tools.apple_deployment_target_flag(
                    self.settings.os, self.settings.get_safe("os.version"),
                    self.settings.get_safe("os.sdk"),
                    self.settings.get_safe("os.subsystem"),
                    self.settings.get_safe("arch"))
                botan_extra_cxx_flags.append(macos_min_version)
            macos_sdk_path = "-isysroot {}".format(
                tools.XCRun(self.settings).sdk_path)
            botan_extra_cxx_flags.append(macos_sdk_path)

        # This is to work around botan's configure script that *replaces* its
        # standard (platform dependent) flags in presence of an environment
        # variable ${CXXFLAGS}. Most notably, this would build botan with
        # disabled compiler optimizations.
        environment_cxxflags = tools.get_env("CXXFLAGS")
        if environment_cxxflags:
            del os.environ["CXXFLAGS"]
            botan_extra_cxx_flags.append(environment_cxxflags)

        if self.options.enable_modules:
            build_flags.append('--minimized-build')
            build_flags.append('--enable-modules={}'.format(
                self.options.enable_modules))

        if self.options.amalgamation:
            build_flags.append('--amalgamation')

        if self.options.get_safe("single_amalgamation"):
            build_flags.append('--single-amalgamation-file')

        if self.options.system_cert_bundle:
            build_flags.append('--system-cert-bundle={}'.format(
                self.options.system_cert_bundle))

        if self.options.with_bzip2:
            build_flags.append('--with-bzip2')
            build_flags.extend(self._dependency_build_flags("bzip2"))

        if self.options.with_openssl:
            build_flags.append('--with-openssl')
            build_flags.extend(self._dependency_build_flags("openssl"))

        if self.options.with_sqlite3:
            build_flags.append('--with-sqlite3')
            build_flags.extend(self._dependency_build_flags("sqlite3"))

        if self.options.with_zlib:
            build_flags.append('--with-zlib')
            build_flags.extend(self._dependency_build_flags("zlib"))

        if self.options.with_boost:
            build_flags.append('--with-boost')
            build_flags.extend(self._dependency_build_flags("boost"))

        if self.options.module_policy:
            build_flags.append('--module-policy={}'.format(
                self.options.module_policy))

        if self.settings.build_type == 'RelWithDebInfo':
            build_flags.append('--with-debug-info')

        if self._is_x86:
            if not self.options.with_sse2:
                build_flags.append('--disable-sse2')

            if not self.options.with_ssse3:
                build_flags.append('--disable-ssse3')

            if not self.options.with_sse4_1:
                build_flags.append('--disable-sse4.1')

            if not self.options.with_sse4_2:
                build_flags.append('--disable-sse4.2')

            if not self.options.with_avx2:
                build_flags.append('--disable-avx2')

            if not self.options.with_bmi2:
                build_flags.append('--disable-bmi2')

            if not self.options.with_rdrand:
                build_flags.append('--disable-rdrand')

            if not self.options.with_rdseed:
                build_flags.append('--disable-rdseed')

            if not self.options.with_aes_ni:
                build_flags.append('--disable-aes-ni')

            if not self.options.with_sha_ni:
                build_flags.append('--disable-sha-ni')

        if self._is_ppc:
            if not self.options.with_powercrypto:
                build_flags.append('--disable-powercrypto')

            if not self.options.with_altivec:
                build_flags.append('--disable-altivec')

        if self._is_arm:
            if not self.options.with_neon:
                build_flags.append('--disable-neon')

            if not self.options.with_armv8crypto:
                build_flags.append('--disable-armv8crypto')

        if str(self.settings.build_type).lower() == 'debug':
            build_flags.append('--debug-mode')

        build_targets = ["shared"] if self.options.shared else ["static"]

        if self._is_mingw_windows:
            build_flags.append('--without-stack-protector')

        if self.settings.compiler == 'Visual Studio':
            build_flags.append('--msvc-runtime=%s' %
                               str(self.settings.compiler.runtime))

        build_flags.append('--without-pkg-config')

        call_python = 'python' if self.settings.os == 'Windows' else ''

        prefix = tools.unix_path(
            self.package_folder
        ) if self._is_mingw_windows else self.package_folder

        botan_abi = ' '.join(botan_abi_flags) if botan_abi_flags else ' '
        botan_cxx_extras = ' '.join(
            botan_extra_cxx_flags) if botan_extra_cxx_flags else ' '

        configure_cmd = ('{python_call} ./configure.py'
                         ' --build-targets={targets}'
                         ' --distribution-info="Conan"'
                         ' --without-documentation'
                         ' --cc-abi-flags="{abi}"'
                         ' --extra-cxxflags="{cxxflags}"'
                         ' --cc={compiler}'
                         ' --cpu={cpu}'
                         ' --prefix={prefix}'
                         ' --os={os}'
                         ' {build_flags}').format(
                             python_call=call_python,
                             targets=",".join(build_targets),
                             abi=botan_abi,
                             cxxflags=botan_cxx_extras,
                             compiler=botan_compiler,
                             cpu=self.settings.arch,
                             prefix=prefix,
                             os=self._botan_os,
                             build_flags=' '.join(build_flags))

        return configure_cmd
Exemplo n.º 18
0
 def test_msys_path(self):
     self.assertEqual(
         '/c/windows/system32',
         tools.unix_path('C:\\Windows\\System32', path_flavor=tools.MSYS2))
Exemplo n.º 19
0
    def build(self):
        self.output.info("")
        self.output.info("---------- build ----------")
        self.output.info("")
        self.output.info("os        : " + str(self.settings.os))
        self.output.info("arch      : " + str(self.settings.arch))
        self.output.info("compiler  : " + str(self.settings.compiler) + " " +
                         str(self.settings.compiler.version))
        self.output.info("build type: " + str(self.settings.build_type))

        if self.settings.compiler == "Visual Studio":
            self.output.info("runtime   : " +
                             str(self.settings.compiler.runtime))
        else:
            self.output.info("libcxx    : " +
                             str(self.settings.compiler.libcxx))

        ffmpegInstallDir = "install"

        params = ""
        params += " --disable-doc"
        params += " --disable-bzlib"
        params += " --disable-lzma"
        params += " --disable-zlib"

        if self.settings.os == "Windows":
            params += " --disable-avdevice"
            params += " --disable-ffmpeg"
            params += " --disable-ffplay"
            params += " --disable-ffprobe"
            params += " --disable-iconv"
            params += " --disable-libopenjpeg"
            params += " --enable-asm"
            params += " --enable-yasm"
            params += " --prefix=\"" + tools.unix_path(ffmpegInstallDir) + "\""
        else:
            params += " --prefix=\"" + ffmpegInstallDir + "\""

        if self.settings.build_type == "Debug":
            params += " --enable-debug"

        if self.settings.compiler == "Visual Studio":
            # use --disable-encoder=ffv1 flag for Visual Studio 2010 to avoid make compilation loop
            if self.settings.compiler.version == "10":
                params += " --disable-encoder=ffv1"

            params += " --toolchain=msvc"
            params += " --extra-cflags=\"-" + str(
                self.settings.compiler.runtime) + "\""
            params += " --extra-cxxflags=\"-" + str(
                self.settings.compiler.runtime) + "\""

            if self.settings.arch == "x86":
                params += " --arch=x86"
                params += " --target-os=win32"
            else:
                params += " --arch=amd64"

            if self.settings.compiler.runtime == "MT":
                params += " --extra-ldflags=\"/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /NODEFAULTLIB:libcmtd.lib\""
            elif self.settings.compiler.runtime == "MTd":
                params += " --extra-ldflags=\"/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib /NODEFAULTLIB:libcmt.lib\""
            elif self.settings.compiler.runtime == "MD":
                params += " --extra-ldflags=\"/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib\""
            elif self.settings.compiler.runtime == "MDd":
                params += " --extra-ldflags=\"/NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrt.lib\""
            else:
                raise Exception("unsupported runtime: " +
                                str(self.settings.compiler.runtime))
        elif self.settings.arch == "armv7hf" and not re.match(
                "arm.*", platform.machine()):
            if not "CC" in os.environ:
                raise Exception(
                    "failed to extract compiler from environment variable \"CC\" (variable is not set)"
                )

            result = re.search("(.*)gcc$", os.environ.get("CC"), re.M | re.I)

            if not result:
                raise Exception(
                    "failed to extract compiler from environment variable \"CC\" (variable value does not end with \"gcc\", e.g. \"arm-linux-gnueabihf-gcc\")"
                )

            params += " --enable-cross-compile --cross-prefix=" + result.group(
                1) + " --arch=armhf --target-os=linux"

        with tools.chdir(self.name):
            command = ""

            if self.settings.os == "Windows":
                if self.settings.compiler == "Visual Studio":
                    command += tools.vcvars_command(self.settings)

                command += " && bash.exe -c \"./configure" + params + "\""
                command += " && bash.exe -c \"make -j" + str(
                    tools.cpu_count()) + " install\""
            else:
                command = "./configure" + params
                command += " && make -j" + str(tools.cpu_count()) + " install"

            self.output.info("")
            self.output.info("executing the following commands:")
            self.output.info(command)

            self.run(command)

            if not os.path.exists(ffmpegInstallDir):
                raise Exception("install directory does not exist: " +
                                ffmpegInstallDir)

            if self.settings.os == "Windows":
                libDir = os.path.join(ffmpegInstallDir, "lib")

                for f in os.listdir(libDir):
                    if f.endswith(".a"):
                        base = os.path.splitext(f)[0]
                        src = os.path.join(libDir, f)
                        dst = os.path.join(libDir, base + ".lib")
                        os.rename(src, dst)
Exemplo n.º 20
0
    def _configure_autotools(self):
        autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)

        yes_no = lambda v: "yes" if v else "no"
        internal_no = lambda v: "internal" if v else "no"
        rootpath = lambda req: tools.unix_path(self.deps_cpp_info[req].rootpath)
        rootpath_no = lambda v, req: rootpath(req) if v else "no"

        args = []
        args.append("--datarootdir={}".format(tools.unix_path(os.path.join(self.package_folder, "res"))))
        # Shared/Static
        args.extend([
            "--enable-static={}".format(yes_no(not self.options.shared)),
            "--enable-shared={}".format(yes_no(self.options.shared)),
        ])
        args.append("--includedir={}".format(tools.unix_path(os.path.join(self.package_folder, "include", "gdal"))))

        # Enable C++14 if requested in conan profile or if with_charls enabled
        if (self.settings.compiler.cppstd and tools.valid_min_cppstd(self, 14)) or self.options.with_charls:
            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_no(self.options.threadsafe)))
        # Depencencies:
        args.append("--with-proj=yes") # always required !
        args.append("--with-libz={}".format(yes_no(self.options.with_zlib)))
        if self._has_with_libdeflate_option:
            args.append("--with-libdeflate={}".format(yes_no(self.options.with_libdeflate)))
        args.append("--with-libiconv-prefix={}".format(rootpath_no(self.options.with_libiconv, "libiconv")))
        args.append("--with-liblzma=no") # always disabled: liblzma is an optional transitive dependency of gdal (through libtiff).
        args.append("--with-zstd={}".format(yes_no(self.options.get_safe("with_zstd")))) # Optional direct dependency of gdal only if lerc lib enabled
        if self._has_with_blosc_option:
            args.append("--with-blosc={}".format(yes_no(self.options.with_blosc)))
        if self._has_with_lz4_option:
            args.append("--with-lz4={}".format(yes_no(self.options.with_lz4)))
        # 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_no(self.options.with_pg)))
        args.extend(["--without-grass", "--without-libgrass"]) # TODO: to implement when libgrass lib available
        args.append("--with-cfitsio={}".format(rootpath_no(self.options.with_cfitsio, "cfitsio")))
        args.append("--with-pcraster={}".format(internal_no(self.options.with_pcraster))) # TODO: use conan recipe when available instead of internal one
        args.append("--with-png={}".format(rootpath_no(self.options.with_png, "libpng")))
        args.append("--with-dds={}".format(rootpath_no(self.options.with_dds, "crunch")))
        args.append("--with-gta={}".format(rootpath_no(self.options.with_gta, "libgta")))
        args.append("--with-pcidsk={}".format(internal_no(self.options.with_pcidsk))) # TODO: use conan recipe when available instead of internal one
        args.append("--with-libtiff={}".format(rootpath("libtiff"))) # always required !
        args.append("--with-geotiff={}".format(rootpath("libgeotiff"))) # always required !
        if self.options.with_jpeg == "libjpeg":
            args.append("--with-jpeg={}".format(rootpath("libjpeg")))
        elif self.options.with_jpeg == "libjpeg-turbo":
            args.append("--with-jpeg={}".format(rootpath("libjpeg-turbo")))
        else:
            args.append("--without-jpeg")
        args.append("--without-jpeg12") # disabled: it requires internal libjpeg and libgeotiff
        args.append("--with-charls={}".format(yes_no(self.options.with_charls)))
        args.append("--with-gif={}".format(rootpath_no(self.options.with_gif, "giflib")))
        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: handle mongo-cxx-driver v2
        args.append("--with-mongocxxv3={}".format(yes_no(self.options.with_mongocxx)))
        args.append("--with-hdf4={}".format(yes_no(self.options.with_hdf4)))
        args.append("--with-hdf5={}".format(yes_no(self.options.with_hdf5)))
        args.append("--with-kea={}".format(yes_no(self.options.with_kea)))
        args.append("--with-netcdf={}".format(rootpath_no(self.options.with_netcdf, "netcdf")))
        args.append("--with-jasper={}".format(rootpath_no(self.options.with_jasper, "jasper")))
        args.append("--with-openjpeg={}".format(yes_no(self.options.with_openjpeg)))
        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_no(self.options.with_gnm)))
        args.append("--with-mysql={}".format(yes_no(self.options.with_mysql)))
        args.append("--without-ingres") # commercial library
        args.append("--with-xerces={}".format(rootpath_no(self.options.with_xerces, "xerces-c")))
        args.append("--with-expat={}".format(yes_no(self.options.with_expat)))
        args.append("--with-libkml={}".format(rootpath_no(self.options.with_libkml, "libkml")))
        if self.options.with_odbc:
            args.append("--with-odbc={}".format("yes" if self.settings.os == "Windows" else rootpath("odbc")))
        else:
            args.append("--without-odbc")
        args.append("--without-dods-root") # TODO: to implement when libdap lib available
        args.append("--with-curl={}".format(yes_no(self.options.with_curl)))
        args.append("--with-xml2={}".format(yes_no(self.options.with_xml2)))
        args.append("--without-spatialite") # TODO: to implement when libspatialite lib available
        args.append("--with-sqlite3={}".format(yes_no(self.options.get_safe("with_sqlite3"))))
        args.append("--without-rasterlite2") # TODO: to implement when rasterlite2 lib available
        if self._has_with_pcre2_option:
            args.append("--with-pcre2={}".format(yes_no(self.options.get_safe("with_pcre2"))))
        args.append("--with-pcre={}".format(yes_no(self.options.get_safe("with_pcre"))))
        args.append("--without-teigha") # commercial library
        args.append("--without-idb") # commercial library
        if tools.Version(self.version) < "3.2.0":
            args.append("--without-sde") # commercial library
        if tools.Version(self.version) < "3.3.0":
            args.append("--without-epsilon")
        args.append("--with-webp={}".format(rootpath_no(self.options.with_webp, "libwebp")))
        args.append("--with-geos={}".format(yes_no(self.options.with_geos)))
        args.append("--without-sfcgal") # TODO: to implement when sfcgal lib available
        args.append("--with-qhull={}".format(yes_no(self.options.with_qhull)))
        if self.options.with_opencl:
            args.extend([
                "--with-opencl",
                "--with-opencl-include={}".format(tools.unix_path(self.deps_cpp_info["opencl-headers"].include_paths[0])),
                "--with-opencl-lib=-L{}".format(tools.unix_path(self.deps_cpp_info["opencl-icd-loader"].lib_paths[0]))
            ])
        else:
            args.append("--without-opencl")
        args.append("--with-freexl={}".format(yes_no(self.options.with_freexl)))
        args.append("--with-libjson-c={}".format(rootpath("json-c"))) # always required !
        if self.options.without_pam:
            args.append("--without-pam")
        args.append("--with-poppler={}".format(yes_no(self.options.with_poppler)))
        args.append("--with-podofo={}".format(rootpath_no(self.options.with_podofo, "podofo")))
        if self.options.with_podofo:
            args.append("--with-podofo-lib=-l{}".format(" -l".join(self._gather_libs("podofo"))))
        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 self._has_with_brunsli_option:
            args.append("--with-brunsli={}".format(yes_no(self.options.with_brunsli)))
        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("--with-cryptopp={}".format(rootpath_no(self.options.with_cryptopp, "cryptopp")))
        args.append("--with-crypto={}".format(yes_no(self.options.with_crypto)))
        if tools.Version(self.version) >= "3.3.0":
            args.append("--with-lerc={}".format(internal_no(not self.options.without_lerc)))
        else:
            args.append("--with-lerc={}".format(yes_no(not self.options.without_lerc)))
        if self.options.with_null:
            args.append("--with-null")
        if self._has_with_exr_option:
            args.append("--with-exr={}".format(yes_no(self.options.with_exr)))
        if self._has_with_heif_option:
            args.append("--with-heif={}".format(yes_no(self.options.with_heif)))

        # Inject -stdlib=libc++ for clang with libc++
        env_build_vars = autotools.vars
        if self.settings.compiler == "clang" and \
           self.settings.os == "Linux" and tools.stdcpp_library(self) == "c++":
            env_build_vars["LDFLAGS"] = "-stdlib=libc++ {}".format(env_build_vars["LDFLAGS"])

        autotools.configure(args=args, vars=env_build_vars)
        return autotools
Exemplo n.º 21
0
    def _configure_cmd(self):
        if self.settings.compiler in ('clang', 'apple-clang'):
            botan_compiler = 'clang'
        elif self.settings.compiler == 'gcc':
            botan_compiler = 'gcc'
        else:
            botan_compiler = 'msvc'

        botan_abi_flags = []
        botan_extra_cxx_flags = []
        build_flags = []

        if self._is_linux_clang_libcxx:
            botan_abi_flags.extend(["-stdlib=libc++", "-lc++abi"])

        if botan_compiler in ['clang', 'apple-clang', 'gcc']:
            if self.settings.arch == "x86":
                botan_abi_flags.append('-m32')
            elif self.settings.arch == "x86_64":
                botan_abi_flags.append('-m64')

        if self.settings.os != "Windows" and self.options.fPIC:
            botan_extra_cxx_flags.append('-fPIC')

        if self.settings.os == "Macos" and self.settings.os.version:
            macos_min_version = tools.apple_deployment_target_flag(
                self.settings.os, self.settings.os.version)
            macos_sdk_path = "-isysroot {}".format(
                tools.XCRun(self.settings).sdk_path)
            botan_extra_cxx_flags.extend([macos_min_version, macos_sdk_path])

        # This is to work around botan's configure script that *replaces* its
        # standard (platform dependent) flags in presence of an environment
        # variable ${CXXFLAGS}. Most notably, this would build botan with
        # disabled compiler optimizations.
        environment_cxxflags = tools.get_env("CXXFLAGS")
        if environment_cxxflags:
            del os.environ["CXXFLAGS"]
            botan_extra_cxx_flags.append(environment_cxxflags)

        if self.options.enable_modules:
            build_flags.append('--minimized-build')
            build_flags.append('--enable-modules={}'.format(
                self.options.enable_modules))

        if self.options.amalgamation:
            build_flags.append('--amalgamation')

        if self.options.single_amalgamation:
            build_flags.append('--single-amalgamation-file')

        if self.options.system_cert_bundle:
            build_flags.append('--system-cert-bundle={}'.format(
                self.options.system_cert_bundle))

        if self.options.bzip2:
            build_flags.append('--with-bzip2')
            build_flags.extend(self._dependency_build_flags("bzip2"))

        if self.options.openssl:
            build_flags.append('--with-openssl')
            build_flags.extend(self._dependency_build_flags("OpenSSL"))

        if self.options.quiet:
            build_flags.append('--quiet')

        if self.options.sqlite3:
            build_flags.append('--with-sqlite3')
            build_flags.extend(self._dependency_build_flags("sqlite3"))

        if self.options.zlib:
            build_flags.append('--with-zlib')
            build_flags.extend(self._dependency_build_flags("zlib"))

        if self.options.boost:
            build_flags.append('--with-boost')
            build_flags.extend(self._dependency_build_flags("boost"))
            # required boost libraries are listed in Botan's src/utils/boost/info.txt
            # under the <libs></libs> tag...
            # Note that boost_system is actually a header-only library as of
            # boost 1.69. We are linking this for compatibility with older boost
            # versions...
            boost_system = [
                lib for lib in self.deps_cpp_info["boost"].libs
                if "boost_system" in lib
            ]
            if len(boost_system) != 1:
                raise ConanException(
                    "did not find a comprehensive boost_system library name: "
                    + str(boost_system))
            boost_system_name = boost_system[
                0] + ".lib" if self.settings.os == "Windows" else boost_system[
                    0]
            build_flags.append(
                '--boost-library-name={}'.format(boost_system_name))

        if self.settings.build_type == 'RelWithDebInfo' or self.options.debug_info:
            build_flags.append('--with-debug-info')

        if str(self.settings.build_type).lower() == 'debug':
            build_flags.append('--debug-mode')

        build_targets = ["shared"] if self.options.shared else ["static"]

        if self._is_mingw_windows:
            build_flags.append('--without-stack-protector')

        if self.settings.compiler == 'Visual Studio':
            build_flags.append('--msvc-runtime=%s' %
                               str(self.settings.compiler.runtime))

        call_python = 'python' if self.settings.os == 'Windows' else ''

        prefix = tools.unix_path(
            self.package_folder
        ) if self._is_mingw_windows else self.package_folder

        botan_abi = ' '.join(botan_abi_flags) if botan_abi_flags else ' '
        botan_cxx_extras = ' '.join(
            botan_extra_cxx_flags) if botan_extra_cxx_flags else ' '

        configure_cmd = ('{python_call} ./configure.py'
                         ' --build-targets={targets}'
                         ' --distribution-info="Conan"'
                         ' --without-documentation'
                         ' --cc-abi-flags="{abi}"'
                         ' --extra-cxxflags="{cxxflags}"'
                         ' --cc={compiler}'
                         ' --cpu={cpu}'
                         ' --prefix={prefix}'
                         ' --os={os}'
                         ' {build_flags}').format(
                             python_call=call_python,
                             targets=",".join(build_targets),
                             abi=botan_abi,
                             cxxflags=botan_cxx_extras,
                             compiler=botan_compiler,
                             cpu=self.settings.arch,
                             prefix=prefix,
                             os=self._botan_os,
                             build_flags=' '.join(build_flags))

        return configure_cmd
Exemplo n.º 22
0
    def _get_configure_command_args(self):
        yes_no = lambda v: "yes" if v else "no"
        params = [
            "--with-libidn2={}".format(yes_no(self.options.with_libidn)),
            "--with-librtmp={}".format(yes_no(self.options.with_librtmp)),
            "--with-libpsl={}".format(yes_no(self.options.with_libpsl)),
            "--with-schannel={}".format(
                yes_no(self.options.with_ssl == "schannel")),
            "--with-secure-transport={}".format(
                yes_no(self.options.with_ssl == "darwinssl")),
            "--with-brotli={}".format(yes_no(self.options.with_brotli)),
            "--enable-shared={}".format(yes_no(self.options.shared)),
            "--enable-static={}".format(yes_no(not self.options.shared)),
            "--enable-dict={}".format(yes_no(self.options.with_dict)),
            "--enable-file={}".format(yes_no(self.options.with_file)),
            "--enable-ftp={}".format(yes_no(self.options.with_ftp)),
            "--enable-gopher={}".format(yes_no(self.options.with_gopher)),
            "--enable-http={}".format(yes_no(self.options.with_http)),
            "--enable-imap={}".format(yes_no(self.options.with_imap)),
            "--enable-ldap={}".format(yes_no(self.options.with_ldap)),
            "--enable-mqtt={}".format(yes_no(self.options.with_mqtt)),
            "--enable-pop3={}".format(yes_no(self.options.with_pop3)),
            "--enable-rtsp={}".format(yes_no(self.options.with_rtsp)),
            "--enable-smb={}".format(yes_no(self.options.with_smb)),
            "--enable-smtp={}".format(yes_no(self.options.with_smtp)),
            "--enable-telnet={}".format(yes_no(self.options.with_telnet)),
            "--enable-tftp={}".format(yes_no(self.options.with_tftp)),
            "--enable-debug={}".format(
                yes_no(self.settings.build_type == "Debug")),
            "--enable-ares={}".format(yes_no(self.options.with_c_ares)),
            "--enable-threaded-resolver={}".format(
                yes_no(self.options.with_c_ares)),
            "--enable-cookies={}".format(yes_no(self.options.with_cookies)),
            "--enable-ipv6={}".format(yes_no(self.options.with_ipv6)),
            "--enable-manual={}".format(yes_no(self.options.with_docs)),
            "--enable-verbose={}".format(
                yes_no(self.options.with_verbose_debug)),
            "--enable-symbol-hiding={}".format(
                yes_no(self.options.with_symbol_hiding)),
            "--enable-unix-sockets={}".format(
                yes_no(self.options.with_unix_sockets)),
        ]
        if self.options.with_ssl == "openssl":
            params.append("--with-ssl={}".format(
                tools.unix_path(self.deps_cpp_info["openssl"].rootpath)))
        else:
            params.append("--without-ssl")
        if self.options.with_ssl == "wolfssl":
            params.append("--with-wolfssl={}".format(
                tools.unix_path(self.deps_cpp_info["wolfssl"].rootpath)))
        else:
            params.append("--without-wolfssl")

        if self.options.with_libssh2:
            params.append("--with-libssh2={}".format(
                tools.unix_path(self.deps_cpp_info["libssh2"].rootpath)))
        else:
            params.append("--without-libssh2")

        if self.options.with_nghttp2:
            params.append("--with-nghttp2={}".format(
                tools.unix_path(self.deps_cpp_info["libnghttp2"].rootpath)))
        else:
            params.append("--without-nghttp2")

        if self.options.with_zlib:
            params.append("--with-zlib={}".format(
                tools.unix_path(self.deps_cpp_info["zlib"].rootpath)))
        else:
            params.append("--without-zlib")

        if self._has_zstd_option:
            params.append("--with-zstd={}".format(
                yes_no(self.options.with_zstd)))

        if self._has_metalink_option:
            params.append("--with-libmetalink={}".format(
                yes_no(self.options.with_libmetalink)))

        if not self.options.with_proxy:
            params.append("--disable-proxy")

        if not self.options.with_rtsp:
            params.append("--disable-rtsp")

        if not self.options.with_crypto_auth:
            params.append(
                "--disable-crypto-auth"
            )  # also disables NTLM in versions of curl prior to 7.78.0

        # ntlm will default to enabled if any SSL options are enabled
        if not self.options.with_ntlm:
            if tools.Version(self.version) <= "7.77.0":
                params.append("--disable-crypto-auth")
            else:
                params.append("--disable-ntlm")

        if not self.options.with_ntlm_wb:
            params.append("--disable-ntlm-wb")

        # Cross building flags
        if tools.cross_building(self.settings):
            if self.settings.os == "Linux" and "arm" in self.settings.arch:
                params.append("--host=%s" % self._get_linux_arm_host())
            elif self.settings.os == "iOS":
                params.append("--enable-threaded-resolver")
                params.append("--disable-verbose")
            elif self.settings.os == "Android":
                pass  # this just works, conan is great!

        return params
Exemplo n.º 23
0
 def _unix_path(self, path):
     if self.settings.os == "Windows":
         return tools.unix_path(path)
     return path
Exemplo n.º 24
0
    def windows_build(self):
        # this overrides pre-configured environments (such as Appveyor's)
        if "VisualStudioVersion" in os.environ:
            del os.environ["VisualStudioVersion"]

        compiler_cxx = compiler_cc = '$PWD/ragel-%s/compile cl -nologo' % self.version

        self.autotools = AutoToolsBuildEnvironment(self, win_bash=True)

        with tools.chdir("{0}-{1}".format('ragel', self.version)):
            tools.run_in_windows_bash(
                self,
                'pacman -S automake-wrapper autoconf --noconfirm --needed')

            makefile_am = os.path.join('ragel',
                                       'Makefile.am').replace('\\', '/')
            self.output.info("Patching: %s" % makefile_am)
            tools.replace_in_file(makefile_am,
                                  'INCLUDES = -I$(top_srcdir)/aapl',
                                  'AM_CPPFLAGS = -I$(top_srcdir)/aapl')

            main_cpp = os.path.join('ragel', 'main.cpp').replace('\\', '/')
            self.output.info("Patching: %s" % main_cpp)
            tools.replace_in_file(main_cpp, '#include <unistd.h>', '')

            tools.run_in_windows_bash(self, 'aclocal')
            tools.run_in_windows_bash(self, 'autoheader')
            tools.run_in_windows_bash(
                self, 'automake --foreign --add-missing --force-missing')
            tools.run_in_windows_bash(self, 'autoconf')

        with tools.vcvars(self.settings):
            compiler_options = '-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE ' \
                               '-D_CRT_NONSTDC_NO_WARNINGS -WL -W2 -WX- -Gy -DNDEBUG ' \
                               '-diagnostics:classic -DWIN32 -D_WINDOWS -O2 -Ob2 '

            compiler_options += '-wd4577 -wd5026 -wd5027 -wd4710 -wd4711 -wd4626 -wd4250 -wd4365 ' \
                                '-wd4625 -wd4774 -wd4530 -wd4100 -wd4706 -wd4512 -wd4800 -wd4702 ' \
                                '-wd4819 -wd4355 -wd4091 -wd4267 -wd4365 -wd4625 -wd4774 -wd4820'

            linker_options = '/MACHINE:X{0}'.format(
                '86' if self.settings.arch_build == 'x86' else '64')
            runtime = '-%s' % str(self.settings.compiler.runtime)

            prefix = tools.unix_path(os.path.abspath(self.package_folder),
                                     tools.MSYS2)

            flags = '{compiler_options} {runtime} -I{prefix}/include'.format(
                compiler_options=compiler_options,
                runtime=runtime,
                prefix=prefix)
            ldflags = '-L{prefix}/lib {linker_options}'.format(
                linker_options=linker_options, prefix=prefix)
            configure_args = [
                'CC={compiler_cc}'.format(compiler_cc=compiler_cc),
                'CXX={compiler_cxx}'.format(compiler_cxx=compiler_cxx),
                'CFLAGS={flags}'.format(flags=flags),
                'CXXFLAGS={flags}'.format(flags=flags),
                'CPPFLAGS={flags}'.format(flags=flags),
                'LDFLAGS={ldflags}'.format(ldflags=ldflags), 'LD=link',
                'NM=dumpbin -symbols', 'STRIP=:', 'RANLIB=:'
            ]
            self.autotools.configure(configure_dir="ragel-%s" % self.version,
                                     args=configure_args)
            self.autotools.make()
Exemplo n.º 25
0
 def _make_program(self):
     if self.settings.compiler == "Visual Studio":
         return "nmake"
     make_program = tools.get_env("CONAN_MAKE_PROGRAM", tools.which("make") or tools.which('mingw32-make'))
     make_program = tools.unix_path(make_program) if tools.os_info.is_windows else make_program
     return make_program
Exemplo n.º 26
0
    def _configure_args(self):
        openssldir = self.options.openssldir or self._get_default_openssl_dir()
        prefix = tools.unix_path(self.package_folder) if self._win_bash else self.package_folder
        openssldir = tools.unix_path(openssldir) if self._win_bash else openssldir
        args = [
            '"%s"' % (self._target),
            "shared" if self.options.shared else "no-shared",
            "--prefix=\"%s\"" % prefix,
            "--libdir=lib",
            "--openssldir=\"%s\"" % openssldir,
            "no-unit-test",
            "no-threads" if self.options.no_threads else "threads",
            "PERL=%s" % self._perl,
            "no-tests",
            "--debug" if self.settings.build_type == "Debug" else "--release",
        ]

        if self.settings.os == "Android":
            args.append(" -D__ANDROID_API__=%s" % str(self.settings.os.api_level))  # see NOTES.ANDROID
        if self.settings.os == "Emscripten":
            args.append("-D__STDC_NO_ATOMICS__=1")
        if self.settings.os == "Windows":
            if self.options.enable_capieng:
                args.append("enable-capieng")
            if self.options.capieng_dialog:
                args.append("-DOPENSSL_CAPIENG_DIALOG=1")
        else:
            args.append("-fPIC" if self.options.get_safe("fPIC", True) else "no-pic")

        args.append("no-fips" if self.options.get_safe("no_fips", True) else "enable-fips")

        if self.settings.os == "Neutrino":
            args.append("no-asm -lsocket -latomic")

        if not self.options.no_zlib:
            zlib_info = self.deps_cpp_info["zlib"]
            include_path = zlib_info.include_paths[0]
            if self.settings.os == "Windows":
                lib_path = "%s/%s.lib" % (zlib_info.lib_paths[0], zlib_info.libs[0])
            else:
                # Just path, linux will find the right file
                lib_path = zlib_info.lib_paths[0]
            if tools.os_info.is_windows:
                # clang-cl doesn't like backslashes in #define CFLAGS (builldinf.h -> cversion.c)
                include_path = include_path.replace("\\", "/")
                lib_path = lib_path.replace("\\", "/")

            if self.options["zlib"].shared:
                args.append("zlib-dynamic")
            else:
                args.append("zlib")

            args.extend([
                '--with-zlib-include="%s"' % include_path,
                '--with-zlib-lib="%s"' % lib_path
            ])

        for option_name in self.options.values.fields:
            if self.options.get_safe(option_name, False) and option_name not in ("shared", "fPIC", "openssldir", "capieng_dialog", "enable_capieng", "zlib", "no_fips"):
                self.output.info(f"Activated option: {option_name}")
                args.append(option_name.replace("_", "-"))
        return args
Exemplo n.º 27
0
    def build_configure(self):
        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'])
Exemplo n.º 28
0
 def test_cygwin_path(self):
     self.assertEqual('/cygdrive/c/windows/system32', tools.unix_path('C:\\Windows\\System32',
                                                                      path_flavor=tools.CYGWIN))
Exemplo n.º 29
0
 def _configure_autotools(self):
     if self._autotools:
         return self._autotools
     self._autotools = AutoToolsBuildEnvironment(self)
     self._autotools.libs = []
     self._autotools.include_paths = []
     if self._with_crypto:
         if self.settings.os == "Linux":
             self._autotools.libs.append("dl")
     conf_args = [
         "--with-apr={}".format(
             tools.unix_path(self.deps_cpp_info["apr"].rootpath)),
         "--with-crypto" if self._with_crypto else "--without-crypto",
         "--with-iconv={}".format(
             tools.unix_path(self.deps_cpp_info["libiconv"].rootpath)),
         "--with-openssl={}".format(
             tools.unix_path(self.deps_cpp_info["openssl"].rootpath))
         if self.options.with_openssl else "--without-openssl",
         "--with-expat={}".format(
             tools.unix_path(self.deps_cpp_info["expat"].rootpath))
         if self.options.with_expat else "--without-expat",
         "--with-mysql={}".format(
             tools.unix_path(self.deps_cpp_info["libmysqlclient"].rootpath))
         if self.options.with_mysql else "--without-mysql",
         "--with-pgsql={}".format(
             tools.unix_path(self.deps_cpp_info["libpq"].rootpath))
         if self.options.with_postgresql else "--without-pgsql",
         "--with-sqlite3={}".format(
             tools.unix_path(self.deps_cpp_info["sqlite3"].rootpath))
         if self.options.with_sqlite3 else "--without-sqlite3",
         "--with-ldap={}".format(
             tools.unix_path(self.deps_cpp_info["ldap"].rootpath))
         if self.options.with_ldap else "--without-ldap",
         "--with-berkeley-db={}".format(
             tools.unix_path(self.deps_cpp_info["libdb"].rootpath))
         if self.options.dbm == "db" else "--without-berkeley-db",
         "--with-gdbm={}".format(
             tools.unix_path(self.deps_cpp_info["gdbm"].rootpath))
         if self.options.dbm == "gdbm" else "--without-gdbm",
         "--with-ndbm={}".format(
             tools.unix_path(self.deps_cpp_info["ndbm"].rootpath))
         if self.options.dbm == "ndbm" else "--without-ndbm",
     ]
     if self.options.dbm:
         conf_args.append("--with-dbm={}".format(self.options.dbm))
     self._autotools.configure(args=conf_args,
                               configure_dir=self._source_subfolder)
     return self._autotools
Exemplo n.º 30
0
 def test_sfu_path(self):
     self.assertEqual('/dev/fs/C/windows/system32', tools.unix_path('C:\\Windows\\System32',
                                                                    path_flavor=tools.SFU))
Exemplo n.º 31
0
 def test_cygwin_path(self):
     self.assertEqual(
         '/cygdrive/c/windows/system32',
         tools.unix_path('C:\\Windows\\System32', path_flavor=tools.CYGWIN))
Exemplo n.º 32
0
 def test_wsl_path(self):
     self.assertEqual(
         '/mnt/c/Windows/System32',
         tools.unix_path('C:\\Windows\\System32', path_flavor=tools.WSL))
Exemplo n.º 33
0
    def build(self):
        if 'MSYS_ROOT' not in os.environ:
            os.environ['MSYS_ROOT'] = self.deps_env_info[
                "msys2_installer"].MSYS_ROOT

        if 'MSYS_ROOT' not in os.environ:
            raise Exception("MSYS_ROOT environment variable must be set.")
        else:
            self.output.info("Using MSYS from: " + os.environ["MSYS_ROOT"])


        os.environ['PATH'] = os.path.join(os.environ['MSYS_ROOT'], 'usr', 'bin') + os.pathsep + \
                             os.environ['PATH']

        compiler_options = ''
        linker_options = ''
        runtime_options = ''
        ld_options = ''
        nm_options = ''
        ranlib_options = ''
        strip_options = ''

        if self.settings.compiler == 'Visual Studio':
            # this overrides pre-configured environments (such as Appveyor's)
            if "VisualStudioVersion" in os.environ:
                del os.environ["VisualStudioVersion"]

            vccmd = tools.vcvars_command(self.settings) + " &&"
            compiler_cc = '$PWD/compile cl -nologo'
            compiler_cxx = compiler_cc

        elif self.settings.compiler == 'gcc':
            vccmd = ''
            if 'MINGW_HOME' in os.environ:
                compiler_cc = tools.unix_path(
                    self.deps_env_info["mingw_installer"].CC)
                compiler_cxx = tools.unix_path(
                    self.deps_env_info["mingw_installer"].CXX)
            else:
                compiler_cc = self.settings.compiler
                compiler_cxx = compiler_cc

        env_build = AutoToolsBuildEnvironment(self)
        with tools.chdir("{0}-{1}".format('ragel', self.version)):
            with tools.environment_append(env_build.vars):

                self.run(
                    "bash -c 'pacman -S automake-wrapper autoconf --noconfirm --needed'"
                )

                makefile_am = os.path.join('ragel',
                                           'Makefile.am').replace('\\', '/')
                self.output.info("Patching: %s" % makefile_am)
                tools.replace_in_file(makefile_am,
                                      'INCLUDES = -I$(top_srcdir)/aapl',
                                      'AM_CPPFLAGS = -I$(top_srcdir)/aapl')

                main_cpp = os.path.join('ragel', 'main.cpp').replace('\\', '/')
                self.output.info("Patching: %s" % main_cpp)
                tools.replace_in_file(main_cpp, '#include <unistd.h>', '')

                self.run("{vccmd} bash -c 'aclocal'".format(vccmd=vccmd))
                self.run("{vccmd} bash -c 'autoheader'".format(vccmd=vccmd))
                self.run(
                    "{vccmd} bash -c 'automake --foreign --add-missing --force-missing'"
                    .format(vccmd=vccmd))
                self.run("{vccmd} bash -c 'autoconf'".format(vccmd=vccmd))

                if self.settings.compiler == 'Visual Studio':
                    compiler_options = '-D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE ' \
                                       '-D_CRT_NONSTDC_NO_WARNINGS -WL -W2 -WX- -Gy -DNDEBUG ' \
                                       '-diagnostics:classic -DWIN32 -D_WINDOWS -O2 -Ob2 '

                    compiler_options += '-wd4577 -wd5026 -wd5027 -wd4710 -wd4711 -wd4626 -wd4250 -wd4365 ' \
                                        '-wd4625 -wd4774 -wd4530 -wd4100 -wd4706 -wd4512 -wd4800 -wd4702 ' \
                                        '-wd4819 -wd4355 -wd4091 -wd4267 -wd4365 -wd4625 -wd4774 -wd4820'

                    linker_options = '/MACHINE:X{0}'.format(
                        '86' if self.settings.arch == 'x86' else '64')
                    runtime_options = '-' + str(self.settings.compiler.runtime)
                    ld_options = 'LD="link" '
                    nm_options = 'NM="dumpbin -symbols" '
                    strip_options = 'STRIP=":" '
                    ranlib_options = 'RANLIB=":" '

                prefix = tools.unix_path(os.path.abspath("../out"))
                self.run(
                    '{vccmd} bash -c \'./configure '
                    '--prefix={prefix} '
                    'CC="{compiler_cc}" '
                    'CXX="{compiler_cxx}" '
                    'CFLAGS="{compiler_options} {runtime} -I{prefix}/include " '
                    'CXXFLAGS="{compiler_options} {runtime} -I{prefix}/include " '
                    'CPPFLAGS="{compiler_options} {runtime} -I{prefix}/include " '
                    'LDFLAGS="-L{prefix}/lib {linker_options}" '
                    '{ld_options}'
                    '{nm_options}'
                    '{strip_options}'
                    '{ranlib_options}'
                    '\''.format(vccmd=vccmd,
                                prefix=prefix,
                                compiler_cc=compiler_cc,
                                compiler_cxx=compiler_cxx,
                                ld_options=ld_options,
                                nm_options=nm_options,
                                strip_options=strip_options,
                                ranlib_options=ranlib_options,
                                compiler_options=compiler_options,
                                linker_options=linker_options,
                                runtime=runtime_options))

                self.run("{vccmd} bash -c 'make -s -j {cpus} install".format(
                    vccmd=vccmd, cpus=tools.cpu_count()))