Example #1
0
    def build(self, args=None, build_dir=None, target=None):
        if not self._conanfile.should_build:
            return
        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder
        if target is not None:
            args = ["--target", target] + args

        if self.parallel:
            if "Makefiles" in self.generator and "NMake" not in self.generator:
                if "--" not in args:
                    args.append("--")
                args.append("-j%i" % cpu_count())
            elif "Visual Studio" in self.generator and \
                    self._compiler_version and Version(self._compiler_version) >= "10":
                if "--" not in args:
                    args.append("--")
                args.append("/m:%i" % cpu_count())

        arg_list = join_arguments([
            args_to_string([build_dir]),
            self.build_config,
            args_to_string(args)
        ])
        command = "cmake --build %s" % arg_list
        self._conanfile.run(command)
Example #2
0
 def command_line(self):
     args = [
         '-G "%s"' % self.generator,
         self.flags,
         '-Wno-dev'
     ]
     if self.toolset:
         args.append('-T "%s"' % self.toolset)
     return join_arguments(args)
Example #3
0
 def make(self, args="", make_program=None, target=None, vars=None):
     if not self._conanfile.should_build:
         return
     make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make"
     with environment_append(vars or self.vars):
         str_args = args_to_string(args)
         cpu_count_option = ("-j%s" % cpu_count()) if "-j" not in str_args else None
         self._conanfile.run("%s" % join_arguments([make_program, target, str_args,
                                                    cpu_count_option]),
                             win_bash=self._win_bash, subsystem=self.subsystem)
Example #4
0
    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):
            command = "cd %s && %s %s" % (args_to_string(
                [self.build_dir]), self._cmake_program, arg_list)
            if platform.system(
            ) == "Windows" and self.generator == "MinGW Makefiles":
                with tools.remove_from_path("sh"):
                    self._run(command)
            else:
                self._run(command)
Example #5
0
 def make(self, args="", make_program=None, target=None):
     if not self._conanfile.should_build:
         return
     make_program = os.getenv(
         "CONAN_MAKE_PROGRAM") or make_program or "make"
     with environment_append(self.vars):
         str_args = args_to_string(args)
         cpu_count_option = ("-j%s" %
                             cpu_count()) if "-j" not in str_args else None
         self._conanfile.run("%s" % join_arguments(
             [make_program, target, str_args, cpu_count_option]),
                             win_bash=self._win_bash,
                             subsystem=self.subsystem)
Example #6
0
    def build(self, args=None, build_dir=None, targets=None):
        if self.backend != "ninja":
            raise ConanException("Build only supported with 'ninja' backend")

        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder

        arg_list = join_arguments([
            "-C %s" % build_dir,
            args_to_string(args),
            args_to_string(targets)
        ])
        command = "ninja %s" % arg_list
        command = self._append_vs_if_needed(command)
        self._conanfile.run(command)
Example #7
0
    def build(self, args=None, build_dir=None, targets=None):
        if not self._conanfile.should_build:
            return
        if self.backend != "ninja":
            raise ConanException("Build only supported with 'ninja' backend")

        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder

        arg_list = join_arguments([
            '-C "%s"' % build_dir,
            args_to_string(args),
            args_to_string(targets)
        ])
        self._run("ninja %s" % arg_list)
Example #8
0
    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 {}

        # overwrite default values with user's inputs
        self.options.update(defs)

        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, self.flags,
            args_to_string(args), 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)
Example #9
0
    def build(self, args=None, build_dir=None, targets=None):
        if not self._conanfile.should_build:
            return
        if self.backend != "ninja":
            raise ConanException("Build only supported with 'ninja' backend")

        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder

        arg_list = join_arguments([
            '-C "%s"' % build_dir,
            args_to_string(args),
            args_to_string(targets)
        ])
        command = "ninja %s" % arg_list
        command = self._append_vs_if_needed(command)
        self._conanfile.run(command)
Example #10
0
    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)
Example #11
0
    def _build_new(self, args=None, build_dir=None, target=None):
        if isinstance(args, ConanFile):
            raise ConanException(deprecated_conanfile_param_message)
        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder
        if target is not None:
            args = ["--target", target] + args

        if self.parallel:
            if "Makefiles" in self.generator:
                if "--" not in args:
                    args.append("--")
                args.append("-j%i" % cpu_count())

        arg_list = join_arguments([
            args_to_string([build_dir]), self.build_config,
            args_to_string(args)
        ])
        command = "cmake --build %s" % arg_list
        self._conanfile.run(command)
Example #12
0
    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 clean_sh_from_path():
                self._conanfile.run(command)
        else:
            self._conanfile.run(command)
Example #13
0
    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)
        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)
Example #14
0
    def build(self, args=None, build_dir=None, target=None):
        args = args or []
        build_dir = build_dir or self.build_dir or self._conanfile.build_folder
        if target is not None:
            args = ["--target", target] + args

        if self.parallel:
            if "Makefiles" in self.generator:
                if "--" not in args:
                    args.append("--")
                args.append("-j%i" % cpu_count())
            elif "Visual Studio" in self.generator:
                if "--" not in args:
                    args.append("--")
                args.append("/m:%i" % cpu_count())

        arg_list = join_arguments([
            args_to_string([build_dir]),
            self.build_config,
            args_to_string(args)
        ])
        command = "cmake --build %s" % arg_list
        self._conanfile.run(command)
Example #15
0
    def command_line(self):
        args = ['-G "%s"' % self.generator] if self.generator else []
        if self.generator_platform:
            if is_generator_platform_supported(self.generator):
                args.append('-A "%s"' % self.generator_platform)
            else:
                raise ConanException(
                    'CMake does not support generator platform with generator "%s:.'
                    'Please check your conan profile to either remove the generator'
                    ' platform, or change the CMake generator.' %
                    self.generator)
        args.append(self.flags)
        args.append('-Wno-dev')

        if self.toolset:
            if is_toolset_supported(self.generator):
                args.append('-T "%s"' % self.toolset)
            else:
                raise ConanException(
                    'CMake does not support toolsets with generator "%s:.'
                    'Please check your conan profile to either remove the toolset,'
                    ' or change the CMake generator.' % self.generator)
        return join_arguments(args)
Example #16
0
    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)
Example #17
0
    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)
Example #18
0
 def command_line(self):
     args = ['-G "%s"' % self.generator, self.flags, '-Wno-dev']
     if self.toolset:
         args.append('-T "%s"' % self.toolset)
     return join_arguments(args)
Example #19
0
 def make(self, args="", make_program=None):
     make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make"
     with environment_append(self.vars):
         str_args = args_to_string(args)
         cpu_count_option = ("-j%s" % cpu_count()) if "-j" not in str_args else None
         self._conanfile.run("%s" % join_arguments([make_program, str_args, cpu_count_option]))