def _make_cppstd_flag(compiler, compiler_version, cppstd=None, compiler_base=None): settings = MockSettings({"compiler": compiler, "compiler.version": compiler_version, "compiler.cppstd": cppstd}) if compiler_base: settings.values["compiler.base"] = compiler_base return cppstd_flag(settings)
def _cppstd_flag(self): if conan_version >= Version("1.24"): return tools.cppstd_flag(self._settings) else: from conans.client.build.cppstd_flags import cppstd_flag, cppstd_from_settings compiler = self._settings.get_safe("compiler") compiler_version = self._settings.get_safe("compiler.version") cppstd = cppstd_from_settings(self._settings) return cppstd_flag(compiler, compiler_version, cppstd)
def _cxx_flags(self): flags = self._get_named_flags('CXXFLAGS', 'cxx_flags') def append(flag): nonlocal flags if flags is not None: flags = flags + ' ' + flag else: flags = flag if str(self.settings.os) in ['watchOS', 'tvOS']: # 'sigaltstack' is unavailable: not available on tvOS / watchOS append('-DBOOST_TEST_DISABLE_ALT_STACK=1') if self.settings.get_safe("compiler.cppstd"): append(cppstd_flag(self.settings)) return flags
def package_info(self): self.cpp_info.includedirs = ["include", "include/liblava/ext"] self.cpp_info.libdirs = ["lib"] self.cpp_info.bindirs = ["bin"] self.cpp_info.cxxflags += [tools.cppstd_flag(self.settings)] self.cpp_info.defines += ["SPDLOG_COMPILED_LIB"] self.cpp_info.libs = [ # in correct linking order "lava.engine", "lava.app", "lava.block", "lava.frame", "lava.asset", "lava.resource", "lava.base", "lava.file", "lava.util", "lava.core", "shaderc_combined", "glfw3", "physfs" if self.settings.compiler != "Visual Studio" else "physfs-static", "spdlog" ] # std::filesystem library if self.settings.get_safe("compiler.libcxx") == "libstdc++11": self.cpp_info.system_libs += ["stdc++fs"] if self.settings.get_safe("compiler") in ["gcc", "clang"]: thread_flag = "-pthread" self.cpp_info.cxxflags += [thread_flag] self.cpp_info.sharedlinkflags += [thread_flag] self.cpp_info.exelinkflags += [thread_flag] self.cpp_info.system_libs += ["dl"]
def _make_cppstd_flag(compiler, compiler_version, cppstd): settings = MockSettings({"compiler": compiler, "compiler.version": compiler_version, "compiler.cppstd": cppstd}) return cppstd_flag(settings)
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) if self.options.layout is not "b2-default": flags.append("--layout=%s" % self.options.layout) 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")) if self.options.i18n_backend == 'icu': flags.append("-sICU_PATH={}".format( self.deps_cpp_info["icu"].rootpath)) flags.append("boost.locale.iconv=off boost.locale.icu=on") elif self.options.i18n_backend == 'iconv': flags.append("boost.locale.iconv=on boost.locale.icu=off") else: flags.append("boost.locale.iconv=off boost.locale.icu=off") flags.append("--disable-icu --disable-iconvv") 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, "xz_utils") 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")) # For details https://boostorg.github.io/build/manual/master/index.html flags.append( "threading=%s" % ("single" if not self.options.multithreading else "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) flags.append("toolset=%s" % self._toolset) if self.settings.get_safe("compiler.cppstd"): flags.append("cxxflags=%s" % cppstd_flag(self.settings)) # CXX FLAGS cxx_flags = [] # fPIC DEFINITION if self.settings.os != "Windows": if self.options.fPIC: cxx_flags.append("-fPIC") if self.settings.build_type == "RelWithDebInfo": if self.settings.compiler == "gcc" or "clang" in str( self.settings.compiler): cxx_flags.append("-g") elif self.settings.compiler == "Visual Studio": cxx_flags.append("/Z7") # Standalone toolchain fails when declare the std lib if self.settings.os != "Android" and self.settings.os != "Emscripten": 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": if self.options.multithreading: 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" ]) if self.options.debug_level: flags.append("-d%d" % self.options.debug_level) return flags
def package_info(self): if self.options.with_boost: self.cpp_info.cxxflags.append(tools.cppstd_flag(self.settings)) else: self.info.header_only()
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) if self.options.layout is not "b2-default": flags.append("--layout=%s" % self.options.layout) flags.append("--user-config=%s" % os.path.join(self._boost_build_dir, 'user-config.jam')) def add_defines(library): for define in self.deps_cpp_info[library].defines: flags.append("define=%s" % define) if self._zip_bzip2_requires_needed: add_defines('zlib') add_defines('bzip2') 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')) # For details https://boostorg.github.io/build/manual/master/index.html flags.append( "threading=%s" % ("single" if not self.options.multithreading else "multi")) flags.append("visibility=%s" % self.options.visibility) 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) # flags.append("toolset=%s" % self._toolset) # CXX FLAGS cxx_flags = [] if self.settings.get_safe("compiler.cppstd"): cxx_flags.append(cppstd_flag(self.settings)) if self.options.multithreading and self.settings.os == 'Emscripten': # NOTE: I tried to compile boost for emscripten and failed. Here are some notes: # - source/source_subfolder/tools/build/src/tools/emscripten.jam needs a patch to fix SEARCHED_LIBS error: # import generators; # generators.override emscripten.searched-lib-generator : searched-lib-generator ; # - tests, coroutines and fibers components don't work # - we have to build shared libraries otherwise log won't link # cxx_flags.append('-pthread') # cxx_flags.append('-fexceptions') pass # fPIC DEFINITION if self.settings.os != "Windows": if self.options.fPIC: cxx_flags.append("-fPIC") if self.settings.build_type == "RelWithDebInfo": if self.settings.compiler == "gcc" or "clang" in str( self.settings.compiler): cxx_flags.append("-g") elif self.settings.compiler == "Visual Studio": cxx_flags.append("/Z7") # Standalone toolchain fails when declare the std lib if self.settings.os not in ["Android", "Emscripten"]: 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" ]) if tools.is_apple_os(self.settings.os): if self.settings.get_safe("os.version"): sdk = self.settings.get_safe('os.sdk') subsystem = self.settings.get_safe('os.subsystem') cxx_flags.append( tools.apple_deployment_target_flag( self.settings.os, self.settings.os.version, sdk, subsystem, self.settings.arch)) if self.settings.os == "iOS": # One of the *_USE_PTHREADS flags causes iOS applications to crash when using boost::log # if self.options.multithreading: # cxx_flags.append("-DBOOST_AC_USE_PTHREADS") # cxx_flags.append("-DBOOST_SP_USE_PTHREADS") # Bitcode flag will be added automatically in darwin-toolchain # cxx_flags.append("-fembed-bitcode") pass 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" ]) if self.options.debug_level: flags.append("-d%d" % self.options.debug_level) return flags