Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgfx: add new version and consolidated recipe #24423

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
13 changes: 10 additions & 3 deletions recipes/bgfx/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
sources:
"cci.20230216":
url: "https://github.com/bkaradzic/bgfx/archive/9d5b980f5c060e54cc30dec18500a5b54db00405.tar.gz"
sha256: "291739720E369C5C2422273D887AEC590084B29E5C9DC5C9441F5A68869B6736"
"1.128.8832":
"bgfx":
url: "https://github.com/bkaradzic/bgfx/archive/cc789e83a69fddfb13f6cbeb89f43aa56dcfff9d.tar.gz"
sha256: "2A0A19DE443563036DB0C7E381EE61882783D400E942658EBAB0F7466AD89B19"
"bimg":
url: "https://github.com/bkaradzic/bimg/archive/0d1c78e77982f18a9174620bfa5762ffcca9d38c.tar.gz"
sha256: "A8623F7B6878049345FE46179D5CFD33AB73951FB745FEC7E953FEA52C497B3A"
"bx":
url: "https://github.com/bkaradzic/bx/archive/2cebc558eb314e324f01ef05735551f234f5ea13.tar.gz"
sha256: "0305DC28FA48CEC0F6B628226373475DECFE21719749B3BEDB6D7D7D1CC9F050"
273 changes: 168 additions & 105 deletions recipes/bgfx/all/conanfile.py

Large diffs are not rendered by default.

37 changes: 36 additions & 1 deletion recipes/bgfx/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported
#include <bx/bx.h>
#include <bx/allocator.h>
#include <bx/platform.h>
#include <bx/math.h>
#include <bx/debug.h>
#include <bx/string.h>
#include <bimg/bimg.h>
#include <bimg/decode.h>

//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 <bgfx/c99/bgfx.h>
#else
#include <bgfx/bgfx.h>
#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);
Expand Down
4 changes: 4 additions & 0 deletions recipes/bgfx/cci2023/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"cci.20230216":
url: "https://github.com/bkaradzic/bgfx/archive/9d5b980f5c060e54cc30dec18500a5b54db00405.tar.gz"
sha256: "291739720E369C5C2422273D887AEC590084B29E5C9DC5C9441F5A68869B6736"
321 changes: 321 additions & 0 deletions recipes/bgfx/cci2023/conanfile.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions recipes/bgfx/cci2023/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions recipes/bgfx/cci2023/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
36 changes: 36 additions & 0 deletions recipes/bgfx/cci2023/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//Important: bgfx shared on windows only works with the C99 API, the C++ API is not exported
#include <bx/platform.h>

#if BGFX_SHARED_LIB_USE && (BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT)
#include <bgfx/c99/bgfx.h>
#else
#include <bgfx/bgfx.h>
#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
}
9 changes: 9 additions & 0 deletions recipes/bgfx/cci2023/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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/)
17 changes: 17 additions & 0 deletions recipes/bgfx/cci2023/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion recipes/bgfx/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"cci.20230216":
"1.127.8789":
folder: all
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
"cci.20230216":
folder: cci2023