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

raylib: add some common build settings to options #24585

Merged
merged 20 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions recipes/raylib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,67 @@ 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
}

def export_sources(self):
export_conandata_patches(self)
@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 config_options(self):
if self.settings.os == "Windows":
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:
self.options.rm_safe("fPIC")
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")

Expand Down Expand Up @@ -72,14 +111,29 @@ 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"

Julianiolo marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()
deps = CMakeDeps(self)
deps.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand All @@ -97,6 +151,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():
Expand Down
1 change: 1 addition & 0 deletions recipes/raylib/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ int main(void) {
if (CheckCollisionSpheres(center, r, center, r)) {
printf("unit sphere collides with itself!\n");
}

return 0;
}