Ejemplo n.º 1
0
    def applyCmakeSettingsForiOS(self, cmake):
        ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
        cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"
        variants = []

        if self.settings.arch == "x86":
            cmake.definitions["IOS_PLATFORM"] = "SIMULATOR"
        elif self.settings.arch == "x86_64":
            cmake.definitions["IOS_PLATFORM"] = "SIMULATOR64"
        else:
            cmake.definitions["IOS_PLATFORM"] = "OS"

        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            variants = ["armv7", "armv7s", "armv8", "armv8.3"]

        # apply build config for all defined architectures
        if len(variants) > 0:
            archs = ""
            for i in range(0, len(variants)):
                if i == 0:
                    archs = tools.to_apple_arch(variants[i])
                else:
                    archs += ";" + tools.to_apple_arch(variants[i])
            cmake.definitions["ARCHS"] = archs
        else:
            cmake.definitions["ARCHS"] = tools.to_apple_arch(
                self.settings.arch)
Ejemplo n.º 2
0
    def applyCmakeSettingsForiOS(self, cmake):
        ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
        variants = []

        tools.replace_in_file(
            "%s/libressl-%s/CMakeLists.txt" %
            (self.source_folder, self.version), "project (LibreSSL C ASM)",
            """project (LibreSSL C ASM)
                    include_directories(BEFORE "ios/include") """)

        cmake.definitions["LIBRESSL_APPS"] = "OFF"
        cmake.definitions["LIBRESSL_TESTS"] = "OFF"
        if self.settings.arch == "x86" or self.settings.arch == "x86_64":
            cmake.definitions["IOS_PLATFORM"] = "SIMULATOR"
        else:
            cmake.definitions["IOS_PLATFORM"] = "OS"

        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            variants = ["armv7", "armv7s", "armv8"]

        # apply build config for all defined architectures
        if len(variants) > 0:
            archs = ""
            for i in range(0, len(variants)):
                if i == 0:
                    archs = tools.to_apple_arch(variants[i])
                else:
                    archs += ";" + tools.to_apple_arch(variants[i])
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = archs
        else:
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)
    def build(self):

        cmake = CMake(self)
        cmake.verbose = True

        src_folder = "%s/protobuf-c-%s/build-cmake" % (self.source_folder,
                                                       self.version)

        if self.settings.os == "Android":
            cmake.definitions[
                "CMAKE_SYSTEM_VERSION"] = self.settings.os.api_level
            cmake.definitions["CMAKE_ANDROID_NDK"] = os.environ[
                "ANDROID_NDK_PATH"]
            cmake.definitions[
                "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION"] = self.settings.compiler
            cmake.definitions[
                "CMAKE_ANDROID_STL_TYPE"] = self.options.android_stl_type

        if self.settings.os == "iOS":
            ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
            cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
            if self.settings.arch == "x86" or self.settings.arch == "x86_64":
                cmake.definitions["IOS_PLATFORM"] = "SIMULATOR"
            else:
                cmake.definitions["IOS_PLATFORM"] = "OS"

        if self.settings.os == "Macos":
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)

        cmake.configure(source_folder=src_folder)
        cmake.build()
        cmake.install()

        lib_dir = os.path.join(self.package_folder, "lib")

        if self.settings.os == "iOS":
            # delete shared artifacts for static builds and the static library for shared builds
            if self.options.shared == False:
                for f in os.listdir(lib_dir):
                    if f.endswith(".a") and os.path.isfile(
                            os.path.join(lib_dir, f)) and not os.path.islink(
                                os.path.join(lib_dir, f)):
                        self.run("xcrun ranlib %s" % os.path.join(lib_dir, f))
                        # thin the library (remove all other archs)
                        self.run("lipo -extract %s %s -output %s" %
                                 (tools.to_apple_arch(self.settings.arch),
                                  os.path.join(lib_dir,
                                               f), os.path.join(lib_dir, f)))
            else:
                # thin the library (remove all other archs)
                for f in os.listdir(lib_dir):
                    if f.endswith(".dylib") and os.path.isfile(
                            os.path.join(lib_dir, f)) and not os.path.islink(
                                os.path.join(lib_dir, f)):
                        self.run("lipo -extract %s %s -output %s" %
                                 (tools.to_apple_arch(self.settings.arch),
                                  os.path.join(lib_dir,
                                               f), os.path.join(lib_dir, f)))
Ejemplo n.º 4
0
    def ios_build(self):
        config_options_string = self._get_flags()
        command = "./Configure iphoneos-cross %s" % config_options_string

        xcrun = tools.XCRun(self.settings)
        cc = xcrun.find("clang")

        cc += " -arch %s" % tools.to_apple_arch(self.arch)
        if not str(self.arch).startswith("arm"):
            cc += " -DOPENSSL_NO_ASM"

        try:
            cc += " -mios-version-min=%s" % self.settings.os.version
            self.output.info("iOS deployment target: %s" %
                             self.settings.os.version)
        except:
            pass

        cc += " -fembed-bitcode"

        os.environ["CROSS_SDK"] = os.path.basename(xcrun.sdk_path)
        os.environ["CROSS_TOP"] = os.path.dirname(
            os.path.dirname(xcrun.sdk_path))

        command = 'CC="%s" %s' % (cc, command)

        self.run_in_src(command)
        self._patch_install_name()
        self.output.warn("----------MAKE OPENSSL %s-------------" %
                         self.version)
        self.run_in_src("make")
Ejemplo n.º 5
0
    def build(self):
        cmake = CMake(self)
        cmake.verbose = True

        cmake.definitions["NATS_BUILD_WITH_TLS"] = "ON"

        if self.settings.os == "Macos":
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(self.settings.arch)

        library_folder = "%s/cnats-%s" % (self.source_folder, self.version)

        cmake.configure(source_folder=library_folder)
        cmake.build()
        cmake.install()

        lib_dir = os.path.join(self.package_folder,"lib")

        if self.settings.os == "Macos":
            # delete shared artifacts for static builds and the static library for shared builds
            if self.options.shared == False:
                for f in os.listdir(lib_dir):
                    if f.endswith(".dylib"):
                        os.remove(os.path.join(lib_dir,f))
                    elif f.endswith("libnats_static.a"):
                        os.rename(os.path.join(lib_dir,f), os.path.join(lib_dir,"libnats.a"))
            else:
                for f in os.listdir(lib_dir):
                    if f.endswith(".a"):
                        os.remove(os.path.join(lib_dir,f))
Ejemplo n.º 6
0
    def _configure_autotools(self):
        if self._autotools:
            return self._autotools
        self._autotools = AutoToolsBuildEnvironment(
            self, win_bash=tools.os_info.is_windows)
        # Need to override environment or configure will fail despite that flex
        # is actually available.
        args = ["LEX=flex"]
        if self.options.shared:
            args.extend(["--disable-static", "--enable-shared"])
        else:
            args.extend(["--disable-shared", "--enable-static"])

        # No idea why this is necessary, but if you don't set CC this way, then
        # configure complains that it can't find gmp.
        if (tools.cross_building(self.settings)
                and self.settings.compiler == "apple-clang"):

            xcr = tools.XCRun(self.settings)
            target = tools.to_apple_arch(self.settings.arch) + "-apple-darwin"

            min_ios = ""
            if self.settings.os == "iOS":
                min_ios = "-miphoneos-version-min={}".format(
                    self.settings.os.version)

            args.append("CC={} -isysroot {} -target {} {}".format(
                xcr.cc, xcr.sdk_path, target, min_ios))

        self._autotools.configure(args=args)
        return self._autotools
    def applyCmakeSettingsForiOS(self, cmake):
        cmake.definitions["CMAKE_SYSTEM_NAME"] = "iOS"
        cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"
        cmake.definitions["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.0"
        cmake.definitions["CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH"] = "NO"
        cmake.definitions["CMAKE_IOS_INSTALL_COMBINED"] = "YES"

        cmake.definitions["BUILD_TESTING"] = "OFF"
        cmake.definitions["BUILD_CURL_EXE"] = "OFF"
        cmake.definitions["CMAKE_USE_LIBSSH2"] = "OFF"
        #cmake.definitions["PICKY_COMPILER"] = "OFF"

        # CMAKE_TOOLCHAIN_FILE needs to be defined, so that the scripts of curl know that we are cross compiling
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ""

        tools.replace_in_file(
            "%s/curl-%s/CMakeLists.txt" % (self.source_folder, self.version),
            "find_package(OpenSSL", "find_host_package(OpenSSL")
        self.addFindHostPackage()

        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            cmake.definitions[
                "CMAKE_OSX_ARCHITECTURES"] = "armv7;armv7s;arm64;arm64e"
        else:
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)
Ejemplo n.º 8
0
    def ios_build(self, config_options_string):
        def find_sysroot(sdk_name):
            return tools.XCRun(self.settings, sdk_name).sdk_path

        def find_cc(settings, sdk_name=None):
            return tools.XCRun(settings, sdk_name).cc

        command = "./Configure iphoneos-cross %s" % config_options_string

        sdk = tools.apple_sdk_name(self.settings)
        sysroot = find_sysroot(sdk)
        cc = find_cc(self.settings, sdk)

        cc += " -arch %s" % tools.to_apple_arch(self.settings.arch)
        if not str(self.settings.arch).startswith("arm"):
            cc += " -DOPENSSL_NO_ASM"

        os.environ["CROSS_SDK"] = os.path.basename(sysroot)
        os.environ["CROSS_TOP"] = os.path.dirname(os.path.dirname(sysroot))

        command = 'CC="%s" %s' % (cc, command)

        self.run_in_src(command)
        # REPLACE -install_name FOR FOLLOW THE CONAN RULES,
        # DYNLIBS IDS AND OTHER DYNLIB DEPS WITHOUT PATH, JUST THE LIBRARY NAME
        old_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$'
        new_str = 'SHAREDFLAGS="$$SHAREDFLAGS -install_name $$SHLIB$'
        tools.replace_in_file("./%s/Makefile.shared" % self.subfolder, old_str,
                              new_str)
        self.output.warn("----------MAKE OPENSSL %s-------------" %
                         self.version)
        self.run_in_src("make")
Ejemplo n.º 9
0
    def package_info(self):
        darwin_arch = tools.to_apple_arch(self.settings.arch)

        if self.settings.os == "watchOS" and self.settings.arch == "armv8":
            darwin_arch = "arm64_32"

        xcrun = tools.XCRun(self.settings)
        sysroot = xcrun.sdk_path

        self.cpp_info.sysroot = sysroot

        common_flags = ["-isysroot%s" % sysroot]

        if self.settings.get_safe("os.version"):
            common_flags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))

        if not self.settings.os == "Macos" and self.options.bitcode:
            if self.settings.build_type == "Debug":
                bitcode_flag = "-fembed-bitcode-marker"
            else:
                bitcode_flag = "-fembed-bitcode"
            common_flags.append(bitcode_flag)

        # CMake issue, for details look https://github.com/conan-io/conan/issues/2378
        cflags = copy.copy(common_flags)
        cflags.extend(["-arch", darwin_arch])
        self.cpp_info.cflags = cflags
        link_flags = copy.copy(common_flags)
        link_flags.append("-arch %s" % darwin_arch)

        self.cpp_info.sharedlinkflags.extend(link_flags)
        self.cpp_info.exelinkflags.extend(link_flags)

        # Set flags in environment too, so that CMake Helper finds them
        cflags_str = " ".join(cflags)
        ldflags_str = " ".join(link_flags)
        self.env_info.CC = xcrun.cc
        self.env_info.CPP = "%s -E" % xcrun.cc
        self.env_info.CXX = xcrun.cxx
        self.env_info.AR = xcrun.ar
        self.env_info.RANLIB = xcrun.ranlib
        self.env_info.STRIP = xcrun.strip

        self.env_info.CFLAGS = cflags_str
        self.env_info.ASFLAGS = cflags_str
        self.env_info.CPPFLAGS = cflags_str
        self.env_info.CXXFLAGS = cflags_str
        self.env_info.LDFLAGS = ldflags_str

        self.env_info.CONAN_CMAKE_SYSTEM_NAME = self.cmake_system_name
        if self.settings.get_safe("os.version"):
            self.env_info.CONAN_CMAKE_OSX_DEPLOYMENT_TARGET = str(
                self.settings.os.version)
        self.env_info.CONAN_CMAKE_OSX_ARCHITECTURES = str(darwin_arch)
        self.env_info.CONAN_CMAKE_SYSROOT = sysroot
        self.env_info.CONAN_CMAKE_TOOLCHAIN_FILE = os.path.join(
            self.package_folder, "darwin-toolchain.cmake")
Ejemplo n.º 10
0
    def create_user_config_jam(self, folder):
        """To help locating the zlib and bzip2 deps"""
        self.output.warn("Patching user-config.jam")

        compiler_command = self._cxx

        contents = ""
        if self.zip_bzip2_requires_needed:
            contents = "\nusing zlib : 1.2.11 : <include>%s <search>%s <name>%s ;" % (
                self.deps_cpp_info["zlib"].include_paths[0].replace('\\', '/'),
                self.deps_cpp_info["zlib"].lib_paths[0].replace('\\', '/'),
                self.deps_cpp_info["zlib"].libs[0])

            contents += "\nusing bzip2 : 1.0.6 : <include>%s <search>%s <name>%s ;" % (
                self.deps_cpp_info["bzip2"].include_paths[0].replace('\\', '/'),
                self.deps_cpp_info["bzip2"].lib_paths[0].replace('\\', '/'),
                self.deps_cpp_info["bzip2"].libs[0])

        if not self.options.without_python:
            # https://www.boost.org/doc/libs/1_69_0/libs/python/doc/html/building/configuring_boost_build.html
            contents += "\nusing python : {version} : {executable} : {includes} :  {libraries} ;"\
                .format(version=self._python_version,
                        executable=self._python_executable,
                        includes=self._python_includes,
                        libraries=self._python_libraries)

        toolset, version, exe = self.get_toolset_version_and_exe()
        exe = compiler_command or exe  # Prioritize CXX

        # Specify here the toolset with the binary if present if don't empty parameter : :
        contents += '\nusing "%s" : "%s" : ' % (toolset, version)
        contents += ' "%s"' % exe.replace("\\", "/")

        if tools.is_apple_os(self.settings.os):
            contents += " -isysroot %s" % tools.XCRun(self.settings).sdk_path
            if self.settings.get_safe("arch"):
                contents += " -arch %s" % tools.to_apple_arch(self.settings.arch)

        contents += " : \n"
        if self._ar:
            contents += '<archiver>"%s" ' % tools.which(self._ar).replace("\\", "/")
        if self._ranlib:
            contents += '<ranlib>"%s" ' % tools.which(self._ranlib).replace("\\", "/")
        if "CXXFLAGS" in os.environ:
            contents += '<cxxflags>"%s" ' % os.environ["CXXFLAGS"]
        if "CFLAGS" in os.environ:
            contents += '<cflags>"%s" ' % os.environ["CFLAGS"]
        if "LDFLAGS" in os.environ:
            contents += '<linkflags>"%s" ' % os.environ["LDFLAGS"]
        if "ASFLAGS" in os.environ:
            contents += '<asmflags>"%s" ' % os.environ["ASFLAGS"]

        contents += " ;"

        self.output.warn(contents)
        filename = "%s/user-config.jam" % folder
        tools.save(filename,  contents)
Ejemplo n.º 11
0
 def _get_env_build(self):
     if not self._env_build:
         self._env_build = AutoToolsBuildEnvironment(self)
         if self.settings.compiler == "apple-clang":
             self._env_build.flags.append("-arch %s" % tools.to_apple_arch(self.settings.arch))
             self._env_build.flags.append("-isysroot %s" % tools.XCRun(self.settings).sdk_path)
             if self.settings.get_safe("os.version"):
                 self._env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                           self.settings.os.version))
     return self._env_build
Ejemplo n.º 12
0
    def build(self):
        cmake = CMake(self)

        library_folder = "json-%s" % self.version

        if self.settings.os == "Macos":
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)

        cmake.configure(source_folder=library_folder)
        cmake.build()
        cmake.test()
Ejemplo n.º 13
0
 def applyCmakeSettingsForiOS(self, cmake):
     cmake.definitions["CMAKE_SYSTEM_NAME"] = "iOS"
     cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"
     cmake.definitions["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.0"
     cmake.definitions["CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH"] = "NO"
     cmake.definitions["CMAKE_IOS_INSTALL_COMBINED"] = "YES"
     cmake.definitions["DJINNI_WITH_OBJC"] = "ON"
     
     # define all architectures for ios fat library
     if "arm" in self.settings.arch:
         cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = "armv7;armv7s;arm64;arm64e"
     else:
         cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(self.settings.arch)
Ejemplo n.º 14
0
    def applyCmakeSettingsForiOS(self, cmake):
        ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
        cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"

        if self.settings.arch == "x86":
            cmake.definitions["PLATFORM"] = "SIMULATOR"
        elif self.settings.arch == "x86_64":
            cmake.definitions["PLATFORM"] = "SIMULATOR64"
        else:
            cmake.definitions["PLATFORM"] = "OS"

        cmake.definitions["ARCHS"] = tools.to_apple_arch(self.settings.arch)
Ejemplo n.º 15
0
 def _get_env_build(self):
     if not self._env_build:
         self._env_build = AutoToolsBuildEnvironment(self)
         if self.settings.compiler == "apple-clang":
             # add flags only if not already specified, avoid breaking Catalyst which needs very special flags
             flags = " ".join(self._env_build.flags)
             if "-arch" not in flags:
                 self._env_build.flags.append("-arch %s" % tools.to_apple_arch(self.settings.arch))
             if "-isysroot" not in flags:
                 self._env_build.flags.append("-isysroot %s" % tools.XCRun(self.settings).sdk_path)
             if self.settings.get_safe("os.version") and "-version-min=" not in flags and "-target" not in flags:
                 self._env_build.flags.append(tools.apple_deployment_target_flag(self.settings.os,
                                                                           self.settings.os.version))
     return self._env_build
    def applyCmakeSettingsForiOS(self, cmake):
        cmake.definitions["CMAKE_SYSTEM_NAME"] = "iOS"
        cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"
        cmake.definitions["CMAKE_OSX_DEPLOYMENT_TARGET"] = "10.0"
        cmake.definitions["CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH"] = "NO"
        cmake.definitions["CMAKE_IOS_INSTALL_COMBINED"] = "YES"

        tools.replace_in_file(
            "%s/libressl-%s/CMakeLists.txt" %
            (self.source_folder, self.version), "project (LibreSSL C ASM)",
            """project (LibreSSL C ASM)
                    include_directories(BEFORE "../ios/include") """)

        # on iOS SDK 13+ we have to remove some checks
        if tools.Version(self.settings.os.version) >= 13.0:
            tools.replace_in_file(
                "%s/libressl-%s/CMakeLists.txt" %
                (self.source_folder, self.version),
                "check_function_exists(reallocarray",
                "#check_function_exists(reallocarray")

            tools.replace_in_file(
                "%s/libressl-%s/CMakeLists.txt" %
                (self.source_folder, self.version),
                "check_function_exists(explicit_bzero",
                "#check_function_exists(explicit_bzero")

            tools.replace_in_file(
                "%s/libressl-%s/CMakeLists.txt" %
                (self.source_folder, self.version),
                "check_function_exists(syslog_r",
                "#check_function_exists(syslog_r")

            tools.replace_in_file(
                "%s/libressl-%s/CMakeLists.txt" %
                (self.source_folder, self.version),
                "check_function_exists(timingsafe_memcmp",
                "#check_function_exists(timingsafe_memcmp")

        cmake.definitions["LIBRESSL_APPS"] = "OFF"
        cmake.definitions["LIBRESSL_TESTS"] = "OFF"

        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            cmake.definitions[
                "CMAKE_OSX_ARCHITECTURES"] = "armv7;armv7s;arm64;arm64e"
        else:
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)
Ejemplo n.º 17
0
 def _build_context(self):
     if self.settings.compiler == "apple-clang":
         env_build = {
             "CC": tools.XCRun(self.settings).cc,
             "CXX": tools.XCRun(self.settings).cxx
         }
         if hasattr(self, "settings_build"):
             # there is no CFLAGS_FOR_BUILD/CXXFLAGS_FOR_BUILD
             xcrun = tools.XCRun(self.settings_build)
             flags = " -Wno-implicit-function-declaration -isysroot {} -arch {}".format(
                 xcrun.sdk_path,
                 tools.to_apple_arch(self.settings_build.arch))
             env_build["CC_FOR_BUILD"] = xcrun.cc + flags
             env_build["CXX_FOR_BUILD"] = xcrun.cxx + flags
         with tools.environment_append(env_build):
             yield
     else:
         yield
Ejemplo n.º 18
0
    def applyCmakeSettingsForiOS(self, cmake):
        ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
        cmake.definitions["DEPLOYMENT_TARGET"] = "10.0"

        if self.settings.arch == "x86":
            cmake.definitions["PLATFORM"] = "SIMULATOR"
        elif self.settings.arch == "x86_64":
            cmake.definitions["PLATFORM"] = "SIMULATOR64"
        else:
            cmake.definitions["PLATFORM"] = "OS"

        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            cmake.definitions["ARCHS"] = "armv7;armv7s;arm64;arm64e"
        else:
            cmake.definitions["ARCHS"] = tools.to_apple_arch(
                self.settings.arch)
Ejemplo n.º 19
0
    def build(self):
        cmake = CMake(self)
        cmake.verbose = True

        library_folder = "soci-%s/src" % self.version

        cmake.definitions["SOCI_TESTS"] = "OFF"

        cmake.definitions[
            "SOCI_SHARED"] = "ON" if self.options.shared == True else "OFF"
        cmake.definitions[
            "SOCI_STATIC"] = "OFF" if self.options.shared == True else "ON"

        if self.settings.os == "Android":
            cmake.definitions[
                "CMAKE_SYSTEM_VERSION"] = self.settings.os.api_level
            cmake.definitions["CMAKE_ANDROID_NDK"] = os.environ[
                "ANDROID_NDK_PATH"]
            cmake.definitions[
                "CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION"] = self.settings.compiler
            cmake.definitions[
                "CMAKE_ANDROID_STL_TYPE"] = self.options.android_stl_type

        if self.settings.os == "iOS":
            ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
            cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
            if self.settings.arch == "x86" or self.settings.arch == "x86_64":
                cmake.definitions["IOS_PLATFORM"] = "SIMULATOR"
            else:
                cmake.definitions["IOS_PLATFORM"] = "OS"

        if self.settings.os == "Macos":
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)

        cmake.configure(source_folder=library_folder)
        cmake.build()
        cmake.install()

        socimysqlheader = "%s/include/soci/mysql/soci-mysql.h"
        if self.version == "3.2.3" and os.path.isfile(socimysqlheader):
            tools.replace_in_file(socimysqlheader % (self.package_folder),
                                  '#include "soci-backend.h"',
                                  '#include "../soci-backend.h"')
Ejemplo n.º 20
0
    def package_info(self):
        darwin_arch = tools.to_apple_arch(self.settings.arch)

        xcrun = tools.XCRun(self.settings)
        sysroot = xcrun.sdk_path

        self.cpp_info.sysroot = sysroot

        common_flags = ["-isysroot%s" % sysroot]

        if self.settings.get_safe("os.version"):
            common_flags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))

        if not self.settings.os == "Macos" and self.options.bitcode:
            if self.settings.build_type == "Debug":
                bitcode_flag = "-fembed-bitcode-marker"
            else:
                bitcode_flag = "-fembed-bitcode"
            common_flags.append(bitcode_flag)

        # CMake issue, for details look https://github.com/conan-io/conan/issues/2378
        cflags = copy.copy(common_flags)
        cflags.extend(["-arch", darwin_arch])
        self.cpp_info.cflags = cflags
        link_flags = copy.copy(common_flags)
        link_flags.append("-arch %s" % darwin_arch)

        self.cpp_info.sharedlinkflags.extend(link_flags)
        self.cpp_info.exelinkflags.extend(link_flags)

        # Set flags in environment too, so that CMake Helper finds them
        cflags_str = " ".join(cflags)
        ldflags_str = " ".join(link_flags)
        self.env_info.CC = xcrun.cc
        self.env_info.CXX = xcrun.cxx
        self.env_info.AR = xcrun.ar
        self.env_info.RANLIB = xcrun.ranlib
        self.env_info.STRIP = xcrun.strip

        self.env_info.CFLAGS = cflags_str
        self.env_info.CXXFLAGS = cflags_str
        self.env_info.LDFLAGS = ldflags_str
Ejemplo n.º 21
0
    def build(self):
        library_folder = "%s/openldap-%s" % (self.source_folder, self.version)
        # autotools = AutoToolsBuildEnvironment(self)
        # env_build_vars = autotools.vars
        # build_host = None

        if self.settings.os == "iOS":
            if self.version == "2.4.46":
                self.run("cd %s; patch -p1 < %s/patches-ios/2.4.46.patch" %
                         (library_folder, self.build_folder))

            # define all architectures for ios fat library
            if "arm" in self.settings.arch:
                self.run("%s/openldap-ios.sh %s arm %s %s" %
                         (self.build_folder, self.version, library_folder,
                          self.settings.build_type))
            else:
                self.run("%s/openldap-ios.sh %s %s %s %s" %
                         (self.build_folder, self.version,
                          tools.to_apple_arch(self.settings.arch),
                          library_folder, self.settings.build_type))
Ejemplo n.º 22
0
    def applyCmakeSettingsForiOS(self, cmake):
        ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
        cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
        cmake.definitions["BUILD_TESTING"] = "OFF"
        cmake.definitions["BUILD_CURL_EXE"] = "OFF"
        cmake.definitions["CMAKE_USE_LIBSSH2"] = "OFF"
        #cmake.definitions["PICKY_COMPILER"] = "OFF"
        tools.replace_in_file("%s/curl-%s/CMakeLists.txt" % (self.source_folder, self.version),
            "find_package(OpenSSL", "find_host_package(OpenSSL")
        
        # define all architectures for ios fat library
        if "arm" in self.settings.arch:
            cmake.definitions["ARCHS"] = "armv7;armv7s;arm64;arm64e"
        else:
            cmake.definitions["ARCHS"] = tools.to_apple_arch(self.settings.arch)

        if self.settings.arch == "x86":
            cmake.definitions["PLATFORM"] = "SIMULATOR"
        elif self.settings.arch == "x86_64":
            cmake.definitions["PLATFORM"] = "SIMULATOR64"
        else:
            cmake.definitions["PLATFORM"] = "OS"
Ejemplo n.º 23
0
    def _create_user_config_jam(self, folder):
        """To help locating the zlib and bzip2 deps"""
        self.output.warn("Patching user-config.jam")

        compiler_command = self._cxx

        contents = ""
        if self._zip_bzip2_requires_needed:
            def create_library_config(name):
                includedir = self.deps_cpp_info[name].include_paths[0].replace('\\', '/')
                libdir = self.deps_cpp_info[name].lib_paths[0].replace('\\', '/')
                lib = self.deps_cpp_info[name].libs[0]
                version = self.deps_cpp_info[name].version
                return "\nusing {name} : {version} : " \
                       "<include>{includedir} " \
                       "<search>{libdir} " \
                       "<name>{lib} ;".format(name=name,
                                              version=version,
                                              includedir=includedir,
                                              libdir=libdir,
                                              lib=lib)

            contents = ""
            if self.options.zlib:
                contents += create_library_config("zlib")
            if self.options.bzip2:
                contents += create_library_config("bzip2")
            if self.options.lzma:
                contents += create_library_config("lzma")
            if self.options.zstd:
                contents += create_library_config("zstd")

        if not self.options.without_python:
            # https://www.boost.org/doc/libs/1_70_0/libs/python/doc/html/building/configuring_boost_build.html
            contents += '\nusing python : {version} : "{executable}" : "{includes}" : "{libraries}" ;'\
                .format(version=self._python_version,
                        executable=self._python_executable,
                        includes=self._python_includes,
                        libraries=self._python_libraries)

        toolset, version, exe = self._toolset_version_and_exe
        exe = compiler_command or exe  # Prioritize CXX

        # Specify here the toolset with the binary if present if don't empty parameter : :
        contents += '\nusing "%s" : "%s" : ' % (toolset, version)
        contents += ' %s' % exe.replace("\\", "/")

        if tools.is_apple_os(self.settings.os):
            if self.settings.compiler == "apple-clang":
                contents += " -isysroot %s" % tools.XCRun(self.settings).sdk_path
            if self.settings.get_safe("arch"):
                contents += " -arch %s" % tools.to_apple_arch(self.settings.arch)

        contents += " : \n"
        if self._ar:
            contents += '<archiver>"%s" ' % tools.which(self._ar).replace("\\", "/")
        if self._ranlib:
            contents += '<ranlib>"%s" ' % tools.which(self._ranlib).replace("\\", "/")
        if "CXXFLAGS" in os.environ:
            contents += '<cxxflags>"%s" ' % os.environ["CXXFLAGS"]
        if "CFLAGS" in os.environ:
            contents += '<cflags>"%s" ' % os.environ["CFLAGS"]
        if "LDFLAGS" in os.environ:
            contents += '<linkflags>"%s" ' % os.environ["LDFLAGS"]
        if "ASFLAGS" in os.environ:
            contents += '<asmflags>"%s" ' % os.environ["ASFLAGS"]

        contents += " ;"

        self.output.warn(contents)
        filename = "%s/user-config.jam" % folder
        tools.save(filename,  contents)
Ejemplo n.º 24
0
    def get_platform_arch(self):
        platform_arch = tools.to_apple_arch(
            self.options.get_safe("ezored_arch"), )

        return platform_arch
 def applyCmakeSettingsFormacOS(self, cmake):
     cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
         self.settings.arch)
Ejemplo n.º 26
0
    def get_build_flags(self):

        if tools.cross_building(self.settings):
            flags = self.get_build_cross_flags()
        else:
            flags = []

        # https://www.boost.org/doc/libs/1_68_0/libs/context/doc/html/context/architectures.html
        if self._b2_os:
            flags.append("target-os=%s" % self._b2_os)
        if self._b2_architecture:
            flags.append("architecture=%s" % self._b2_architecture)
        if self._b2_address_model:
            flags.append("address-model=%s" % self._b2_address_model)
        if self._b2_binary_format:
            flags.append("binary-format=%s" % self._b2_binary_format)
        if self._b2_abi:
            flags.append("abi=%s" % self._b2_abi)

        if self.settings.compiler == "gcc":
            flags.append("--layout=system")

        if self.settings.compiler == "Visual Studio" and self.settings.compiler.runtime:
            flags.append("runtime-link=%s" % ("static" if "MT" in str(self.settings.compiler.runtime) else "shared"))

        if self.settings.os == "Windows" and self.settings.compiler == "gcc":
            flags.append("threading=multi")

        flags.append("link=%s" % ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in lib_list:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        if self.settings.cppstd:
            toolset, _, _ = self.get_toolset_version_and_exe()
            flags.append("toolset=%s" % toolset)
            flags.append("cxxflags=%s" % cppstd_flag(
                    self.settings.get_safe("compiler"),
                    self.settings.get_safe("compiler.version"),
                    self.settings.get_safe("cppstd")
                )
            )

        # CXX FLAGS
        cxx_flags = []
        # fPIC DEFINITION
        if self.settings.compiler != "Visual Studio":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os != "Android":
            try:
                if str(self.settings.compiler.libcxx) == "libstdc++":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=0")
                elif str(self.settings.compiler.libcxx) == "libstdc++11":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=1")
                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
            except:
                pass

        if self.settings.os == "iOS":
            arch = self.settings.get_safe('arch')

            cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
            cxx_flags.append("-DBOOST_SP_USE_PTHREADS")
            cxx_flags.append("-fvisibility=hidden")
            cxx_flags.append("-fvisibility-inlines-hidden")
            cxx_flags.append("-fembed-bitcode")
            cxx_flags.extend(["-arch", tools.to_apple_arch(arch)])

            try:
                cxx_flags.append("-mios-version-min=%s" % self.settings.os.version)
                self.output.info("iOS deployment target: %s" % self.settings.os.version)
            except:
                pass

            flags.append("macosx-version=%s" % self.b2_macosx_version())

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        return flags
Ejemplo n.º 27
0
    def get_build_flags(self):

        if tools.cross_building(self.settings):
            flags = self.get_build_cross_flags()
        else:
            flags = []
            if self.settings.arch == 'x86' and 'address-model=32' not in flags:
                flags.append('address-model=32')
            elif self.settings.arch == 'x86_64' and 'address-model=64' not in flags:
                flags.append('address-model=64')

        if self.settings.compiler == "gcc":
            flags.append("--layout=system")

        if self.settings.compiler == "Visual Studio" and self.settings.compiler.runtime:
            flags.append("runtime-link=%s" % ("static" if "MT" in str(
                self.settings.compiler.runtime) else "shared"))

        if self.settings.os == "Windows" and self.settings.compiler == "gcc":
            flags.append("threading=multi")

        flags.append("link=%s" %
                     ("static" if not self.options.shared else "shared"))
        if self.settings.build_type == "Debug":
            flags.append("variant=debug")
        else:
            flags.append("variant=release")

        for libname in lib_list:
            if getattr(self.options, "without_%s" % libname):
                flags.append("--without-%s" % libname)

        # CXX FLAGS
        cxx_flags = []
        # fPIC DEFINITION
        if self.settings.compiler != "Visual Studio":
            if self.options.fPIC:
                cxx_flags.append("-fPIC")

        # Standalone toolchain fails when declare the std lib
        if self.settings.os != "Android":
            try:
                if str(self.settings.compiler.libcxx) == "libstdc++":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=0")
                elif str(self.settings.compiler.libcxx) == "libstdc++11":
                    flags.append("define=_GLIBCXX_USE_CXX11_ABI=1")
                if "clang" in str(self.settings.compiler):
                    if str(self.settings.compiler.libcxx) == "libc++":
                        cxx_flags.append("-stdlib=libc++")
                        cxx_flags.append("-std=c++11")
                        flags.append('linkflags="-stdlib=libc++"')
                    else:
                        cxx_flags.append("-stdlib=libstdc++")
                        cxx_flags.append("-std=c++11")
            except:
                pass

        if self.settings.os == "iOS":
            arch = self.settings.get_safe('arch')

            cxx_flags.append("-DBOOST_AC_USE_PTHREADS")
            cxx_flags.append("-DBOOST_SP_USE_PTHREADS")
            cxx_flags.append("-fvisibility=hidden")
            cxx_flags.append("-fvisibility-inlines-hidden")
            cxx_flags.append("-fembed-bitcode")
            cxx_flags.extend(["-arch", tools.to_apple_arch(arch)])

            try:
                cxx_flags.append("-mios-version-min=%s" %
                                 self.settings.os.version)
                self.output.info("iOS deployment target: %s" %
                                 self.settings.os.version)
            except:
                pass

            flags.append("macosx-version=%s" % self.b2_macosx_version())

        cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else ""
        flags.append(cxx_flags)

        return flags
Ejemplo n.º 28
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 = []

        def opt_enable_disable(what, v):
            return "--{}-{}".format("enable" if v else "disable", what)

        def opt_append_disable_if_set(args, what, v):
            if v:
                args.append("--disable-{}".format(what))

        args = [
            "--pkg-config-flags=--static",
            "--disable-doc",
            opt_enable_disable("cross-compile", tools.cross_building(self)),
            opt_enable_disable("asm", self.options.with_asm),
            # Libraries
            opt_enable_disable("shared", self.options.shared),
            opt_enable_disable("static", not self.options.shared),
            opt_enable_disable("pic", self.options.get_safe("fPIC", True)),
            # Components
            opt_enable_disable("avdevice", self.options.avdevice),
            opt_enable_disable("avcodec", self.options.avcodec),
            opt_enable_disable("avformat", self.options.avformat),
            opt_enable_disable("swresample", self.options.swresample),
            opt_enable_disable("swscale", self.options.swscale),
            opt_enable_disable("postproc", self.options.postproc),
            opt_enable_disable("avfilter", self.options.avfilter),

            # Dependencies
            opt_enable_disable("bzlib", self.options.with_bzip2),
            opt_enable_disable("zlib", self.options.with_zlib),
            opt_enable_disable("lzma", self.options.with_lzma),
            opt_enable_disable("iconv", self.options.with_libiconv),
            opt_enable_disable("libopenjpeg", self.options.with_openjpeg),
            opt_enable_disable("libopenh264", self.options.with_openh264),
            opt_enable_disable("libvorbis", self.options.with_vorbis),
            opt_enable_disable("libopus", self.options.with_opus),
            opt_enable_disable("libzmq", self.options.with_zeromq),
            opt_enable_disable("sdl2", self.options.with_sdl),
            opt_enable_disable("libx264", self.options.with_libx264),
            opt_enable_disable("libx265", self.options.with_libx265),
            opt_enable_disable("libvpx", self.options.with_libvpx),
            opt_enable_disable("libmp3lame", self.options.with_libmp3lame),
            opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac),
            opt_enable_disable("libwebp", self.options.with_libwebp),
            opt_enable_disable("openssl", self.options.with_ssl == "openssl"),
            opt_enable_disable("alsa", self.options.get_safe("with_libalsa")),
            opt_enable_disable("libpulse",
                               self.options.get_safe("with_pulse")),
            opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")),
            opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")),
            opt_enable_disable("libxcb", self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shm",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shape",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-xfixes",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("appkit", self.options.get_safe("with_appkit")),
            opt_enable_disable("avfoundation",
                               self.options.get_safe("with_avfoundation")),
            opt_enable_disable("coreimage",
                               self.options.get_safe("with_coreimage")),
            opt_enable_disable("audiotoolbox",
                               self.options.get_safe("with_audiotoolbox")),
            opt_enable_disable("videotoolbox",
                               self.options.get_safe("with_videotoolbox")),
            opt_enable_disable("securetransport",
                               self.options.with_ssl == "securetransport"),
            "--disable-cuda",  # FIXME: CUDA support
            "--disable-cuvid",  # FIXME: CUVID support
            # Licenses
            opt_enable_disable(
                "nonfree", self.options.with_libfdk_aac
                or (self.options.with_ssl and
                    (self.options.with_libx264 or self.options.with_libx265
                     or self.options.postproc))),
            opt_enable_disable(
                "gpl", self.options.with_libx264 or self.options.with_libx265
                or self.options.postproc)
        ]

        # Individual Component Options
        opt_append_disable_if_set(args, "everything",
                                  self.options.disable_everything)
        opt_append_disable_if_set(args, "encoders",
                                  self.options.disable_all_encoders)
        opt_append_disable_if_set(args, "decoders",
                                  self.options.disable_all_decoders)
        opt_append_disable_if_set(
            args, "hwaccels", self.options.disable_all_hardware_accelerators)
        opt_append_disable_if_set(args, "muxers",
                                  self.options.disable_all_muxers)
        opt_append_disable_if_set(args, "demuxers",
                                  self.options.disable_all_demuxers)
        opt_append_disable_if_set(args, "parsers",
                                  self.options.disable_all_parsers)
        opt_append_disable_if_set(args, "bsfs",
                                  self.options.disable_all_bitstream_filters)
        opt_append_disable_if_set(args, "protocols",
                                  self.options.disable_all_protocols)
        opt_append_disable_if_set(args, "devices",
                                  self.options.disable_all_devices)
        opt_append_disable_if_set(args, "indevs",
                                  self.options.disable_all_input_devices)
        opt_append_disable_if_set(args, "outdevs",
                                  self.options.disable_all_output_devices)
        opt_append_disable_if_set(args, "filters",
                                  self.options.disable_all_filters)

        args.extend(
            self._split_and_format_options_string(
                "enable-encoder", self.options.enable_encoders))
        args.extend(
            self._split_and_format_options_string(
                "disable-encoder", self.options.disable_encoders))
        args.extend(
            self._split_and_format_options_string(
                "enable-decoder", self.options.enable_decoders))
        args.extend(
            self._split_and_format_options_string(
                "disable-decoder", self.options.disable_decoders))
        args.extend(
            self._split_and_format_options_string(
                "enable-hwaccel", self.options.enable_hardware_accelerators))
        args.extend(
            self._split_and_format_options_string(
                "disable-hwaccel", self.options.disable_hardware_accelerators))
        args.extend(
            self._split_and_format_options_string("enable-muxer",
                                                  self.options.enable_muxers))
        args.extend(
            self._split_and_format_options_string("disable-muxer",
                                                  self.options.disable_muxers))
        args.extend(
            self._split_and_format_options_string(
                "enable-demuxer", self.options.enable_demuxers))
        args.extend(
            self._split_and_format_options_string(
                "disable-demuxer", self.options.disable_demuxers))
        args.extend(
            self._split_and_format_options_string("enable-parser",
                                                  self.options.enable_parsers))
        args.extend(
            self._split_and_format_options_string(
                "disable-parser", self.options.disable_parsers))
        args.extend(
            self._split_and_format_options_string(
                "enable-bsf", self.options.enable_bitstream_filters))
        args.extend(
            self._split_and_format_options_string(
                "disable-bsf", self.options.disable_bitstream_filters))
        args.extend(
            self._split_and_format_options_string(
                "enable-protocol", self.options.enable_protocols))
        args.extend(
            self._split_and_format_options_string(
                "disable-protocol", self.options.disable_protocols))
        args.extend(
            self._split_and_format_options_string(
                "enable-indev", self.options.enable_input_devices))
        args.extend(
            self._split_and_format_options_string(
                "disable-indev", self.options.disable_input_devices))
        args.extend(
            self._split_and_format_options_string(
                "enable-outdev", self.options.enable_output_devices))
        args.extend(
            self._split_and_format_options_string(
                "disable-outdev", self.options.disable_output_devices))
        args.extend(
            self._split_and_format_options_string("enable-filter",
                                                  self.options.enable_filters))
        args.extend(
            self._split_and_format_options_string(
                "disable-filter", self.options.disable_filters))

        if self._version_supports_vulkan():
            args.append(
                opt_enable_disable("vulkan",
                                   self.options.get_safe("with_vulkan")))
        if tools.is_apple_os(self.settings.os):
            # relocatable shared libs
            args.append("--install-name-dir=@rpath")
        args.append("--arch={}".format(self._target_arch))
        if self.settings.build_type == "Debug":
            args.extend([
                "--disable-optimizations",
                "--disable-mmx",
                "--disable-stripping",
                "--enable-debug",
            ])
        if not self.options.with_programs:
            args.append("--disable-programs")
        # since ffmpeg"s build system ignores CC and CXX
        if tools.get_env("AS"):
            args.append("--as={}".format(tools.get_env("AS")))
        if tools.get_env("CC"):
            args.append("--cc={}".format(tools.get_env("CC")))
        if tools.get_env("CXX"):
            args.append("--cxx={}".format(tools.get_env("CXX")))
        extra_cflags = []
        extra_ldflags = []
        if tools.is_apple_os(self.settings.os) and self.settings.os.version:
            extra_cflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
            extra_ldflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
        if self._is_msvc:
            args.append("--pkg-config={}".format(tools.get_env("PKG_CONFIG")))
            args.append("--toolchain=msvc")
            if self.settings.compiler == "Visual Studio" and tools.Version(
                    self.settings.compiler.version) <= "12":
                # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++)
                self._autotools.defines.append("inline=__inline")
        if tools.cross_building(self):
            if self._target_os == "emscripten":
                args.append("--target-os=none")
            else:
                args.append("--target-os={}".format(self._target_os))

            if tools.is_apple_os(self.settings.os):
                xcrun = tools.XCRun(self.settings)
                apple_arch = tools.to_apple_arch(str(self.settings.arch))
                extra_cflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])
                extra_ldflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])

        args.append("--extra-cflags={}".format(" ".join(extra_cflags)))
        args.append("--extra-ldflags={}".format(" ".join(extra_ldflags)))

        self._autotools.configure(args=args,
                                  configure_dir=self._source_subfolder,
                                  build=False,
                                  host=False,
                                  target=False)
        return self._autotools
Ejemplo n.º 29
0
    def build(self):
        cmake = CMake(self)
        library_folder = "%s/curl-%s" % (self.source_folder, self.version)
        cmake.verbose = True
        variants = []

        if self.settings.os == "Android":
            android_toolchain = os.environ[
                "ANDROID_NDK_PATH"] + "/build/cmake/android.toolchain.cmake"
            cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = android_toolchain
            cmake.definitions["ANDROID_NDK"] = os.environ["ANDROID_NDK_PATH"]
            cmake.definitions["ANDROID_ABI"] = tools.to_android_abi(
                self.settings.arch)
            cmake.definitions["ANDROID_STL"] = self.options.android_stl_type
            cmake.definitions[
                "ANDROID_NATIVE_API_LEVEL"] = self.settings.os.api_level
            cmake.definitions["ANDROID_TOOLCHAIN"] = "clang"
            cmake.definitions["BUILD_TESTING"] = "OFF"
            cmake.definitions["BUILD_CURL_EXE"] = "OFF"
            tools.replace_in_file(
                "%s/curl-%s/CMakeLists.txt" %
                (self.source_folder, self.version), "find_package(OpenSSL",
                "find_host_package(OpenSSL")
            self.addFindHostPackage()

        if self.settings.os == "iOS":
            ios_toolchain = "cmake-modules/Toolchains/ios.toolchain.cmake"
            cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = ios_toolchain
            cmake.definitions["BUILD_TESTING"] = "OFF"
            cmake.definitions["BUILD_CURL_EXE"] = "OFF"
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)
            tools.replace_in_file(
                "%s/curl-%s/CMakeLists.txt" %
                (self.source_folder, self.version), "find_package(OpenSSL",
                "find_host_package(OpenSSL")

            # define all architectures for ios fat library
            if "arm" in self.settings.arch:
                variants = ["armv7", "armv7s", "armv8"]

            # apply build config for all defined architectures
            if len(variants) > 0:
                archs = ""
                for i in range(0, len(variants)):
                    if i == 0:
                        archs = tools.to_apple_arch(variants[i])
                    else:
                        archs += ";" + tools.to_apple_arch(variants[i])
                cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = archs

            if self.settings.arch == "x86":
                cmake.definitions["IOS_PLATFORM"] = "SIMULATOR"
            elif self.settings.arch == "x86_64":
                cmake.definitions["IOS_PLATFORM"] = "SIMULATOR64"
            else:
                cmake.definitions["IOS_PLATFORM"] = "OS"

        if self.settings.os == "Macos":
            cmake.definitions["CMAKE_OSX_ARCHITECTURES"] = tools.to_apple_arch(
                self.settings.arch)

        cmake.definitions["CURL_DISABLE_LDAP"] = not self.options.with_ldap
        cmake.definitions[
            "BUILD_SHARED_LIBS"] = "ON" if self.options.shared else "OFF"

        cmake.configure(source_folder=library_folder)
        cmake.build()
        cmake.install()
Ejemplo n.º 30
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 = []
        opt_enable_disable = lambda what, v: "--{}-{}".format(
            "enable" if v else "disable", what)
        args = [
            "--pkg-config-flags=--static",
            "--disable-doc",
            "--disable-programs",
            opt_enable_disable("cross-compile", tools.cross_building(self)),
            # Libraries
            opt_enable_disable("shared", self.options.shared),
            opt_enable_disable("static", not self.options.shared),
            opt_enable_disable("pic", self.options.get_safe("fPIC", True)),
            opt_enable_disable("postproc", self.options.postproc),
            # Dependencies
            opt_enable_disable("bzlib", self.options.with_bzip2),
            opt_enable_disable("zlib", self.options.with_zlib),
            opt_enable_disable("lzma", self.options.with_lzma),
            opt_enable_disable("iconv", self.options.with_libiconv),
            opt_enable_disable("libopenjpeg", self.options.with_openjpeg),
            opt_enable_disable("libopenh264", self.options.with_openh264),
            opt_enable_disable("libvorbis", self.options.with_vorbis),
            opt_enable_disable("libopus", self.options.with_opus),
            opt_enable_disable("libzmq", self.options.with_zeromq),
            opt_enable_disable("sdl2", self.options.with_sdl),
            opt_enable_disable("libx264", self.options.with_libx264),
            opt_enable_disable("libx265", self.options.with_libx265),
            opt_enable_disable("libvpx", self.options.with_libvpx),
            opt_enable_disable("libmp3lame", self.options.with_libmp3lame),
            opt_enable_disable("libfdk-aac", self.options.with_libfdk_aac),
            opt_enable_disable("libwebp", self.options.with_libwebp),
            opt_enable_disable("openssl", self.options.with_ssl == "openssl"),
            opt_enable_disable("alsa", self.options.get_safe("with_libalsa")),
            opt_enable_disable("libpulse",
                               self.options.get_safe("with_pulse")),
            opt_enable_disable("vaapi", self.options.get_safe("with_vaapi")),
            opt_enable_disable("vdpau", self.options.get_safe("with_vdpau")),
            opt_enable_disable("libxcb", self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shm",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-shape",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("libxcb-xfixes",
                               self.options.get_safe("with_xcb")),
            opt_enable_disable("appkit", self.options.get_safe("with_appkit")),
            opt_enable_disable("avfoundation",
                               self.options.get_safe("with_avfoundation")),
            opt_enable_disable("coreimage",
                               self.options.get_safe("with_coreimage")),
            opt_enable_disable("audiotoolbox",
                               self.options.get_safe("with_audiotoolbox")),
            opt_enable_disable("videotoolbox",
                               self.options.get_safe("with_videotoolbox")),
            opt_enable_disable("securetransport",
                               self.options.with_ssl == "securetransport"),
            "--disable-cuda",  # FIXME: CUDA support
            "--disable-cuvid",  # FIXME: CUVID support
            # Licenses
            opt_enable_disable("nonfree", self.options.with_libfdk_aac),
            opt_enable_disable(
                "gpl", self.options.with_libx264 or self.options.with_libx265
                or self.options.postproc)
        ]
        args.append("--arch={}".format(self._target_arch))
        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 tools.get_env("AS"):
            args.append("--as={}".format(tools.get_env("AS")))
        if tools.get_env("CC"):
            args.append("--cc={}".format(tools.get_env("CC")))
        if tools.get_env("CXX"):
            args.append("--cxx={}".format(tools.get_env("CXX")))
        extra_cflags = []
        extra_ldflags = []
        if tools.is_apple_os(self.settings.os) and self.settings.os.version:
            extra_cflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
            extra_ldflags.append(
                tools.apple_deployment_target_flag(self.settings.os,
                                                   self.settings.os.version))
        if self.settings.compiler == "Visual Studio":
            args.append("--pkg-config={}".format(tools.get_env("PKG_CONFIG")))
            args.append("--toolchain=msvc")
            if tools.Version(str(self.settings.compiler.version)) <= 12:
                # Visual Studio 2013 (and earlier) doesn't support "inline" keyword for C (only for C++)
                self._autotools.defines.append("inline=__inline")
        if tools.cross_building(self):
            args.append("--target-os={}".format(self._target_os))
            if tools.is_apple_os(self.settings.os):
                xcrun = tools.XCRun(self.settings)
                apple_arch = tools.to_apple_arch(str(self.settings.arch))
                extra_cflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])
                extra_ldflags.extend([
                    "-arch {}".format(apple_arch),
                    "-isysroot {}".format(xcrun.sdk_path)
                ])

        args.append("--extra-cflags={}".format(" ".join(extra_cflags)))
        args.append("--extra-ldflags={}".format(" ".join(extra_ldflags)))

        self._autotools.configure(args=args,
                                  configure_dir=self._source_subfolder,
                                  build=False,
                                  host=False,
                                  target=False)
        return self._autotools