コード例 #1
0
    def command_line_env(self):
        if self.os == "Linux" or self.os == "Macos" or self.os == "FreeBSD" or self.os == "SunOS":
            if self.compiler == "gcc" or "clang" in str(
                    self.compiler) or "sun-cc" in str(self.compiler):
                return self._gcc_env()
        elif self.os == "Windows":
            commands = []
            commands.append("@echo off")
            vcvars = ""
            if self.compiler == "Visual Studio":
                cl_args = " ".join([
                    '/I"%s"' % lib for lib in self._deps_cpp_info.include_paths
                ])
                lib_paths = ";".join(
                    ['%s' % lib for lib in self._deps_cpp_info.lib_paths])
                commands.append(
                    'if defined LIB (SET "LIB=%LIB%;{0}") else (SET "LIB={0}")'
                    .format(lib_paths))
                commands.append(
                    'if defined CL (SET "CL=%CL% {0}") else (SET "CL={0}")'.
                    format(cl_args))
                vcvars = tools.vcvars_command(self._settings)
                if vcvars:
                    vcvars += " && "
            elif self.compiler == "gcc":
                include_paths = ";".join(
                    ['%s' % lib for lib in self._deps_cpp_info.include_paths])
                commands.append(
                    'if defined C_INCLUDE_PATH (SET "C_INCLUDE_PATH=%C_INCLUDE_PATH%;{0}")'
                    ' else (SET "C_INCLUDE_PATH={0}")'.format(include_paths))
                commands.append(
                    'if defined CPLUS_INCLUDE_PATH '
                    '(SET "CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%;{0}")'
                    ' else (SET "CPLUS_INCLUDE_PATH={0}")'.format(
                        include_paths))

                lib_paths = ";".join(
                    [lib for lib in self._deps_cpp_info.lib_paths])
                commands.append(
                    'if defined LIBRARY_PATH (SET "LIBRARY_PATH=%LIBRARY_PATH%;{0}")'
                    ' else (SET "LIBRARY_PATH={0}")'.format(lib_paths))

            commands.extend(
                get_setenv_variables_commands(self._deps_env_info, "SET"))
            save("_conan_env.bat", "\r\n".join(commands))
            command = "%scall _conan_env.bat" % vcvars
            return command

        return " && ".join(get_setenv_variables_commands(self._deps_env_info))
コード例 #2
0
    def command_line(self):
        """
            env = ConfigureEnvironment(self.deps_cpp_info, self.settings)
            command = '%s && nmake /f Makefile.msvc"' % env.command_line
            self.run(command)
        """
        command = ""
        if self.os == "Linux" or self.os == "Macos" or (
                self.os == "Windows" and self.compiler == "gcc"):
            libflags = " ".join(
                ["-l%s" % lib for lib in self._deps_cpp_info.libs])
            libs = 'LIBS="%s"' % libflags
            archflag = "-m32" if self.arch == "x86" else ""
            exe_linker_flags = " ".join(self._deps_cpp_info.exelinkflags)
            shared_linker_flags = " ".join(self._deps_cpp_info.sharedlinkflags)
            lib_paths = " ".join(
                ["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
            ldflags = 'LDFLAGS="%s %s %s %s %s"' % (lib_paths, libflags,
                                                    archflag, exe_linker_flags,
                                                    shared_linker_flags)
            debug = "-g" if self.build_type == "Debug" else "-s -DNDEBUG"
            include_flags = " ".join(
                ['-I%s' % i for i in self._deps_cpp_info.include_paths])
            cflags = 'CFLAGS="%s %s %s %s"' % (archflag, " ".join(
                self._deps_cpp_info.cflags), debug, include_flags)

            # Append the definition for libcxx
            all_cpp_flags = copy.copy(self._deps_cpp_info.cppflags)
            if self.libcxx:
                if str(self.libcxx) == "libstdc++":
                    all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=0")
                elif str(self.libcxx) == "libstdc++11":
                    all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=1")

                if "clang" in str(self.compiler):
                    if str(self.libcxx) == "libc++":
                        all_cpp_flags.append("-stdlib=libc++")
                    else:
                        all_cpp_flags.append("-stdlib=libstdc++")

            cpp_flags = 'CPPFLAGS="%s %s %s %s"' % (
                archflag, " ".join(all_cpp_flags), debug, include_flags)
            include_paths = ":".join(
                ['"%s"' % lib for lib in self._deps_cpp_info.include_paths])
            headers_flags = 'C_INCLUDE_PATH=%s CPP_INCLUDE_PATH=%s' % (
                include_paths, include_paths)
            command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags,
                                              headers_flags)
        elif self.os == "Windows" and self.compiler == "Visual Studio":
            cl_args = " ".join(
                ['/I"%s"' % lib for lib in self._deps_cpp_info.include_paths])
            lib_paths = ";".join(
                ['"%s"' % lib for lib in self._deps_cpp_info.lib_paths])
            command = "SET LIB=%s;%%LIB%% && SET CL=%s" % (lib_paths, cl_args)

        # Add the rest of env variables from deps_env_info
        command += " ".join(
            get_setenv_variables_commands(
                self._deps_env_info, "" if self.os != "Windows" else "SET"))
        return command
コード例 #3
0
ファイル: configure_environment.py プロジェクト: lasote/conan
    def command_line(self):
        """
            env = ConfigureEnvironment(self.deps_cpp_info, self.settings)
            command = '%s && nmake /f Makefile.msvc"' % env.command_line
            self.run(command)
        """
        command = ""
        if self.os == "Linux" or self.os == "Macos" or (self.os == "Windows" and
                                                        self.compiler == "gcc"):
            libflags = " ".join(["-l%s" % lib for lib in self._deps_cpp_info.libs])
            libs = 'LIBS="%s"' % libflags
            archflag = "-m32" if self.arch == "x86" else ""
            exe_linker_flags = " ".join(self._deps_cpp_info.exelinkflags)
            shared_linker_flags = " ".join(self._deps_cpp_info.sharedlinkflags)
            lib_paths = " ".join(["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
            ldflags = 'LDFLAGS="%s %s %s %s $LDFLAGS"' % (lib_paths, archflag,
                                                          exe_linker_flags, shared_linker_flags)
            debug = "-g" if self.build_type == "Debug" else "-s -DNDEBUG"
            include_flags = " ".join(['-I%s' % i for i in self._deps_cpp_info.include_paths])
            cflags = 'CFLAGS="$CFLAGS %s %s %s %s"' % (archflag, " ".join(self._deps_cpp_info.cflags),
                                                       debug, include_flags)

            # Append the definition for libcxx
            all_cpp_flags = copy.copy(self._deps_cpp_info.cppflags)
            if self.libcxx:
                if str(self.libcxx) == "libstdc++":
                    all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=0")
                elif str(self.libcxx) == "libstdc++11":
                    all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=1")

                if "clang" in str(self.compiler):
                    if str(self.libcxx) == "libc++":
                        all_cpp_flags.append("-stdlib=libc++")
                    else:
                        all_cpp_flags.append("-stdlib=libstdc++")

            cpp_flags = 'CPPFLAGS="$CPPFLAGS %s %s %s %s"' % (archflag, " ".join(all_cpp_flags),
                                                              debug, include_flags)
            include_paths = ":".join(['"%s"' % lib for lib in self._deps_cpp_info.include_paths])
            headers_flags = 'C_INCLUDE_PATH=$C_INCLUDE_PATH:{0} CPP_INCLUDE_PATH=$CPP_INCLUDE_PATH:{0}'.format(include_paths)
            command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags, headers_flags)
        elif self.os == "Windows" and self.compiler == "Visual Studio":
            cl_args = " ".join(['/I"%s"' % lib for lib in self._deps_cpp_info.include_paths])
            lib_paths = ";".join(['"%s"' % lib for lib in self._deps_cpp_info.lib_paths])
            command = "SET LIB=%%LIB%%;%s && SET CL=%%CL%% %s" % (lib_paths, cl_args)

        # Add the rest of env variables from deps_env_info
        command += " ".join(get_setenv_variables_commands(self._deps_env_info,
                                                          "" if self.os != "Windows" else "SET"))
        return command
コード例 #4
0
    def command_line_env(self):
        if self.os == "Linux" or self.os == "Macos" or self.os == "FreeBSD":
            if self.compiler == "gcc" or "clang" in str(self.compiler):
                return self._gcc_env()
        elif self.os == "Windows":
            commands = []
            commands.append("@echo off")
            vcvars = ""
            if self.compiler == "Visual Studio":
                cl_args = " ".join(['/I"%s"' % lib for lib in self._deps_cpp_info.include_paths])
                lib_paths = ";".join(['%s' % lib for lib in self._deps_cpp_info.lib_paths])
                commands.append('if defined LIB (SET "LIB=%LIB%;{0}") else (SET "LIB={0}")'.
                                format(lib_paths))
                commands.append('if defined CL (SET "CL=%CL% {0}") else (SET "CL={0}")'.
                                format(cl_args))
                vcvars = tools.vcvars_command(self._settings)
                if vcvars:
                    vcvars += " && "
            elif self.compiler == "gcc":
                include_paths = ";".join(['%s'
                                          % lib for lib in self._deps_cpp_info.include_paths])
                commands.append('if defined C_INCLUDE_PATH (SET "C_INCLUDE_PATH=%C_INCLUDE_PATH%;{0}")'
                                ' else (SET "C_INCLUDE_PATH={0}")'.format(include_paths))
                commands.append('if defined CPLUS_INCLUDE_PATH '
                                '(SET "CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%;{0}")'
                                ' else (SET "CPLUS_INCLUDE_PATH={0}")'.format(include_paths))

                lib_paths = ";".join([lib for lib in self._deps_cpp_info.lib_paths])
                commands.append('if defined LIBRARY_PATH (SET "LIBRARY_PATH=%LIBRARY_PATH%;{0}")'
                                ' else (SET "LIBRARY_PATH={0}")'.format(lib_paths))

            commands.extend(get_setenv_variables_commands(self._deps_env_info, "SET"))
            save("_conan_env.bat", "\r\n".join(commands))
            command = "%scall _conan_env.bat" % vcvars
            return command

        return " && ".join(get_setenv_variables_commands(self._deps_env_info))
コード例 #5
0
    def _gcc_env(self):
        libflags = " ".join(["-l%s" % lib for lib in self._deps_cpp_info.libs])
        libs = 'LIBS="%s"' % libflags
        archflag = "-m32" if self.arch == "x86" else ""
        exe_linker_flags = " ".join(self._deps_cpp_info.exelinkflags)
        shared_linker_flags = " ".join(self._deps_cpp_info.sharedlinkflags)
        lib_paths = " ".join(
            ["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
        ldflags = 'LDFLAGS="%s %s %s %s $LDFLAGS"' % (
            lib_paths, archflag, exe_linker_flags, shared_linker_flags)
        debug = "-g" if self.build_type == "Debug" else "-s -DNDEBUG"
        include_flags = " ".join(
            ['-I%s' % i for i in self._deps_cpp_info.include_paths])
        defines = " ".join(['-D%s' % i for i in self._deps_cpp_info.defines])
        cflags = 'CFLAGS="$CFLAGS %s %s %s %s %s"' % (archflag, " ".join(
            self._deps_cpp_info.cflags), debug, include_flags, defines)

        # Append the definition for libcxx
        all_cpp_flags = copy.copy(self._deps_cpp_info.cppflags)
        if self.libcxx:
            if str(self.libcxx) == "libstdc++":
                all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=0")
            elif str(self.libcxx) == "libstdc++11":
                all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=1")

            if "clang" in str(self.compiler):
                if str(self.libcxx) == "libc++":
                    all_cpp_flags.append("-stdlib=libc++")
                else:
                    all_cpp_flags.append("-stdlib=libstdc++")

        cpp_flags = 'CPPFLAGS="$CPPFLAGS %s %s %s %s %s"' % (
            archflag, " ".join(all_cpp_flags), debug, include_flags, defines)
        include_paths = ":".join(
            ['"%s"' % lib for lib in self._deps_cpp_info.include_paths])
        headers_flags = (
            'C_INCLUDE_PATH=$C_INCLUDE_PATH:{0} '
            'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:{0}'.format(include_paths))
        command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags,
                                          headers_flags)
        # Do not include "export" command, they are passed to env
        command += " ".join(
            get_setenv_variables_commands(self._deps_env_info, ""))
        return command
コード例 #6
0
    def _gcc_env(self):
        libflags = " ".join(["-l%s" % lib for lib in self._deps_cpp_info.libs])
        libs = 'LIBS="%s"' % libflags
        archflag = "-m32" if self.arch == "x86" else ""
        exe_linker_flags = " ".join(self._deps_cpp_info.exelinkflags)
        shared_linker_flags = " ".join(self._deps_cpp_info.sharedlinkflags)
        lib_paths = " ".join(["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
        ldflags = 'LDFLAGS="%s %s %s %s $LDFLAGS"' % (lib_paths, archflag,
                                                      exe_linker_flags, shared_linker_flags)
        if self.build_type == "Debug":
            debug = "-g"
        else:
            debug = "-s -DNDEBUG" if self.compiler == "gcc" else "-DNDEBUG"
        include_flags = " ".join(['-I%s' % i for i in self._deps_cpp_info.include_paths])
        defines = " ".join(['-D%s' % i for i in self._deps_cpp_info.defines])
        cflags = 'CFLAGS="$CFLAGS %s %s %s %s %s"' % (archflag,
                                                      " ".join(self._deps_cpp_info.cflags),
                                                      debug, include_flags, defines)

        # Append the definition for libcxx
        all_cpp_flags = copy.copy(self._deps_cpp_info.cppflags)
        if self.libcxx:
            if str(self.libcxx) == "libstdc++":
                all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=0")
            elif str(self.libcxx) == "libstdc++11":
                all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=1")

            if "clang" in str(self.compiler):
                if str(self.libcxx) == "libc++":
                    all_cpp_flags.append("-stdlib=libc++")
                else:
                    all_cpp_flags.append("-stdlib=libstdc++")

        cpp_flags = 'CPPFLAGS="$CPPFLAGS %s %s %s %s %s"' % (archflag, " ".join(all_cpp_flags),
                                                             debug, include_flags, defines)
        include_paths = ":".join(['"%s"' % lib for lib in self._deps_cpp_info.include_paths])
        headers_flags = ('C_INCLUDE_PATH=$C_INCLUDE_PATH:{0} '
                         'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:{0}'.format(include_paths))
        command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags, headers_flags)
        # Do not include "export" command, they are passed to env
        command += " ".join(get_setenv_variables_commands(self._deps_env_info, ""))
        return command
コード例 #7
0
    def command_line(self):
        """
            env = ConfigureEnvironment(self.deps_cpp_info, self.settings)
            command = '%s && nmake /f Makefile.msvc"' % env.command_line
            self.run(command)
        """

        if self.os == "Linux" or self.os == "Macos":
            return self._nix_env()
        if self.os == "Windows":
            if self.compiler == "Visual Studio":
                cl_args = " ".join(['/I"%s"' % lib for lib in self._deps_cpp_info.include_paths])
                lib_paths = ";".join(['"%s"' % lib for lib in self._deps_cpp_info.lib_paths])
                commands = []
                commands.append('SET LIB={};%LIB%'.format(lib_paths))
                commands.append('SET CL={}'.format(cl_args))
                commands.extend(get_setenv_variables_commands(self._deps_env_info, "SET"))
                command = " && ".join(commands)

        return command
コード例 #8
0
    def _gcc_env(self):
        libflags = " ".join(["-l%s" % lib for lib in self._deps_cpp_info.libs])
        libs = 'LIBS="%s"' % libflags
        archflag = self._gcc_arch_flags()
        exe_linker_flags = " ".join(self._deps_cpp_info.exelinkflags)
        shared_linker_flags = " ".join(self._deps_cpp_info.sharedlinkflags)
        lib_paths = " ".join(
            ["-L%s" % lib for lib in self._deps_cpp_info.lib_paths])
        ldflags = 'LDFLAGS="%s %s %s %s $LDFLAGS"' % (
            lib_paths, archflag, exe_linker_flags, shared_linker_flags)
        if self.build_type == "Debug":
            debug = "-g"
        else:
            debug = "-s -DNDEBUG" if self.compiler == "gcc" else "-DNDEBUG"
        include_flags = " ".join(
            ['-I%s' % i for i in self._deps_cpp_info.include_paths])
        defines = " ".join(['-D%s' % i for i in self._deps_cpp_info.defines])
        cflags = 'CFLAGS="$CFLAGS %s %s %s %s %s"' % (archflag, " ".join(
            self._deps_cpp_info.cflags), debug, include_flags, defines)

        # Append the definition for libcxx
        all_cpp_flags = copy.copy(self._deps_cpp_info.cppflags)
        all_cpp_flags.extend(self._gcc_lib_flags())

        cpp_flags = 'CPPFLAGS="$CPPFLAGS %s %s %s %s %s"' % (
            archflag, " ".join(all_cpp_flags), debug, include_flags, defines)
        include_paths = ":".join(
            ['"%s"' % lib for lib in self._deps_cpp_info.include_paths])
        headers_flags = (
            'C_INCLUDE_PATH=$C_INCLUDE_PATH:{0} '
            'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:{0}'.format(include_paths))
        command = "env %s %s %s %s %s" % (libs, ldflags, cflags, cpp_flags,
                                          headers_flags)
        # Do not include "export" command, they are passed to env
        command += " ".join(
            get_setenv_variables_commands(self._deps_env_info, ""))
        return command