def configure(self, args=None, defs=None, source_dir=None, build_dir=None, pkg_config_paths=None): args = args or [] defs = defs or {} pc_paths = os.pathsep.join(pkg_config_paths or [self._conanfile.build_folder]) source_dir = source_dir or self._conanfile.source_folder self.build_dir = build_dir or self.build_dir or self._conanfile.build_folder or "." mkdir(self.build_dir) build_type = ("--buildtype=%s" % self.build_type if self.build_type else "").lower() arg_list = join_arguments([ "--backend=%s" % self.backend, args_to_string(args), defs_to_string(defs), build_type ]) command = 'meson "%s" "%s" %s' % (source_dir, self.build_dir, arg_list) command = self._append_vs_if_needed(command) with tools.environment_append({"PKG_CONFIG_PATH": pc_paths}): self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None, source_folder=None, build_folder=None, cache_build_folder=None): # TODO: Deprecate source_dir and build_dir in favor of xxx_folder args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) mkdir(self.build_dir) arg_list = join_arguments([ self.command_line, args_to_string(args), defs_to_string(defs), args_to_string([source_dir]) ]) command = "cd %s && cmake %s" % (args_to_string([self.build_dir ]), arg_list) if platform.system( ) == "Windows" and self.generator == "MinGW Makefiles": with tools.remove_from_path("sh"): self._conanfile.run(command) else: self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None, pkg_config_paths=None, cache_build_folder=None, build_folder=None, source_folder=None): args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) if pkg_config_paths: pc_paths = os.pathsep.join(self._get_dir(f, self._conanfile.install_folder) for f in pkg_config_paths) else: pc_paths = self._conanfile.install_folder mkdir(self.build_dir) build_type = ("--buildtype=%s" % self.build_type if self.build_type else "").lower() arg_list = join_arguments([ "--backend=%s" % self.backend, args_to_string(args), defs_to_string(defs), build_type ]) command = 'meson "%s" "%s" %s' % (source_dir, self.build_dir, arg_list) command = self._append_vs_if_needed(command) with tools.environment_append({"PKG_CONFIG_PATH": pc_paths}): self._conanfile.run(command)
def _configure_new(self, args=None, defs=None, source_dir=None, build_dir=None): if isinstance(args, ConanFile): raise ConanException(deprecated_conanfile_param_message) args = args or [] defs = defs or {} source_dir = source_dir or self._conanfile.source_folder self.build_dir = build_dir or self.build_dir or self._conanfile.build_folder mkdir(self.build_dir) arg_list = join_arguments([ self.command_line, args_to_string(args), defs_to_string(defs), args_to_string([source_dir]) ]) command = "cd %s && cmake %s" % (args_to_string([self.build_dir ]), arg_list) if platform.system( ) == "Windows" and self.generator == "MinGW Makefiles": with clean_sh_from_path(): self._conanfile.run(command) else: self._conanfile.run(command)
def _configure(self, args=None, defs=None, source_dir=None, build_dir=None, source_folder=None, build_folder=None, cache_build_folder=None, pkg_config_paths=None): # TODO: Deprecate source_dir and build_dir in favor of xxx_folder if not self._conanfile.should_configure: return args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) mkdir(self.build_dir) arg_list = join_arguments([ self.command_line, args_to_string(args), defs_to_string(defs), args_to_string([source_dir]) ]) if pkg_config_paths: pkg_env = { "PKG_CONFIG_PATH": os.pathsep.join( get_abs_path(f, self._conanfile.install_folder) for f in pkg_config_paths) } else: # If we are using pkg_config generator automate the pcs location, otherwise it could # read wrong files set_env = "pkg_config" in self._conanfile.generators \ and "PKG_CONFIG_PATH" not in os.environ pkg_env = { "PKG_CONFIG_PATH": self._conanfile.install_folder } if set_env else {} with tools.environment_append(pkg_env): compiler = self._settings.get_safe("compiler") command = "cd %s && cmake %s" % (args_to_string([self.build_dir ]), arg_list) if compiler == 'emcc': self._conanfile.output.warn('Used hacked CMake in emcc build') command = "cd %s && emcmake cmake %s" % (args_to_string( [self.build_dir]), arg_list) if platform.system( ) == "Windows" and self.generator == "MinGW Makefiles": with tools.remove_from_path("sh"): self._conanfile.run(command) else: self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None, pkg_config_paths=None, cache_build_folder=None, build_folder=None, source_folder=None): if not self._conanfile.should_configure: return args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) if pkg_config_paths: pc_paths = os.pathsep.join( get_abs_path(f, self._conanfile.install_folder) for f in pkg_config_paths) else: pc_paths = self._conanfile.install_folder mkdir(self.build_dir) bt = { "RelWithDebInfo": "debugoptimized", "MinSizeRel": "release", "Debug": "debug", "Release": "release" }.get(str(self.build_type), "") build_type = "--buildtype=%s" % bt arg_list = join_arguments([ "--backend=%s" % self.backend, args_to_string(args), defs_to_string(defs), build_type ]) command = 'meson "%s" "%s" %s' % (source_dir, self.build_dir, arg_list) command = self._append_vs_if_needed(command) with tools.environment_append({"PKG_CONFIG_PATH": pc_paths}): self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None): args = args or [] defs = defs or {} source_dir = source_dir or self._conanfile.source_folder self.build_dir = build_dir or self.build_dir or self._conanfile.build_folder mkdir(self.build_dir) arg_list = join_arguments([ self.command_line, args_to_string(args), defs_to_string(defs), args_to_string([source_dir]) ]) command = "cd %s && cmake %s" % (args_to_string([self.build_dir]), arg_list) if platform.system() == "Windows" and self.generator == "MinGW Makefiles": with clean_sh_from_path(): self._conanfile.run(command) else: self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None, source_folder=None, build_folder=None, cache_build_folder=None): # TODO: Deprecate source_dir and build_dir in favor of xxx_folder if not self._conanfile.should_configure: return args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) mkdir(self.build_dir) arg_list = join_arguments([ self.command_line, args_to_string(args), defs_to_string(defs), args_to_string([source_dir]) ]) command = "cd %s && cmake %s" % (args_to_string([self.build_dir]), arg_list) if platform.system() == "Windows" and self.generator == "MinGW Makefiles": with tools.remove_from_path("sh"): self._conanfile.run(command) else: self._conanfile.run(command)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None, pkg_config_paths=None, cache_build_folder=None, build_folder=None, source_folder=None): if not self._conanfile.should_configure: return args = args or [] defs = defs or {} source_dir, self.build_dir = self._get_dirs(source_folder, build_folder, source_dir, build_dir, cache_build_folder) if pkg_config_paths: pc_paths = os.pathsep.join(self._get_dir(f, self._conanfile.install_folder) for f in pkg_config_paths) else: pc_paths = self._conanfile.install_folder mkdir(self.build_dir) bt = {"RelWithDebInfo": "debugoptimized", "MinSizeRel": "release", "Debug": "debug", "Release": "release"}.get(str(self.build_type), "") build_type = "--buildtype=%s" % bt arg_list = join_arguments([ "--backend=%s" % self.backend, args_to_string(args), defs_to_string(defs), build_type ]) command = 'meson "%s" "%s" %s' % (source_dir, self.build_dir, arg_list) command = self._append_vs_if_needed(command) with tools.environment_append({"PKG_CONFIG_PATH": pc_paths}): self._conanfile.run(command)
def flags(self): return defs_to_string(self.options)
def flags(self): return defs_to_string(self.definitions)
def runtime(self): return defs_to_string(self._runtime_definition())
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, 'libdir': 'lib', 'bindir': 'bin', 'sbindir': 'bin', 'libexecdir': 'bin', 'includedir': 'include', '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)
def runtime(self): return defs_to_string( self.definitions.get(runtime_definition_var_name))