Esempio n. 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.generator and 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._run(command)
Esempio n. 2
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)
Esempio n. 3
0
File: cmake.py Progetto: zesem/conan
    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)
Esempio n. 4
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.generator and self.parallel:
            compiler_version = self._settings.get_safe("compiler.version")
            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 \
                    compiler_version and Version(compiler_version) >= "10":
                if "--" not in args:
                    args.append("--")
                # Parallel for building projects in the solution
                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._run(command)
Esempio n. 5
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)
Esempio n. 6
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):
        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)
Esempio n. 7
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)
Esempio n. 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):
        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)
Esempio n. 9
0
    def generate_args(self):
        configure_args = []
        configure_args.extend(self.configure_args)
        user_args_str = args_to_string(self.configure_args)
        for flag, var in (("host", self._host), ("build", self._build),
                          ("target", self._target)):
            if var and flag not in user_args_str:
                configure_args.append('--{}={}'.format(flag, var))

        args = {
            "configure_args": args_to_string(configure_args),
            "make_args": args_to_string(self.make_args),
            "autoreconf_args": args_to_string(self.autoreconf_args)
        }

        save_toolchain_args(args, namespace=self._namespace)
Esempio n. 10
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]),
                             win_bash=self._win_bash)
Esempio n. 11
0
    def configure(self,
                  configure_dir=None,
                  args=None,
                  build=None,
                  host=None,
                  target=None,
                  pkg_config_paths=None):
        """
        :param pkg_config_paths: Optional paths to locate the *.pc files
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.  "False" skips the --target flag
                       When the tool chain generates executable program, in which target system the program will run.
        :return: None

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

        """
        if configure_dir:
            configure_dir = configure_dir.rstrip("/")
        else:
            configure_dir = "."
        auto_build, auto_host, auto_target = None, None, None
        if build is None or host is None or target is None:
            auto_build, auto_host, auto_target = self._get_host_build_target_flags(
                detected_architecture(), platform.system())

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or auto_build:  # User specified value or automatic
                triplet_args.append("--build=%s" % (build or auto_build))

        if host is not False:  # Skipped by user
            if host or auto_host:  # User specified value or automatic
                triplet_args.append("--host=%s" % (host or auto_host))

        if target is not False:  # Skipped by user
            if target or auto_target:  # User specified value or automatic
                triplet_args.append("--target=%s" % (target or auto_target))

        if pkg_config_paths:
            pkg_env = {"PKG_CONFIG_PATH": os.pathsep.join(pkg_config_paths)}
        else:
            # If we are using pkg_config generator automate the pcs location, otherwise it could
            # read wrong files
            pkg_env = {"PKG_CONFIG_PATH": self._conanfile.build_folder} \
                if "pkg_config" in self._conanfile.generators else {}

        with environment_append(pkg_env):
            with environment_append(self.vars):
                configure_dir = self._adjust_path(configure_dir)
                self._conanfile.run('%s/configure %s %s' %
                                    (configure_dir, args_to_string(args),
                                     " ".join(triplet_args)),
                                    win_bash=self._win_bash,
                                    subsystem=self.subsystem)
Esempio n. 12
0
    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)
Esempio n. 13
0
 def autoreconf(self, args=None):
     args = args or []
     command = join_arguments(
         ["autoreconf", self._autoreconf_args,
          args_to_string(args)])
     with chdir(self, self._conanfile.source_folder):
         self._conanfile.run(command)
Esempio n. 14
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)
Esempio n. 15
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)
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
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)
    def generate_args(self):
        configure_args = []
        configure_args.extend(self.configure_args)

        if self.default_configure_install_args:
            # If someone want arguments but not the defaults can pass them in args manually
            configure_args.extend(
                    ["--prefix=%s" % self._conanfile.package_folder.replace("\\", "/"),
                     "--bindir=${prefix}/bin",
                     "--sbindir=${prefix}/bin",
                     "--libdir=${prefix}/lib",
                     "--includedir=${prefix}/include",
                     "--oldincludedir=${prefix}/include",
                     "--datarootdir=${prefix}/share"])
        user_args_str = args_to_string(self.configure_args)
        for flag, var in (("host", self._host), ("build", self._build), ("target", self._target)):
            if var and flag not in user_args_str:
                configure_args.append('--{}={}'.format(flag, var))

        args = {"configure_args": args_to_string(configure_args),
                "make_args":  args_to_string(self.make_args)}

        save_toolchain_args(args)
Esempio n. 20
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)
Esempio n. 21
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(
                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)
Esempio n. 22
0
    def configure(self,
                  configure_dir=None,
                  args=None,
                  build=None,
                  host=None,
                  target=None):
        """
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.  "False" skips the --target flag
                       When the tool chain generates executable program, in which target system the program will run.
        :return: None

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

        """
        configure_dir = configure_dir or "./"
        auto_build, auto_host, auto_target = None, None, None
        if build is None or host is None or target is None:
            auto_build, auto_host, auto_target = self._get_host_build_target_flags(
                detected_architecture(), platform.system())

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or auto_build:  # User specified value or automatic
                triplet_args.append("--build %s" % (build or auto_build))

        if host is not False:  # Skipped by user
            if host or auto_host:  # User specified value or automatic
                triplet_args.append("--host %s" % (host or auto_host))

        if target is not False:  # Skipped by user
            if target or auto_target:  # User specified value or automatic
                triplet_args.append("--target %s" % (target or auto_target))

        with environment_append(self.vars):
            self._conanfile.run(
                "%sconfigure %s %s" %
                (configure_dir, args_to_string(args), " ".join(triplet_args)))
Esempio n. 23
0
    def configure(self, build_script_folder=None, args=None):
        """
        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
        """
        script_folder = os.path.join(self._conanfile.source_folder, build_script_folder) \
            if build_script_folder else self._conanfile.source_folder

        configure_args = []
        configure_args.extend(args or [])

        self._configure_args = "{} {}".format(self._configure_args,
                                              args_to_string(configure_args))

        configure_cmd = "{}/configure".format(script_folder)
        subsystem = deduce_subsystem(self._conanfile, scope="build")
        configure_cmd = subsystem_path(subsystem, configure_cmd)
        cmd = '"{}" {}'.format(configure_cmd, self._configure_args)
        self._conanfile.output.info("Calling:\n > %s" % cmd)
        self._conanfile.run(cmd)
Esempio n. 24
0
    def configure(self, configure_dir=None, args=None, build=None, host=None, target=None):
        """
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.  "False" skips the --target flag
                       When the tool chain generates executable program, in which target system the program will run.
        :return: None

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

        """
        if configure_dir:
            configure_dir = configure_dir.rstrip("/")
        else:
            configure_dir = "."
        auto_build, auto_host, auto_target = None, None, None
        if build is None or host is None or target is None:
            auto_build, auto_host, auto_target = self._get_host_build_target_flags(detected_architecture(),
                                                                                   platform.system())

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or auto_build:  # User specified value or automatic
                triplet_args.append("--build %s" % (build or auto_build))

        if host is not False:   # Skipped by user
            if host or auto_host:  # User specified value or automatic
                triplet_args.append("--host %s" % (host or auto_host))

        if target is not False:  # Skipped by user
            if target or auto_target:  # User specified value or automatic
                triplet_args.append("--target %s" % (target or auto_target))

        with environment_append(self.vars):
            self._conanfile.run("%s/configure %s %s"
                                % (configure_dir, args_to_string(args), " ".join(triplet_args)))
Esempio n. 25
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)
Esempio n. 26
0
 def make(self, args=""):
     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 ""
         self._conanfile.run("make %s %s" % (str_args, cpu_count_option))
Esempio n. 27
0
 def make(self, args=""):
     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 ""
         self._conanfile.run("make %s %s" % (str_args, cpu_count_option))
Esempio n. 28
0
    def configure(self,
                  configure_dir=None,
                  args=None,
                  build=None,
                  host=None,
                  target=None,
                  pkg_config_paths=None,
                  vars=None,
                  use_default_install_dirs=True):
        """
        :param pkg_config_paths: Optional paths to locate the *.pc files
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.
                       "False" skips the --target flag
                       When the tool chain generates executable program, in which target system
                       the program will run.

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
        :param use_default_install_dirs: Use or not the defaulted installation dirs

        """
        if not self._conanfile.should_configure:
            return
        if configure_dir:
            configure_dir = configure_dir.rstrip("/")
        else:
            configure_dir = "."

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or self.build:  # User specified value or automatic
                triplet_args.append("--build=%s" % (build or self.build))

        if host is not False:  # Skipped by user
            if host or self.host:  # User specified value or automatic
                triplet_args.append("--host=%s" % (host or self.host))

        if target is not False:  # Skipped by user
            if target or self.target:  # User specified value or automatic
                triplet_args.append("--target=%s" % (target or self.target))

        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
            pkg_env = {"PKG_CONFIG_PATH": [self._conanfile.install_folder]} \
                if "pkg_config" in self._conanfile.generators else {}

        configure_dir = self._adjust_path(configure_dir)

        if self._conanfile.package_folder is not None:
            if not args:
                args = [
                    "--prefix=%s" %
                    self._conanfile.package_folder.replace("\\", "/")
                ]
            elif not self._is_flag_in_args("prefix", args):
                args.append("--prefix=%s" %
                            self._conanfile.package_folder.replace("\\", "/"))

            all_flags = [
                "bindir", "sbin", "libexec", "libdir", "includedir",
                "oldincludedir", "datarootdir"
            ]
            help_output = self._configure_help_output(configure_dir)
            available_flags = [
                flag for flag in all_flags if "--%s" % flag in help_output
            ]

            if use_default_install_dirs:
                for varname in ["bindir", "sbin", "libexec"]:
                    if self._valid_configure_flag(varname, args,
                                                  available_flags):
                        args.append("--%s=${prefix}/%s" %
                                    (varname, DEFAULT_BIN))
                if self._valid_configure_flag("libdir", args, available_flags):
                    args.append("--libdir=${prefix}/%s" % DEFAULT_LIB)
                for varname in ["includedir", "oldincludedir"]:
                    if self._valid_configure_flag(varname, args,
                                                  available_flags):
                        args.append("--%s=${prefix}/%s" %
                                    (varname, DEFAULT_INCLUDE))
                if self._valid_configure_flag("datarootdir", args,
                                              available_flags):
                    args.append("--datarootdir=${prefix}/%s" % DEFAULT_RES)

        with environment_append(pkg_env):
            with environment_append(vars or self.vars):
                command = '%s/configure %s %s' % (configure_dir,
                                                  args_to_string(args),
                                                  " ".join(triplet_args))
                self._conanfile.output.info("Calling:\n > %s" % command)
                self._conanfile.run(command,
                                    win_bash=self._win_bash,
                                    subsystem=self.subsystem)
Esempio n. 29
0
    def configure(self, configure_dir=None, args=None, build=None, host=None, target=None,
                  pkg_config_paths=None, vars=None):
        """
        :param pkg_config_paths: Optional paths to locate the *.pc files
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.
                       "False" skips the --target flag
                       When the tool chain generates executable program, in which target system
                       the program will run.
        :return: None

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

        """
        if not self._conanfile.should_configure:
            return
        if configure_dir:
            configure_dir = configure_dir.rstrip("/")
        else:
            configure_dir = "."

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or self.build:  # User specified value or automatic
                triplet_args.append("--build=%s" % (build or self.build))

        if host is not False:   # Skipped by user
            if host or self.host:  # User specified value or automatic
                triplet_args.append("--host=%s" % (host or self.host))

        if target is not False:  # Skipped by user
            if target or self.target:  # User specified value or automatic
                triplet_args.append("--target=%s" % (target or self.target))

        if pkg_config_paths:
            pkg_env = {"PKG_CONFIG_PATH": os.pathsep.join(pkg_config_paths)}
        else:
            # If we are using pkg_config generator automate the pcs location, otherwise it could
            # read wrong files
            pkg_env = {"PKG_CONFIG_PATH": self._conanfile.build_folder} \
                if "pkg_config" in self._conanfile.generators else {}

        if self._conanfile.package_folder is not None:
            if not args:
                args = ["--prefix=%s" % self._conanfile.package_folder.replace("\\", "/")]
            elif not any(["--prefix=" in arg for arg in args]):
                args.append("--prefix=%s" % self._conanfile.package_folder.replace("\\", "/"))

        with environment_append(pkg_env):
            with environment_append(vars or self.vars):
                configure_dir = self._adjust_path(configure_dir)
                command = '%s/configure %s %s' % (configure_dir,
                                                  args_to_string(args), " ".join(triplet_args))
                self._conanfile.output.info("Calling:\n > %s" % command)
                self._conanfile.run(command,
                                    win_bash=self._win_bash,
                                    subsystem=self.subsystem)
Esempio n. 30
0
    def configure(self, configure_dir=None, args=None, build=None, host=None, target=None,
                  pkg_config_paths=None, vars=None):
        """
        :param pkg_config_paths: Optional paths to locate the *.pc files
        :param configure_dir: Absolute or relative path to the configure script
        :param args: Optional arguments to pass to configure.
        :param build: In which system the program will be built. "False" skips the --build flag
        :param host: In which system the generated program will run.  "False" skips the --host flag
        :param target: This option is only used to build a cross-compiling toolchain.
                       "False" skips the --target flag
                       When the tool chain generates executable program, in which target system
                       the program will run.
        :return: None

        http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
        https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html

        """
        if not self._conanfile.should_configure:
            return
        if configure_dir:
            configure_dir = configure_dir.rstrip("/")
        else:
            configure_dir = "."

        triplet_args = []

        if build is not False:  # Skipped by user
            if build or self.build:  # User specified value or automatic
                triplet_args.append("--build=%s" % (build or self.build))

        if host is not False:   # Skipped by user
            if host or self.host:  # User specified value or automatic
                triplet_args.append("--host=%s" % (host or self.host))

        if target is not False:  # Skipped by user
            if target or self.target:  # User specified value or automatic
                triplet_args.append("--target=%s" % (target or self.target))

        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
            pkg_env = {"PKG_CONFIG_PATH": self._conanfile.install_folder} \
                if "pkg_config" in self._conanfile.generators else {}

        if self._conanfile.package_folder is not None:
            if not args:
                args = ["--prefix=%s" % self._conanfile.package_folder.replace("\\", "/")]
            elif not any(["--prefix=" in arg for arg in args]):
                args.append("--prefix=%s" % self._conanfile.package_folder.replace("\\", "/"))

        with environment_append(pkg_env):
            with environment_append(vars or self.vars):
                configure_dir = self._adjust_path(configure_dir)
                command = '%s/configure %s %s' % (configure_dir,
                                                  args_to_string(args), " ".join(triplet_args))
                self._conanfile.output.info("Calling:\n > %s" % command)
                self._conanfile.run(command,
                                    win_bash=self._win_bash,
                                    subsystem=self.subsystem)