def configure_environment_test(self): env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings()) self.assertEquals( env.command_line, 'SET LIB=%LIB%;"path/to/lib1";"path/to/lib2" && ' 'SET CL=%CL% /I"path/to/includes/lib1" ' '/I"path/to/includes/lib2"') env = ConfigureEnvironment(BuildInfoMock(), MockLinuxSettings()) 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" ' 'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -s -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2" ' 'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":' '"path/to/includes/lib2" ' 'CPP_INCLUDE_PATH=$CPP_INCLUDE_PATH:"path/to/includes/lib1":' '"path/to/includes/lib2"') # Not supported yet env = ConfigureEnvironment(BuildInfoMock(), MockWinGccSettings()) 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" ' 'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -s -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2" ' 'C_INCLUDE_PATH=$C_INCLUDE_PATH:"path/to/includes/lib1":' '"path/to/includes/lib2" ' 'CPP_INCLUDE_PATH=$CPP_INCLUDE_PATH:"path/to/includes/lib1":' '"path/to/includes/lib2"')
def append_variables_test(self): output = TestBufferConanOutput() runner = ConanRunner() if platform.system() != "Windows": os.environ["LDFLAGS"] = "ldflag=23 otherldflag=33" os.environ["CPPFLAGS"] = "-cppflag -othercppflag" 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()) 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( "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) # Reset env vars to not mess with other tests os.environ["LDFLAGS"] = "" os.environ["CPPFLAGS"] = "" os.environ["CFLAGS"] = "" os.environ["C_INCLUDE_PATH"] = "" os.environ["CPLUS_INCLUDE_PATH"] = "" else: os.environ["LIB"] = '"/path/to/lib.a"' os.environ["CL"] = '/I"path/to/cl1" /I"path/to/cl2"' env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings()) command = "%s && SET" % env.command_line runner(command, output=output) self.assertIn('LIB="path/to/lib1";"path/to/lib2";"/path/to/lib.a"', output) self.assertIn( 'CL=/I"path/to/includes/lib1" /I"path/to/includes/lib2"', output) os.environ["LIB"] = "" os.environ["CL"] = ""
def configure_environment_test(self): env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings()) self.assertEquals(env.command_line, 'SET LIB="path/to/lib1";"path/to/lib2";%LIB% && ' 'SET CL=/I"path/to/includes/lib1" ' '/I"path/to/includes/lib2"') env = ConfigureEnvironment(BuildInfoMock(), MockLinuxSettings()) self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 ' '-Lpath/to/lib2" CFLAGS="-m32 cflag1" ' 'CPPFLAGS="-m32 cppflag1" ' 'C_INCLUDE_PATH="path/to/includes/lib1":' '"path/to/includes/lib2" ' 'CPP_INCLUDE_PATH="path/to/includes/lib1":' '"path/to/includes/lib2"') # Not supported yet env = ConfigureEnvironment(BuildInfoMock(), MockWinGccSettings()) self.assertEquals(env.command_line, "")
def append_variables_test(self): output = TestBufferConanOutput() runner = ConanRunner() if platform.system() != "Windows": os.environ["LDFLAGS"] = "ldflag=23 otherldflag=33" os.environ["CPPFLAGS"] = "-cppflag -othercppflag" 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" c11settings_release = MockSettings("Release", os="Linux", arch="x86", compiler_name="gcc", libcxx="libstdc++11", version="6.2") env = ConfigureEnvironment(MockConanfile(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 -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) # Reset env vars to not mess with other tests os.environ["LDFLAGS"] = "" os.environ["CPPFLAGS"] = "" os.environ["CFLAGS"] = "" os.environ["C_INCLUDE_PATH"] = "" os.environ["CPLUS_INCLUDE_PATH"] = "" else: os.environ["LIB"] = '/path/to/lib.a' os.environ["CL"] = '/I"path/to/cl1" /I"path/to/cl2"' win_settings = MockSettings("Release", os="Windows", arch="x86", compiler_name="Visual Studio", libcxx=None, version="12") env = ConfigureEnvironment(MockConanfile(win_settings)) command = "%s && SET" % env.command_line runner(command, output=output) self.assertIn('/path/to/lib.a;path/to/lib1;path/to/lib2', output) self.assertIn('CL=/I"path/to/cl1" /I"path/to/cl2" ' '/I"path/to/includes/lib1" /I"path/to/includes/lib2"', output) os.environ["LIB"] = "" os.environ["CL"] = ""
def configure_environment_test(self): env = ConfigureEnvironment(BuildInfoMock(), MockWinSettings()) expected = 'call "%vs140comntools%../../VC/vcvarsall.bat" x86 && call _conan_env.bat' self.assertEquals(env.command_line, expected) env = ConfigureEnvironment(BuildInfoMock(), MockLinuxSettings()) 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 ' '-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()) self.assertEquals(env.command_line_env, 'call _conan_env.bat')
def configure_environment_test(self): 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) 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 -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 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 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 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 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"') freebsd_settings = MockSettings("Release", os="FreeBSD", arch="x86", compiler_name="clang", libcxx="libc++", version="3.8") env = ConfigureEnvironment(BuildInfoMock(), freebsd_settings) 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 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m32 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"') solaris_settings = MockSettings("Release", os="SunOS", arch="x86_64", compiler_name="sun-cc", libcxx="libstlport", version="5.10") env = ConfigureEnvironment(BuildInfoMock(), solaris_settings) self.assertEquals( env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 ' '-Lpath/to/lib2 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 cppflag1 -library=stlport4 -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"') # Not supported yet 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 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 -m64 -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 -m64 -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 -m64 -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++') freebsd_s_clang_32 = MockSettings("Debug", os="FreeBSD", arch="x86", compiler_name="clang", libcxx="libc++", version="3.8") env = ConfigureEnvironment(BuildInfoMock(), freebsd_s_clang_32) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m32 -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++') freebsd_s_clang_64 = MockSettings("Debug", os="FreeBSD", arch="x86_64", compiler_name="clang", libcxx="libc++", version="3.8") env = ConfigureEnvironment(BuildInfoMock(), freebsd_s_clang_64) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m64 -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++') solaris_s_sun_cc_32 = MockSettings("Debug", os="SunOS", arch="x86", compiler_name="sun-cc", libcxx="libCstd", version="5.10") env = ConfigureEnvironment(BuildInfoMock(), solaris_s_sun_cc_32) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m32 -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 -library=Cstd') solaris_s_sun_cc_64 = MockSettings("Debug", os="SunOS", arch="x86_64", compiler_name="sun-cc", libcxx="libCstd", version="5.10") env = ConfigureEnvironment(BuildInfoMock(), solaris_s_sun_cc_64) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m64 -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 -library=Cstd') solaris_s_sun_cc_stlport = MockSettings("Debug", os="SunOS", arch="x86_64", compiler_name="sun-cc", libcxx="libstlport", version="5.10") env = ConfigureEnvironment(BuildInfoMock(), solaris_s_sun_cc_stlport) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m64 -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 -library=stlport4') solaris_s_sun_cc_stdcxx = MockSettings("Debug", os="SunOS", arch="x86_64", compiler_name="sun-cc", libcxx="libstdcxx", version="5.10") env = ConfigureEnvironment(BuildInfoMock(), solaris_s_sun_cc_stdcxx) self.assertEquals( env.compile_flags, '-llib1 -llib2 -m64 -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 -library=stdcxx4')
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): win_settings = MockSettings("Release", os="Windows", arch="x86", compiler_name="Visual Studio", libcxx=None, version="14") env = ConfigureEnvironment(MockConanfile(win_settings)) if platform.system() == "Windows": expected = 'call ".+VC/vcvarsall.bat" x86 && call _conan_env.bat' self.assertRegexpMatches(env.command_line, expected) else: with self.assertRaisesRegexp(ConanException, "variable not defined"): env.command_line linux_s = MockSettings("Release", os="Linux", arch="x86", compiler_name="gcc", libcxx="libstdc++", version="4.9") env = ConfigureEnvironment(MockConanfile(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 -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(MockConanfile(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(MockConanfile(clang_settings_64)) self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 ' '-Lpath/to/lib2 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 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(MockConanfile(clang_settings_std)) self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 ' '-Lpath/to/lib2 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 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(MockConanfile(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"') freebsd_settings = MockSettings("Release", os="FreeBSD", arch="x86", compiler_name="clang", libcxx="libc++", version="3.8") env = ConfigureEnvironment(MockConanfile(freebsd_settings)) 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 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m32 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"') solaris_settings = MockSettings("Release", os="SunOS", arch="x86_64", compiler_name="sun-cc", libcxx="libstlport", version="5.10") env = ConfigureEnvironment(MockConanfile(solaris_settings)) self.assertEquals(env.command_line, 'env LIBS="-llib1 -llib2" LDFLAGS="-Lpath/to/lib1 ' '-Lpath/to/lib2 -m64 -framework thing -framework thing2 $LDFLAGS" ' 'CFLAGS="$CFLAGS -m64 cflag1 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m64 cppflag1 -library=stlport4 -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"') solaris_sparc_settings = MockSettings("Release", os="SunOS", arch="sparc", compiler_name="sun-cc", libcxx="libstlport", version="5.10") env = ConfigureEnvironment(MockConanfile(solaris_sparc_settings)) 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 -DNDEBUG ' '-Ipath/to/includes/lib1 -Ipath/to/includes/lib2 -DMYDEF1 -DMYDEF2" ' 'CPPFLAGS="$CPPFLAGS -m32 cppflag1 -library=stlport4 -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"') # Not supported yet win_gcc = MockSettings("Release", os="Windows", arch="x86", compiler_name="gcc", libcxx=None, version="4.9") env = ConfigureEnvironment(MockConanfile(win_gcc)) self.assertEquals(env.command_line_env, 'call _conan_env.bat')