def warn_when_no_triplet_test(self): conan_file = ConanFileMock() deps_cpp_info = namedtuple("Deps", "libs, include_paths, lib_paths, defines, cflags, " "cppflags, sharedlinkflags, exelinkflags, sysroot") conan_file.deps_cpp_info = deps_cpp_info([], [], [], [], [], [], [], [], "") conan_file.settings = MockSettings({"arch": "UNKNOWN_ARCH", "os": "Linux"}) AutoToolsBuildEnvironment(conan_file) self.assertIn("Unknown 'UNKNOWN_ARCH' machine, Conan doesn't know " "how to translate it to the GNU triplet", conan_file.output)
def partial_build_test(self): conan_file = ConanFileMock() conan_file.settings = Settings() conan_file.should_configure = False conan_file.should_build = False meson = Meson(conan_file) meson.configure() self.assertIsNone(conan_file.command) meson.build() self.assertIsNone(conan_file.command)
def _get_conanfile(self, settings): conan_file = ConanFileMock() conan_file.settings = settings conan_file.source_folder = "my_cache_source_folder" conan_file.build_folder = "my_cache_build_folder" conan_file.deps_env_info = DepsEnvInfo() conan_file.deps_user_info = DepsUserInfo() conan_file.deps_cpp_info = DepsCppInfo() cpp_info = CppInfo("/root") cpp_info.include_paths.append("path/to/include1") cpp_info.lib_paths.append("path/to/lib1") cpp_info.libs.append("mylib") cpp_info.bindirs = "path/to/bin1" cpp_info.cflags.append("c_flag1") cpp_info.cppflags.append("cxx_flag1") cpp_info.defines.append("mydefine1") conan_file.deps_cpp_info.update(cpp_info, "zlib") conan_file.env_info = EnvInfo() return conan_file
def partial_build_test(self): conan_file = ConanFileMock() deps_cpp_info = namedtuple("Deps", "libs, include_paths, lib_paths, defines, cflags, " "cppflags, sharedlinkflags, exelinkflags, sysroot") conan_file.deps_cpp_info = deps_cpp_info([], [], [], [], [], [], [], [], "") conan_file.settings = Settings() be = AutoToolsBuildEnvironment(conan_file) conan_file.should_configure = False conan_file.should_build = False conan_file.should_install = False be.configure() self.assertIsNone(conan_file.command) be.make() self.assertIsNone(conan_file.command)
def partial_build_test(self): conan_file = ConanFileMock() conan_file.settings = Settings() conan_file.should_configure = False conan_file.should_build = False conan_file.package_folder = os.path.join(self.tempdir, "my_cache_package_folder") meson = Meson(conan_file) meson.configure() self.assertIsNone(conan_file.command) meson.build() self.assertIsNone(conan_file.command) meson.test() self.assertIsNone(conan_file.command) meson.install() self.assertIsNone(conan_file.command)
def visual_studio_extensions_test(self): settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.compiler = "Visual Studio" settings.compiler.version = "15" settings.arch = "x86" settings.build_type = "Release" conan_file = ConanFileMock() conan_file.settings = settings conan_file.deps_env_info = DepsEnvInfo() conan_file.deps_user_info = DepsUserInfo() conan_file.deps_cpp_info = DepsCppInfo() cpp_info = CppInfo("/root") cpp_info.libs.append("mylib") cpp_info.libs.append("other.lib") conan_file.deps_cpp_info.update(cpp_info, "zlib") conan_file.env_info = EnvInfo() gen = CompilerArgsGenerator(conan_file) self.assertEquals('-O2 -Ob2 -DNDEBUG -link mylib.lib other.lib', gen.content)
def folders_test(self): settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.compiler = "gcc" settings.compiler.version = "6.3" settings.arch = "x86" settings.build_type = "Release" conan_file = ConanFileMock() conan_file.settings = settings conan_file.source_folder = os.path.join(self.tempdir, "my_cache_source_folder") conan_file.build_folder = os.path.join(self.tempdir, "my_cache_build_folder") meson = Meson(conan_file) meson.configure(source_dir=os.path.join(self.tempdir, "../subdir"), build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "../subdir") build_expected = os.path.join(self.tempdir, "build") self.assertEquals( conan_file.command, 'meson "%s" "%s" ' '--backend=ninja --buildtype=release' % (source_expected, build_expected)) meson.configure(build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "build") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) meson.configure() source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "my_cache_build_folder") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja --buildtype=release' % (source_expected, build_expected)) meson.configure(source_folder="source", build_folder="build") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = True meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = False meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = True meson.configure(build_dir="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder") self.assertEquals( conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) # Raise mixing with self.assertRaisesRegexp(ConanException, "Use 'build_folder'/'source_folder'"): meson.configure(source_folder="source", build_dir="build")
def folders_test(self): settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.compiler = "gcc" settings.compiler.version = "6.3" settings.arch = "x86" settings.build_type = "Release" conan_file = ConanFileMock() conan_file.settings = settings conan_file.source_folder = os.path.join(self.tempdir, "my_cache_source_folder") conan_file.build_folder = os.path.join(self.tempdir, "my_cache_build_folder") meson = Meson(conan_file) meson.configure(source_dir=os.path.join(self.tempdir, "../subdir"), build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "../subdir") build_expected = os.path.join(self.tempdir, "build") self.assertEquals(conan_file.command, 'meson "%s" "%s" ' '--backend=ninja --buildtype=release' % (source_expected, build_expected)) meson.configure(build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "build") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) meson.configure() source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "my_cache_build_folder") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja --buildtype=release' % (source_expected, build_expected)) meson.configure(source_folder="source", build_folder="build") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = True meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = False meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) conan_file.in_local_cache = True meson.configure(build_dir="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder") self.assertEquals(conan_file.command, 'meson "%s" "%s" --backend=ninja ' '--buildtype=release' % (source_expected, build_expected)) # Raise mixing with self.assertRaisesRegexp(ConanException, "Use 'build_folder'/'source_folder'"): meson.configure(source_folder="source", build_dir="build")
def folders_test(self): settings = Settings.loads(default_settings_yml) settings.os = "Linux" settings.compiler = "gcc" settings.compiler.version = "6.3" settings.arch = "x86" settings.build_type = "Release" package_folder = os.path.join(self.tempdir, "my_cache_package_folder") conan_file = ConanFileMock() conan_file.settings = settings conan_file.source_folder = os.path.join(self.tempdir, "my_cache_source_folder") conan_file.build_folder = os.path.join(self.tempdir, "my_cache_build_folder") conan_file.package_folder = package_folder meson = Meson(conan_file) defs = { 'default-library': 'shared', 'prefix': package_folder, 'cpp_std': 'none' } meson.configure(source_dir=os.path.join(self.tempdir, "../subdir"), build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "../subdir") build_expected = os.path.join(self.tempdir, "build") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) meson.configure(build_dir=os.path.join(self.tempdir, "build")) source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "build") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) meson.configure() source_expected = os.path.join(self.tempdir, "my_cache_source_folder") build_expected = os.path.join(self.tempdir, "my_cache_build_folder") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) meson.configure(source_folder="source", build_folder="build") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) conan_file.in_local_cache = True meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) conan_file.in_local_cache = False meson.configure(source_folder="source", build_folder="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) conan_file.in_local_cache = True meson.configure(build_dir="build", cache_build_folder="rel_only_cache") build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "rel_only_cache") source_expected = os.path.join(self.tempdir, "my_cache_source_folder") cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ % (source_expected, build_expected, defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) args = ['--werror', '--warnlevel 3'] defs['default-library'] = 'static' meson.configure(source_folder="source", build_folder="build", args=args, defs={'default-library': 'static'}) build_expected = os.path.join(self.tempdir, "my_cache_build_folder", "build") source_expected = os.path.join(self.tempdir, "my_cache_source_folder", "source") cmd_expected = 'meson "%s" "%s" --backend=ninja %s %s --buildtype=release' \ % (source_expected, build_expected, args_to_string(args), defs_to_string(defs)) self._check_commands(cmd_expected, conan_file.command) # Raise mixing with self.assertRaisesRegexp(ConanException, "Use 'build_folder'/'source_folder'"): meson.configure(source_folder="source", build_dir="build") meson.test() self.assertEquals( "ninja -C \"%s\" %s" % (build_expected, args_to_string(["test"])), conan_file.command) meson.install() self.assertEquals( "ninja -C \"%s\" %s" % (build_expected, args_to_string(["install"])), conan_file.command)