Example #1
0
    def build_requirements(self):
        if self._settings_build.os == "Windows" and not tools.get_env(
                "CONAN_BASH_PATH"):
            if self.settings.arch == 'x86':
                self.build_requires("msys2/20200517")
            else:
                self.build_requires("msys2/20210725")

        if tools.cross_building(self, skip_x64_x86=True) and hasattr(
                self, 'settings_build'):
            self.build_requires("icu/{}".format(self.original_version))
Example #2
0
def _flags_from_env():
    flags_from_env = {}
    if tools.get_env('ASFLAGS'):
        flags_from_env['cpp.assemblerFlags'] = '%s' % (
            _env_var_to_list(tools.get_env('ASFLAGS')))
    if tools.get_env('CFLAGS'):
        flags_from_env['cpp.cFlags'] = '%s' % (
            _env_var_to_list(tools.get_env('CFLAGS')))
    if tools.get_env('CPPFLAGS'):
        flags_from_env['cpp.cppFlags'] = '%s' % (
            _env_var_to_list(tools.get_env('CPPFLAGS')))
    if tools.get_env('CXXFLAGS'):
        flags_from_env['cpp.cxxFlags'] = '%s' % (
            _env_var_to_list(tools.get_env('CXXFLAGS')))
    if tools.get_env('LDFLAGS'):
        parser = LinkerFlagsParser(_env_var_to_list(tools.get_env('LDFLAGS')))
        flags_from_env['cpp.linkerFlags'] = str(parser.linker_flags)
        flags_from_env['cpp.driverLinkerFlags'] = str(
            parser.driver_linker_flags)
    return flags_from_env
Example #3
0
 def _build_autotools(self):
     with tools.chdir(self._source_subfolder):
         self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                  win_bash=tools.os_info.is_windows)
         if self.settings.os == "Android" and tools.os_info.is_windows:
             # remove escape for quotation marks, to make ndk on windows happy
             tools.replace_in_file(
                 "configure", "s/[	 `~#$^&*(){}\\\\|;'\\\''\"<>?]/\\\\&/g",
                 "s/[	 `~#$^&*(){}\\\\|;<>?]/\\\\&/g")
     autotools = self._configure_autotools()
     autotools.make()
Example #4
0
 def build(self):
     environment = {}
     if self.settings.compiler == "Visual Studio":
         environment.update(tools.vcvars_dict(self.settings))
     with tools.environment_append(environment):
         cxx = tools.get_env("CXX")
         self.run("{cxx} {src} -o example".format(cxx=cxx,
                                                  src=os.path.join(
                                                      self.source_folder,
                                                      "example.cpp")),
                  win_bash=self.settings.os is "Windows")
Example #5
0
 def _make_context(self):
     if self._use_nmake:
         # Windows: when cmake generates its cache, it populates some environment variables as well.
         # If cmake also initiates openssl build, their values (containing spaces and forward slashes)
         # break nmake (don't know about mingw make). So we fix them
         def sanitize_env_var(var):
             return '"{}"'.format(var).replace('/', '\\') if '"' not in var else var
         env = {key: sanitize_env_var(tools.get_env(key)) for key in ("CC", "RC") if tools.get_env(key)}
         with tools.environment_append(env):
             yield
     else:
         yield
Example #6
0
 def build(self):
     self._patch_sources()
     if self.settings.compiler == "Visual Studio":
         cmake = self._configure_cmake()
         cmake.build(target="libapr-1" if self.options.shared else "apr-1")
     else:
         if self._should_call_autoreconf:
             with tools.chdir(self._source_subfolder):
                 self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                          win_bash=tools.os_info.is_windows)
         autotools = self._configure_autotools()
         autotools.make()
Example #7
0
 def _make_program(self):
     if self._use_nmake:
         return "nmake"
     make_program = tools.get_env(
         "CONAN_MAKE_PROGRAM",
         tools.which("make") or tools.which("mingw32-make"))
     if not make_program:
         raise Exception(
             'could not find "make" executable. please set "CONAN_MAKE_PROGRAM" environment variable'
         )
     make_program = tools.unix_path(make_program)
     return make_program
Example #8
0
 def build(self):
     for patch in self.conan_data["patches"].get(self.version, []):
         tools.patch(**patch)
     with tools.chdir(self._source_subfolder):
         self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                  run_environment=True,
                  win_bash=tools.os_info.is_windows)
     with self._build_context():
         autotools = self._configure_autotools()
         autotools.make()
         if self.settings.os != "Windows":
             autotools.make(args=["-C", "x86dis"])
Example #9
0
    def build(self):
        self._patch_sources()
        shutil.copy(self.deps_user_info["gnu-config"].CONFIG_SUB,
                    os.path.join(self._source_subfolder, "config.sub"))
        shutil.copy(self.deps_user_info["gnu-config"].CONFIG_GUESS,
                    os.path.join(self._source_subfolder, "config.guess"))

        with self._build_context():
            autotools = self._configure_autotools()
            autotools.make()
            if tools.get_env("CONAN_RUN_TESTS", False):
                autotools.make(target="check")
 def build(self):
     for patch in self.conan_data.get("patches", {}).get(self.version, []):
         tools.patch(**patch)
     if self.settings.os == "Windows":
         cmake = self._configure_cmake()
         cmake.build()
     else:
         with tools.chdir(os.path.join(self._source_subfolder, "c++")):
             self.run("{} --install --verbose -Wall".format(
                 tools.get_env("AUTORECONF")))
         autotools = self._configure_autotools()
         autotools.make()
Example #11
0
 def build(self):
     save(
         self,
         os.path.join(self._source_subfolder, "libkmod", "docs",
                      "gtk-doc.make"), "")
     self.run("{} -fiv".format(tools.get_env("AUTORECONF") or "autoreconf"),
              win_bash=tools.os_info.is_windows,
              run_environment=True,
              cwd=self._source_subfolder)
     autotools = Autotools(self)
     autotools.configure(build_script_folder=self._source_subfolder)
     autotools.make()
Example #12
0
 def build(self):
     for patch in self.conan_data.get("patches", {}).get(self.version, []):
         tools.patch(**patch)
     if self._is_msvc:
         self._build_vs()
     else:
         with tools.chdir(self._source_subfolder):
             self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                      win_bash=tools.os_info.is_windows,
                      run_environment=True)
         autotools = self._configure_autotools()
         autotools.make()
Example #13
0
 def _patch_sources(self):
     if self.settings.os == "Android" and "ANDROID_NDK_HOME" in os.environ:
         shutil.copyfile(
             os.path.join(tools.get_env("ANDROID_NDK_HOME"), "sources",
                          "android", "cpufeatures", "cpu-features.h"),
             os.path.join(self._source_subfolder, "cpu-features.h"))
     for patch in self.conan_data.get("patches", {}).get(self.version, []):
         tools.patch(**patch)
     # Honor fPIC option
     tools.replace_in_file(
         os.path.join(self._source_subfolder, "CMakeLists.txt"),
         "SET(CMAKE_POSITION_INDEPENDENT_CODE 1)", "")
Example #14
0
 def build(self):
     self._validate_dependency_graph()
     self._patch_sources()
     if self.settings.compiler == "Visual Studio":
         self._edit_nmake_opt()
         with self._msvc_build_environment():
             self.run("nmake -f makefile.vc {}".format(" ".join(self._get_nmake_args())))
     else:
         with self._autotools_build_environment():
             self.run("{} -fiv".format(tools.get_env("AUTORECONF")), win_bash=tools.os_info.is_windows)
             autotools = self._configure_autotools()
             autotools.make()
Example #15
0
 def _configure_cmake(self):
     if self._cmake:
         return self._cmake
     generator = None
     if self.settings.compiler == "Visual Studio":
         generator = "NMake Makefiles"
     self._cmake = CMake(self, generator=generator)
     if tools.get_env("CONAN_RUN_TESTS", default=False):
         self._cmake.definitions["INDICATORS_DEMO"] = True
         self._cmake.definitions["INDICATORS_SAMPLES"] = True
     self._cmake.configure()
     return self._cmake
Example #16
0
    def _run_makefile(self, target=None):
        target = target or ""
        autotools = AutoToolsBuildEnvironment(self)
        autotools.libs = []
        if self.settings.os == "Windows" and self.settings.compiler != "Visual Studio":
            autotools.link_flags.append("-lcrypt32")
        if self.settings.os == "Macos" and self.settings.arch == "armv8":
            # FIXME: should be handled by helper
            autotools.link_flags.append("-arch arm64")
        args = autotools.vars
        args.update({
            "PREFIX": self.package_folder,
        })
        if self.settings.compiler != "Visual Studio":
            if tools.get_env("CC"):
                args["CC"] = tools.get_env("CC")
            if tools.get_env("LD"):
                args["LD"] = tools.get_env("LD")
            if tools.get_env("AR"):
                args["AR"] = tools.get_env("AR")

            args["LIBTOOL"] = "libtool"
        arg_str = " ".join("{}=\"{}\"".format(k, v) for k, v in args.items())

        with tools.environment_append(args):
            with tools.chdir(self._source_subfolder):
                if self.settings.compiler == "Visual Studio":
                    if self.options.shared:
                        target = "tommath.dll"
                    else:
                        target = "tommath.lib"
                    with tools.vcvars(self):
                        self.run("nmake -f makefile.msvc {} {}".format(
                            target,
                            arg_str,
                        ), run_environment=True)
                else:
                    if self.settings.os == "Windows":
                        makefile = "makefile.mingw"
                        if self.options.shared:
                            target = "libtommath.dll"
                        else:
                            target = "libtommath.a"
                    else:
                        if self.options.shared:
                            makefile = "makefile.shared"
                        else:
                            makefile = "makefile.unix"
                    self.run("{} -f {} {} {} -j{}".format(
                        tools.get_env("CONAN_MAKE_PROGRAM", "make"),
                        makefile,
                        target,
                        arg_str,
                        tools.cpu_count(),
                    ), run_environment=True)
Example #17
0
    def build(self):
        with tools.chdir(self._source_subfolder):
            if self.settings.compiler == "Visual Studio":
                tools.replace_in_file(
                    "Makefile", "	copy pthreadV*.lib $(LIBDEST)",
                    "	if exist pthreadV*.lib copy pthreadV*.lib $(LIBDEST)")
                tools.replace_in_file(
                    "Makefile", "	copy libpthreadV*.lib $(LIBDEST)",
                    "	if exist libpthreadV*.lib copy libpthreadV*.lib $(LIBDEST)"
                )
                tools.replace_in_file("Makefile", "XCFLAGS=\"/MD\"", "")
                tools.replace_in_file("Makefile", "XCFLAGS=\"/MDd\"", "")
                tools.replace_in_file("Makefile", "XCFLAGS=\"/MT\"", "")
                tools.replace_in_file("Makefile", "XCFLAGS=\"/MTd\"", "")
                target = {
                    "CPP": "VCE",
                    "SEH": "SSE",
                }.get(str(self.options.exception_scheme), "VC")
                if not self.options.shared:
                    target += "-static"
                if self.settings.build_type == "Debug":
                    target += "-debug"
                with tools.vcvars(self.settings):
                    with tools.environment_append(
                            VisualStudioBuildEnvironment(self).vars):
                        self.run("nmake {}".format(target))
            else:
                self.run("{}".format(tools.get_env("AUTOHEADER")),
                         win_bash=tools.os_info.is_windows)
                self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                         win_bash=tools.os_info.is_windows)

                autotools = self._configure_autotools()

                make_target = "GCE" if self.options.exception_scheme == "CPP" else "GC"
                if not self.options.shared:
                    make_target += "-static"
                if self.settings.build_type == "Debug":
                    make_target += "-debug"
                autotools.make(target=make_target, args=["-j1"])
Example #18
0
    def build(self):
        def add_flag(name, value):
            if name in environ:
                environ[name] += ' ' + value
            else:
                environ[name] = value

        extra = "" if self.settings.os == "Windows" or self.options.shared else "extra_inc=big_iron.inc"
        if self.settings.arch == "x86":
            arch = "ia32"
        elif self.settings.arch == "x86_64":
            arch = "intel64"
        elif self.settings.arch == "armv7":
            arch = "armv7"
        elif self.settings.arch == "armv8":
            arch = "aarch64"
        if self.settings.compiler in ['gcc', 'clang', 'apple-clang']:
            if str(self.settings.compiler.libcxx) in [
                    'libstdc++', 'libstdc++11'
            ]:
                extra += " stdlib=libstdc++"
            elif str(self.settings.compiler.libcxx) == 'libc++':
                extra += " stdlib=libc++"
            extra += " compiler=gcc" if self.settings.compiler == 'gcc' else " compiler=clang"

            extra += " gcc_version={}".format(
                str(self.settings.compiler.version))
        make = tools.get_env(
            "CONAN_MAKE_PROGRAM",
            tools.which("make") or tools.which('mingw32-make'))
        if not make:
            raise ConanInvalidConfiguration(
                "This package needs 'make' in the path to build")

        with tools.chdir(self._source_subfolder):
            # intentionally not using AutoToolsBuildEnvironment for now - it's broken for clang-cl
            if self.is_clanglc:
                add_flag('CFLAGS', '-mrtm')
                add_flag('CXXFLAGS', '-mrtm')

            targets = self.get_targets()
            if self.is_msvc:
                # intentionally not using vcvars for clang-cl yet
                with tools.vcvars(self.settings):
                    self.run("%s arch=%s %s %s" %
                             (make, arch, extra, " ".join(targets)))
            elif self.is_mingw:
                self.run("%s arch=%s compiler=gcc %s %s" %
                         (make, arch, extra, " ".join(targets)))
            else:
                self.run("%s arch=%s %s %s" %
                         (make, arch, extra, " ".join(targets)))
Example #19
0
 def build(self):
     cmake = CMake(self)
     defs = {"OE_BUILD_MODE": 0, "OE_BUILD_TESTS": True}
     if self.options.oe_build_mode == "vulkan":
         defs["OE_BUILD_MODE"] = 2
     elif self.options.oe_build_mode == "shaderc":
         defs["OE_BUILD_MODE"] = 1
     defs["OE_BUILD_TESTS"] = self.options.oe_build_tests
     cmake.configure(defs=defs)
     cmake.build()
     if tools.get_env("OE_RUN_TESTS", False):
         self.run("cd tests && ctest -j{} --output-on-failure".format(
             tools.cpu_count()))
Example #20
0
 def test(self):
     if not tools.cross_building(self, skip_x64_x86=True):
         self.run("nasm --version", run_environment=True)
         asm_file = os.path.join(self.source_folder, "hello_linux.asm")
         out_file = os.path.join(self.build_folder, "hello_linux.o")
         bin_file = os.path.join(self.build_folder, "hello_linux")
         self.run("nasm -felf64 {} -o {}".format(asm_file, out_file),
                  run_environment=True)
         if self.settings.os == "Linux" and self.settings.arch == "x86_64":
             ld = tools.get_env("LD", "ld")
             self.run("{} hello_linux.o -o {}".format(ld, bin_file),
                      run_environment=True)
             self.run(bin_file)
Example #21
0
 def build(self):
     with tools.chdir(self._source_subfolder):
         tools.save("help2man", '#!/usr/bin/env bash\n:')
         if os.name == 'posix':
             os.chmod("help2man", os.stat("help2man").st_mode | 0o111)
     self._patch_sources()
     with self._build_context():
         autotools = self._configure_autotools()
         autotools.make()
         if tools.get_env("CONAN_RUN_TESTS", False):
             self.output.info("Running m4 checks...")
             with tools.chdir("tests"):
                 autotools.make(target="check")
Example #22
0
 def build_requirements(self):
     if self._is_using_cmake_build:
         if self._is_win_x_android:
             self.build_requires("ninja/1.10.2")
     else:
         self.build_requires("libtool/2.4.6")
         self.build_requires("pkgconf/1.7.4")
         if tools.os_info.is_windows and not tools.get_env(
                 "CONAN_BASH_PATH"):
             if self.settings.arch == "x86":
                 self.build_requires("msys2/20200517")
             else:
                 self.build_requires("msys2/20210725")
Example #23
0
 def build(self):
     self._patch_sources()
     if self._is_msvc:
         self._build_msvc()
     else:
         with tools.chdir(self._source_subfolder):
             self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
                      win_bash=tools.os_info.is_windows)
             # relocatable shared lib on macOS
             tools.replace_in_file("configure", "-install_name \\$rpath/",
                                   "-install_name @rpath/")
         autotools = self._configure_autotools()
         autotools.make()
Example #24
0
 def build(self):
     for src in self.exports_sources:
         shutil.copy(os.path.join(self.source_folder, src),
                     self.build_folder)
     self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
              run_environment=True,
              win_bash=self._settings_build.os == "Windows")
     with self._build_context():
         autotools = AutoToolsBuildEnvironment(
             self, win_bash=self._settings_build.os == "Windows")
         autotools.libs = []
         autotools.configure()
         autotools.make()
Example #25
0
def build(obj):
    logging.info( "Building native libraries..." )
    cmake = configure(obj)
    cmake.build()
    if obj.options.get_safe("with_unit_tests", default=False):
        env_run = RunEnvironment(obj)
        test_env = env_run.vars
        test_env["DYLD_LIBRARY_PATH"].append( os.path.join( obj.build_folder, "lib" ) )
        test_env["LD_LIBRARY_PATH"].append( os.path.join( obj.build_folder, "lib" ) )
        test_env["GTEST_OUTPUT"] = f"xml:{os.path.join(obj.build_folder,'test_results',obj.module_name)}/"
        logging.info( "Running tests..." )
        ctest_count = tools.get_env("CTEST_REPEAT", 1)
        with tools.environment_append(test_env):
            obj.run( f"ctest --repeat until-fail:{ctest_count} --output-on-failure {'-VV' if obj.verbose else ''}", run_environment=True, cwd=obj.build_folder )
Example #26
0
 def test(self):
     shutil.copy(os.path.join(self.source_folder, "file_to_check.cpp"),
                 os.path.join(self.build_folder, "file_to_check.cpp"))
     if not tools.cross_building(self.settings):
         self.run(
             "cppcheck --enable=warning,style,performance --std=c++11 .",
             cwd=self.source_folder,
             run_environment=True)
         # On windows we need to explicitly use python to run the python script
         if self.settings.os == 'Windows':
             self.run("{} {} -h".format(
                 sys.executable, tools.get_env("CPPCHECK_HTMLREPORT")))
         else:
             self.run("cppcheck-htmlreport -h", run_environment=True)
Example #27
0
 def configure(self):
     if self.settings.os == "Macos":
         raise ConanInvalidConfiguration("pdcurses does not support Macos")
     if self.settings.os == "Linux":
         if not tools.get_env("PDCURSES_OVERRIDE_X11", False):
             raise ConanInvalidConfiguration(
                 "conan-center-index has no packages for X11 (yet)")
     if self.options.with_sdl:
         raise ConanInvalidConfiguration(
             "conan-center-index has no packages for sdl2 (yet)")
     if self.options.shared:
         del self.options.fPIC
     del self.settings.compiler.cppstd
     del self.settings.compiler.libcxx
Example #28
0
    def package(self):
        self.copy(pattern="LICENSE*", dst="licenses", src=self._source_subfolder)
        self.copy(pattern="COPYRIGHT", dst="licenses", src=self._source_subfolder)
        with self._build_context():
            autotools = self._configure_autotools()
            autotools.install()

        if self.settings.compiler != "Visual Studio":
            with tools.chdir(os.path.join(self.package_folder, "bin")):
                strip = (tools.get_env("STRIP") or tools.which("strip")).replace("\\", "/")
                ext = ".exe" if tools.os_info.is_windows else ""
                if strip:
                    self.run("{} swig{}".format(strip, ext), win_bash=tools.os_info.is_windows)
                    self.run("{} ccache-swig{}".format(strip, ext), win_bash=tools.os_info.is_windows)
Example #29
0
 def build(self):
     for src in self.exports_sources:
         shutil.copy(os.path.join(self.source_folder, src),
                     os.path.join(self.build_folder, src))
     self.run("{} -fiv".format(tools.get_env("AUTORECONF")),
              run_environment=True,
              win_bash=tools.os_info.is_windows)
     autotools = AutoToolsBuildEnvironment(
         self, win_bash=tools.os_info.is_windows)
     args = [
         "--enable-option-checking=fatal",
         "--enable-gtk-doc=no",
     ]
     autotools.configure(args=args)
Example #30
0
    def _build_with_autotools(self):
        with tools.chdir(self._source_subfolder):
            # autoreconf
            self.run("{} -fiv".format(tools.get_env("AUTORECONF") or "autoreconf"), win_bash=tools.os_info.is_windows, run_environment=True)

            # fix generated autotools files on alle to have relocateable binaries
            if tools.is_apple_os(self.settings.os):
                tools.replace_in_file("configure", "-install_name \\$rpath/", "-install_name ")

            self.run("chmod +x configure")

            # run configure with *LD_LIBRARY_PATH env vars it allows to pick up shared openssl
            with tools.run_environment(self):
                autotools, autotools_vars = self._configure_autotools()
                autotools.make(vars=autotools_vars)
Example #31
0
 def get_env_unit_test(self):
     """
     Unit tests tools.get_env
     """
     # Test default
     self.assertIsNone(
         tools.get_env("NOT_DEFINED", environment={}),
         None
     )
     # Test defined default
     self.assertEqual(
         tools.get_env("NOT_DEFINED_KEY", default="random_default", environment={}),
         "random_default"
     )
     # Test return defined string
     self.assertEqual(
         tools.get_env("FROM_STR", default="", environment={"FROM_STR": "test_string_value"}),
         "test_string_value"
     )
     # Test boolean conversion
     self.assertEqual(
         tools.get_env("BOOL_FROM_STR", default=False, environment={"BOOL_FROM_STR": "1"}),
         True
     )
     self.assertEqual(
         tools.get_env("BOOL_FROM_STR", default=True, environment={"BOOL_FROM_STR": "0"}),
         False
     )
     self.assertEqual(
         tools.get_env("BOOL_FROM_STR", default=False, environment={"BOOL_FROM_STR": "True"}),
         True
     )
     self.assertEqual(
         tools.get_env("BOOL_FROM_STR", default=True, environment={"BOOL_FROM_STR": ""}),
         False
     )
     # Test int conversion
     self.assertEqual(
         tools.get_env("TO_INT", default=2, environment={"TO_INT": "1"}),
         1
     )
     # Test float conversion
     self.assertEqual(
         tools.get_env("TO_FLOAT", default=2.0, environment={"TO_FLOAT": "1"}),
         1.0
     ),
     # Test list conversion
     self.assertEqual(
         tools.get_env("TO_LIST", default=[], environment={"TO_LIST": "1,2,3"}),
         ["1", "2", "3"]
     )
     self.assertEqual(
         tools.get_env("TO_LIST_NOT_TRIMMED", default=[], environment={"TO_LIST_NOT_TRIMMED": " 1 , 2 , 3 "}),
         ["1", "2", "3"]
     )