From 9b360b27556d0df4cfcf76c47cc4b97b2b2a7ca8 Mon Sep 17 00:00:00 2001 From: Raziel Date: Sun, 23 Jun 2024 19:13:25 +0300 Subject: [PATCH 1/9] Add locally tested recipe for consolidated bgfx --- recipes/bgfx/config.yml | 2 + recipes/bgfx/consolidated/conandata.yml | 11 + recipes/bgfx/consolidated/conanfile.py | 368 ++++++++++++++++++ .../consolidated/test_package/CMakeLists.txt | 9 + .../consolidated/test_package/conanfile.py | 25 ++ .../test_package/test_package.cpp | 71 ++++ .../test_v1_package/CMakeLists.txt | 9 + .../consolidated/test_v1_package/conanfile.py | 17 + 8 files changed, 512 insertions(+) create mode 100644 recipes/bgfx/consolidated/conandata.yml create mode 100644 recipes/bgfx/consolidated/conanfile.py create mode 100644 recipes/bgfx/consolidated/test_package/CMakeLists.txt create mode 100644 recipes/bgfx/consolidated/test_package/conanfile.py create mode 100644 recipes/bgfx/consolidated/test_package/test_package.cpp create mode 100644 recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt create mode 100644 recipes/bgfx/consolidated/test_v1_package/conanfile.py diff --git a/recipes/bgfx/config.yml b/recipes/bgfx/config.yml index 0fa69d015c844..b7dab758ed797 100644 --- a/recipes/bgfx/config.yml +++ b/recipes/bgfx/config.yml @@ -1,3 +1,5 @@ versions: + "1.127.8771": + folder: consolidated "cci.20230216": folder: all diff --git a/recipes/bgfx/consolidated/conandata.yml b/recipes/bgfx/consolidated/conandata.yml new file mode 100644 index 0000000000000..f98b6a817afb5 --- /dev/null +++ b/recipes/bgfx/consolidated/conandata.yml @@ -0,0 +1,11 @@ +sources: + "1.127.8771": + "bgfx": + url: "https://github.com/bkaradzic/bgfx/archive/06d0e2af2f50fee3e8e84e0c3b407073692a678c.tar.gz" + sha256: "0869F9D18C63AB8D804918FEFCC53D8568626A26FCAE7273DF1A70D4C8E7AFE3" + "bimg": + url: "https://github.com/bkaradzic/bimg/archive/2afa64c14c1e3dd5d28412ee03bee0dfe7242f03.tar.gz" + sha256: "376E17EA4A70CEE72E6006DD942CB2F2FE3DB047F524A3F203A15A8BBA1BCD90" + "bx": + url: "https://github.com/bkaradzic/bx/archive/e64b7c097f30d33134fe8fa522b3c95fc461c3d3.tar.gz" + sha256: "2A6E438AC6250CD6052CBBABF2906482DFA1585E537064CB5DA47E2EC728FE92" diff --git a/recipes/bgfx/consolidated/conanfile.py b/recipes/bgfx/consolidated/conanfile.py new file mode 100644 index 0000000000000..a68959823183f --- /dev/null +++ b/recipes/bgfx/consolidated/conanfile.py @@ -0,0 +1,368 @@ +from conan import ConanFile +from conan.tools.files import copy, get, rename, replace_in_file +from conan.tools.build import check_min_cppstd +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, check_min_vs, is_msvc_static_runtime +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import MSBuild, VCVars +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.env import VirtualBuildEnv +from pathlib import Path +import os + +required_conan_version = ">=1.50.0" + +class bgfxConan(ConanFile): + name = "bgfx" + license = "BSD-2-Clause" + homepage = "https://github.com/bkaradzic/bgfx" + url = "https://github.com/conan-io/conan-center-index" + description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." + topics = ("rendering", "graphics", "gamedev") + settings = "os", "compiler", "arch", "build_type" + options = {"fPIC": [True, False], "shared": [True, False], "tools": [True, False], "rtti": [True, False]} + default_options = {"fPIC": True, "shared": False, "tools": False, "rtti": True} + + @property + def _bx_folder(self): + return "bx" + + @property + def _bimg_folder(self): + return "bimg" + + @property + def _bgfx_folder(self): + return "bgfx" + + @property + def _bgfx_path(self): + return os.path.join(self.source_folder, self._bgfx_folder) + + @property + def _genie_extra(self): + genie_extra = "" + if is_msvc(self) and not is_msvc_static_runtime(self): + genie_extra += " --with-dynamic-runtime" + if self.options.shared: + genie_extra += " --with-shared-lib" + # generate tools projects regardless of tools option because that also generates bimg_encode + genie_extra += " --with-tools" + return genie_extra + + @property + def _lib_target_prefix(self): + if is_msvc(self): + return "libs\\" + else: + return "" + + @property + def _tool_target_prefix(self): + if is_msvc(self): + return "tools\\" + else: + return "" + + @property + def _shaderc_target_prefix(self): + if is_msvc(self): + return "shaderc\\" + else: + return "" + + @property + def _tools(self): + return ["texturec", "texturev", "geometryc", "geometryv", "shaderc"] + + @property + def _projs(self): + projs = [f"{self._lib_target_prefix}bx", f"{self._lib_target_prefix}bimg", f"{self._lib_target_prefix}bimg_decode", f"{self._lib_target_prefix}bimg_encode"] + if self.options.shared: + projs.extend([f"{self._lib_target_prefix}bgfx-shared-lib"]) + else: + projs.extend([f"{self._lib_target_prefix}bgfx"]) + if self.options.tools: + for tool in self._tools: + if "shaderc" in tool: + projs.extend([f"{self._tool_target_prefix}{self._shaderc_target_prefix}{tool}"]) + else: + projs.extend([f"{self._tool_target_prefix}{tool}"]) + return projs + + @property + def _compiler_required(self): + return { + "gcc": "8", + "clang": "11", + "apple-clang": "12", #to keep CCI compiling on osx 11.0 or higher, for now + } + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + self.requires("opengl/system") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + check_min_vs(self, 192) + if not is_msvc(self): + try: + minimum_required_compiler_version = self._compiler_required[str(self.settings.compiler)] + if Version(self.settings.compiler.version) < minimum_required_compiler_version: + raise ConanInvalidConfiguration("This package requires C++17 support. The current compiler does not support it.") + except KeyError: + self.output.warn("This recipe has no checking for the current compiler. Please consider adding it.") + + def build_requirements(self): + self.tool_requires("genie/1170") + if not is_msvc(self) and self._settings_build.os == "Windows": + if self.settings.os == "Windows": # building for windows mingw + # self.win_bash = True + # if not self.conf.get("tools.microsoft.bash:path", check_type=str): + # self.tool_requires("msys2/cci.latest") + if "MINGW" not in os.environ: + self.tool_requires("mingw-builds/13.2.0") + else: # cross-compiling for something else, probably android; get native make + self.tool_requires("make/[>=4.4.1]") + if self.settings.os == "Android" and "ANDROID_NDK_ROOT" not in os.environ: + self.tool_requires("android-ndk/[>=r26d]") + + def source(self): + get(self, **self.conan_data["sources"][self.version]["bgfx"], strip_root=True, + destination=os.path.join(self.source_folder, self._bgfx_folder)) + # bgfx's genie project, and the projects generated by it, expect bx and bimg source to be present on the same relative root as bgfx's in order to build + # usins a pre-built bx and bimg instead would require significant changes to the genie project but may be worth looking into in the future, if upstream wants to go that route + get(self, **self.conan_data["sources"][self.version]["bx"], strip_root=True, + destination=os.path.join(self.source_folder, self._bx_folder)) + get(self, **self.conan_data["sources"][self.version]["bimg"], strip_root=True, + destination=os.path.join(self.source_folder, self._bimg_folder)) + + def generate(self): + vbe = VirtualBuildEnv(self) + vbe.generate() + if is_msvc(self): + tc = VCVars(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + tc.generate() + + def build(self): + # Patch rtti - cci expects most packages to be built with rtti enabled; mismatches can cause link issues + if self.options.rtti: + self.output.info("Disabling no-rtti.") + replace_in_file(self, os.path.join(self.source_folder, self._bx_folder, "scripts", "toolchain.lua"), + "\"NoRTTI\",", "") + if is_msvc(self): + # Conan to Genie translation maps + vs_ver_to_genie = {"17": "2022", "16": "2019", "15": "2017", + "194": "2022", "193": "2022", "192": "2019", "191": "2017"} + + # Use genie directly, then msbuild on specific projects based on requirements + genie_VS = f"vs{vs_ver_to_genie[str(self.settings.compiler.version)]}" + genie_gen = f"{self._genie_extra} {genie_VS}" + self.run(f"genie {genie_gen}", cwd=self._bgfx_path) + + msbuild = MSBuild(self) + # customize to Release when RelWithDebInfo + msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release" + # use Win32 instead of the default value when building x86 + msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform + msbuild.build(os.path.join(self._bgfx_path, ".build", "projects", genie_VS, "bgfx.sln"), targets=self._projs) + else: + # Not sure if XCode can be spefically handled by conan for building through, so assume everything not VS is make + # gcc-multilib and g++-multilib required for 32bit cross-compilation, should see if we can check and install through conan + + # Conan to Genie translation maps + compiler_str = str(self.settings.compiler) + compiler_and_os_to_genie = {"Windows": f"--gcc=mingw-{compiler_str}", "Linux": f"--gcc=linux-{compiler_str}", + "FreeBSD": "--gcc=freebsd", "Macos": "--gcc=osx", + "Android": "--gcc=android", "iOS": "--gcc=ios"} + gmake_os_to_proj = {"Windows": "mingw", "Linux": "linux", "FreeBSD": "freebsd", "Macos": "osx", "Android": "android", "iOS": "ios"} + gmake_android_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x86_64", "armv8": "-arm64", "armv7": "-arm"} + gmake_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x64", "armv8": "-arm64", "armv7": "-arm"} + os_to_use_arch_config_suffix = {"Windows": False, "Linux": False, "FreeBSD": False, "Macos": True, "Android": True, "iOS": True} + + build_type_to_make_config = {"Debug": "config=debug", "Release": "config=release"} + arch_to_make_config_suffix = {"x86": "32", "x86_64": "64"} + os_to_use_make_config_suffix = {"Windows": True, "Linux": True, "FreeBSD": True, "Macos": False, "Android": False, "iOS": False} + + # Generate projects through genie + genie_args = f"{self._genie_extra} {compiler_and_os_to_genie[str(self.settings.os)]}" + if os_to_use_arch_config_suffix[str(self.settings.os)]: + if (self.settings.os == "Android"): + genie_args += F"{gmake_android_arch_to_genie_suffix[str(self.settings.arch)]}" + else: + genie_args += f"{gmake_arch_to_genie_suffix[str(self.settings.arch)]}" + genie_args += " gmake" + self.run(f"genie {genie_args}", cwd=self._bgfx_path) + + # Build project folder and path from given settings + proj_folder = f"gmake-{gmake_os_to_proj[str(self.settings.os)]}" + if self.settings.os == "Windows" or (compiler_str not in ["gcc", "apple-clang"] and self.settings.os != "Android"): + proj_folder += f"-{compiler_str}" #mingw-gcc or mingw-clang for windows; -clang for linux (where gcc on linux has no extra) + if os_to_use_arch_config_suffix[str(self.settings.os)]: + if (self.settings.os == "Android"): + proj_folder += gmake_android_arch_to_genie_suffix[str(self.settings.arch)] + else: + proj_folder += gmake_arch_to_genie_suffix[str(self.settings.arch)] + proj_path = os.path.sep.join([self._bgfx_path, ".build", "projects", proj_folder]) + + # Build make args from settings + conf = build_type_to_make_config[str(self.settings.build_type)] + if os_to_use_make_config_suffix[str(self.settings.os)]: + conf += arch_to_make_config_suffix[str(self.settings.arch)] + if self.settings.os == "Windows": + if "mingw-builds" in self.dependencies.build: + # self.run("if [ ! -d /mingw64 ]; then mkdir /mingw64; fi") + # self.run("pacman -Sy mingw-w64-x86_64-gcc --needed --noconfirm") + # mingw = "MINGW=$MSYS_ROOT/mingw64" + mingw = f"MINGW={self.dependencies.build['mingw-builds'].package_folder}" + else: + mingw = "MINGW=$MINGW" # user is expected to have an env var pointing to mingw; x86_64-w64-mingw32-g++ is expected in $MINGW/bin/ + proj_path = proj_path.replace("\\", "/") # Fix path for linux style... + else: + mingw = "" + autotools = Autotools(self) + # Build with make + for proj in self._projs: + autotools.make(target=proj, args=["-R", f"-C {proj_path}", mingw, conf]) + + def package(self): + lib_names = ["bx", "bimg", "bgfx"] + # Set platform suffixes and prefixes + if self.settings.os == "Windows" and is_msvc(self): + package_lib_prefix = "" + lib_pat = ".lib" + shared_lib_pat = ".lib" + else: + package_lib_prefix = "lib" + lib_pat = ".a" + if self.options.shared: + if is_apple_os(self): + shared_lib_pat = ".dylib" + else: + shared_lib_pat = ".so" + + # Get build bin folder + for out_dir in os.listdir(os.path.join(self._bgfx_path, ".build")): + if not out_dir=="projects": + build_bin = os.path.join(self._bgfx_path, ".build", out_dir, "bin") + break + + # Copy license + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self._bgfx_path) + # Copy includes + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) + # Copy libs + for lib_name in lib_names: + if lib_name == "bgfx" and self.options.shared: + copy(self, pattern=f"*{lib_name}*shared*{shared_lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + copy(self, pattern=f"*{lib_name}*shared*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + else: + copy(self, pattern=f"*{lib_name}*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + if self.options.shared and self.settings.os == "Windows": + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + + # Copy tools + if self.options.tools: + for tool in self._tools: + if is_msvc(self): + # avoid copying pdb, exp and lib files for tools on windows msvc + copy(self, pattern=f"{tool}*.exe", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + else: + copy(self, pattern=f"{tool}*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + + # Rename for consistency across platforms and configs + for lib_name in lib_names: + for out_file in Path(os.path.join(self.package_folder, "lib")).glob(f"*{lib_name}*"): + if out_file.suffix != "dylib": # dylibs break when renamed + lib_name_extra = "" + if out_file.name.find("encode") >= 0: + lib_name_extra = "_encode" + elif out_file.name.find("decode") >= 0: + lib_name_extra = "_decode" + rename(self, os.path.join(self.package_folder, "lib", out_file.name), + os.path.join(self.package_folder, "lib", f"{package_lib_prefix}{lib_name}{lib_name_extra}{out_file.suffix}")) + if self.options.tools: + for tool in self._tools: + for out_file in Path(os.path.join(self.package_folder, "bin")).glob(f"*{tool}*"): + rename(self, os.path.join(self.package_folder, "bin", out_file.name), + os.path.join(self.package_folder, "bin", f"{tool}{out_file.suffix}")) + + # Maybe this helps + if is_apple_os(self): + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + # Warning: order of linked libs matters on linux + if self.options.shared and is_apple_os(self): + self.cpp_info.libs.extend([f"bgfx-shared-lib{self.settings.build_type}"]) + else: + self.cpp_info.libs.extend(["bgfx"]) + self.cpp_info.libs.extend(["bimg_encode", "bimg_decode", "bimg", "bx"]) + + if self.options.shared: + self.cpp_info.defines.extend(["BGFX_SHARED_LIB_USE=1"]) + + if self.settings.build_type == "Debug": + self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=1"]) + else: + self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=0"]) + + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["gdi32"]) + if self.settings.arch == "x86": + self.cpp_info.system_libs.extend(["psapi"]) + if is_msvc(self): + self.cpp_info.defines.extend(["__STDC_LIMIT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_CONSTANT_MACROS"]) + self.cpp_info.includedirs.extend(["include/compat/msvc"]) + self.cpp_info.cxxflags.extend(["/Zc:__cplusplus", "/Zc:preprocessor"]) + else: + self.cpp_info.includedirs.extend(["include/compat/mingw"]) + self.cpp_info.system_libs.extend(["comdlg32"]) + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["dl", "pthread", "X11", "GL"]) + if self.settings.os == "Linux": + self.cpp_info.includedirs.extend(["include/compat/linux"]) + else: + self.cpp_info.includedirs.extend(["include/compat/freebsd"]) + elif is_apple_os(self): + self.cpp_info.frameworks.extend(["CoreFoundation", "Foundation", "Cocoa", "AppKit", "IOKit", "QuartzCore", "Metal"]) + if self.settings.os in ["Macos"]: + self.cpp_info.frameworks.extend(["OpenGL"]) + self.cpp_info.includedirs.extend(["include/compat/osx"]) + else: + self.cpp_info.frameworks.extend(["OpenGLES", "UIKit"]) + self.cpp_info.includedirs.extend(["include/compat/ios"]) + elif self.settings.os in ["Android"]: + self.cpp_info.system_libs.extend(["c", "dl", "m", "android", "log", "c++_shared", "EGL", "GLESv2"]) + + self.cpp_info.set_property("cmake_file_name", "bgfx") + self.cpp_info.set_property("cmake_target_name", "bgfx::bgfx") + self.cpp_info.set_property("pkg_config_name", "bgfx") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "bgfx" + self.cpp_info.filenames["cmake_find_package_multi"] = "bgfx" + self.cpp_info.names["cmake_find_package"] = "bgfx" + self.cpp_info.names["cmake_find_package_multi"] = "bgfx" diff --git a/recipes/bgfx/consolidated/test_package/CMakeLists.txt b/recipes/bgfx/consolidated/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..2c968e2dda718 --- /dev/null +++ b/recipes/bgfx/consolidated/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +find_package(bgfx REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +target_link_libraries(${PROJECT_NAME} bgfx::bgfx) diff --git a/recipes/bgfx/consolidated/test_package/conanfile.py b/recipes/bgfx/consolidated/test_package/conanfile.py new file mode 100644 index 0000000000000..4e578144a798a --- /dev/null +++ b/recipes/bgfx/consolidated/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/bgfx/consolidated/test_package/test_package.cpp b/recipes/bgfx/consolidated/test_package/test_package.cpp new file mode 100644 index 0000000000000..c19356456589b --- /dev/null +++ b/recipes/bgfx/consolidated/test_package/test_package.cpp @@ -0,0 +1,71 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported +#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) +#include +#else +#include +#endif + +//An embedded 2x2 PNG image in RGB8 format with a red pixel, a green pixel, a blue pixel and a white pixel +const unsigned char img[129] ={0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, +0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x02, +0x00, 0x00, 0x00, 0x02, 0x08, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xd4, 0x9a, +0x73, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, +0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, +0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, +0x59, 0x73, 0x00, 0x00, 0x0e, 0xc3, 0x00, 0x00, 0x0e, 0xc3, 0x01, 0xc7, +0x6f, 0xa8, 0x64, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54, 0x18, +0x57, 0x63, 0x78, 0x2b, 0xa3, 0xa2, 0xb4, 0xd1, 0x87, 0xc1, 0xde, 0xe3, +0xcc, 0xff, 0xff, 0xff, 0x01, 0x24, 0xec, 0x06, 0x9d, 0x64, 0xf4, 0x18, +0xdc, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; + + +int main() { + //test bx + float tLerp = bx::lerp(0.0f, 10.0f, 0.5f); + BX_TRACE("Lerped 0.0f to 10.0f at 0.5f, result %f", tLerp); + BX_ASSERT(bx::isEqual(tLerp, 5.0f, 0.1f), "isEqual failed"); + bx::debugPrintf("Length of \"test\" is: %d", bx::strLen("test")); + + //test bimg + bx::DefaultAllocator defAlloc; + bimg::ImageContainer* imageContainer = nullptr; + imageContainer = bimg::imageParse(&defAlloc, (const void*) img, 129 * sizeof(char)); + BX_ASSERT(imageContainer->m_format == bimg::TextureFormat::RGB8, "Image incorrectly decoded.") + bimg::imageFree(imageContainer); + + //test bgfx +#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) + bgfx_init_t init; + bgfx_init_ctor(&init); + init.type = bgfx_renderer_type::BGFX_RENDERER_TYPE_NOOP; + init.vendorId = BGFX_PCI_ID_NONE; + init.platformData.nwh = nullptr; + init.platformData.ndt = nullptr; + init.resolution.width = 0; + init.resolution.height = 0; + init.resolution.reset = BGFX_RESET_NONE; + bgfx_init(&init); + bgfx_shutdown(); + return 0; +#else + bgfx::Init init; + init.type = bgfx::RendererType::Noop; + init.vendorId = BGFX_PCI_ID_NONE; + init.platformData.nwh = nullptr; + init.platformData.ndt = nullptr; + init.resolution.width = 0; + init.resolution.height = 0; + init.resolution.reset = BGFX_RESET_NONE; + bgfx::init(init); + bgfx::shutdown(); +#endif +} diff --git a/recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt b/recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt new file mode 100644 index 0000000000000..667976629550a --- /dev/null +++ b/recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.8) + +project(test_package LANGUAGES CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/bgfx/consolidated/test_v1_package/conanfile.py b/recipes/bgfx/consolidated/test_v1_package/conanfile.py new file mode 100644 index 0000000000000..056e75eddb91c --- /dev/null +++ b/recipes/bgfx/consolidated/test_v1_package/conanfile.py @@ -0,0 +1,17 @@ +from conans import ConanFile, CMake, tools +import os + + +class BimgTestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "cmake_find_package_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From df89034560c73be9e3d4d61e0ad907b991b3662d Mon Sep 17 00:00:00 2001 From: Raziel Date: Mon, 24 Jun 2024 00:10:52 +0300 Subject: [PATCH 2/9] Move new recipe to all Move old recipe to cci2023 Use matching bx commit Add cppstd handling for conan 1 to toolchain generators Add apple sdk checks Change warning for compiler check --- recipes/bgfx/all/conandata.yml | 13 +- recipes/bgfx/all/conanfile.py | 262 ++++++++----- .../bgfx/all/test_package/test_package.cpp | 37 +- recipes/bgfx/cci2023/conandata.yml | 4 + recipes/bgfx/cci2023/conanfile.py | 321 +++++++++++++++ .../test_package/CMakeLists.txt | 0 .../test_package/conanfile.py | 0 .../cci2023/test_package/test_package.cpp | 36 ++ .../test_v1_package/CMakeLists.txt | 0 .../test_v1_package/conanfile.py | 0 recipes/bgfx/config.yml | 4 +- recipes/bgfx/consolidated/conandata.yml | 11 - recipes/bgfx/consolidated/conanfile.py | 368 ------------------ .../test_package/test_package.cpp | 71 ---- 14 files changed, 566 insertions(+), 561 deletions(-) create mode 100644 recipes/bgfx/cci2023/conandata.yml create mode 100644 recipes/bgfx/cci2023/conanfile.py rename recipes/bgfx/{consolidated => cci2023}/test_package/CMakeLists.txt (100%) rename recipes/bgfx/{consolidated => cci2023}/test_package/conanfile.py (100%) create mode 100644 recipes/bgfx/cci2023/test_package/test_package.cpp rename recipes/bgfx/{consolidated => cci2023}/test_v1_package/CMakeLists.txt (100%) rename recipes/bgfx/{consolidated => cci2023}/test_v1_package/conanfile.py (100%) delete mode 100644 recipes/bgfx/consolidated/conandata.yml delete mode 100644 recipes/bgfx/consolidated/conanfile.py delete mode 100644 recipes/bgfx/consolidated/test_package/test_package.cpp diff --git a/recipes/bgfx/all/conandata.yml b/recipes/bgfx/all/conandata.yml index 47606f9539fe5..0a3bd024a04bb 100644 --- a/recipes/bgfx/all/conandata.yml +++ b/recipes/bgfx/all/conandata.yml @@ -1,4 +1,11 @@ sources: - "cci.20230216": - url: "https://github.com/bkaradzic/bgfx/archive/9d5b980f5c060e54cc30dec18500a5b54db00405.tar.gz" - sha256: "291739720E369C5C2422273D887AEC590084B29E5C9DC5C9441F5A68869B6736" + "1.127.8771": + "bgfx": + url: "https://github.com/bkaradzic/bgfx/archive/06d0e2af2f50fee3e8e84e0c3b407073692a678c.tar.gz" + sha256: "0869F9D18C63AB8D804918FEFCC53D8568626A26FCAE7273DF1A70D4C8E7AFE3" + "bimg": + url: "https://github.com/bkaradzic/bimg/archive/2afa64c14c1e3dd5d28412ee03bee0dfe7242f03.tar.gz" + sha256: "376E17EA4A70CEE72E6006DD942CB2F2FE3DB047F524A3F203A15A8BBA1BCD90" + "bx": + url: "https://github.com/bkaradzic/bx/archive/c5b7b4629961ed7ac882cd3f64f28e1b25910e55.tar.gz" + sha256: "0fc705c7bb7ae01f2a2e1ef2be2426b877407e4cdab1b3ca5d4f77eb814716df" diff --git a/recipes/bgfx/all/conanfile.py b/recipes/bgfx/all/conanfile.py index 9de812b7f94ea..46f1d6cf5b927 100644 --- a/recipes/bgfx/all/conanfile.py +++ b/recipes/bgfx/all/conanfile.py @@ -1,12 +1,12 @@ from conan import ConanFile -from conan.tools.files import copy, get, rename +from conan.tools.files import copy, get, rename, replace_in_file from conan.tools.build import check_min_cppstd from conan.tools.layout import basic_layout from conan.tools.microsoft import is_msvc, check_min_vs, is_msvc_static_runtime from conan.tools.apple import fix_apple_shared_install_name, is_apple_os from conan.tools.scm import Version from conan.errors import ConanInvalidConfiguration -from conan.tools.microsoft import MSBuild, VCVars +from conan.tools.microsoft import MSBuild, MSBuildToolchain from conan.tools.gnu import Autotools, AutotoolsToolchain from conan.tools.env import VirtualBuildEnv from pathlib import Path @@ -20,10 +20,10 @@ class bgfxConan(ConanFile): homepage = "https://github.com/bkaradzic/bgfx" url = "https://github.com/conan-io/conan-center-index" description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." - topics = ("rendering", "graphics") + topics = ("rendering", "graphics", "gamedev") settings = "os", "compiler", "arch", "build_type" - options = {"shared": [True, False], "tools": [True, False]} - default_options = {"shared": False, "tools": False} + options = {"fPIC": [True, False], "shared": [True, False], "tools": [True, False], "rtti": [True, False]} + default_options = {"fPIC": True, "shared": False, "tools": False, "rtti": True} @property def _bx_folder(self): @@ -48,119 +48,133 @@ def _genie_extra(self): genie_extra += " --with-dynamic-runtime" if self.options.shared: genie_extra += " --with-shared-lib" - if self.options.tools: - genie_extra += " --with-tools" + # generate tools projects regardless of tools option because that also generates bimg_encode + genie_extra += " --with-tools" return genie_extra @property def _lib_target_prefix(self): - if self.settings.os == "Windows": + if is_msvc(self): return "libs\\" else: return "" @property def _tool_target_prefix(self): - if self.settings.os == "Windows": + if is_msvc(self): return "tools\\" else: return "" @property def _shaderc_target_prefix(self): - if self.settings.os == "Windows": + if is_msvc(self): return "shaderc\\" else: return "" + + @property + def _tools(self): + return ["texturec", "texturev", "geometryc", "geometryv", "shaderc"] @property def _projs(self): + projs = [f"{self._lib_target_prefix}bx", f"{self._lib_target_prefix}bimg", f"{self._lib_target_prefix}bimg_decode", f"{self._lib_target_prefix}bimg_encode"] if self.options.shared: - projs = [f"{self._lib_target_prefix}bgfx-shared-lib"] + projs.extend([f"{self._lib_target_prefix}bgfx-shared-lib"]) else: - projs = [f"{self._lib_target_prefix}bgfx"] + projs.extend([f"{self._lib_target_prefix}bgfx"]) if self.options.tools: - projs.extend([f"{self._tool_target_prefix}{self._shaderc_target_prefix}shaderc", - f"{self._tool_target_prefix}texturev", - f"{self._tool_target_prefix}geometryc", - f"{self._tool_target_prefix}geometryv"]) + for tool in self._tools: + if "shaderc" in tool: + projs.extend([f"{self._tool_target_prefix}{self._shaderc_target_prefix}{tool}"]) + else: + projs.extend([f"{self._tool_target_prefix}{tool}"]) return projs @property def _compiler_required(self): return { "gcc": "8", - "clang": "3.3", + "clang": "11", "apple-clang": "12", #to keep CCI compiling on osx 11.0 or higher, for now - "msvc": "191", - "Visual Studio": "15" #TODO remove with conan 2.0 } - @property - def _bx_version(self): #mapping of bgfx version to required/used bx version - return {"cci.20230216": "cci.20221116"} - - @property - def _bimg_version(self): #mapping of bgfx version to required/used bimg version - return {"cci.20230216": "cci.20230114"} - @property def _settings_build(self): return getattr(self, "settings_build", self.settings) + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + def layout(self): basic_layout(self, src_folder="src") def requirements(self): - # bgfx's C99 API absolutely requires a header from bx so we need those to be transitive - self.requires(f"bx/{self._bx_version[self.version]}", transitive_headers=True) - self.requires(f"bimg/{self._bimg_version[self.version]}") self.requires("opengl/system") def validate(self): if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, 14) - check_min_vs(self, 191) + check_min_cppstd(self, 17) + check_min_vs(self, 192) + if self.settings.os == "Macos" and self.settings.get_safe("os.sdk_version") and self.settings.get_safe("os.sdk_version") < "13.0": + raise ConanInvalidConfiguration(f"{self.ref} requires macos sdk version >= 13") + if self.settings.os in ["iOS", "tvOS"] and self.settings.get_safe("os.sdk_version") and self.settings.get_safe("os.sdk_version") < "16.0": + raise ConanInvalidConfiguration(f"{self.ref} requires iOS/tvOS sdk version >= 16") if not is_msvc(self): try: minimum_required_compiler_version = self._compiler_required[str(self.settings.compiler)] if Version(self.settings.compiler.version) < minimum_required_compiler_version: - raise ConanInvalidConfiguration("This package requires C++14 support. The current compiler does not support it.") + raise ConanInvalidConfiguration("This package requires C++17 support. The current compiler does not support it.") except KeyError: - self.output.warn("This recipe has no checking for the current compiler. Please consider adding it.") + self.output.warning(f"{self.ref} does no checking for the current compiler. Assuming it works, please consider adding it.") def build_requirements(self): self.tool_requires("genie/1170") if not is_msvc(self) and self._settings_build.os == "Windows": - self.win_bash = True - if not self.conf.get("tools.microsoft.bash:path", check_type=str): - self.tool_requires("msys2/cci.latest") + if self.settings.os == "Windows": # building for windows mingw + if "MINGW" not in os.environ: + self.tool_requires("mingw-builds/13.2.0") + else: # cross-compiling for something else, probably android; get native make + self.tool_requires("make/[>=4.4.1]") + if self.settings.os == "Android" and "ANDROID_NDK_ROOT" not in os.environ: + self.tool_requires("android-ndk/[>=r26d]") def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True, + get(self, **self.conan_data["sources"][self.version]["bgfx"], strip_root=True, destination=os.path.join(self.source_folder, self._bgfx_folder)) - # bgfx's genie project, and the projects generated by it, expect bx and bimg source to be present on the same relative root as bimg's in order to build - # usins a pre-built bx and bimg instead would require significant changes to the genie project but may be worth looking into in the future - get(self, **self.dependencies["bx"].conan_data["sources"][self._bx_version[self.version]], strip_root=True, + # bgfx's genie project, and the projects generated by it, expect bx and bimg source to be present on the same relative root as bgfx's in order to build + # usins a pre-built bx and bimg instead would require significant changes to the genie project but may be worth looking into in the future, if upstream wants to go that route + get(self, **self.conan_data["sources"][self.version]["bx"], strip_root=True, destination=os.path.join(self.source_folder, self._bx_folder)) - get(self, **self.dependencies["bimg"].conan_data["sources"][self._bimg_version[self.version]], strip_root=True, + get(self, **self.conan_data["sources"][self.version]["bimg"], strip_root=True, destination=os.path.join(self.source_folder, self._bimg_folder)) def generate(self): vbe = VirtualBuildEnv(self) vbe.generate() if is_msvc(self): - tc = VCVars(self) + tc = MSBuildToolchain(self) + if not self.settings.get_safe("compiler.cppstd"): + tc.cppstd = "c++17" tc.generate() else: tc = AutotoolsToolchain(self) + if not self.settings.get_safe("compiler.cppstd"): + tc.cppstd = "c++17" tc.generate() def build(self): + # Patch rtti - cci expects most packages to be built with rtti enabled; mismatches can cause link issues + if self.options.rtti: + self.output.info("Disabling no-rtti.") + replace_in_file(self, os.path.join(self.source_folder, self._bx_folder, "scripts", "toolchain.lua"), + "\"NoRTTI\",", "") if is_msvc(self): # Conan to Genie translation maps vs_ver_to_genie = {"17": "2022", "16": "2019", "15": "2017", - "193": "2022", "192": "2019", "191": "2017"} + "194": "2022", "193": "2022", "192": "2019", "191": "2017"} # Use genie directly, then msbuild on specific projects based on requirements genie_VS = f"vs{vs_ver_to_genie[str(self.settings.compiler.version)]}" @@ -183,6 +197,7 @@ def build(self): "FreeBSD": "--gcc=freebsd", "Macos": "--gcc=osx", "Android": "--gcc=android", "iOS": "--gcc=ios"} gmake_os_to_proj = {"Windows": "mingw", "Linux": "linux", "FreeBSD": "freebsd", "Macos": "osx", "Android": "android", "iOS": "ios"} + gmake_android_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x86_64", "armv8": "-arm64", "armv7": "-arm"} gmake_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x64", "armv8": "-arm64", "armv7": "-arm"} os_to_use_arch_config_suffix = {"Windows": False, "Linux": False, "FreeBSD": False, "Macos": True, "Android": True, "iOS": True} @@ -191,27 +206,39 @@ def build(self): os_to_use_make_config_suffix = {"Windows": True, "Linux": True, "FreeBSD": True, "Macos": False, "Android": False, "iOS": False} # Generate projects through genie - genieGen = f"{self._genie_extra} {compiler_and_os_to_genie[str(self.settings.os)]}" + genie_args = f"{self._genie_extra} {compiler_and_os_to_genie[str(self.settings.os)]}" if os_to_use_arch_config_suffix[str(self.settings.os)]: - genieGen += f"{gmake_arch_to_genie_suffix[str(self.settings.arch)]}" - genieGen += " gmake" - self.run(f"genie {genieGen}", cwd=self._bgfx_path) + if (self.settings.os == "Android"): + genie_args += F"{gmake_android_arch_to_genie_suffix[str(self.settings.arch)]}" + else: + genie_args += f"{gmake_arch_to_genie_suffix[str(self.settings.arch)]}" + genie_args += " gmake" + self.run(f"genie {genie_args}", cwd=self._bgfx_path) # Build project folder and path from given settings - projFolder = f"gmake-{gmake_os_to_proj[str(self.settings.os)]}" - if self.settings.os == "Windows" or compiler_str not in ["gcc", "apple-clang"]: - projFolder += f"-{compiler_str}" #mingw-gcc or mingw-clang for windows; -clang for linux (where gcc on linux has no extra) + proj_folder = f"gmake-{gmake_os_to_proj[str(self.settings.os)]}" + if self.settings.os == "Windows" or (compiler_str not in ["gcc", "apple-clang"] and self.settings.os != "Android"): + proj_folder += f"-{compiler_str}" #mingw-gcc or mingw-clang for windows; -clang for linux (where gcc on linux has no extra) if os_to_use_arch_config_suffix[str(self.settings.os)]: - projFolder += gmake_arch_to_genie_suffix[str(self.settings.arch)] - proj_path = os.path.sep.join([self._bgfx_path, ".build", "projects", projFolder]) + if (self.settings.os == "Android"): + proj_folder += gmake_android_arch_to_genie_suffix[str(self.settings.arch)] + else: + proj_folder += gmake_arch_to_genie_suffix[str(self.settings.arch)] + proj_path = os.path.sep.join([self._bgfx_path, ".build", "projects", proj_folder]) # Build make args from settings conf = build_type_to_make_config[str(self.settings.build_type)] if os_to_use_make_config_suffix[str(self.settings.os)]: conf += arch_to_make_config_suffix[str(self.settings.arch)] if self.settings.os == "Windows": - mingw = "MINGW=$MINGW_PREFIX" - proj_path = proj_path.replace("\\", "/") # Fix path for msys... + if "mingw-builds" in self.dependencies.build: + # self.run("if [ ! -d /mingw64 ]; then mkdir /mingw64; fi") + # self.run("pacman -Sy mingw-w64-x86_64-gcc --needed --noconfirm") + # mingw = "MINGW=$MSYS_ROOT/mingw64" + mingw = f"MINGW={self.dependencies.build['mingw-builds'].package_folder}" + else: + mingw = "MINGW=$MINGW" # user is expected to have an env var pointing to mingw; x86_64-w64-mingw32-g++ is expected in $MINGW/bin/ + proj_path = proj_path.replace("\\", "/") # Fix path for linux style... else: mingw = "" autotools = Autotools(self) @@ -220,95 +247,120 @@ def build(self): autotools.make(target=proj, args=["-R", f"-C {proj_path}", mingw, conf]) def package(self): - # Set platform suffixes and prefixes - if self.settings.os == "Windows": - if self.options.shared: - lib_pat = "*bgfx-shared-lib*.lib" - else: - lib_pat = "*bgfx*.lib" + lib_names = ["bx", "bimg", "bgfx"] + # Set platform suffixes and prefixes + if self.settings.os == "Windows" and is_msvc(self): package_lib_prefix = "" - elif self.settings.os in ["Linux", "FreeBSD"]: - if self.options.shared: - lib_pat = "*bgfx*.so" - else: - lib_pat = "*bgfx*.a" + lib_pat = ".lib" + shared_lib_pat = ".lib" + else: package_lib_prefix = "lib" - elif self.settings.os in ["Macos", "iOS"]: + lib_pat = ".a" if self.options.shared: - lib_pat = "*bgfx*.dylib" - else: - lib_pat = "*bgfx*.a" - package_lib_prefix = "lib" + if is_apple_os(self): + shared_lib_pat = ".dylib" + else: + shared_lib_pat = ".so" # Get build bin folder - for bimg_out_dir in os.listdir(os.path.join(self._bgfx_path, ".build")): - if not bimg_out_dir=="projects": - build_bin = os.path.join(self._bgfx_path, ".build", bimg_out_dir, "bin") + for out_dir in os.listdir(os.path.join(self._bgfx_path, ".build")): + if not out_dir=="projects": + build_bin = os.path.join(self._bgfx_path, ".build", out_dir, "bin") break # Copy license copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self._bgfx_path) # Copy includes copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) + copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) # Copy libs - copy(self, pattern=lib_pat, dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) - if self.options.shared: + for lib_name in lib_names: + if lib_name == "bgfx" and self.options.shared: + copy(self, pattern=f"*{lib_name}*shared*{shared_lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + copy(self, pattern=f"*{lib_name}*shared*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + else: + copy(self, pattern=f"*{lib_name}*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + if self.options.shared and self.settings.os == "Windows": copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) # Copy tools if self.options.tools: - copy(self, pattern="shaderc*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - copy(self, pattern="texturev*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - copy(self, pattern="geometryc*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - copy(self, pattern="geometryv*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + for tool in self._tools: + if is_msvc(self): + # avoid copying pdb, exp and lib files for tools on windows msvc + copy(self, pattern=f"{tool}*.exe", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + else: + copy(self, pattern=f"{tool}*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) # Rename for consistency across platforms and configs - if not (is_apple_os(self) and self.options.shared): #Apparently apple dylibs break if renamed - for bgfx_file in Path(os.path.join(self.package_folder, "lib")).glob("*bgfx*"): - rename(self, os.path.join(self.package_folder, "lib", bgfx_file.name), - os.path.join(self.package_folder, "lib", f"{package_lib_prefix}bgfx{bgfx_file.suffix}")) + for lib_name in lib_names: + for out_file in Path(os.path.join(self.package_folder, "lib")).glob(f"*{lib_name}*"): + if out_file.suffix != "dylib": # dylibs break when renamed + lib_name_extra = "" + if out_file.name.find("encode") >= 0: + lib_name_extra = "_encode" + elif out_file.name.find("decode") >= 0: + lib_name_extra = "_decode" + rename(self, os.path.join(self.package_folder, "lib", out_file.name), + os.path.join(self.package_folder, "lib", f"{package_lib_prefix}{lib_name}{lib_name_extra}{out_file.suffix}")) if self.options.tools: - for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*shaderc*"): - rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), - os.path.join(self.package_folder, "bin", f"shaderc{bgfx_file.suffix}")) - for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*texturev*"): - rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), - os.path.join(self.package_folder, "bin", f"texturev{bgfx_file.suffix}")) - for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*geometryc*"): - rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), - os.path.join(self.package_folder, "bin", f"geometryc{bgfx_file.suffix}")) - for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*geometryv*"): - rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), - os.path.join(self.package_folder, "bin", f"geometryv{bgfx_file.suffix}")) - + for tool in self._tools: + for out_file in Path(os.path.join(self.package_folder, "bin")).glob(f"*{tool}*"): + rename(self, os.path.join(self.package_folder, "bin", out_file.name), + os.path.join(self.package_folder, "bin", f"{tool}{out_file.suffix}")) + # Maybe this helps if is_apple_os(self): fix_apple_shared_install_name(self) def package_info(self): self.cpp_info.includedirs = ["include"] - if self.options.shared and self.settings.os in ["Macos", "iOS"]: - self.cpp_info.libs = [f"bgfx-shared-lib{self.settings.build_type}"] + # Warning: order of linked libs matters on linux + if self.options.shared and is_apple_os(self): + self.cpp_info.libs.extend([f"bgfx-shared-lib{self.settings.build_type}"]) else: - self.cpp_info.libs = ["bgfx"] + self.cpp_info.libs.extend(["bgfx"]) + self.cpp_info.libs.extend(["bimg_encode", "bimg_decode", "bimg", "bx"]) if self.options.shared: self.cpp_info.defines.extend(["BGFX_SHARED_LIB_USE=1"]) + if self.settings.build_type == "Debug": + self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=1"]) + else: + self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=0"]) + if self.settings.os == "Windows": self.cpp_info.system_libs.extend(["gdi32"]) - if not is_msvc(self): + if self.settings.arch == "x86": + self.cpp_info.system_libs.extend(["psapi"]) + if is_msvc(self): + self.cpp_info.defines.extend(["__STDC_LIMIT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_CONSTANT_MACROS"]) + self.cpp_info.includedirs.extend(["include/compat/msvc"]) + self.cpp_info.cxxflags.extend(["/Zc:__cplusplus", "/Zc:preprocessor"]) + else: + self.cpp_info.includedirs.extend(["include/compat/mingw"]) self.cpp_info.system_libs.extend(["comdlg32"]) elif self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["X11", "GL"]) - elif self.settings.os in ["Macos", "iOS"]: - self.cpp_info.frameworks.extend(["CoreFoundation", "AppKit", "IOKit", "QuartzCore", "Metal"]) + self.cpp_info.system_libs.extend(["dl", "pthread", "X11", "GL"]) + if self.settings.os == "Linux": + self.cpp_info.includedirs.extend(["include/compat/linux"]) + else: + self.cpp_info.includedirs.extend(["include/compat/freebsd"]) + elif is_apple_os(self): + self.cpp_info.frameworks.extend(["CoreFoundation", "Foundation", "Cocoa", "AppKit", "IOKit", "QuartzCore", "Metal"]) if self.settings.os in ["Macos"]: self.cpp_info.frameworks.extend(["OpenGL"]) + self.cpp_info.includedirs.extend(["include/compat/osx"]) else: self.cpp_info.frameworks.extend(["OpenGLES", "UIKit"]) + self.cpp_info.includedirs.extend(["include/compat/ios"]) elif self.settings.os in ["Android"]: - self.cpp_info.system_libs.extend(["EGL", "GLESv2"]) + self.cpp_info.system_libs.extend(["c", "dl", "m", "android", "log", "c++_shared", "EGL", "GLESv2"]) self.cpp_info.set_property("cmake_file_name", "bgfx") self.cpp_info.set_property("cmake_target_name", "bgfx::bgfx") diff --git a/recipes/bgfx/all/test_package/test_package.cpp b/recipes/bgfx/all/test_package/test_package.cpp index 630c14bc99ec9..c19356456589b 100644 --- a/recipes/bgfx/all/test_package/test_package.cpp +++ b/recipes/bgfx/all/test_package/test_package.cpp @@ -1,13 +1,48 @@ -//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported +#include +#include #include +#include +#include +#include +#include +#include +//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported #if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) #include #else #include #endif +//An embedded 2x2 PNG image in RGB8 format with a red pixel, a green pixel, a blue pixel and a white pixel +const unsigned char img[129] ={0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, +0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x02, +0x00, 0x00, 0x00, 0x02, 0x08, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xd4, 0x9a, +0x73, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, +0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, +0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, +0x59, 0x73, 0x00, 0x00, 0x0e, 0xc3, 0x00, 0x00, 0x0e, 0xc3, 0x01, 0xc7, +0x6f, 0xa8, 0x64, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54, 0x18, +0x57, 0x63, 0x78, 0x2b, 0xa3, 0xa2, 0xb4, 0xd1, 0x87, 0xc1, 0xde, 0xe3, +0xcc, 0xff, 0xff, 0xff, 0x01, 0x24, 0xec, 0x06, 0x9d, 0x64, 0xf4, 0x18, +0xdc, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; + + int main() { + //test bx + float tLerp = bx::lerp(0.0f, 10.0f, 0.5f); + BX_TRACE("Lerped 0.0f to 10.0f at 0.5f, result %f", tLerp); + BX_ASSERT(bx::isEqual(tLerp, 5.0f, 0.1f), "isEqual failed"); + bx::debugPrintf("Length of \"test\" is: %d", bx::strLen("test")); + + //test bimg + bx::DefaultAllocator defAlloc; + bimg::ImageContainer* imageContainer = nullptr; + imageContainer = bimg::imageParse(&defAlloc, (const void*) img, 129 * sizeof(char)); + BX_ASSERT(imageContainer->m_format == bimg::TextureFormat::RGB8, "Image incorrectly decoded.") + bimg::imageFree(imageContainer); + + //test bgfx #if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) bgfx_init_t init; bgfx_init_ctor(&init); diff --git a/recipes/bgfx/cci2023/conandata.yml b/recipes/bgfx/cci2023/conandata.yml new file mode 100644 index 0000000000000..47606f9539fe5 --- /dev/null +++ b/recipes/bgfx/cci2023/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20230216": + url: "https://github.com/bkaradzic/bgfx/archive/9d5b980f5c060e54cc30dec18500a5b54db00405.tar.gz" + sha256: "291739720E369C5C2422273D887AEC590084B29E5C9DC5C9441F5A68869B6736" diff --git a/recipes/bgfx/cci2023/conanfile.py b/recipes/bgfx/cci2023/conanfile.py new file mode 100644 index 0000000000000..9de812b7f94ea --- /dev/null +++ b/recipes/bgfx/cci2023/conanfile.py @@ -0,0 +1,321 @@ +from conan import ConanFile +from conan.tools.files import copy, get, rename +from conan.tools.build import check_min_cppstd +from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc, check_min_vs, is_msvc_static_runtime +from conan.tools.apple import fix_apple_shared_install_name, is_apple_os +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +from conan.tools.microsoft import MSBuild, VCVars +from conan.tools.gnu import Autotools, AutotoolsToolchain +from conan.tools.env import VirtualBuildEnv +from pathlib import Path +import os + +required_conan_version = ">=1.50.0" + +class bgfxConan(ConanFile): + name = "bgfx" + license = "BSD-2-Clause" + homepage = "https://github.com/bkaradzic/bgfx" + url = "https://github.com/conan-io/conan-center-index" + description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." + topics = ("rendering", "graphics") + settings = "os", "compiler", "arch", "build_type" + options = {"shared": [True, False], "tools": [True, False]} + default_options = {"shared": False, "tools": False} + + @property + def _bx_folder(self): + return "bx" + + @property + def _bimg_folder(self): + return "bimg" + + @property + def _bgfx_folder(self): + return "bgfx" + + @property + def _bgfx_path(self): + return os.path.join(self.source_folder, self._bgfx_folder) + + @property + def _genie_extra(self): + genie_extra = "" + if is_msvc(self) and not is_msvc_static_runtime(self): + genie_extra += " --with-dynamic-runtime" + if self.options.shared: + genie_extra += " --with-shared-lib" + if self.options.tools: + genie_extra += " --with-tools" + return genie_extra + + @property + def _lib_target_prefix(self): + if self.settings.os == "Windows": + return "libs\\" + else: + return "" + + @property + def _tool_target_prefix(self): + if self.settings.os == "Windows": + return "tools\\" + else: + return "" + + @property + def _shaderc_target_prefix(self): + if self.settings.os == "Windows": + return "shaderc\\" + else: + return "" + + @property + def _projs(self): + if self.options.shared: + projs = [f"{self._lib_target_prefix}bgfx-shared-lib"] + else: + projs = [f"{self._lib_target_prefix}bgfx"] + if self.options.tools: + projs.extend([f"{self._tool_target_prefix}{self._shaderc_target_prefix}shaderc", + f"{self._tool_target_prefix}texturev", + f"{self._tool_target_prefix}geometryc", + f"{self._tool_target_prefix}geometryv"]) + return projs + + @property + def _compiler_required(self): + return { + "gcc": "8", + "clang": "3.3", + "apple-clang": "12", #to keep CCI compiling on osx 11.0 or higher, for now + "msvc": "191", + "Visual Studio": "15" #TODO remove with conan 2.0 + } + + @property + def _bx_version(self): #mapping of bgfx version to required/used bx version + return {"cci.20230216": "cci.20221116"} + + @property + def _bimg_version(self): #mapping of bgfx version to required/used bimg version + return {"cci.20230216": "cci.20230114"} + + @property + def _settings_build(self): + return getattr(self, "settings_build", self.settings) + + def layout(self): + basic_layout(self, src_folder="src") + + def requirements(self): + # bgfx's C99 API absolutely requires a header from bx so we need those to be transitive + self.requires(f"bx/{self._bx_version[self.version]}", transitive_headers=True) + self.requires(f"bimg/{self._bimg_version[self.version]}") + self.requires("opengl/system") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 14) + check_min_vs(self, 191) + if not is_msvc(self): + try: + minimum_required_compiler_version = self._compiler_required[str(self.settings.compiler)] + if Version(self.settings.compiler.version) < minimum_required_compiler_version: + raise ConanInvalidConfiguration("This package requires C++14 support. The current compiler does not support it.") + except KeyError: + self.output.warn("This recipe has no checking for the current compiler. Please consider adding it.") + + def build_requirements(self): + self.tool_requires("genie/1170") + if not is_msvc(self) and self._settings_build.os == "Windows": + self.win_bash = True + if not self.conf.get("tools.microsoft.bash:path", check_type=str): + self.tool_requires("msys2/cci.latest") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True, + destination=os.path.join(self.source_folder, self._bgfx_folder)) + # bgfx's genie project, and the projects generated by it, expect bx and bimg source to be present on the same relative root as bimg's in order to build + # usins a pre-built bx and bimg instead would require significant changes to the genie project but may be worth looking into in the future + get(self, **self.dependencies["bx"].conan_data["sources"][self._bx_version[self.version]], strip_root=True, + destination=os.path.join(self.source_folder, self._bx_folder)) + get(self, **self.dependencies["bimg"].conan_data["sources"][self._bimg_version[self.version]], strip_root=True, + destination=os.path.join(self.source_folder, self._bimg_folder)) + + def generate(self): + vbe = VirtualBuildEnv(self) + vbe.generate() + if is_msvc(self): + tc = VCVars(self) + tc.generate() + else: + tc = AutotoolsToolchain(self) + tc.generate() + + def build(self): + if is_msvc(self): + # Conan to Genie translation maps + vs_ver_to_genie = {"17": "2022", "16": "2019", "15": "2017", + "193": "2022", "192": "2019", "191": "2017"} + + # Use genie directly, then msbuild on specific projects based on requirements + genie_VS = f"vs{vs_ver_to_genie[str(self.settings.compiler.version)]}" + genie_gen = f"{self._genie_extra} {genie_VS}" + self.run(f"genie {genie_gen}", cwd=self._bgfx_path) + + msbuild = MSBuild(self) + # customize to Release when RelWithDebInfo + msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release" + # use Win32 instead of the default value when building x86 + msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform + msbuild.build(os.path.join(self._bgfx_path, ".build", "projects", genie_VS, "bgfx.sln"), targets=self._projs) + else: + # Not sure if XCode can be spefically handled by conan for building through, so assume everything not VS is make + # gcc-multilib and g++-multilib required for 32bit cross-compilation, should see if we can check and install through conan + + # Conan to Genie translation maps + compiler_str = str(self.settings.compiler) + compiler_and_os_to_genie = {"Windows": f"--gcc=mingw-{compiler_str}", "Linux": f"--gcc=linux-{compiler_str}", + "FreeBSD": "--gcc=freebsd", "Macos": "--gcc=osx", + "Android": "--gcc=android", "iOS": "--gcc=ios"} + gmake_os_to_proj = {"Windows": "mingw", "Linux": "linux", "FreeBSD": "freebsd", "Macos": "osx", "Android": "android", "iOS": "ios"} + gmake_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x64", "armv8": "-arm64", "armv7": "-arm"} + os_to_use_arch_config_suffix = {"Windows": False, "Linux": False, "FreeBSD": False, "Macos": True, "Android": True, "iOS": True} + + build_type_to_make_config = {"Debug": "config=debug", "Release": "config=release"} + arch_to_make_config_suffix = {"x86": "32", "x86_64": "64"} + os_to_use_make_config_suffix = {"Windows": True, "Linux": True, "FreeBSD": True, "Macos": False, "Android": False, "iOS": False} + + # Generate projects through genie + genieGen = f"{self._genie_extra} {compiler_and_os_to_genie[str(self.settings.os)]}" + if os_to_use_arch_config_suffix[str(self.settings.os)]: + genieGen += f"{gmake_arch_to_genie_suffix[str(self.settings.arch)]}" + genieGen += " gmake" + self.run(f"genie {genieGen}", cwd=self._bgfx_path) + + # Build project folder and path from given settings + projFolder = f"gmake-{gmake_os_to_proj[str(self.settings.os)]}" + if self.settings.os == "Windows" or compiler_str not in ["gcc", "apple-clang"]: + projFolder += f"-{compiler_str}" #mingw-gcc or mingw-clang for windows; -clang for linux (where gcc on linux has no extra) + if os_to_use_arch_config_suffix[str(self.settings.os)]: + projFolder += gmake_arch_to_genie_suffix[str(self.settings.arch)] + proj_path = os.path.sep.join([self._bgfx_path, ".build", "projects", projFolder]) + + # Build make args from settings + conf = build_type_to_make_config[str(self.settings.build_type)] + if os_to_use_make_config_suffix[str(self.settings.os)]: + conf += arch_to_make_config_suffix[str(self.settings.arch)] + if self.settings.os == "Windows": + mingw = "MINGW=$MINGW_PREFIX" + proj_path = proj_path.replace("\\", "/") # Fix path for msys... + else: + mingw = "" + autotools = Autotools(self) + # Build with make + for proj in self._projs: + autotools.make(target=proj, args=["-R", f"-C {proj_path}", mingw, conf]) + + def package(self): + # Set platform suffixes and prefixes + if self.settings.os == "Windows": + if self.options.shared: + lib_pat = "*bgfx-shared-lib*.lib" + else: + lib_pat = "*bgfx*.lib" + package_lib_prefix = "" + elif self.settings.os in ["Linux", "FreeBSD"]: + if self.options.shared: + lib_pat = "*bgfx*.so" + else: + lib_pat = "*bgfx*.a" + package_lib_prefix = "lib" + elif self.settings.os in ["Macos", "iOS"]: + if self.options.shared: + lib_pat = "*bgfx*.dylib" + else: + lib_pat = "*bgfx*.a" + package_lib_prefix = "lib" + + # Get build bin folder + for bimg_out_dir in os.listdir(os.path.join(self._bgfx_path, ".build")): + if not bimg_out_dir=="projects": + build_bin = os.path.join(self._bgfx_path, ".build", bimg_out_dir, "bin") + break + + # Copy license + copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self._bgfx_path) + # Copy includes + copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) + # Copy libs + copy(self, pattern=lib_pat, dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) + if self.options.shared: + copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + + # Copy tools + if self.options.tools: + copy(self, pattern="shaderc*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + copy(self, pattern="texturev*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + copy(self, pattern="geometryc*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + copy(self, pattern="geometryv*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) + + # Rename for consistency across platforms and configs + if not (is_apple_os(self) and self.options.shared): #Apparently apple dylibs break if renamed + for bgfx_file in Path(os.path.join(self.package_folder, "lib")).glob("*bgfx*"): + rename(self, os.path.join(self.package_folder, "lib", bgfx_file.name), + os.path.join(self.package_folder, "lib", f"{package_lib_prefix}bgfx{bgfx_file.suffix}")) + if self.options.tools: + for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*shaderc*"): + rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), + os.path.join(self.package_folder, "bin", f"shaderc{bgfx_file.suffix}")) + for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*texturev*"): + rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), + os.path.join(self.package_folder, "bin", f"texturev{bgfx_file.suffix}")) + for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*geometryc*"): + rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), + os.path.join(self.package_folder, "bin", f"geometryc{bgfx_file.suffix}")) + for bgfx_file in Path(os.path.join(self.package_folder, "bin")).glob("*geometryv*"): + rename(self, os.path.join(self.package_folder, "bin", bgfx_file.name), + os.path.join(self.package_folder, "bin", f"geometryv{bgfx_file.suffix}")) + + # Maybe this helps + if is_apple_os(self): + fix_apple_shared_install_name(self) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + if self.options.shared and self.settings.os in ["Macos", "iOS"]: + self.cpp_info.libs = [f"bgfx-shared-lib{self.settings.build_type}"] + else: + self.cpp_info.libs = ["bgfx"] + + if self.options.shared: + self.cpp_info.defines.extend(["BGFX_SHARED_LIB_USE=1"]) + + if self.settings.os == "Windows": + self.cpp_info.system_libs.extend(["gdi32"]) + if not is_msvc(self): + self.cpp_info.system_libs.extend(["comdlg32"]) + elif self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs.extend(["X11", "GL"]) + elif self.settings.os in ["Macos", "iOS"]: + self.cpp_info.frameworks.extend(["CoreFoundation", "AppKit", "IOKit", "QuartzCore", "Metal"]) + if self.settings.os in ["Macos"]: + self.cpp_info.frameworks.extend(["OpenGL"]) + else: + self.cpp_info.frameworks.extend(["OpenGLES", "UIKit"]) + elif self.settings.os in ["Android"]: + self.cpp_info.system_libs.extend(["EGL", "GLESv2"]) + + self.cpp_info.set_property("cmake_file_name", "bgfx") + self.cpp_info.set_property("cmake_target_name", "bgfx::bgfx") + self.cpp_info.set_property("pkg_config_name", "bgfx") + + # TODO: to remove in conan v2 once cmake_find_package_* generators removed + self.cpp_info.filenames["cmake_find_package"] = "bgfx" + self.cpp_info.filenames["cmake_find_package_multi"] = "bgfx" + self.cpp_info.names["cmake_find_package"] = "bgfx" + self.cpp_info.names["cmake_find_package_multi"] = "bgfx" diff --git a/recipes/bgfx/consolidated/test_package/CMakeLists.txt b/recipes/bgfx/cci2023/test_package/CMakeLists.txt similarity index 100% rename from recipes/bgfx/consolidated/test_package/CMakeLists.txt rename to recipes/bgfx/cci2023/test_package/CMakeLists.txt diff --git a/recipes/bgfx/consolidated/test_package/conanfile.py b/recipes/bgfx/cci2023/test_package/conanfile.py similarity index 100% rename from recipes/bgfx/consolidated/test_package/conanfile.py rename to recipes/bgfx/cci2023/test_package/conanfile.py diff --git a/recipes/bgfx/cci2023/test_package/test_package.cpp b/recipes/bgfx/cci2023/test_package/test_package.cpp new file mode 100644 index 0000000000000..630c14bc99ec9 --- /dev/null +++ b/recipes/bgfx/cci2023/test_package/test_package.cpp @@ -0,0 +1,36 @@ +//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported +#include + +#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) +#include +#else +#include +#endif + +int main() { +#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) + bgfx_init_t init; + bgfx_init_ctor(&init); + init.type = bgfx_renderer_type::BGFX_RENDERER_TYPE_NOOP; + init.vendorId = BGFX_PCI_ID_NONE; + init.platformData.nwh = nullptr; + init.platformData.ndt = nullptr; + init.resolution.width = 0; + init.resolution.height = 0; + init.resolution.reset = BGFX_RESET_NONE; + bgfx_init(&init); + bgfx_shutdown(); + return 0; +#else + bgfx::Init init; + init.type = bgfx::RendererType::Noop; + init.vendorId = BGFX_PCI_ID_NONE; + init.platformData.nwh = nullptr; + init.platformData.ndt = nullptr; + init.resolution.width = 0; + init.resolution.height = 0; + init.resolution.reset = BGFX_RESET_NONE; + bgfx::init(init); + bgfx::shutdown(); +#endif +} diff --git a/recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt b/recipes/bgfx/cci2023/test_v1_package/CMakeLists.txt similarity index 100% rename from recipes/bgfx/consolidated/test_v1_package/CMakeLists.txt rename to recipes/bgfx/cci2023/test_v1_package/CMakeLists.txt diff --git a/recipes/bgfx/consolidated/test_v1_package/conanfile.py b/recipes/bgfx/cci2023/test_v1_package/conanfile.py similarity index 100% rename from recipes/bgfx/consolidated/test_v1_package/conanfile.py rename to recipes/bgfx/cci2023/test_v1_package/conanfile.py diff --git a/recipes/bgfx/config.yml b/recipes/bgfx/config.yml index b7dab758ed797..b937602634db4 100644 --- a/recipes/bgfx/config.yml +++ b/recipes/bgfx/config.yml @@ -1,5 +1,5 @@ versions: "1.127.8771": - folder: consolidated - "cci.20230216": folder: all + "cci.20230216": + folder: cci2023 diff --git a/recipes/bgfx/consolidated/conandata.yml b/recipes/bgfx/consolidated/conandata.yml deleted file mode 100644 index f98b6a817afb5..0000000000000 --- a/recipes/bgfx/consolidated/conandata.yml +++ /dev/null @@ -1,11 +0,0 @@ -sources: - "1.127.8771": - "bgfx": - url: "https://github.com/bkaradzic/bgfx/archive/06d0e2af2f50fee3e8e84e0c3b407073692a678c.tar.gz" - sha256: "0869F9D18C63AB8D804918FEFCC53D8568626A26FCAE7273DF1A70D4C8E7AFE3" - "bimg": - url: "https://github.com/bkaradzic/bimg/archive/2afa64c14c1e3dd5d28412ee03bee0dfe7242f03.tar.gz" - sha256: "376E17EA4A70CEE72E6006DD942CB2F2FE3DB047F524A3F203A15A8BBA1BCD90" - "bx": - url: "https://github.com/bkaradzic/bx/archive/e64b7c097f30d33134fe8fa522b3c95fc461c3d3.tar.gz" - sha256: "2A6E438AC6250CD6052CBBABF2906482DFA1585E537064CB5DA47E2EC728FE92" diff --git a/recipes/bgfx/consolidated/conanfile.py b/recipes/bgfx/consolidated/conanfile.py deleted file mode 100644 index a68959823183f..0000000000000 --- a/recipes/bgfx/consolidated/conanfile.py +++ /dev/null @@ -1,368 +0,0 @@ -from conan import ConanFile -from conan.tools.files import copy, get, rename, replace_in_file -from conan.tools.build import check_min_cppstd -from conan.tools.layout import basic_layout -from conan.tools.microsoft import is_msvc, check_min_vs, is_msvc_static_runtime -from conan.tools.apple import fix_apple_shared_install_name, is_apple_os -from conan.tools.scm import Version -from conan.errors import ConanInvalidConfiguration -from conan.tools.microsoft import MSBuild, VCVars -from conan.tools.gnu import Autotools, AutotoolsToolchain -from conan.tools.env import VirtualBuildEnv -from pathlib import Path -import os - -required_conan_version = ">=1.50.0" - -class bgfxConan(ConanFile): - name = "bgfx" - license = "BSD-2-Clause" - homepage = "https://github.com/bkaradzic/bgfx" - url = "https://github.com/conan-io/conan-center-index" - description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." - topics = ("rendering", "graphics", "gamedev") - settings = "os", "compiler", "arch", "build_type" - options = {"fPIC": [True, False], "shared": [True, False], "tools": [True, False], "rtti": [True, False]} - default_options = {"fPIC": True, "shared": False, "tools": False, "rtti": True} - - @property - def _bx_folder(self): - return "bx" - - @property - def _bimg_folder(self): - return "bimg" - - @property - def _bgfx_folder(self): - return "bgfx" - - @property - def _bgfx_path(self): - return os.path.join(self.source_folder, self._bgfx_folder) - - @property - def _genie_extra(self): - genie_extra = "" - if is_msvc(self) and not is_msvc_static_runtime(self): - genie_extra += " --with-dynamic-runtime" - if self.options.shared: - genie_extra += " --with-shared-lib" - # generate tools projects regardless of tools option because that also generates bimg_encode - genie_extra += " --with-tools" - return genie_extra - - @property - def _lib_target_prefix(self): - if is_msvc(self): - return "libs\\" - else: - return "" - - @property - def _tool_target_prefix(self): - if is_msvc(self): - return "tools\\" - else: - return "" - - @property - def _shaderc_target_prefix(self): - if is_msvc(self): - return "shaderc\\" - else: - return "" - - @property - def _tools(self): - return ["texturec", "texturev", "geometryc", "geometryv", "shaderc"] - - @property - def _projs(self): - projs = [f"{self._lib_target_prefix}bx", f"{self._lib_target_prefix}bimg", f"{self._lib_target_prefix}bimg_decode", f"{self._lib_target_prefix}bimg_encode"] - if self.options.shared: - projs.extend([f"{self._lib_target_prefix}bgfx-shared-lib"]) - else: - projs.extend([f"{self._lib_target_prefix}bgfx"]) - if self.options.tools: - for tool in self._tools: - if "shaderc" in tool: - projs.extend([f"{self._tool_target_prefix}{self._shaderc_target_prefix}{tool}"]) - else: - projs.extend([f"{self._tool_target_prefix}{tool}"]) - return projs - - @property - def _compiler_required(self): - return { - "gcc": "8", - "clang": "11", - "apple-clang": "12", #to keep CCI compiling on osx 11.0 or higher, for now - } - - @property - def _settings_build(self): - return getattr(self, "settings_build", self.settings) - - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC - - def layout(self): - basic_layout(self, src_folder="src") - - def requirements(self): - self.requires("opengl/system") - - def validate(self): - if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, 17) - check_min_vs(self, 192) - if not is_msvc(self): - try: - minimum_required_compiler_version = self._compiler_required[str(self.settings.compiler)] - if Version(self.settings.compiler.version) < minimum_required_compiler_version: - raise ConanInvalidConfiguration("This package requires C++17 support. The current compiler does not support it.") - except KeyError: - self.output.warn("This recipe has no checking for the current compiler. Please consider adding it.") - - def build_requirements(self): - self.tool_requires("genie/1170") - if not is_msvc(self) and self._settings_build.os == "Windows": - if self.settings.os == "Windows": # building for windows mingw - # self.win_bash = True - # if not self.conf.get("tools.microsoft.bash:path", check_type=str): - # self.tool_requires("msys2/cci.latest") - if "MINGW" not in os.environ: - self.tool_requires("mingw-builds/13.2.0") - else: # cross-compiling for something else, probably android; get native make - self.tool_requires("make/[>=4.4.1]") - if self.settings.os == "Android" and "ANDROID_NDK_ROOT" not in os.environ: - self.tool_requires("android-ndk/[>=r26d]") - - def source(self): - get(self, **self.conan_data["sources"][self.version]["bgfx"], strip_root=True, - destination=os.path.join(self.source_folder, self._bgfx_folder)) - # bgfx's genie project, and the projects generated by it, expect bx and bimg source to be present on the same relative root as bgfx's in order to build - # usins a pre-built bx and bimg instead would require significant changes to the genie project but may be worth looking into in the future, if upstream wants to go that route - get(self, **self.conan_data["sources"][self.version]["bx"], strip_root=True, - destination=os.path.join(self.source_folder, self._bx_folder)) - get(self, **self.conan_data["sources"][self.version]["bimg"], strip_root=True, - destination=os.path.join(self.source_folder, self._bimg_folder)) - - def generate(self): - vbe = VirtualBuildEnv(self) - vbe.generate() - if is_msvc(self): - tc = VCVars(self) - tc.generate() - else: - tc = AutotoolsToolchain(self) - tc.generate() - - def build(self): - # Patch rtti - cci expects most packages to be built with rtti enabled; mismatches can cause link issues - if self.options.rtti: - self.output.info("Disabling no-rtti.") - replace_in_file(self, os.path.join(self.source_folder, self._bx_folder, "scripts", "toolchain.lua"), - "\"NoRTTI\",", "") - if is_msvc(self): - # Conan to Genie translation maps - vs_ver_to_genie = {"17": "2022", "16": "2019", "15": "2017", - "194": "2022", "193": "2022", "192": "2019", "191": "2017"} - - # Use genie directly, then msbuild on specific projects based on requirements - genie_VS = f"vs{vs_ver_to_genie[str(self.settings.compiler.version)]}" - genie_gen = f"{self._genie_extra} {genie_VS}" - self.run(f"genie {genie_gen}", cwd=self._bgfx_path) - - msbuild = MSBuild(self) - # customize to Release when RelWithDebInfo - msbuild.build_type = "Debug" if self.settings.build_type == "Debug" else "Release" - # use Win32 instead of the default value when building x86 - msbuild.platform = "Win32" if self.settings.arch == "x86" else msbuild.platform - msbuild.build(os.path.join(self._bgfx_path, ".build", "projects", genie_VS, "bgfx.sln"), targets=self._projs) - else: - # Not sure if XCode can be spefically handled by conan for building through, so assume everything not VS is make - # gcc-multilib and g++-multilib required for 32bit cross-compilation, should see if we can check and install through conan - - # Conan to Genie translation maps - compiler_str = str(self.settings.compiler) - compiler_and_os_to_genie = {"Windows": f"--gcc=mingw-{compiler_str}", "Linux": f"--gcc=linux-{compiler_str}", - "FreeBSD": "--gcc=freebsd", "Macos": "--gcc=osx", - "Android": "--gcc=android", "iOS": "--gcc=ios"} - gmake_os_to_proj = {"Windows": "mingw", "Linux": "linux", "FreeBSD": "freebsd", "Macos": "osx", "Android": "android", "iOS": "ios"} - gmake_android_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x86_64", "armv8": "-arm64", "armv7": "-arm"} - gmake_arch_to_genie_suffix = {"x86": "-x86", "x86_64": "-x64", "armv8": "-arm64", "armv7": "-arm"} - os_to_use_arch_config_suffix = {"Windows": False, "Linux": False, "FreeBSD": False, "Macos": True, "Android": True, "iOS": True} - - build_type_to_make_config = {"Debug": "config=debug", "Release": "config=release"} - arch_to_make_config_suffix = {"x86": "32", "x86_64": "64"} - os_to_use_make_config_suffix = {"Windows": True, "Linux": True, "FreeBSD": True, "Macos": False, "Android": False, "iOS": False} - - # Generate projects through genie - genie_args = f"{self._genie_extra} {compiler_and_os_to_genie[str(self.settings.os)]}" - if os_to_use_arch_config_suffix[str(self.settings.os)]: - if (self.settings.os == "Android"): - genie_args += F"{gmake_android_arch_to_genie_suffix[str(self.settings.arch)]}" - else: - genie_args += f"{gmake_arch_to_genie_suffix[str(self.settings.arch)]}" - genie_args += " gmake" - self.run(f"genie {genie_args}", cwd=self._bgfx_path) - - # Build project folder and path from given settings - proj_folder = f"gmake-{gmake_os_to_proj[str(self.settings.os)]}" - if self.settings.os == "Windows" or (compiler_str not in ["gcc", "apple-clang"] and self.settings.os != "Android"): - proj_folder += f"-{compiler_str}" #mingw-gcc or mingw-clang for windows; -clang for linux (where gcc on linux has no extra) - if os_to_use_arch_config_suffix[str(self.settings.os)]: - if (self.settings.os == "Android"): - proj_folder += gmake_android_arch_to_genie_suffix[str(self.settings.arch)] - else: - proj_folder += gmake_arch_to_genie_suffix[str(self.settings.arch)] - proj_path = os.path.sep.join([self._bgfx_path, ".build", "projects", proj_folder]) - - # Build make args from settings - conf = build_type_to_make_config[str(self.settings.build_type)] - if os_to_use_make_config_suffix[str(self.settings.os)]: - conf += arch_to_make_config_suffix[str(self.settings.arch)] - if self.settings.os == "Windows": - if "mingw-builds" in self.dependencies.build: - # self.run("if [ ! -d /mingw64 ]; then mkdir /mingw64; fi") - # self.run("pacman -Sy mingw-w64-x86_64-gcc --needed --noconfirm") - # mingw = "MINGW=$MSYS_ROOT/mingw64" - mingw = f"MINGW={self.dependencies.build['mingw-builds'].package_folder}" - else: - mingw = "MINGW=$MINGW" # user is expected to have an env var pointing to mingw; x86_64-w64-mingw32-g++ is expected in $MINGW/bin/ - proj_path = proj_path.replace("\\", "/") # Fix path for linux style... - else: - mingw = "" - autotools = Autotools(self) - # Build with make - for proj in self._projs: - autotools.make(target=proj, args=["-R", f"-C {proj_path}", mingw, conf]) - - def package(self): - lib_names = ["bx", "bimg", "bgfx"] - # Set platform suffixes and prefixes - if self.settings.os == "Windows" and is_msvc(self): - package_lib_prefix = "" - lib_pat = ".lib" - shared_lib_pat = ".lib" - else: - package_lib_prefix = "lib" - lib_pat = ".a" - if self.options.shared: - if is_apple_os(self): - shared_lib_pat = ".dylib" - else: - shared_lib_pat = ".so" - - # Get build bin folder - for out_dir in os.listdir(os.path.join(self._bgfx_path, ".build")): - if not out_dir=="projects": - build_bin = os.path.join(self._bgfx_path, ".build", out_dir, "bin") - break - - # Copy license - copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self._bgfx_path) - # Copy includes - copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) - copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self._bgfx_path, "include")) - copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) - copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bx_folder), "include")) - copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) - copy(self, pattern="*.inl", dst=os.path.join(self.package_folder, "include"), src=os.path.join(os.path.join(self.source_folder, self._bimg_folder), "include")) - # Copy libs - for lib_name in lib_names: - if lib_name == "bgfx" and self.options.shared: - copy(self, pattern=f"*{lib_name}*shared*{shared_lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) - copy(self, pattern=f"*{lib_name}*shared*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) - else: - copy(self, pattern=f"*{lib_name}*{lib_pat}", dst=os.path.join(self.package_folder, "lib"), src=build_bin, keep_path=False) - if self.options.shared and self.settings.os == "Windows": - copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - - # Copy tools - if self.options.tools: - for tool in self._tools: - if is_msvc(self): - # avoid copying pdb, exp and lib files for tools on windows msvc - copy(self, pattern=f"{tool}*.exe", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - else: - copy(self, pattern=f"{tool}*", dst=os.path.join(self.package_folder, "bin"), src=build_bin, keep_path=False) - - # Rename for consistency across platforms and configs - for lib_name in lib_names: - for out_file in Path(os.path.join(self.package_folder, "lib")).glob(f"*{lib_name}*"): - if out_file.suffix != "dylib": # dylibs break when renamed - lib_name_extra = "" - if out_file.name.find("encode") >= 0: - lib_name_extra = "_encode" - elif out_file.name.find("decode") >= 0: - lib_name_extra = "_decode" - rename(self, os.path.join(self.package_folder, "lib", out_file.name), - os.path.join(self.package_folder, "lib", f"{package_lib_prefix}{lib_name}{lib_name_extra}{out_file.suffix}")) - if self.options.tools: - for tool in self._tools: - for out_file in Path(os.path.join(self.package_folder, "bin")).glob(f"*{tool}*"): - rename(self, os.path.join(self.package_folder, "bin", out_file.name), - os.path.join(self.package_folder, "bin", f"{tool}{out_file.suffix}")) - - # Maybe this helps - if is_apple_os(self): - fix_apple_shared_install_name(self) - - def package_info(self): - self.cpp_info.includedirs = ["include"] - # Warning: order of linked libs matters on linux - if self.options.shared and is_apple_os(self): - self.cpp_info.libs.extend([f"bgfx-shared-lib{self.settings.build_type}"]) - else: - self.cpp_info.libs.extend(["bgfx"]) - self.cpp_info.libs.extend(["bimg_encode", "bimg_decode", "bimg", "bx"]) - - if self.options.shared: - self.cpp_info.defines.extend(["BGFX_SHARED_LIB_USE=1"]) - - if self.settings.build_type == "Debug": - self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=1"]) - else: - self.cpp_info.defines.extend(["BX_CONFIG_DEBUG=0"]) - - if self.settings.os == "Windows": - self.cpp_info.system_libs.extend(["gdi32"]) - if self.settings.arch == "x86": - self.cpp_info.system_libs.extend(["psapi"]) - if is_msvc(self): - self.cpp_info.defines.extend(["__STDC_LIMIT_MACROS", "__STDC_FORMAT_MACROS", "__STDC_CONSTANT_MACROS"]) - self.cpp_info.includedirs.extend(["include/compat/msvc"]) - self.cpp_info.cxxflags.extend(["/Zc:__cplusplus", "/Zc:preprocessor"]) - else: - self.cpp_info.includedirs.extend(["include/compat/mingw"]) - self.cpp_info.system_libs.extend(["comdlg32"]) - elif self.settings.os in ["Linux", "FreeBSD"]: - self.cpp_info.system_libs.extend(["dl", "pthread", "X11", "GL"]) - if self.settings.os == "Linux": - self.cpp_info.includedirs.extend(["include/compat/linux"]) - else: - self.cpp_info.includedirs.extend(["include/compat/freebsd"]) - elif is_apple_os(self): - self.cpp_info.frameworks.extend(["CoreFoundation", "Foundation", "Cocoa", "AppKit", "IOKit", "QuartzCore", "Metal"]) - if self.settings.os in ["Macos"]: - self.cpp_info.frameworks.extend(["OpenGL"]) - self.cpp_info.includedirs.extend(["include/compat/osx"]) - else: - self.cpp_info.frameworks.extend(["OpenGLES", "UIKit"]) - self.cpp_info.includedirs.extend(["include/compat/ios"]) - elif self.settings.os in ["Android"]: - self.cpp_info.system_libs.extend(["c", "dl", "m", "android", "log", "c++_shared", "EGL", "GLESv2"]) - - self.cpp_info.set_property("cmake_file_name", "bgfx") - self.cpp_info.set_property("cmake_target_name", "bgfx::bgfx") - self.cpp_info.set_property("pkg_config_name", "bgfx") - - # TODO: to remove in conan v2 once cmake_find_package_* generators removed - self.cpp_info.filenames["cmake_find_package"] = "bgfx" - self.cpp_info.filenames["cmake_find_package_multi"] = "bgfx" - self.cpp_info.names["cmake_find_package"] = "bgfx" - self.cpp_info.names["cmake_find_package_multi"] = "bgfx" diff --git a/recipes/bgfx/consolidated/test_package/test_package.cpp b/recipes/bgfx/consolidated/test_package/test_package.cpp deleted file mode 100644 index c19356456589b..0000000000000 --- a/recipes/bgfx/consolidated/test_package/test_package.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported -#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) -#include -#else -#include -#endif - -//An embedded 2x2 PNG image in RGB8 format with a red pixel, a green pixel, a blue pixel and a white pixel -const unsigned char img[129] ={0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, -0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x02, -0x00, 0x00, 0x00, 0x02, 0x08, 0x02, 0x00, 0x00, 0x00, 0xfd, 0xd4, 0x9a, -0x73, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, -0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, -0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, -0x59, 0x73, 0x00, 0x00, 0x0e, 0xc3, 0x00, 0x00, 0x0e, 0xc3, 0x01, 0xc7, -0x6f, 0xa8, 0x64, 0x00, 0x00, 0x00, 0x16, 0x49, 0x44, 0x41, 0x54, 0x18, -0x57, 0x63, 0x78, 0x2b, 0xa3, 0xa2, 0xb4, 0xd1, 0x87, 0xc1, 0xde, 0xe3, -0xcc, 0xff, 0xff, 0xff, 0x01, 0x24, 0xec, 0x06, 0x9d, 0x64, 0xf4, 0x18, -0xdc, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; - - -int main() { - //test bx - float tLerp = bx::lerp(0.0f, 10.0f, 0.5f); - BX_TRACE("Lerped 0.0f to 10.0f at 0.5f, result %f", tLerp); - BX_ASSERT(bx::isEqual(tLerp, 5.0f, 0.1f), "isEqual failed"); - bx::debugPrintf("Length of \"test\" is: %d", bx::strLen("test")); - - //test bimg - bx::DefaultAllocator defAlloc; - bimg::ImageContainer* imageContainer = nullptr; - imageContainer = bimg::imageParse(&defAlloc, (const void*) img, 129 * sizeof(char)); - BX_ASSERT(imageContainer->m_format == bimg::TextureFormat::RGB8, "Image incorrectly decoded.") - bimg::imageFree(imageContainer); - - //test bgfx -#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT) - bgfx_init_t init; - bgfx_init_ctor(&init); - init.type = bgfx_renderer_type::BGFX_RENDERER_TYPE_NOOP; - init.vendorId = BGFX_PCI_ID_NONE; - init.platformData.nwh = nullptr; - init.platformData.ndt = nullptr; - init.resolution.width = 0; - init.resolution.height = 0; - init.resolution.reset = BGFX_RESET_NONE; - bgfx_init(&init); - bgfx_shutdown(); - return 0; -#else - bgfx::Init init; - init.type = bgfx::RendererType::Noop; - init.vendorId = BGFX_PCI_ID_NONE; - init.platformData.nwh = nullptr; - init.platformData.ndt = nullptr; - init.resolution.width = 0; - init.resolution.height = 0; - init.resolution.reset = BGFX_RESET_NONE; - bgfx::init(init); - bgfx::shutdown(); -#endif -} From c6715c1878f447ce32ffe301dcf5bf6a5fb19571 Mon Sep 17 00:00:00 2001 From: Raziel Date: Mon, 24 Jun 2024 00:45:38 +0300 Subject: [PATCH 3/9] Fix cppstd for AutotoolsToolchain --- recipes/bgfx/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/bgfx/all/conanfile.py b/recipes/bgfx/all/conanfile.py index 46f1d6cf5b927..4c2165e57ea3b 100644 --- a/recipes/bgfx/all/conanfile.py +++ b/recipes/bgfx/all/conanfile.py @@ -162,7 +162,7 @@ def generate(self): else: tc = AutotoolsToolchain(self) if not self.settings.get_safe("compiler.cppstd"): - tc.cppstd = "c++17" + tc.cppstd = "-std=c++17" tc.generate() def build(self): From 14b13c5ec1dfeb0e6dd6a89950435b0bf1173914 Mon Sep 17 00:00:00 2001 From: Raziel Date: Tue, 25 Jun 2024 20:27:46 +0300 Subject: [PATCH 4/9] Expose with-profiler setting Try with-macos=11 for macos [11, 13) --- recipes/bgfx/all/conanfile.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/recipes/bgfx/all/conanfile.py b/recipes/bgfx/all/conanfile.py index 4c2165e57ea3b..6d4897633f9c8 100644 --- a/recipes/bgfx/all/conanfile.py +++ b/recipes/bgfx/all/conanfile.py @@ -22,8 +22,8 @@ class bgfxConan(ConanFile): description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." topics = ("rendering", "graphics", "gamedev") settings = "os", "compiler", "arch", "build_type" - options = {"fPIC": [True, False], "shared": [True, False], "tools": [True, False], "rtti": [True, False]} - default_options = {"fPIC": True, "shared": False, "tools": False, "rtti": True} + options = {"fPIC": [True, False], "shared": [True, False], "rtti": [True, False], "tools": [True, False], "profiler": [True, False]} + default_options = {"fPIC": True, "shared": False, "rtti": True, "tools": False, "profiler": False} @property def _bx_folder(self): @@ -48,8 +48,18 @@ def _genie_extra(self): genie_extra += " --with-dynamic-runtime" if self.options.shared: genie_extra += " --with-shared-lib" + if self.options.profiler: + genie_extra += " --with-profiler" # generate tools projects regardless of tools option because that also generates bimg_encode genie_extra += " --with-tools" + # deal with macos 11 to 13 + if self.settings.os == "Macos": + if self.settings.get_safe("os.sdk_version"): + if self.settings.get_safe("os.sdk_version") < "13.0" and self.settings.get_safe("os.sdk_version") >= "11.0": + genie_extra += " --with-macos=11" + else: + # err on the side of comaptibility if sdk version not set + genie_extra += " --with-macos=11" return genie_extra @property @@ -118,8 +128,8 @@ def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, 17) check_min_vs(self, 192) - if self.settings.os == "Macos" and self.settings.get_safe("os.sdk_version") and self.settings.get_safe("os.sdk_version") < "13.0": - raise ConanInvalidConfiguration(f"{self.ref} requires macos sdk version >= 13") + if self.settings.os == "Macos" and self.settings.get_safe("os.sdk_version") and self.settings.get_safe("os.sdk_version") < "11.0": + raise ConanInvalidConfiguration(f"{self.ref} requires macos sdk version >= 11") if self.settings.os in ["iOS", "tvOS"] and self.settings.get_safe("os.sdk_version") and self.settings.get_safe("os.sdk_version") < "16.0": raise ConanInvalidConfiguration(f"{self.ref} requires iOS/tvOS sdk version >= 16") if not is_msvc(self): From b5e79367dbeb960767ec213325f0174c17f9d469 Mon Sep 17 00:00:00 2001 From: Raziel Date: Wed, 14 Aug 2024 18:40:23 +0300 Subject: [PATCH 5/9] Update to 1.127.8789 --- recipes/bgfx/all/conandata.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/recipes/bgfx/all/conandata.yml b/recipes/bgfx/all/conandata.yml index 0a3bd024a04bb..7ed7f963fd52d 100644 --- a/recipes/bgfx/all/conandata.yml +++ b/recipes/bgfx/all/conandata.yml @@ -1,11 +1,11 @@ sources: - "1.127.8771": + "1.127.8789": "bgfx": - url: "https://github.com/bkaradzic/bgfx/archive/06d0e2af2f50fee3e8e84e0c3b407073692a678c.tar.gz" - sha256: "0869F9D18C63AB8D804918FEFCC53D8568626A26FCAE7273DF1A70D4C8E7AFE3" + url: "https://github.com/bkaradzic/bgfx/archive/0b73e8c7e22a2876a8979a4dd9b77d0686058090.tar.gz" + sha256: "EE4F928DE194B3C90BD8013CC341F318DA64DAFCB1644C592B1599E5ACA5671C" "bimg": - url: "https://github.com/bkaradzic/bimg/archive/2afa64c14c1e3dd5d28412ee03bee0dfe7242f03.tar.gz" - sha256: "376E17EA4A70CEE72E6006DD942CB2F2FE3DB047F524A3F203A15A8BBA1BCD90" + url: "https://github.com/bkaradzic/bimg/archive/aaf9125234e657393f504404a279289669d89fcb.tar.gz" + sha256: "D4FC002A0CB3611B673BEB55622ABB7A28E881BAC49A9828ECBE520BB6AEAB30" "bx": - url: "https://github.com/bkaradzic/bx/archive/c5b7b4629961ed7ac882cd3f64f28e1b25910e55.tar.gz" - sha256: "0fc705c7bb7ae01f2a2e1ef2be2426b877407e4cdab1b3ca5d4f77eb814716df" + url: "https://github.com/bkaradzic/bx/archive/3d53a4abaa91162db7ea195d43a4410335a67cf2.tar.gz" + sha256: "8748958343CC4DA020F4E51D1524B3E95C9F14AEB3C2F638B2D15B5E0D831757" From 62568b97a2ba68c6d9aa8bf279bc3665463d46d7 Mon Sep 17 00:00:00 2001 From: Raziel Date: Wed, 14 Aug 2024 19:05:04 +0300 Subject: [PATCH 6/9] Update version in config.yml --- recipes/bgfx/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/bgfx/config.yml b/recipes/bgfx/config.yml index b937602634db4..15435616d4934 100644 --- a/recipes/bgfx/config.yml +++ b/recipes/bgfx/config.yml @@ -1,5 +1,5 @@ versions: - "1.127.8771": + "1.127.8789": folder: all "cci.20230216": folder: cci2023 From 0160e8de0daa40d75ace490fbdd336518cc2bc5f Mon Sep 17 00:00:00 2001 From: Raziel Date: Fri, 1 Nov 2024 17:20:15 +0200 Subject: [PATCH 7/9] Update genie to 1181 --- recipes/bgfx/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/bgfx/all/conanfile.py b/recipes/bgfx/all/conanfile.py index d87531c565383..55b503e81de96 100644 --- a/recipes/bgfx/all/conanfile.py +++ b/recipes/bgfx/all/conanfile.py @@ -141,7 +141,7 @@ def validate(self): self.output.warning(f"{self.ref} does no checking for the current compiler. Assuming it works, please consider adding it.") def build_requirements(self): - self.tool_requires("genie/1170") + self.tool_requires("genie/1181") if not is_msvc(self) and self._settings_build.os == "Windows": if self.settings.os == "Windows": # building for windows mingw if "MINGW" not in os.environ: From 6a9eab1cf502cf61e2089e56eabde8e797dcc537 Mon Sep 17 00:00:00 2001 From: Raziel Date: Fri, 1 Nov 2024 17:26:55 +0200 Subject: [PATCH 8/9] Add package_type to new recipe --- recipes/bgfx/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/bgfx/all/conanfile.py b/recipes/bgfx/all/conanfile.py index 55b503e81de96..e5f15c7297940 100644 --- a/recipes/bgfx/all/conanfile.py +++ b/recipes/bgfx/all/conanfile.py @@ -21,6 +21,7 @@ class bgfxConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" description = "Cross-platform, graphics API agnostic, \"Bring Your Own Engine/Framework\" style rendering library." topics = ("rendering", "graphics", "gamedev") + package_type = "library" settings = "os", "compiler", "arch", "build_type" options = {"fPIC": [True, False], "shared": [True, False], "rtti": [True, False], "tools": [True, False], "profiler": [True, False]} default_options = {"fPIC": True, "shared": False, "rtti": True, "tools": False, "profiler": False} From 132a5a78bb2f6d0616cfa1cd64087ce1574431e7 Mon Sep 17 00:00:00 2001 From: Raziel Date: Fri, 1 Nov 2024 19:52:02 +0200 Subject: [PATCH 9/9] Update to latest (1.128.8832) --- recipes/bgfx/all/conandata.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/recipes/bgfx/all/conandata.yml b/recipes/bgfx/all/conandata.yml index 7ed7f963fd52d..a79c67c61d93e 100644 --- a/recipes/bgfx/all/conandata.yml +++ b/recipes/bgfx/all/conandata.yml @@ -1,11 +1,11 @@ sources: - "1.127.8789": + "1.128.8832": "bgfx": - url: "https://github.com/bkaradzic/bgfx/archive/0b73e8c7e22a2876a8979a4dd9b77d0686058090.tar.gz" - sha256: "EE4F928DE194B3C90BD8013CC341F318DA64DAFCB1644C592B1599E5ACA5671C" + url: "https://github.com/bkaradzic/bgfx/archive/cc789e83a69fddfb13f6cbeb89f43aa56dcfff9d.tar.gz" + sha256: "2A0A19DE443563036DB0C7E381EE61882783D400E942658EBAB0F7466AD89B19" "bimg": - url: "https://github.com/bkaradzic/bimg/archive/aaf9125234e657393f504404a279289669d89fcb.tar.gz" - sha256: "D4FC002A0CB3611B673BEB55622ABB7A28E881BAC49A9828ECBE520BB6AEAB30" + url: "https://github.com/bkaradzic/bimg/archive/0d1c78e77982f18a9174620bfa5762ffcca9d38c.tar.gz" + sha256: "A8623F7B6878049345FE46179D5CFD33AB73951FB745FEC7E953FEA52C497B3A" "bx": - url: "https://github.com/bkaradzic/bx/archive/3d53a4abaa91162db7ea195d43a4410335a67cf2.tar.gz" - sha256: "8748958343CC4DA020F4E51D1524B3E95C9F14AEB3C2F638B2D15B5E0D831757" + url: "https://github.com/bkaradzic/bx/archive/2cebc558eb314e324f01ef05735551f234f5ea13.tar.gz" + sha256: "0305DC28FA48CEC0F6B628226373475DECFE21719749B3BEDB6D7D7D1CC9F050"