Skip to content

Commit

Permalink
Merge branch 'release/0.17.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Dec 21, 2016
2 parents 8086384 + 0d41f14 commit ae41bfe
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 47 deletions.
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
COMPLEX_SEARCH_CAPABILITY = "complex_search"
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]

__version__ = '0.17.1'
__version__ = '0.17.2'

2 changes: 1 addition & 1 deletion conans/client/configure_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, *args):
self.build_type = None

try:
self.libcxx = str(self.compiler.libcxx)
self.libcxx = str(self._settings.compiler.libcxx)
except:
self.libcxx = None

Expand Down
192 changes: 147 additions & 45 deletions conans/test/compile_helpers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,46 @@
from conans.paths import CONANFILE


class MockWinSettings(Settings):
class MockCompiler(object):

@property
def os(self):
return "Windows"
def __init__(self, name, libcxx, version):
self.name = name
self.libcxx = libcxx
self.version = version

@property
def arch(self):
return "x86"
def __repr__(self, *args, **kwargs):
return self.name

@property
def compiler(self):
class Compiler(object):
@property
def version(self):
return "14"

def __str__(self):
return "Visual Studio"
return Compiler()
class MockSettings(Settings):

def __init__(self, build_type="Release", os=None, arch=None,
compiler_name=None, libcxx=None, version=None):
self._build_type = build_type
self._libcxx = libcxx or "libstdc++"
self._os = os or "Linux"
self._arch = arch or "x86"
self._compiler = MockCompiler(compiler_name or "gcc", self._libcxx, version or "4.8")

@property
def build_type(self):
return "release"


class MockWinGccSettings(MockWinSettings):
return self._build_type

@property
def compiler(self):
return "gcc"


class MockLinuxSettings(Settings):

def __init__(self, build_type="Release"):
self._build_type = build_type
def libcxx(self):
return self._libcxx

@property
def os(self):
return "Linux"
return self._os

@property
def arch(self):
return "x86"
return self._arch

@property
def compiler(self):
return "gcc"

@property
def build_type(self):
return self._build_type
return self._compiler


class MockAndroidSettings(Settings):
Expand Down Expand Up @@ -124,32 +111,142 @@ def setUp(self):
def tearDown(self):
os.chdir(self.current)

def compile_flag_test(self):
win_settings = MockSettings("Release", os="Windows", arch="x86",
compiler_name="Visual Studio", libcxx=None, version="14")
env = ConfigureEnvironment(BuildInfoMock(), win_settings)
self.assertEquals(env.compile_flags, "lib1.lib lib2.lib")

linux_s = MockSettings("Release", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++", version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), linux_s)
self.assertEquals(env.compile_flags, '-llib1 -llib2 -m32 -framework thing -framework '
'thing2 -s -DNDEBUG -DMYDEF1 -DMYDEF2 '
'-I"path/to/includes/lib1" -I"path/to/includes/lib2" '
'-L"path/to/lib1" -L"path/to/lib2" cppflag1 '
'-D_GLIBCXX_USE_CXX11_ABI=0')

linux_s_11 = MockSettings("Debug", os="Linux", arch="x86_64",
compiler_name="gcc", libcxx="libstdc++11", version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), linux_s_11)
self.assertEquals(env.compile_flags, '-llib1 -llib2 -framework thing -framework thing2'
' -g -DMYDEF1 -DMYDEF2 -I"path/to/includes/lib1" '
'-I"path/to/includes/lib2" -L"path/to/lib1" '
'-L"path/to/lib2" cppflag1 '
'-D_GLIBCXX_USE_CXX11_ABI=1')

linux_s_clang_std = MockSettings("Debug", os="Linux", arch="x86_64",
compiler_name="clang", libcxx="libstdc", version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), linux_s_clang_std)
self.assertEquals(env.compile_flags, '-llib1 -llib2 -framework thing -framework thing2'
' -g -DMYDEF1 -DMYDEF2 -I"path/to/includes/lib1" '
'-I"path/to/includes/lib2" -L"path/to/lib1" '
'-L"path/to/lib2" cppflag1 -stdlib=libstdc++')

linux_s_clang = MockSettings("Debug", os="Linux", arch="x86_64",
compiler_name="clang", libcxx="libc++", version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), linux_s_clang)
self.assertEquals(env.compile_flags, '-llib1 -llib2 -framework thing -framework thing2'
' -g -DMYDEF1 -DMYDEF2 -I"path/to/includes/lib1" '
'-I"path/to/includes/lib2" -L"path/to/lib1" '
'-L"path/to/lib2" cppflag1 -stdlib=libc++')

def configure_environment_test(self):
env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings())
win_settings = MockSettings("Release", os="Windows", arch="x86",
compiler_name="Visual Studio", libcxx=None, version="14")

env = ConfigureEnvironment(BuildInfoMock(), win_settings)

expected = 'call "%vs140comntools%../../VC/vcvarsall.bat" x86 && call _conan_env.bat'
self.assertEquals(env.command_line, expected)

env = ConfigureEnvironment(BuildInfoMock(), MockLinuxSettings())
linux_s = MockSettings("Release", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++", version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), linux_s)
self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 '
'-Lpath/to/lib2 -m32 -framework thing -framework thing2 $LDFLAGS" '
'CFLAGS="$CFLAGS -m32 cflag1 -s -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -s -DNDEBUG '
'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -D_GLIBCXX_USE_CXX11_ABI=0 -s -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2" '
'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2"')

c11settings = MockSettings("Release", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++11", version="6.2")
env = ConfigureEnvironment(BuildInfoMock(), c11settings)
self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 '
'-Lpath/to/lib2 -m32 -framework thing -framework thing2 $LDFLAGS" '
'CFLAGS="$CFLAGS -m32 cflag1 -s -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -D_GLIBCXX_USE_CXX11_ABI=1 -s -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2" '
'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2"')

clang_settings_64 = MockSettings("Release", os="Macos", arch="x86_64",
compiler_name="clang", libcxx="libc++", version="3.8")
env = ConfigureEnvironment(BuildInfoMock(), clang_settings_64)
self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 '
'-Lpath/to/lib2 -framework thing -framework thing2 $LDFLAGS" '
'CFLAGS="$CFLAGS cflag1 -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'CPPFLAGS="$CPPFLAGS cppflag1 -stdlib=libc++ -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2" '
'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2"')

clang_settings_std = MockSettings("Release", os="Macos", arch="x86_64",
compiler_name="clang", libcxx="libstdc", version="3.8")
env = ConfigureEnvironment(BuildInfoMock(), clang_settings_std)
self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 '
'-Lpath/to/lib2 -framework thing -framework thing2 $LDFLAGS" '
'CFLAGS="$CFLAGS cflag1 -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'CPPFLAGS="$CPPFLAGS cppflag1 -stdlib=libstdc++ -DNDEBUG '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2" '
'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2"')

clang_settings_std_debug = MockSettings("Debug", os="Macos", arch="x86",
compiler_name="clang", libcxx="libstdc", version="3.8")
env = ConfigureEnvironment(BuildInfoMock(), clang_settings_std_debug)
self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 '
'-Lpath/to/lib2 -m32 -framework thing -framework thing2 $LDFLAGS" '
'CFLAGS="$CFLAGS -m32 cflag1 -g '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -stdlib=libstdc++ -g '
'-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" '
'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2" '
'CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:"path/to/includes/lib1":'
'"path/to/includes/lib2"')

# Not supported yet
env = ConfigureEnvironment(BuildInfoMock(), MockWinGccSettings())
win_gcc = MockSettings("Release", os="Windows", arch="x86",
compiler_name="gcc", libcxx=None, version="4.9")
env = ConfigureEnvironment(BuildInfoMock(), win_gcc)
self.assertEquals(env.command_line_env, 'call _conan_env.bat')

def gcc_test(self):
gcc = GCC(MockLinuxSettings())
c11settings_release = MockSettings("Release", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++11",
version="6.2")
gcc = GCC(c11settings_release)
self.assertEquals(gcc.command_line, "-s -DNDEBUG -m32 ")

gcc = GCC(MockLinuxSettings("Debug"))
c11settings_debug = MockSettings("Debug", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++",
version="6.2")
gcc = GCC(c11settings_debug)
self.assertEquals(gcc.command_line, "-g -m32 ")

def append_variables_test(self):
Expand All @@ -161,11 +258,13 @@ def append_variables_test(self):
os.environ["CFLAGS"] = "-cflag"
os.environ["C_INCLUDE_PATH"] = "/path/to/c_include_path:/anotherpath"
os.environ["CPLUS_INCLUDE_PATH"] = "/path/to/cpp_include_path:/anotherpathpp"

env = ConfigureEnvironment(BuildInfoMock(), MockLinuxSettings())
c11settings_release = MockSettings("Release", os="Linux", arch="x86",
compiler_name="gcc", libcxx="libstdc++11",
version="6.2")
env = ConfigureEnvironment(BuildInfoMock(), c11settings_release)
runner(env.command_line, output=output)
self.assertIn("LDFLAGS=-Lpath/to/lib1 -Lpath/to/lib2 -m32 -framework thing -framework thing2 ldflag=23 otherldflag=33\n", output)
self.assertIn("CPPFLAGS=-cppflag -othercppflag -m32 cppflag1 -s -DNDEBUG -Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2\n", output)
self.assertIn("CPPFLAGS=-cppflag -othercppflag -m32 cppflag1 -D_GLIBCXX_USE_CXX11_ABI=1 -s -DNDEBUG -Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2\n", output)
self.assertIn("CFLAGS=-cflag -m32 cflag1 -s -DNDEBUG -Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2\n", output)
self.assertIn("C_INCLUDE_PATH=/path/to/c_include_path:/anotherpath:path/to/includes/lib1:path/to/includes/lib2\n", output)
self.assertIn("CPLUS_INCLUDE_PATH=/path/to/cpp_include_path:/anotherpathpp:path/to/includes/lib1:path/to/includes/lib2\n", output)
Expand All @@ -180,7 +279,10 @@ def append_variables_test(self):
os.environ["LIB"] = '/path/to/lib.a'
os.environ["CL"] = '/I"path/to/cl1" /I"path/to/cl2"'

env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings())
win_settings = MockSettings("Release", os="Windows", arch="x86",
compiler_name="Visual Studio", libcxx=None,
version="12")
env = ConfigureEnvironment(BuildInfoMock(), win_settings)
command = "%s && SET" % env.command_line
runner(command, output=output)

Expand Down

0 comments on commit ae41bfe

Please sign in to comment.