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)
def _build_mingw(self, args): env_build = AutoToolsBuildEnvironment(self) env = {'PATH': ['%s/bin' % self.conanfile_directory, '%s/qtbase/bin' % self.conanfile_directory, '%s/gnuwin32/bin' % self.conanfile_directory, '%s/qtrepotools/bin' % self.conanfile_directory], 'QMAKESPEC': 'win32-g++'} env.update(env_build.vars) with tools.environment_append(env): # Workaround for configure using clang first if in the path new_path = [] for item in os.environ['PATH'].split(';'): if item != 'C:\\Program Files\\LLVM\\bin': new_path.append(item) os.environ['PATH'] = ';'.join(new_path) # end workaround args += ["-developer-build", "-opengl %s" % self.options.opengl, "-platform win32-g++"] self.output.info("Using '%s' threads" % str(cpu_count())) self.run("cd %s && configure.bat %s" % (self.source_dir, " ".join(args))) self.run("cd %s && mingw32-make -j %s" % (self.source_dir, str(cpu_count()))) self.run("cd %s && mingw32-make install" % (self.source_dir))
def _build_unix(self, args): if self.settings.os == "Linux": args += ["-silent", "-xcb"] if self.settings.arch == "x86": args += ["-platform linux-g++-32"] else: args += ["-silent", "-no-framework"] if self.settings.arch == "x86": args += ["-platform macx-clang-32"] self.output.info("Using '%s' threads" % str(cpu_count())) self.run("cd %s && ./configure %s" % (self.source_dir, " ".join(args))) self.run("cd %s && make -j %s" % (self.source_dir, str(cpu_count()))) self.run("cd %s && make install" % (self.source_dir))
def test_deprecated_behaviour(self): """"Remove when deprecate the old settings parameter to CMake and conanfile to configure/build/test""" settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.compiler = "Visual Studio" settings.compiler.version = "12" settings.arch = "x86" settings.os = "Windows" dot_dir = "." if sys.platform == 'win32' else "'.'" cross = "-DCMAKE_SYSTEM_NAME=\"Windows\" " if platform.system() != "Windows" else "" conan_file = ConanFileMock() conan_file.settings = settings cmake = CMake(settings) cmake.configure(conan_file) cores = '-DCONAN_CXX_FLAGS="/MP{0}" -DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count()) self.assertEqual('cd {0} && cmake -G "Visual Studio 12 2013" {1}-DCONAN_EXPORTED="1" ' '-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" {2}' '-Wno-dev {0}'.format(dot_dir, cross, cores), conan_file.command) cmake.build(conan_file) self.assertEqual('cmake --build %s' % dot_dir, conan_file.command) cmake.test() self.assertEqual('cmake --build %s %s' % (dot_dir, CMakeTest.scape('--target RUN_TESTS')), conan_file.command)
def parallel_test(self): command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True, build_type='Debug', arch='armv7', parallel=False) self.assertIn('msbuild dummy.sln', command) self.assertIn('/p:Platform="ARM"', command) self.assertIn('devenv dummy.sln /upgrade', command) self.assertNotIn('/m:%s' % cpu_count(), command) self.assertNotIn('/target:teapot', command)
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)
def _build_msvc(self, args): build_command = find_executable("jom.exe") if build_command: build_args = ["-j", str(cpu_count())] else: build_command = "nmake.exe" build_args = [] self.output.info("Using '%s %s' to build" % (build_command, " ".join(build_args))) env = {} env.update({'PATH': ['%s/qtbase/bin' % self.conanfile_directory, '%s/gnuwin32/bin' % self.conanfile_directory, '%s/qtrepotools/bin' % self.conanfile_directory]}) # it seems not enough to set the vcvars for older versions if self.settings.compiler == "Visual Studio": if self.settings.compiler.version == "14": env.update({'QMAKESPEC': 'win32-msvc2015'}) args += ["-platform win32-msvc2015"] if self.settings.compiler.version == "12": env.update({'QMAKESPEC': 'win32-msvc2013'}) args += ["-platform win32-msvc2013"] if self.settings.compiler.version == "11": env.update({'QMAKESPEC': 'win32-msvc2012'}) args += ["-platform win32-msvc2012"] if self.settings.compiler.version == "10": env.update({'QMAKESPEC': 'win32-msvc2010'}) args += ["-platform win32-msvc2010"] env_build = VisualStudioBuildEnvironment(self) env.update(env_build.vars) # Workaround for conan-io/conan#1408 for name, value in env.items(): if not value: del env[name] with tools.environment_append(env): vcvars = tools.vcvars_command(self.settings) args += ["-opengl %s" % self.options.opengl] if self.options.openssl == "no": args += ["-no-openssl"] elif self.options.openssl == "yes": args += ["-openssl"] else: args += ["-openssl-linked"] self.run("cd %s && %s && set" % (self.source_dir, vcvars)) self.run("cd %s && %s && configure %s" % (self.source_dir, vcvars, " ".join(args))) self.run("cd %s && %s && %s %s" % (self.source_dir, vcvars, build_command, " ".join(build_args))) self.run("cd %s && %s && %s install" % (self.source_dir, vcvars, build_command))
def check(text, build_config, generator=None): os = str(settings.os) for cmake_system_name in (True, False): cross = ("-DCMAKE_SYSTEM_NAME=\"%s\" -DCMAKE_SYSROOT=\"/path/to/sysroot\" " % {"Macos": "Darwin"}.get(os, os) if (platform.system() != os and cmake_system_name) else "") cmake = CMake(conan_file, generator=generator, cmake_system_name=cmake_system_name) new_text = text.replace("-DCONAN_EXPORTED", "%s-DCONAN_EXPORTED" % cross) if "Visual Studio" in text: cores = ('-DCONAN_CXX_FLAGS="/MP{0}" ' '-DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count())) new_text = new_text.replace("-Wno-dev", "%s-Wno-dev" % cores) self.assertEqual(new_text, cmake.command_line) self.assertEqual(build_config, cmake.build_config)
def upgrade_test(self): command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True, build_type='Debug', arch='x86_64', parallel=False) self.assertIn('msbuild dummy.sln', command) self.assertIn('/p:Platform="x64"', command) self.assertIn('devenv dummy.sln /upgrade', command) self.assertNotIn('/m:%s' % cpu_count(), command) self.assertNotIn('/target:teapot', command) with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "1"}): command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True, build_type='Debug', arch='x86_64', parallel=False) self.assertIn('msbuild dummy.sln', command) self.assertIn('/p:Platform="x64"', command) self.assertNotIn('devenv dummy.sln /upgrade', command) self.assertNotIn('/m:%s' % cpu_count(), command) self.assertNotIn('/target:teapot', command) with tools.environment_append({"CONAN_SKIP_VS_PROJECTS_UPGRADE": "False"}): command = build_sln_command(Settings({}), sln_path='dummy.sln', targets=None, upgrade_project=True, build_type='Debug', arch='x86_64', parallel=False) self.assertIn('devenv dummy.sln /upgrade', command)
def _build_cygwin_msvc(self): self.cfg['platform'] = 'Cygwin/MSVC' if 'CYGWIN_ROOT' not in os.environ: raise Exception("CYGWIN_ROOT environment variable must be set.") else: self.output.info("Using Cygwin from: " + os.environ["CYGWIN_ROOT"]) os.environ['PATH'] = os.path.join(os.environ['CYGWIN_ROOT'], 'bin') + os.pathsep + \ os.path.join(os.environ['CYGWIN_ROOT'], 'usr', 'bin') + os.pathsep + \ os.environ['PATH'] os.mkdir(self.cfg['build_dir']) self.output.info("Starting configuration.") config_cmd = self.build_config_cmd() self.run("{vccmd} && cd {builddir} && bash -c '{config_cmd}'".format( vccmd=self.cfg['vccmd'], builddir=self.cfg['build_dir'], config_cmd=config_cmd)) self.output.info("Starting built.") self.run( "{vccmd} && cd {builddir} && make {silent} -j {cpus_var}".format( vccmd=self.cfg['vccmd'], builddir=self.cfg['build_dir'], silent=self.cfg['silent'], cpus_var=tools.cpu_count())) if self.options.with_unit_tests: self.run("{vccmd} && cd {builddir} && make {silent} check".format( vccmd=self.cfg['vccmd'], builddir=self.cfg['build_dir'], silent=self.cfg['silent'])) self.run("{vccmd} && cd {builddir} && make {silent} install".format( vccmd=self.cfg['vccmd'], builddir=self.cfg['build_dir'], silent=self.cfg['silent']))
def build_unix(self): # Enable compiler interposition under Linux to enforce the correct flags for libc++ from libcxx import LibCxx LibCxx.set_vars(self) # Run autogen.sh self.run("./autogen.sh") # Patch out iconv support under Linux, since the UE4 bundled toolchain doesn't include it if self.settings.os == "Linux": tools.replace_in_file("./configure", "iconv.h", "iconv_h") # Under Linux, the UE4-bundled version of zlib is typically named libz_fPIC.a, but GDAL expects libz.a zlibName = self.deps_cpp_info["zlib"].libs[0] if zlibName != "z": tools.replace_in_file("./configure", "-lz", "-l{}".format(zlibName)) # Patch the check for GEOS so that it works nicely with a static GEOS library tools.replace_in_file( "./configure", "GEOS_LIBS=\"`${GEOS_CONFIG} --ldflags` -lgeos_c\"", "GEOS_LIBS=\"`${GEOS_CONFIG} --static-clibs` -lpthread\"" ) # Patch all linker checks to use CXX instead of CC, since otherwise the check for -lgeos_c fails with undefined references to C++ standard library symbols tools.replace_in_file( "./configure", "ac_link='$CC", "ac_link='$CXX" ) # Prepare the autotools build environment autotools = AutoToolsBuildEnvironment(self) LibCxx.fix_autotools(autotools) # Build using autotools autotools.configure(args=self.configure_flags()) autotools.make(args=["-j{}".format(tools.cpu_count())]) autotools.make(target="install")
def build_gcc(self, flags): flags.append("-icu") flags.append("-optimized-qmake") flags.append("-no-glib") flags.append("-eglfs") flags.append("-xcb-xlib") flags.append("-qt-xcb") flags.append("-no-journald") flags.append("-no-syslog") flags.append("-no-kms") flags.append("-no-gbm") flags.append("-no-directfb") flags.append("-no-linuxfb") flags.append("-no-mirclient") flags.append("-no-libinput") flags.append("-no-tslib") flags.append("-no-dbus") flags.append("-no-openssl") # root_gstreamer = self.deps_cpp_info["gstreamer"].rootpath # root_gst_plugins_base = self.deps_cpp_info["gst-plugins-base"].rootpath # flags.append("-I %s/include/" % root_gstreamer) # flags.append("-I %s/include/gstreamer-1.0" % root_gstreamer) # flags.append("-I %s/include/" % root_gst_plugins_base) # flags.append("-I %s/include/gstreamer-1.0" % root_gst_plugins_base) # flags.append("-gstreamer 1.0") flags = " ".join(flags) with tools.environment_append({}): # "LD_RUN_PATH" : "%s/lib:%s/lib" % (root_gstreamer, root_gst_plugins_base), # "PKG_CONFIG_PATH" : "%s/lib/pkgconfig:%s/lib/pkgconfig" % (root_gstreamer, root_gst_plugins_base), # "GST_PLUGIN_PATH" : "%s/lib/gstreamer-1.0:%s/lib/gstreamer-1.0" % (root_gstreamer, root_gst_plugins_base) self.run("cd %s && ./configure %s" % (self.build_dir, flags)) self.run("cd %s && make -j%s" % (self.build_dir, tools.cpu_count())) self.run("cd %s && make install" % self.build_dir)
def build(self): cmake = self._configure_cmake() if self.settings.compiler == 'gcc': cmake.definitions["CMAKE_C_COMPILER"] = "gcc-{}".format( self.settings.compiler.version) cmake.definitions["CMAKE_CXX_COMPILER"] = "g++-{}".format( self.settings.compiler.version) #cmake.definitions["CMAKE_TOOLCHAIN_FILE"] = 'conan_paths.cmake' # The CMakeLists.txt file must be in `source_folder` cmake.configure(source_folder=".") cpu_count = tools.cpu_count() self.output.info('Detected %s CPUs' % (cpu_count)) # -j flag for parallel builds cmake.build(args=["--", "-j%s" % cpu_count]) if self.options.enable_tests: self.output.info('Running tests') self.run('ctest --parallel %s' % (cpu_count))
def check(text, build_config, generator=None): os = str(settings.os) for cmake_system_name in (True, False): cross = ( "-DCMAKE_SYSTEM_NAME=\"%s\" -DCMAKE_SYSROOT=\"/path/to/sysroot\" " % { "Macos": "Darwin" }.get(os, os) if (platform.system() != os and cmake_system_name) else "") cmake = CMake(conan_file, generator=generator, cmake_system_name=cmake_system_name) new_text = text.replace("-DCONAN_EXPORTED", "%s-DCONAN_EXPORTED" % cross) if "Visual Studio" in text: cores = ('-DCONAN_CXX_FLAGS="/MP{0}" ' '-DCONAN_C_FLAGS="/MP{0}" '.format( tools.cpu_count())) new_text = new_text.replace("-Wno-dev", "%s-Wno-dev" % cores) self.assertEqual(new_text, cmake.command_line) self.assertEqual(build_config, cmake.build_config)
def build(self): flags = "--disable-documentation" if self.options.shared: flags += " --enable-shared --disable-static" else: flags += " --disable-shared --enable-static" make_options = os.getenv("MAKEOPTS") or "" if not re.match("/[^A-z-a-z_-]-j", make_options): cpucount = tools.cpu_count() make_options += " -j %s" % cpucount # configure self.run( ". ./activate_build.* && cd libpqxx-%s && ./configure --prefix=%s %s" % (self.version, self.package_folder, flags), run_environment=True) # build self.run(". ./activate_build.* && cd libpqxx-%s && make %s" % (self.version, make_options), run_environment=True)
def build(self): cmake = CMake(self) finished_package = os.getcwd() + "/pkg" make_options = os.getenv("MAKEOPTS") or "" if not re.match("/[^A-z-a-z_-]-j", make_options): cpucount = tools.cpu_count() make_options += " -j %s" % (cpucount * 2) # cmake self.run('mkdir -p pkg && mkdir -p build') self.run( 'cd build && cmake %s -DCMAKE_SKIP_BUILD_RPATH=FALSE ' % cmake.command_line + '-DBUILD_SHARED_LIBS:BOOL=%s' % ("TRUE" if self.options.shared else "FALSE") + '-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE -DCMAKE_INSTALL_RPATH="%s/lib" ' % finished_package + '-DCMAKE_INSTALL_PREFIX:PATH="%s" -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -f ../' % finished_package) # build self.run("cd build && make %s install" % make_options)
def build_unix(self): env_build = AutoToolsBuildEnvironment(self) env_build.fpic = self.options.shared with tools.environment_append(env_build.vars): configure_command = "./configure" configure_command += " --prefix=" + self.build_folder + "/buildinstall" configure_command += " --with-apr=" + self.deps_cpp_info[ "apache-apr"].rootpath configure_command += " --with-expat=" + self.deps_cpp_info[ "expat"].rootpath # How to enable shared util builds # configure_command += " --enable-shared=" + ("yes" if self.options.shared else "no") # configure_command += " --enable-static=" + ("yes" if not self.options.shared else "no") # add with-ssl flag? with tools.chdir(self.source_subfolder): self.run(configure_command) self.run("find ./") self.run("make -j " + str(max(tools.cpu_count() - 1, 1))) self.run("make install")
def unix_build(self): build_env = { "CFLAGS": "-fPIC -fexceptions -fvisibility=hidden", "CXXFLAGS": "-fPIC -fexceptions -fvisibility=hidden -Wno-ctor-dtor-privacy -std=c++14" } if self.settings.build_type == "Debug": build_env["CFLAGS"] = "-Og -g -ggdb " + build_env["CFLAGS"] build_env["CXXFLAGS"] = "-Og -g -ggdb " + build_env["CXXFLAGS"] else: build_env["CFLAGS"] = "-O3 -DNDEBUG" + build_env["CFLAGS"] build_env["CXXFLAGS"] = "-O3 -DNDEBUG" + build_env["CXXFLAGS"] if self.settings.arch == "x86_64": build_env["CFLAGS"] = "-m64 " + build_env["CFLAGS"] build_env["CXXFLAGS"] = "-m64 " + build_env["CXXFLAGS"] build_env["LDFLAGS"] = "-m64" elif self.settings.arch == "x86": build_env["CFLAGS"] = "-m32 " + build_env["CFLAGS"] build_env["CXXFLAGS"] = "-m32 " + build_env["CXXFLAGS"] build_env["LDFLAGS"] = "-m32" # with tools.chdir("src"), tools.environment_append(build_env): self.run("make -j %s" % tools.cpu_count())
def build_unix(self): # Enable compiler interposition under Linux to enforce the correct flags for libc++ from libcxx import LibCxx LibCxx.set_vars(self) # Run autogen.sh self.run("./autogen.sh") # Patch out iconv support under Mac OS X and patch GDAL v2.4.0 for XCode 12.x if self.settings.os == "Macos": self.run( "sed -i '' 's/-D_XOPEN_SOURCE=500 //g' ogr/ogrsf_frmts/geojson/libjson/GNUmakefile" ) tools.replace_in_file("./configure", "iconv.h", "iconv_h") # Patch out iconv support under Linux, since the UE4 bundled toolchain doesn't include it if self.settings.os == "Linux": tools.replace_in_file("./configure", "iconv.h", "iconv_h") # Under Linux, the UE4-bundled version of zlib is typically named libz_fPIC.a, but GDAL expects libz.a zlibName = self.deps_cpp_info["zlib"].libs[0] if zlibName != "z": tools.replace_in_file("./configure", "-lz", "-l{}".format(zlibName)) # Prepare the autotools build environment autotools = AutoToolsBuildEnvironment(self) LibCxx.fix_autotools(autotools) # Ensure the configure script can load the GEOS shared library when running tests geosPaths = self.deps_cpp_info["geos-ue4"].lib_paths ldPath = ":".join([os.environ.get("LD_LIBRARY_PATH", "")] + geosPaths) # Build using autotools with tools.environment_append({"LD_LIBRARY_PATH": ldPath}): autotools.configure(args=self.configure_flags()) autotools.make(args=["-j{}".format(tools.cpu_count())]) autotools.make(target="install")
def _build_mingw(self, args): # Workaround for configure using clang first if in the path new_path = [] for item in os.environ['PATH'].split(';'): if item != 'C:\\Program Files\\LLVM\\bin': new_path.append(item) os.environ['PATH'] = ';'.join(new_path) # end workaround args += ["-platform win32-g++"] with tools.environment_append( {"MAKEFLAGS": "-j %d" % tools.cpu_count()}): configurePath = os.path.join(self.build_folder, "qtbase", "tools", "configure") os.makedirs(configurePath) shutil.copy2( os.path.join(self.source_folder, "qt5", "qtbase", "tools", "configure", "configure_pch.h"), configurePath) self.run("%s/qt5/configure.bat %s" % (self.source_folder, " ".join(args))) self.run("mingw32-make") self.run("mingw32-make install")
def build(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) if self._is_msvc: run_configure_icu_file = os.path.join(self._source_subfolder, "source", "runConfigureICU") flags = "-%s" % self.settings.compiler.runtime if self.settings.build_type in [ "Debug", "RelWithDebInfo" ] and tools.Version(self.settings.compiler.version) >= "12": flags += " -FS" tools.replace_in_file(run_configure_icu_file, "-MDd", flags) tools.replace_in_file(run_configure_icu_file, "-MD", flags) self._workaround_icu_20545() env_build = self._configure_autotools() build_dir = os.path.join(self.build_folder, self._source_subfolder, "build") os.mkdir(build_dir) with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.environment_append(env_build.vars): with tools.chdir(build_dir): # workaround for https://unicode-org.atlassian.net/browse/ICU-20531 os.makedirs(os.path.join("data", "out", "tmp")) self.run(self._build_config_cmd, win_bash=tools.os_info.is_windows) command = "{make} {silent} -j {cpu_count}".format( make=self._make_tool, silent=self._silent, cpu_count=tools.cpu_count()) self.run(command, win_bash=tools.os_info.is_windows) if self.options.with_unit_tests: command = "{make} {silent} check".format( make=self._make_tool, silent=self._silent) self.run(command, win_bash=tools.os_info.is_windows)
def build(self): if tools.os_info.is_windows and self.settings.compiler == "Visual Studio": f = open("ACE_wrappers/ace/config.h", "a") f.write("""#include "ace/config-win32.h" """) f.close() if self.settings.compiler.version == 14: vsString = "14" if self.settings.compiler.version == 15: vsString = "2017" if self.settings.compiler.version == 16: vsString = "2019" sln_file = "ACE_wrappers/ACE_wrappers_vs%s.sln" % vsString msbuild = MSBuild(self) winsdk_version = self._find_windows_10_sdk() if not winsdk_version: raise Exception("Windows 10 SDK wasn't found") self.output.info("set windows 10 sdk to %s" % winsdk_version) msbuild.build(sln_file, targets=["ACE"], arch=self.settings.arch, build_type=self.settings.build_type, winsdk_version=winsdk_version) if tools.os_info.is_linux: f = open("ACE_wrappers/ace/config.h", "a") f.write("""#include "ace/config-linux.h" """) f.close() shutil.copyfile("ACE_wrappers/ace/config-linux.h", "ACE_wrappers/ace/config.h") os.environ["ACE_ROOT"] = os.getcwd() + "/ACE_wrappers" shutil.copyfile( os.getcwd() + "/ACE_wrappers/include/makeinclude/platform_linux.GNU", os.getcwd() + "/ACE_wrappers/include/makeinclude/platform_macros.GNU") n_cores = tools.cpu_count() self.run("cd ACE_wrappers && make -j%s" % n_cores)
def _build_msvc(self, args): build_command = find_executable("jom.exe") if build_command: build_args = ["-j", str(tools.cpu_count())] else: build_command = "nmake.exe" build_args = [] self.output.info("Using '%s %s' to build" % (build_command, " ".join(build_args))) env = {} env.update({ 'PATH': [ '%s/qtbase/bin' % self.source_folder, '%s/gnuwin32/bin' % self.source_folder, '%s/qtrepotools/bin' % self.source_folder ] }) env_build = VisualStudioBuildEnvironment(self) env.update(env_build.vars) with tools.environment_append(env): vcvars = tools.vcvars_command(self.settings) args += ["-opengl %s" % self.options.opengl] if self.options.openssl == "no": args += ["-no-openssl"] elif self.options.openssl == "yes": args += ["-openssl"] else: args += ["-openssl-linked"] with tools.chdir(self.source_dir): self.run("%s && configure %s" % (vcvars, " ".join(args))) self.run("%s && %s %s" % (vcvars, build_command, " ".join(build_args))) self.run("%s && %s install" % (vcvars, build_command))
def build(self): tools.patch(patch_file="patches/openssl_lib_order.patch") BUILD_gn = 'crashpad/third_party/mini_chromium/mini_chromium/build/BUILD.gn' tools.replace_in_file(BUILD_gn, 'cc = "clang"', 'cc = "{}"'.format(os.environ.get('CC', 'cc'))) tools.replace_in_file(BUILD_gn, 'cxx = "clang++"', 'cxx = "{}"'.format(os.environ.get('CXX', 'c++'))) if self.settings.os != "Windows" and self.settings.compiler == "gcc": tools.replace_in_file(BUILD_gn, '"-Werror",', '"-Wno-multichar",') tools.replace_in_file(BUILD_gn, '"-Wheader-hygiene",', '') tools.replace_in_file(BUILD_gn, '"-Wnewline-eof",', '') tools.replace_in_file(BUILD_gn, '"-Wstring-conversion",', '') tools.replace_in_file(BUILD_gn, '"-Wexit-time-destructors"', '') tools.replace_in_file(BUILD_gn, '"-fobjc-call-cxx-cdtors",', '') def quote(x): return '"{}"'.format(x) ldflags = list(map(quote, os.environ.get('LDFLAGS', '').split(' '))) cflags = list(map(quote, os.environ.get('CFLAGS', '').split(' '))) cflags.append('"-std=c11"') cxxflags = list(map(quote, os.environ.get('CXXFLAGS', '').split(' '))) cxxflags.append('"-std=c++14"') if "openssl" in self.deps_cpp_info.deps: openssl_info = self.deps_cpp_info["openssl"] ldflags.append('"-L{}"'.format(openssl_info.lib_paths[0])) cxxflags.append('"-I{}"'.format(openssl_info.include_paths[0])) tools.replace_in_file(BUILD_gn, 'ldflags = []', 'ldflags = [ {} ]'.format(", ".join(ldflags))) tools.replace_in_file(BUILD_gn, 'cflags_c = [ "-std=c11" ]', 'cflags_c = [ {} ]'.format(", ".join(cflags))) tools.replace_in_file(BUILD_gn, 'cflags_cc = [ "-std=c++14" ]', 'cflags_cc = [ {} ]'.format(", ".join(cxxflags))) with tools.chdir(self._source_dir): self.run('gn gen %s --args="%s"' % (self._build_name, self._setup_args_gn()), run_environment=True) self.run("ninja -j%d -C %s" % (tools.cpu_count(), self._build_name), run_environment=True)
def build(self): with tools.chdir(self.source_dir): build_dir = path.join(self.build_folder, "build-dir") if self.settings.os == "Windows": python_executable = "C:\\Python27\\python.exe" build_env = tools.vcvars_dict(self.settings) else: python_executable = "python3" # GNU binutils's ld and gold don't support Darwin (macOS) # Use the default provided linker build_env = dict() if self.settings.os == "Linux": build_env["LDFLAGS"] = "-fuse-ld=gold" with tools.environment_append(build_env): self.run("{python} build/gen.py --out-path={build_dir}"\ .format(python=python_executable, build_dir=build_dir)) self.run("ninja -j {cpu_nb} -C {build_dir}"\ .format(cpu_nb=tools.cpu_count()-1, build_dir=build_dir)) if self.options.tests: self.run( "{build_dir}/gn_unittests".format(build_dir=build_dir))
def build(self): if self.options.header_only: self.output.warn("Header only package, skipping build") return self._clean() self._bootstrap() if self._use_bcp: self._build_bcp() self._run_bcp() flags = self._get_build_flags() # Help locating bzip2 and zlib self._create_user_config_jam(self._boost_build_dir) # JOIN ALL FLAGS b2_flags = " ".join(flags) full_command = "%s %s -j%s --abbreviate-paths -d2" % ( self._b2_exe, b2_flags, tools.cpu_count()) # -d2 is to print more debug info and avoid travis timing out without output sources = os.path.join(self.source_folder, self._boost_dir) full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.chdir(sources): # to locate user config jam (BOOST_BUILD_PATH) with tools.environment_append( {"BOOST_BUILD_PATH": self._boost_build_dir}): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) self.run(full_command) arch = self.settings.get_safe("arch") if arch.startswith("asm.js"): self._create_emscripten_libs()
def build(self): if self.options.header_only: self.output.warn("Header only package, skipping build") return if not self.options.without_python: tools.patch(base_path=os.path.join(self.build_folder, self.folder_name), patch_file='patches/python_base_prefix.patch', strip=1) b2_exe = self.bootstrap() flags = self.get_build_flags() # Help locating bzip2 and zlib self.create_user_config_jam(self.build_folder) # JOIN ALL FLAGS b2_flags = " ".join(flags) full_command = "%s %s -j%s --abbreviate-paths -d2" % ( b2_exe, b2_flags, tools.cpu_count()) # -d2 is to print more debug info and avoid travis timing out without output sources = os.path.join(self.source_folder, self.folder_name) if self.options.toolset: full_command += ' toolset=' + self.options.toolset.value full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) with tools.vcvars( self.settings ) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.chdir(sources): # to locate user config jam (BOOST_BUILD_PATH) with tools.environment_append( {"BOOST_BUILD_PATH": self.build_folder}): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) self.run(full_command)
def build(self): if self.settings.os == "Windows": args = ['-Dprotobuf_BUILD_TESTS=OFF'] args += [ '-DZLIB_ROOT=%s' % dict(self.deps_cpp_info.dependencies)["zlib"].rootpath ] args += [ '-DBUILD_SHARED_LIBS=%s' % ('ON' if self.options.shared else 'OFF') ] if self.settings.compiler == "Visual Studio": args += [ '-Dprotobuf_MSVC_STATIC_RUNTIME=%s' % ('ON' if "MT" in str( self.settings.compiler.runtime) else 'OFF') ] cmake = CMake(self.settings) cmake_dir = os.path.sep.join([self._source_dir, "cmake"]) self.run('cmake . %s %s' % (cmake.command_line, ' '.join(args)), cwd=cmake_dir) self.run("cmake --build . %s" % cmake.build_config, cwd=cmake_dir) else: env = AutoToolsBuildEnvironment(self) with tools.environment_append(env.vars): cpus = tools.cpu_count() self.run("./autogen.sh", cwd=self._source_dir) args = ['--disable-dependency-tracking', '--with-zlib'] if not self.options.shared: args += ['--disable-shared'] if self.options.shared or self.options.fPIC: args += ['"CFLAGS=-fPIC" "CXXFLAGS=-fPIC"'] self.run("./configure %s" % (' '.join(args)), cwd=self._source_dir) self.run("make -j %s" % cpus, cwd=self._source_dir)
def _build_common(self): for lib_short_name in self.lib_short_names: lib_dir = os.path.join(lib_short_name, "lib") jam_file = os.path.join(lib_dir, "jamroot.jam") if self.is_header_only(lib_short_name): header_only_content = self.jam_header_only_content.format( lib_short_name=lib_short_name) tools.save(jam_file, header_only_content, append=True) else: b2_command = [ "b2", "-j%s" % (tools.cpu_count()), "-d+%s" % (os.getenv('CONAN_B2_DEBUG', '1')), "-a", "--hash=yes", "--debug-configuration", "--layout=system", self.all_b2_args(), lib_short_name + "-build", ] self.output.info("%s: %s" % (os.getcwd(), " ".join(b2_command))) with tools.environment_append( {'PATH': [os.getenv('MPI_BIN', '')]}): self.run(" ".join(b2_command)) libs = self._collect_build_libs(lib_dir) for lib in libs: search_content = self.jam_search_content.format( lib_link_name=lib) tools.save(jam_file, search_content, append=True) if "boost_" + lib_short_name not in libs: alias_content = self.jam_alias_content.format( lib_short_name=lib_short_name, space_joined_libs=" ".join(libs)) tools.save(jam_file, alias_content, append=True)
def build(self): if self.options.header_only: self.output.warn("Header only package, skipping build") return b2_exe = self.bootstrap() flags = self.get_build_flags() # Help locating bzip2 and zlib self.create_user_config_jam(self.build_folder) # JOIN ALL FLAGS b2_flags = " ".join(flags) full_command = "%s %s -j%s --abbreviate-paths" % (b2_exe, b2_flags, tools.cpu_count()) sources = os.path.join(self.source_folder, self.folder_name) full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) with tools.vcvars(self.settings) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.chdir(sources): # to locate user config jam (BOOST_BUILD_PATH) with tools.environment_append({"BOOST_BUILD_PATH": self.build_folder}): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) self.run(full_command)
def build(self): configure_args = [] prefix = os.path.abspath("install") configure_args.append("--prefix=%s" % prefix) configure_args.append("--enable-shared=%s" % ("yes" if self.options.shared else "no")) configure_args.append("--enable-static=%s" % ("yes" if not self.options.shared else "no")) if self.options.fPIC: configure_args.append("--with-pic") env_build = AutoToolsBuildEnvironment(self) env_vars = dict(env_build.vars) with tools.environment_append(env_vars): self.output.info("Build environment: %s" % env_vars) self.run("cd protobuf && ./autogen.sh") self.output.info("./configure %s" % " ".join(configure_args)) self.run("cd protobuf && ./configure %s" % " ".join(configure_args)) self.run("cd protobuf && make -j%s" % tools.cpu_count()) self.run("cd protobuf && make install")
def build(self): if self.options.header_only: self.output.warn("Header only package, skipping build") return src = os.path.join(self.source_folder, self.folder_name) clean_dirs = [os.path.join(self.build_folder, "bin.v2"), os.path.join(self.build_folder, "architecture"), os.path.join(src, "stage"), os.path.join(src, "tools", "build", "src", "engine", "bootstrap"), os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86"), os.path.join(src, "tools", "build", "src", "engine", "bin.ntx86_64")] for d in clean_dirs: if os.path.isdir(d): shutil.rmtree(d) b2_exe = self.bootstrap() flags = self.get_build_flags() # Help locating bzip2 and zlib self.create_user_config_jam(self.build_folder) # JOIN ALL FLAGS b2_flags = " ".join(flags) full_command = "%s %s -j%s --abbreviate-paths -d2" % (b2_exe, b2_flags, tools.cpu_count()) # -d2 is to print more debug info and avoid travis timing out without output sources = os.path.join(self.source_folder, self.folder_name) full_command += ' --debug-configuration --build-dir="%s"' % self.build_folder self.output.warn(full_command) with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.chdir(sources): # to locate user config jam (BOOST_BUILD_PATH) with tools.environment_append({"BOOST_BUILD_PATH": self.build_folder}): # To show the libraries *1 # self.run("%s --show-libraries" % b2_exe) self.run(full_command)
def build(self): with tools.chdir(self._source_subfolder): with self._build_context(): # Generate dummy header to be able to run `build/ben.py` with `--no-last-commit-position`. This allows running the script without the tree having to be a git checkout. tools.save(os.path.join("src", "gn", "last_commit_position.h"), textwrap.dedent("""\ #pragma once #define LAST_COMMIT_POSITION "1" #define LAST_COMMIT_POSITION_NUM 1 """)) conf_args = [ "--no-last-commit-position", "--host={}".format(self._to_gn_platform(self.settings.os, self.settings.compiler)), ] if self.settings.build_type == "Debug": conf_args.append("-d") self.run("python build/gen.py {}".format(" ".join(conf_args)), run_environment=True) # Try sleeping one second to avoid time skew of the generated ninja.build file (and having to re-run build/gen.py) time.sleep(1) build_args = [ "-C", "out", "-j{}".format(tools.cpu_count()), ] self.run("ninja {}".format(" ".join(build_args)), run_environment=True)
def build(self): self._patch_sources() if self.options.dat_package_file: dat_package_file = glob.glob( os.path.join(self.source_folder, self._source_subfolder, "source", "data", "in", "*.dat")) if dat_package_file: shutil.copy(str(self.options.dat_package_file), dat_package_file[0]) env_build = self._configure_autotools() build_dir = os.path.join(self.build_folder, self._source_subfolder, "build") os.mkdir(build_dir) with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.environment_append(env_build.vars): with tools.chdir(build_dir): # workaround for https://unicode-org.atlassian.net/browse/ICU-20531 os.makedirs(os.path.join("data", "out", "tmp")) # workaround for "No rule to make target 'out/tmp/dirs.timestamp'" tools.save( os.path.join("data", "out", "tmp", "dirs.timestamp"), "") self.run(self._build_config_cmd, win_bash=tools.os_info.is_windows) command = "{make} {silent} -j {cpu_count}".format( make=self._make_tool, silent=self._silent, cpu_count=tools.cpu_count()) self.run(command, win_bash=tools.os_info.is_windows) if self.options.with_unit_tests: command = "{make} {silent} check".format( make=self._make_tool, silent=self._silent) self.run(command, win_bash=tools.os_info.is_windows)
def _build_flags(self): flags = self._build_cross_flags # https://www.boost.org/doc/libs/1_70_0/libs/context/doc/html/context/architectures.html if self._b2_os: flags.append("target-os=%s" % self._b2_os) if self._b2_architecture: flags.append("architecture=%s" % self._b2_architecture) if self._b2_address_model: flags.append("address-model=%s" % self._b2_address_model) if self._b2_binary_format: flags.append("binary-format=%s" % self._b2_binary_format) if self._b2_abi: flags.append("abi=%s" % self._b2_abi) flags.append("--layout=%s" % self.options.layout) flags.append("-sBOOST_BUILD_PATH=%s" % self._boost_build_dir) flags.append("--user-config=%s" % os.path.join(self._boost_build_dir, 'user-config.jam')) flags.append("-sNO_ZLIB=%s" % ("0" if self.options.zlib else "1")) flags.append("-sNO_BZIP2=%s" % ("0" if self.options.bzip2 else "1")) flags.append("-sNO_LZMA=%s" % ("0" if self.options.lzma else "1")) flags.append("-sNO_ZSTD=%s" % ("0" if self.options.zstd else "1")) def add_defines(option, library): if option: for define in self.deps_cpp_info[library].defines: flags.append("define=%s" % define) if self._zip_bzip2_requires_needed: add_defines(self.options.zlib, "zlib") add_defines(self.options.bzip2, "bzip2") add_defines(self.options.lzma, "lzma") add_defines(self.options.zstd, "zstd") if self._is_msvc and self.settings.compiler.runtime: flags.append("runtime-link=%s" % ("static" if "MT" in str(self.settings.compiler.runtime) else "shared")) flags.append("threading=multi") flags.append("link=%s" % ("static" if not self.options.shared else "shared")) if self.settings.build_type == "Debug": flags.append("variant=debug") else: flags.append("variant=release") for libname in lib_list: if getattr(self.options, "without_%s" % libname): flags.append("--without-%s" % libname) toolset, _, _ = self._toolset_version_and_exe flags.append("toolset=%s" % toolset) if self.settings.get_safe("compiler.cppstd"): flags.append("cxxflags=%s" % cppstd_flag( self.settings.get_safe("compiler"), self.settings.get_safe("compiler.version"), self.settings.get_safe("compiler.cppstd") ) ) # CXX FLAGS cxx_flags = [] # fPIC DEFINITION if self.settings.os != "Windows": if self.options.fPIC: cxx_flags.append("-fPIC") # Standalone toolchain fails when declare the std lib if self.settings.os != "Android": try: if self._gnu_cxx11_abi: flags.append("define=_GLIBCXX_USE_CXX11_ABI=%s" % self._gnu_cxx11_abi) if "clang" in str(self.settings.compiler): if str(self.settings.compiler.libcxx) == "libc++": cxx_flags.append("-stdlib=libc++") flags.append('linkflags="-stdlib=libc++"') else: cxx_flags.append("-stdlib=libstdc++") except: pass if self.options.error_code_header_only: flags.append("define=BOOST_ERROR_CODE_HEADER_ONLY=1") if self.options.system_no_deprecated: flags.append("define=BOOST_SYSTEM_NO_DEPRECATED=1") if self.options.asio_no_deprecated: flags.append("define=BOOST_ASIO_NO_DEPRECATED=1") if self.options.filesystem_no_deprecated: flags.append("define=BOOST_FILESYSTEM_NO_DEPRECATED=1") if self.options.segmented_stacks: flags.extend(["segmented-stacks=on", "define=BOOST_USE_SEGMENTED_STACKS=1", "define=BOOST_USE_UCONTEXT=1"]) flags.append("pch=on" if self.options.pch else "pch=off") if tools.is_apple_os(self.settings.os): if self.settings.get_safe("os.version"): cxx_flags.append(tools.apple_deployment_target_flag(self.settings.os, self.settings.os.version)) if self.settings.os == "iOS": cxx_flags.append("-DBOOST_AC_USE_PTHREADS") cxx_flags.append("-DBOOST_SP_USE_PTHREADS") cxx_flags.append("-fvisibility=hidden") cxx_flags.append("-fvisibility-inlines-hidden") cxx_flags.append("-fembed-bitcode") cxx_flags = 'cxxflags="%s"' % " ".join(cxx_flags) if cxx_flags else "" flags.append(cxx_flags) if self.options.extra_b2_flags: flags.append(str(self.options.extra_b2_flags)) flags.extend(["install", "--prefix=%s" % self.package_folder, "-j%s" % tools.cpu_count(), "--abbreviate-paths", "-d%s" % str(self.options.debug_level)]) return flags
def _build_bcp(self): folder = os.path.join(self.source_folder, self._folder_name, 'tools', 'bcp') with tools.vcvars(self.settings) if self._is_msvc else tools.no_op(): with tools.chdir(folder): toolset, _, _ = self._toolset_version_and_exe command = "%s -j%s --abbreviate-paths -d2 toolset=%s" % (self._b2_exe, tools.cpu_count(), toolset) self.output.warn(command) self.run(command)
def cpu_count_test(self): cpus = tools.cpu_count() self.assertIsInstance(cpus, int) self.assertGreaterEqual(cpus, 1) with tools.environment_append({"CONAN_CPU_COUNT": "34"}): self.assertEquals(tools.cpu_count(), 34)
def build(self): args = [ "-confirm-license", "-silent", "-nomake examples", "-nomake tests", "-prefix %s" % self.package_folder ] if self.options.commercial: args.append("-commercial") else: args.append("-opensource") if not self.options.GUI: args.append("-no-gui") if not self.options.widgets: args.append("-no-widgets") if not self.options.shared: args.insert(0, "-static") if self.settings.compiler == "Visual Studio": if self.settings.compiler.runtime == "MT" or self.settings.compiler.runtime == "MTd": args.append("-static-runtime") else: args.insert(0, "-shared") if self.options.multiconfiguration: args.append("-debug-and-release") elif self.settings.build_type == "Debug": args.append("-debug") elif self.settings.build_type == "Release": args.append("-release") elif self.settings.build_type == "RelWithDebInfo": args.append("-release") args.append("-force-debug-info") elif self.settings.build_type == "MinSizeRel": args.append("-release") args.append("-optimize-size") for module in self._submodules: if module != 'qtbase' and not getattr(self.options, module) \ and os.path.isdir(os.path.join(self.source_folder, 'qt5', self._submodules[module]['path'])): args.append("-skip " + module) args.append("--zlib=system") # openGL if self.options.opengl == "no": args += ["-no-opengl"] elif self.options.opengl == "es2": args += ["-opengl es2"] elif self.options.opengl == "desktop": args += ["-opengl desktop"] elif self.options.opengl == "dynamic": args += ["-opengl dynamic"] # openSSL if not self.options.openssl: args += ["-no-openssl"] else: if self.options["openssl"].shared: args += ["-openssl-runtime"] else: args += ["-openssl-linked"] # args.append("--iconv=" + ("gnu" if self.options.with_libiconv else "no")) args.append("--glib=" + ("yes" if self.options.with_glib else "no")) args.append("--pcre=" + ("system" if self.options.with_pcre2 else "qt")) args.append("--fontconfig=" + ("yes" if self.options.with_fontconfig else "no")) args.append("--icu=" + ("yes" if self.options.with_icu else "no")) args.append("--sql-mysql=" + ("yes" if self.options.with_mysql else "no")) args.append("--sql-psql=" + ("yes" if self.options.with_pq else "no")) args.append("--sql-odbc=" + ("yes" if self.options.with_odbc else "no")) if self.options.qtmultimedia: args.append("--alsa=" + ("yes" if self.options.with_libalsa else "no")) for opt, conf_arg in [("with_doubleconversion", "doubleconversion"), ("with_freetype", "freetype"), ("with_harfbuzz", "harfbuzz"), ("with_libjpeg", "libjpeg"), ("with_libpng", "libpng"), ("with_sqlite3", "sqlite")]: if getattr(self.options, opt): if self.options.multiconfiguration: args += ["-qt-" + conf_arg] else: args += ["-system-" + conf_arg] else: args += ["-no-" + conf_arg] libmap = [ ("zlib", "ZLIB"), ("openssl", "OPENSSL"), ("pcre2", "PCRE2"), ("glib", "GLIB"), # ("libiconv", "ICONV"), ("double-conversion", "DOUBLECONVERSION"), ("freetype", "FREETYPE"), ("fontconfig", "FONTCONFIG"), ("icu", "ICU"), ("harfbuzz", "HARFBUZZ"), ("libjpeg-turbo", "LIBJPEG"), ("libpng", "LIBPNG"), ("sqlite3", "SQLITE"), ("libmysqlclient", "MYSQL"), ("libpq", "PSQL"), ("odbc", "ODBC"), ("sdl2", "SDL2"), ("openal", "OPENAL"), ("libalsa", "ALSA") ] libPaths = [] for package, var in libmap: if package in self.deps_cpp_info.deps: if package == 'freetype': args.append( "\"%s_INCDIR=%s\"" % (var, self.deps_cpp_info[package].include_paths[-1])) #else: # MercsEng: no else, we DO want freetype included like other packages. args += [ "-I " + s for s in self.deps_cpp_info[package].include_paths ] args += [ "-D " + s for s in self.deps_cpp_info[package].defines ] def _remove_duplicate(l): seen = set() seen_add = seen.add for element in itertools.filterfalse(seen.__contains__, l): seen_add(element) yield element def _gather_libs(p): libs = ["-l" + i for i in self.deps_cpp_info[p].libs] if self.settings.os in ["Macos", "iOS", "watchOS", "tvOS"]: libs += [ "-framework " + i for i in self.deps_cpp_info[p].frameworks ] libs += self.deps_cpp_info[p].sharedlinkflags for dep in self.deps_cpp_info[p].public_deps: libs += _gather_libs(dep) return _remove_duplicate(libs) args.append("\"%s_LIBS=%s\"" % (var, " ".join(_gather_libs(package)))) def _gather_lib_paths(p): lib_paths = self.deps_cpp_info[p].lib_paths for dep in self.deps_cpp_info[p].public_deps: lib_paths += _gather_lib_paths(dep) return _remove_duplicate(lib_paths) libPaths += _gather_lib_paths(package) args += ["-L " + s for s in _remove_duplicate(libPaths)] if 'libmysqlclient' in self.deps_cpp_info.deps: args.append( "-mysql_config " + os.path.join(self.deps_cpp_info['libmysqlclient'].rootpath, "bin", "mysql_config")) if 'libpq' in self.deps_cpp_info.deps: args.append("-psql_config " + os.path.join( self.deps_cpp_info['libpq'].rootpath, "bin", "pg_config")) if self.settings.os == "Linux": if self.options.GUI: args.append("-qt-xcb") elif self.settings.os == "Macos": args += ["-no-framework"] elif self.settings.os == "Android": args += [ "-android-ndk-platform android-%s" % self.settings.os.api_level ] args += [ "-android-arch %s" % { "armv6": "armeabi", "armv7": "armeabi-v7a", "armv8": "arm64-v8a", "x86": "x86", "x86_64": "x86_64", "mips": "mips", "mips64": "mips64" }.get(str(self.settings.arch)) ] # args += ["-android-toolchain-version %s" % self.settings.compiler.version] if self.options.sysroot: args += ["-sysroot %s" % self.options.sysroot] if self.options.device: args += ["-device %s" % self.options.device] if self.options.cross_compile: args += [ "-device-option CROSS_COMPILE=%s" % self.options.cross_compile ] else: xplatform_val = self._xplatform() if xplatform_val: if not tools.cross_building(self.settings, skip_x64_x86=True): args += ["-platform %s" % xplatform_val] else: args += ["-xplatform %s" % xplatform_val] else: self.output.warn( "host not supported: %s %s %s %s" % (self.settings.os, self.settings.compiler, self.settings.compiler.version, self.settings.arch)) def _getenvpath(var): val = os.getenv(var) if val and tools.os_info.is_windows: val = val.replace("\\", "/") os.environ[var] = val return val value = _getenvpath('CC') if value: args += [ 'QMAKE_CC="' + value + '"', 'QMAKE_LINK_C="' + value + '"', 'QMAKE_LINK_C_SHLIB="' + value + '"' ] value = _getenvpath('CXX') if value: args += [ 'QMAKE_CXX="' + value + '"', 'QMAKE_LINK="' + value + '"', 'QMAKE_LINK_SHLIB="' + value + '"' ] if tools.os_info.is_linux and self.settings.compiler == "clang": args += ['QMAKE_CXXFLAGS+="-ftemplate-depth=1024"'] if self.settings.os != "Windows": args += ["-no-d3d12"] if self.options.config: args.append(str(self.options.config)) for package in ['xkbcommon', 'glib']: if package in self.deps_cpp_info.deps: lib_path = self.deps_cpp_info[package].rootpath for dirpath, _, filenames in os.walk(lib_path): for filename in filenames: if filename.endswith('.pc'): shutil.copyfile(os.path.join(dirpath, filename), filename) tools.replace_prefix_in_pc_file(filename, lib_path) with tools.vcvars( self.settings ) if self.settings.compiler == "Visual Studio" else tools.no_op(): with tools.environment_append({ "MAKEFLAGS": "j%d" % tools.cpu_count(), "PKG_CONFIG_PATH": os.getcwd() }): try: self.run("%s/qt5/configure %s" % (self.source_folder, " ".join(args))) finally: self.output.info( open('config.log', errors='backslashreplace').read()) if self.settings.compiler == "Visual Studio": make = "jom" elif tools.os_info.is_windows: make = "mingw32-make" else: make = "make" self.run(make, run_environment=True) self.run("%s install" % make) with open('qtbase/bin/qt.conf', 'w') as f: f.write('[Paths]\nPrefix = ..')
def cpu_count_test(self): cpus = tools.cpu_count() self.assertIsInstance(cpus, int) self.assertGreaterEqual(cpus, 1)
def convenient_functions_test(self): settings = Settings.loads(default_settings_yml) settings.os = "Windows" settings.compiler = "Visual Studio" settings.compiler.version = "12" settings.compiler.runtime = "MDd" settings.arch = "x86" settings.build_type = None if sys.platform == 'win32': dot_dir = "." tempdir = self.tempdir else: dot_dir = "'.'" tempdir = "'" + self.tempdir + "'" conan_file = ConanFileMock() conan_file.settings = settings cmake = CMake(conan_file) cross = "-DCMAKE_SYSTEM_NAME=\"Windows\" -DCMAKE_SYSROOT=\"/path/to/sysroot\" " if platform.system() != "Windows" else "" target_test = CMakeTest.scape('--target RUN_TESTS') cmake.configure() cores = '-DCONAN_CXX_FLAGS="/MP{0}" -DCONAN_C_FLAGS="/MP{0}" '.format(tools.cpu_count()) self.assertEqual('cd {0} && cmake -G "Visual Studio 12 2013" -DCONAN_LINK_RUNTIME="/MDd" {1}-DCONAN_EXPORTED="1"' ' -DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" {2}' '-Wno-dev {0}'.format(dot_dir, cross, cores), conan_file.command) cmake.build() self.assertEqual('cmake --build %s' % dot_dir, conan_file.command) cmake.test() self.assertEqual('cmake --build %s %s' % (dot_dir, target_test), conan_file.command) settings.build_type = "Debug" cmake = CMake(conan_file) cmake.build() self.assertEqual('cmake --build %s --config Debug' % dot_dir, conan_file.command) cmake.test() self.assertEqual('cmake --build %s --config Debug %s' % (dot_dir, target_test), conan_file.command) cmake.configure(source_dir="/source", build_dir=self.tempdir, args=['--foo "bar"'], defs={"SHARED": True}) if sys.platform == 'win32': escaped_args = r'"--foo \"bar\"" -DSHARED="True" /source' else: escaped_args = "'--foo \"bar\"' -DSHARED=\"True\" '/source'" self.assertEqual('cd %s && cmake -G "Visual Studio 12 2013" -DCONAN_LINK_RUNTIME="/MDd" %s-DCONAN_EXPORTED="1" ' '-DCONAN_COMPILER="Visual Studio" -DCONAN_COMPILER_VERSION="12" %s' '-Wno-dev %s' % (tempdir, cross, cores, escaped_args), conan_file.command) cmake.build(args=["--bar 'foo'"], target="install") if sys.platform == 'win32': escaped_args = '--target install "--bar \'foo\'"' else: escaped_args = r"'--target' 'install' '--bar '\''foo'\'''" self.assertEqual('cmake --build %s --config Debug %s' % (tempdir, escaped_args), conan_file.command) cmake.test(args=["--bar 'foo'"]) if sys.platform == 'win32': escaped_args = '%s "--bar \'foo\'"' % target_test else: escaped_args = r"%s '--bar '\''foo'\'''" % target_test self.assertEqual('cmake --build %s --config Debug %s' % (tempdir, escaped_args), conan_file.command) settings.build_type = "Release" cmake = CMake(conan_file) cmake.build() self.assertEqual('cmake --build %s --config Release' % dot_dir, conan_file.command) cmake.test() self.assertEqual('cmake --build %s --config Release %s' % (dot_dir, target_test), conan_file.command) cmake.build(build_dir=self.tempdir) self.assertEqual('cmake --build %s --config Release' % tempdir, conan_file.command) cmake.test(build_dir=self.tempdir) self.assertEqual('cmake --build %s --config Release %s' % (tempdir, target_test), conan_file.command) settings.compiler = "gcc" settings.compiler.version = "5.4" cmake = CMake(conan_file) cmake.build() self.assertEqual('cmake --build %s' % (CMakeTest.scape('. -- -j%i' % cpu_count())), conan_file.command) cmake.test() self.assertEqual('cmake --build %s' % (CMakeTest.scape('. --target test -- -j%i' % cpu_count())), conan_file.command) cmake.build(args=['foo', '--', 'bar']) self.assertEqual('cmake --build %s' % (CMakeTest.scape('. foo -- bar -j%i' % cpu_count())), conan_file.command) cmake.test(args=['foo', '--', 'bar']) self.assertEqual('cmake --build %s' % (CMakeTest.scape('. --target test foo -- bar -j%i' % cpu_count())), conan_file.command) cmake = CMake(conan_file, parallel=False) cmake.build() self.assertEqual('cmake --build %s' % CMakeTest.scape('.'), conan_file.command) cmake.test() self.assertEqual('cmake --build %s' % CMakeTest.scape('. --target test'), conan_file.command)
def _get_cmake_definitions(self): def add_cmake_flag(cmake_flags, name, flag): """ appends compiler linker flags (if already present), or just sets """ if flag: if name not in cmake_flags: cmake_flags[name] = flag else: cmake_flags[name] = ' ' + flag return cmake_flags ret = OrderedDict() ret.update(self._build_type_definition()) ret.update(self._runtime_definition()) ret.update(self._cmake_compiler_options()) ret.update(self._cmake_cross_build_defines()) ret.update(self._get_cpp_standard_vars()) ret["CONAN_EXPORTED"] = "1" if self._compiler: ret["CONAN_COMPILER"] = self._compiler if self._compiler_version: ret["CONAN_COMPILER_VERSION"] = str(self._compiler_version) # Force compiler flags -- TODO: give as environment/setting parameter? arch_flag = architecture_flag(compiler=self._compiler, arch=self._arch) ret = add_cmake_flag(ret, 'CONAN_CXX_FLAGS', arch_flag) ret = add_cmake_flag(ret, 'CONAN_SHARED_LINKER_FLAGS', arch_flag) ret = add_cmake_flag(ret, 'CONAN_C_FLAGS', arch_flag) if self._set_cmake_flags: ret = add_cmake_flag(ret, 'CMAKE_CXX_FLAGS', arch_flag) ret = add_cmake_flag(ret, 'CMAKE_SHARED_LINKER_FLAGS', arch_flag) ret = add_cmake_flag(ret, 'CMAKE_C_FLAGS', arch_flag) if self._libcxx: ret["CONAN_LIBCXX"] = self._libcxx # Shared library try: ret["BUILD_SHARED_LIBS"] = "ON" if self._conanfile.options.shared else "OFF" except ConanException: pass # Install to package folder try: if self._conanfile.package_folder: ret["CMAKE_INSTALL_PREFIX"] = self._conanfile.package_folder except AttributeError: pass if str(self._os) in ["Windows", "WindowsStore"] and self._compiler == "Visual Studio": if self.parallel: cpus = tools.cpu_count() ret["CONAN_CXX_FLAGS"] = "/MP%s" % cpus ret["CONAN_C_FLAGS"] = "/MP%s" % cpus # fpic if str(self._os) not in ["Windows", "WindowsStore"]: fpic = self._conanfile.options.get_safe("fPIC") if fpic is not None: shared = self._conanfile.options.get_safe("shared") ret["CONAN_CMAKE_POSITION_INDEPENDENT_CODE"] = "ON" if (fpic or shared) else "OFF" return ret
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))