コード例 #1
0
ファイル: autotoolstoolchain.py プロジェクト: Imerso3D/conan
    def __init__(self, conanfile, namespace=None):
        self._conanfile = conanfile
        self._namespace = namespace
        build_type = self._conanfile.settings.get_safe("build_type")

        self.configure_args = []
        self.make_args = []
        self.default_configure_install_args = False

        # TODO: compiler.runtime for Visual studio?
        # defines
        self.ndebug = None
        if build_type in ['Release', 'RelWithDebInfo', 'MinSizeRel']:
            self.ndebug = "NDEBUG"
        self.gcc_cxx11_abi = self._cxx11_abi_define()
        self.defines = []

        # cxxflags, cflags
        self.cxxflags = []
        self.cflags = []
        self.ldflags = []
        self.libcxx = self._libcxx()
        self.fpic = self._conanfile.options.get_safe("fPIC")

        self.cppstd = cppstd_flag(self._conanfile.settings)
        self.arch_flag = architecture_flag(self._conanfile.settings)
        # TODO: This is also covering compilers like Visual Studio, necessary to test it (&remove?)
        self.build_type_flags = build_type_flags(self._conanfile.settings)

        # Cross build
        self._host = None
        self._build = None
        self._target = None

        self.apple_arch_flag = self.apple_isysroot_flag = None

        self.apple_min_version_flag = apple_min_version_flag(self._conanfile)
        if cross_building(self._conanfile):
            os_build, arch_build, os_host, arch_host = get_cross_building_settings(
                self._conanfile)
            self._host = _get_gnu_triplet(os_host, arch_host)
            self._build = _get_gnu_triplet(os_build, arch_build)

            # Apple Stuff
            if os_build == "Macos":
                sdk_path = apple_sdk_path(conanfile)
                apple_arch = to_apple_arch(
                    self._conanfile.settings.get_safe("arch"))
                # https://man.archlinux.org/man/clang.1.en#Target_Selection_Options
                self.apple_arch_flag = "-arch {}".format(
                    apple_arch) if apple_arch else None
                # -isysroot makes all includes for your library relative to the build directory
                self.apple_isysroot_flag = "-isysroot {}".format(
                    sdk_path) if sdk_path else None

        check_using_build_profile(self._conanfile)
コード例 #2
0
ファイル: toolchain.py プロジェクト: ericLemanissier/conan
    def _add_apple_flags(self):
        conanfile = self._conanfile
        os_ = conanfile.settings.get_safe("os")
        if not is_apple_os(os_):
            return

        # SDK path is mandatory for cross-building
        sdk_path = conanfile.conf.get("tools.apple:sdk_path")
        if not sdk_path and self.cross_build:
            raise ConanException(
                "You must provide a valid SDK path for cross-compilation.")

        # TODO: Delete this os_sdk check whenever the _guess_apple_sdk_name() function disappears
        os_sdk = conanfile.settings.get_safe('os.sdk')
        if not os_sdk and os_ != "Macos":
            raise ConanException(
                "Please, specify a suitable value for os.sdk.")

        arch = to_apple_arch(conanfile.settings.get_safe("arch"))
        # Calculating the main Apple flags
        deployment_target_flag = apple_min_version_flag(conanfile)
        sysroot_flag = "-isysroot " + sdk_path if sdk_path else ""
        arch_flag = "-arch " + arch if arch else ""

        apple_flags = {}
        if deployment_target_flag:
            flag_ = deployment_target_flag.split("=")[0]
            apple_flags[flag_] = deployment_target_flag
        if sysroot_flag:
            apple_flags["-isysroot"] = sysroot_flag
        if arch_flag:
            apple_flags["-arch"] = arch_flag

        for flag, arg_value in apple_flags.items():
            v = " " + arg_value
            if flag not in self.c_args:
                self.c_args += v
            if flag not in self.c_link_args:
                self.c_link_args += v
            if flag not in self.cpp_args:
                self.cpp_args += v
            if flag not in self.cpp_link_args:
                self.cpp_link_args += v
コード例 #3
0
    def _resolve_apple_flags(self):
        if not is_apple_os(self._os):
            return
        # SDK path is mandatory for cross-building
        sdk_path = self._conanfile.conf.get("tools.apple:sdk_path")
        if not sdk_path and self.cross_build:
            raise ConanException(
                "You must provide a valid SDK path for cross-compilation.")

        # TODO: Delete this os_sdk check whenever the _guess_apple_sdk_name() function disappears
        os_sdk = self._conanfile.settings.get_safe('os.sdk')
        if not os_sdk and self._os != "Macos":
            raise ConanException(
                "Please, specify a suitable value for os.sdk.")

        # Calculating the main Apple flags
        arch = to_apple_arch(self._conanfile.settings.get_safe("arch"))
        self.apple_arch_flag = ["-arch", arch] if arch else []
        self.apple_isysroot_flag = ["-isysroot", sdk_path] if sdk_path else []
        self.apple_min_version_flag = [apple_min_version_flag(self._conanfile)]