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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
41 changes: 40 additions & 1 deletion recipes/raylib/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
Julianiolo marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, save, replace_in_file
Julianiolo marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os
Expand All @@ -22,11 +23,23 @@ class RaylibConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"opengl_version": [None, "4.3", "3.3", "2.1", "1.1", "ES-2.0"],
"module_rshapes": [True, False],
"module_rtextures": [True, False],
"module_rtext": [True, False],
"module_rmodels": [True, False],
"module_raudio": [True, False],
"custom_frame_control": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"opengl_version": None,
"module_rshapes": True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding only option that you really need for now, otherwise, it will increase the recipe maintenance. We can not validate each combination, which means there is a risk breaking things depending the combination.

I also would request a build log, if possible, using the options that you are adding, I mean, using the non-default option value, to make sure it's not broken. I asking it because we found recipes with custom options that are not working and the CI really does not check it (only shared, fPIC and header_only are checked), so any user opens an issue months later reporting about that option is broken and recipe/upstream is bugged.

"module_rtextures": True,
"module_rtext": True,
"module_rmodels": True,
"module_raudio": True,
"custom_frame_control": False
}

def export_sources(self):
Expand Down Expand Up @@ -54,6 +67,10 @@ def requirements(self):
if self.settings.os == "Linux":
self.requires("xorg/system")

def validate(self):
if self.options.module_rtext and not self.options.module_rtextures:
raise ConanInvalidConfiguration("Cannot build rtext without rtextures")
Julianiolo marked this conversation as resolved.
Show resolved Hide resolved

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

Expand All @@ -80,6 +97,28 @@ def generate(self):

def build(self):
apply_conandata_patches(self)

config_file = os.path.join(self.source_folder, "src", "config.h")
if not self.options.module_rshapes:
opt = "#define SUPPORT_MODULE_RSHAPES"
replace_in_file(self, config_file, opt, "//"+opt, strict=True)
if not self.options.module_rtextures:
opt = "#define SUPPORT_MODULE_RTEXTURES"
replace_in_file(self, config_file, opt, "//"+opt, strict=True)
if not self.options.module_rtext:
opt = "#define SUPPORT_MODULE_RTEXT"
replace_in_file(self, config_file, opt, "//"+opt, strict=True)
if not self.options.module_rmodels:
opt = "#define SUPPORT_MODULE_RMODELS"
replace_in_file(self, config_file, opt, "//"+opt, strict=True)
if not self.options.module_raudio:
opt = "#define SUPPORT_MODULE_RAUDIO"
replace_in_file(self, config_file, opt, "//"+opt, strict=True)

if self.options.custom_frame_control:
opt = "#define SUPPORT_CUSTOM_FRAME_CONTROL"
replace_in_file(self, config_file, "//"+opt, opt, strict=True)

cmake = CMake(self)
cmake.configure()
cmake.build()
Expand Down
Loading