From effafc52c5a7647440683794f1bb9d2fa6fed728 Mon Sep 17 00:00:00 2001 From: Julianiolo <50519317+Julianiolo@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:47:49 +0100 Subject: [PATCH] (#24585) raylib: add some common build settings to options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * support custom frame control * add some more common settings * Update recipes/raylib/all/conanfile.py Co-authored-by: Abril Rincón Blanco * moved from patching defines to cmake options * Update recipes/raylib/all/conanfile.py Co-authored-by: Uilian Ries * reduce number of options * reduced number of options, added on_off converter * removed some options * incorporated review * add camera, gestures and rprand support * added resdirs * Simplify custom modules headers Signed-off-by: Uilian Ries * Include headers from version 3.5.0 Signed-off-by: Uilian Ries * fix rprand typo * fix linter warnings * Update recipes/raylib/all/conanfile.py Co-authored-by: Uilian Ries * readd patches --------- Signed-off-by: Uilian Ries Co-authored-by: Abril Rincón Blanco Co-authored-by: Uilian Ries --- recipes/raylib/all/conanfile.py | 68 +++++++++++++++++++ .../raylib/all/test_package/test_package.c | 1 + 2 files changed, 69 insertions(+) diff --git a/recipes/raylib/all/conanfile.py b/recipes/raylib/all/conanfile.py index 38b018aee6008..26644f7b9bb79 100644 --- a/recipes/raylib/all/conanfile.py +++ b/recipes/raylib/all/conanfile.py @@ -22,13 +22,41 @@ class RaylibConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "opengl_version": [None, "4.3", "3.3", "2.1", "1.1", "ES-2.0"], + + "customize_build": [True, False], + "module_raudio": [True, False], + "camera_system": [True, False], + "gestures_system": [True, False], + "rprand_generator": [True, False], + "events_waiting": [True, False], + "custom_frame_control": [True, False] } default_options = { "shared": False, "fPIC": True, "opengl_version": None, + + "customize_build": False, + "module_raudio": True, + "camera_system": True, + "gestures_system": True, + "rprand_generator": True, + "events_waiting": False, + "custom_frame_control": False } + @property + def _support_custom_modules(self): + return Version(self.version) >= "4.2.0" + + @property + def _support_rprand_generator(self): + return Version(self.version) >= "5.0" + + @property + def _support_frame_control(self): + return Version(self.version) >= "4.6" + def export_sources(self): export_conandata_patches(self) @@ -37,6 +65,12 @@ def config_options(self): del self.options.fPIC if self.settings.os == "Android": del self.options.opengl_version + if not self._support_custom_modules: + del self.options.module_raudio + if not self._support_rprand_generator: + del self.options.rprand_generator + if not self._support_frame_control: + del self.options.custom_frame_control def configure(self): if self.options.shared: @@ -44,6 +78,14 @@ def configure(self): self.settings.rm_safe("compiler.cppstd") self.settings.rm_safe("compiler.libcxx") + if not self.options.customize_build: + self.options.rm_safe("module_raudio") + del self.options.camera_system + del self.options.gestures_system + self.options.rm_safe("rprand_generator") + del self.options.events_waiting + self.options.rm_safe("custom_frame_control") + def layout(self): cmake_layout(self, src_folder="src") @@ -57,6 +99,7 @@ def requirements(self): def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) + def generate(self): tc = CMakeToolchain(self) tc.variables["BUILD_EXAMPLES"] = False @@ -72,8 +115,24 @@ def generate(self): tc.variables["USE_EXTERNAL_GLFW"] = "ON" tc.variables["OPENGL_VERSION"] = "OFF" if not self.options.opengl_version else self.options.opengl_version tc.variables["WITH_PIC"] = self.options.get_safe("fPIC", True) + + tc.variables["CUSTOMIZE_BUILD"] = self.options.customize_build + if self.options.customize_build: + if self._support_custom_modules: + tc.variables["SUPPORT_MODULE_RAUDIO"] = self.options.module_raudio + tc.variables["SUPPORT_EVENTS_WAITING"] = self.options.events_waiting + if self._support_frame_control: + tc.variables["SUPPORT_CUSTOM_FRAME_CONTROL"] = self.options.custom_frame_control + + # this makes it include the headers rcamera.h, rgesture.h and rprand.h + tc.variables["SUPPORT_CAMERA_SYSTEM"] = self.options.camera_system + tc.variables["SUPPORT_GESTURES_SYSTEM"] = self.options.gestures_system + if self._support_rprand_generator: + tc.variables["SUPPORT_RPRAND_GENERATOR"] = self.options.rprand_generator + # Due to a specific logic of cmakedeps_macros.cmake used by CMakeDeps to try to locate shared libs on Windows tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0054"] = "NEW" + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW" tc.generate() deps = CMakeDeps(self) deps.generate() @@ -97,6 +156,15 @@ def package(self): {"raylib": "raylib::raylib"} ) + # INFO: Custom modules are enabled by default but need to copy the headers manually + include_path = os.path.join(self.package_folder, "include") + if self.options.get_safe("camera_system", True): + copy(self, pattern="*camera.h", dst=include_path, src=os.path.join(self.source_folder, "src")) + if self.options.get_safe("gestures_system", True): + copy(self, pattern="*gestures.h", dst=include_path, src=os.path.join(self.source_folder, "src")) + if self._support_rprand_generator and self.options.get_safe("rprand_generator", True): + copy(self, pattern="rprand.h", dst=include_path, src=os.path.join(self.source_folder, "src", "external")) + def _create_cmake_module_alias_targets(self, module_file, targets): content = "" for alias, aliased in targets.items(): diff --git a/recipes/raylib/all/test_package/test_package.c b/recipes/raylib/all/test_package/test_package.c index 97c33c55b19d9..30f0b1d640db4 100644 --- a/recipes/raylib/all/test_package/test_package.c +++ b/recipes/raylib/all/test_package/test_package.c @@ -8,5 +8,6 @@ int main(void) { if (CheckCollisionSpheres(center, r, center, r)) { printf("unit sphere collides with itself!\n"); } + return 0; }