-
Notifications
You must be signed in to change notification settings - Fork 988
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Develop version * more or less work with saving bat file * fixing broken tests * fixed ENV tests in linux * adding defines to ENV and minor refactor * added clang in test for OSX * removed temp conan_env.bat file & fixed test creating it * incremented times for DiamondTest failing with new ENV
- Loading branch information
1 parent
5b2d99e
commit 14dcc1f
Showing
9 changed files
with
412 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
import os | ||
|
||
__version__ = '0.13.3' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
import copy | ||
from conans.client.generators.virtualenv import get_setenv_variables_commands | ||
from conans.model.env_info import DepsEnvInfo | ||
from conans.util.files import save | ||
from conans import tools | ||
|
||
|
||
class ConfigureEnvironment(object): | ||
|
@@ -54,51 +56,130 @@ def command_line(self): | |
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.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 | ||
|
||
def _nix_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) | ||
# Add the rest of env variables from deps_env_info, WITHOUT SET, not needed with ENV | ||
command += " ".join(get_setenv_variables_commands(self._deps_env_info, "")) | ||
return command | ||
|
||
@property | ||
def command_line_env(self): | ||
if self.os == "Linux" or self.os == "Macos": | ||
return self._nix_env() | ||
|
||
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("@echo off") | ||
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)) | ||
commands.extend(get_setenv_variables_commands(self._deps_env_info, "SET")) | ||
|
||
save("_conan_env.bat", "\r\n".join(commands)) | ||
command = "call _conan_env.bat" | ||
vcvars = tools.vcvars_command(self._settings) | ||
if vcvars: | ||
command = vcvars + " && " + command | ||
elif self.os == "Windows" and self.compiler == "gcc": | ||
include_paths = ";".join(['%s' | ||
% lib for lib in self._deps_cpp_info.include_paths]) | ||
commands = [] | ||
commands.append("@echo off") | ||
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)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
annulen
Contributor
|
||
command = "call _conan_env.bat" | ||
|
||
return command | ||
|
||
@property | ||
def compile_flags(self): | ||
if self.compiler == "gcc" or "clang" in str(self.compiler): | ||
flags = [] | ||
flags.extend("-l%s" % lib for lib in self._deps_cpp_info.libs) | ||
if self.arch == "x86": | ||
flags.append("-m32") | ||
flags.extend(self._deps_cpp_info.exelinkflags) | ||
flags.extend(self._deps_cpp_info.sharedlinkflags) | ||
flags.append("-g" if self.build_type == "Debug" else "-s -DNDEBUG") | ||
flags.extend('-D%s' % i for i in self._deps_cpp_info.defines) | ||
flags.extend('-I"%s"' % i for i in self._deps_cpp_info.include_paths) | ||
flags.extend('-L"%s"' % i for i in self._deps_cpp_info.lib_paths) | ||
flags.extend(self._deps_cpp_info.cppflags) | ||
if self.libcxx: | ||
if str(self.libcxx) == "libstdc++": | ||
all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=0") | ||
flags.append("-D_GLIBCXX_USE_CXX11_ABI=0") | ||
elif str(self.libcxx) == "libstdc++11": | ||
all_cpp_flags.append("-D_GLIBCXX_USE_CXX11_ABI=1") | ||
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++") | ||
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 = ("(if defined LIB (SET LIB=%LIB%;{lib_paths}) else (SET LIB={lib_paths}))" | ||
" && (if defined CL (SET CL=%CL% {cl_args}) else (SET CL={cl_args}))". | ||
format(lib_paths=lib_paths, cl_args=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 | ||
flags.append("-stdlib=libstdc++") | ||
|
||
return " ".join(flags) | ||
if self.compiler == "Visual Studio": | ||
libs = " ".join("%s.lib" % lib for lib in self._deps_cpp_info.libs) | ||
return libs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Using _conan_env.bat breaks working in MSYS shell, which is required for building anything using autotools