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

Conversation

Julianiolo
Copy link
Contributor

@Julianiolo Julianiolo commented Jul 11, 2024

Summary

Changes to recipe: raylib/*

Motivation

raylib defines a lot of build settings in config.h. I added some of the most common/important ones to the recipe options

Details

We just patch the config.h file to match the options. This seems to be the easiest way to do this, and it makes the config.h file mirror the current configuration (although that file is currently not exported; I guess this is relevant to that: #24472).


@conan-center-bot

This comment has been minimized.

@AbrilRBS AbrilRBS self-assigned this Jul 11, 2024
AbrilRBS
AbrilRBS previously approved these changes Jul 15, 2024
Copy link
Member

@AbrilRBS AbrilRBS left a comment

Choose a reason for hiding this comment

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

Thanks @Julianiolo for taking the time to add the options :)

recipes/raylib/all/conanfile.py Outdated Show resolved Hide resolved
Co-authored-by: Abril Rincón Blanco <[email protected]>
@conan-center-bot

This comment has been minimized.

@uilianries
Copy link
Member

As this configuration is not exposed as project option, I would suggest using Conan configuration to pass any custom definition to the compiler instead:

https://docs.conan.io/2/reference/config_files/global_conf.html

You can add it to your profile, or use via command line directly:

conan create all --version=5.0 -c 'tools.build:defines=["SUPPORT_MODULE_RTEXTURES", "SUPPORT_MODULE_RAUDIO"]'

This configuration will pass -DSUPPORT_MODULE_RTEXTURES -DSUPPORT_MODULE_RAUDIO directly to the compiler. The -D is automatically added by CMake, Conan passes those definition to the build tool actually.

As it may affect the package ID, in case changing the result of the library behavior, you still can inject that configuration as part of the package ID as well:

conan create all --version=5.0 -c 'tools.build:defines=["SUPPORT_MODULE_RTEXTURES", "SUPPORT_MODULE_RAUDIO"]' -c 'tools.info.package_id:confs=["tools.build:defines"]'

So, in summary tools.info.package_id:confs will change the package ID according to defines listed in the tools.build:defines, in case you change that values, it will result in a different package ID as well.

@Julianiolo
Copy link
Contributor Author

Julianiolo commented Jul 15, 2024

@uilianries I think they are intended as project options, raylib just manages them via this config.h file, not via some build script. (as It also has build scripts for like 5+ different build systems)

The intention is to be able to set these options from a consuming recipe, would that even be possible with the configuration?

@uilianries
Copy link
Member

@Julianiolo I'm reading raylib cmake files and indeed those options are exposed: https://github.com/raysan5/raylib/blob/5.0/CMakeOptions.txt#L31. Why passing via CMakeToolchain.variables does not work?

The intention is to be able to set these options from a consuming recipe, would that even be possible with the configuration?

Configurations work for both cases, building and consuming.

@Julianiolo
Copy link
Contributor Author

Oh WOW, how did I not see that lol, I was looking at the wrong CMakeLists.txt....

@Julianiolo
Copy link
Contributor Author

I just saw this, I guess this might just be the solution to #24472? Unless there are more relevant files.

@conan-center-bot

This comment has been minimized.

@uilianries
Copy link
Member

@Julianiolo That could work, but need to test first. Thank for spotting it.

recipes/raylib/all/conanfile.py Outdated Show resolved Hide resolved
Comment on lines 114 to 115
true_false = lambda x: True if x else False
tc.variables["SUPPORT_MODULE_RSHAPES"] = true_false(self.options.module_rshapes)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
true_false = lambda x: True if x else False
tc.variables["SUPPORT_MODULE_RSHAPES"] = true_false(self.options.module_rshapes)
tc.variables["SUPPORT_MODULE_RSHAPES"] = self.options.module_rshapes

The OptionValue is converted to boolean already, you should not need another helper function.

}
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.

@Julianiolo
Copy link
Contributor Author

Julianiolo commented Jul 16, 2024

@uilianries I just saw this: raysan5/raylib@307c998

So I guess maybe the patching approach is actually more future safe?

On second thought, why does it parse the config.h to then produce cmake options, when it could just include the config.h in the code??

@conan-center-bot

This comment has been minimized.

@uilianries
Copy link
Member

On second thought, why does it parse the config.h to then produce cmake options, when it could just include the config.h in the code??

@Julianiolo because we avoid patching anything as we will become the maintainers of that patch.

The project offers transparent options via CMake, and it reflects to the Conan generator CMaketoolchain, that's is well prepared and integrated to work with the project, and we have been using it for any other project. So, using CMake will consume less maintenance from our side.

@Julianiolo
Copy link
Contributor Author

Julianiolo commented Jul 16, 2024

@uilianries No, with that commit, it does not support options via cmake anymore (or am I reading this wrong?)
The commit is newer than 5.0

I'm going to investigate this...

@Julianiolo
Copy link
Contributor Author

Ok, turns out I was reading that completely wrong, lol
It generates the cmake options from config.h, everything should work as before

@conan-center-bot

This comment has been minimized.

@Julianiolo
Copy link
Contributor Author

So now I removed some options, and added a on_off converter, as I had some problems just passing the booleans to cmake.

@uilianries Do you mean by build logs just the output from conan create all/conanfile.py .... ? I can certainly do that :)

@uilianries
Copy link
Member

does that also work for the test package? I tried it and it does not seem to work.

@Julianiolo What do you mean exactly? The test package should receive the include dirs from Conan generators, like CMakeDeps. In the test pacakge, you should not need to configure dependencies include dirs, only consume them.

@Julianiolo
Copy link
Contributor Author

@uilianries well we copy the headers in the test package ( the def generate(self): copy(self, pattern="rcamera.h", src=self.dependencies["raylib"].cpp_info.resdirs[0], dst=os.path.join(self.build_folder, "raylib_stuff"))), but then how do we add that directory to the include directories?

@Julianiolo
Copy link
Contributor Author

@uilianries any idea on this?

@uilianries
Copy link
Member

@uilianries any idea on this?

Hello @Julianiolo ! I'm on vacation 🌴, please, ping @conan-io/barbarians for further support. I should be back by next week. Have a nice day

@Julianiolo
Copy link
Contributor Author

@uilianries ah sorry then, have a nice vacation :)

@uilianries
Copy link
Member

@Julianiolo Hello again! I reviewed this PR again and tested locally. Please, consider the PR Julianiolo#1 as my review/fixing.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@Julianiolo
Copy link
Contributor Author

Julianiolo commented Oct 31, 2024

@uilianries how did this fail again?

Also, why does it even suddenly need that policy?

Also also, how does Conan 1 fail with a compile error? (This is the problem that raylib defines functions with the same name as windows.h. For that reason raylib does not normally include that (but I guess something did?))

@uilianries
Copy link
Member

@Julianiolo You have to revert the commit 08dc263

This recipe has patches and they are needed! https://github.com/conan-io/conan-center-index/tree/master/recipes/raylib/all/patches

@Julianiolo
Copy link
Contributor Author

Julianiolo commented Oct 31, 2024

@uilianries OH, you are right...

The Recipe linter gave me an error about them being unused (see), I guess that is a bug...

@uilianries
Copy link
Member

The Recipe linter gave me an error about them being unused (see), I guess that is a bug...

@Julianiolo You are right, it's a bug! Good catch. It's because the version 5.0 does not have any patch. Will open an issue reporting the case, thank you!

@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

Warning

Conan Center will stop receiving updates for Conan 1.x packages soon - please see announcement.

All green in build 16 (eb91ffd8b70bc67c3bddd1dd87c417d05c46912b):

  • raylib/3.5.0:
    Built 20 packages out of 22 (All logs)

  • raylib/4.0.0:
    Built 20 packages out of 22 (All logs)

  • raylib/5.0:
    Built 20 packages out of 22 (All logs)


Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 16 (eb91ffd8b70bc67c3bddd1dd87c417d05c46912b):

  • raylib/5.0:
    All packages built successfully! (All logs)

  • raylib/4.0.0:
    All packages built successfully! (All logs)

  • raylib/3.5.0:
    All packages built successfully! (All logs)

Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@AbrilRBS AbrilRBS left a comment

Choose a reason for hiding this comment

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

Thanks!

@conan-center-bot conan-center-bot merged commit c42b245 into conan-io:master Nov 1, 2024
16 checks passed
@Julianiolo Julianiolo deleted the raylib_cfc branch November 7, 2024 12:13
OMGtechy pushed a commit to OMGtechy/conan-center-index that referenced this pull request Dec 31, 2024
* support custom frame control

* add some more common settings

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Abril Rincón Blanco <[email protected]>

* moved from patching defines to cmake options

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* 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 <[email protected]>

* Include headers from version 3.5.0

Signed-off-by: Uilian Ries <[email protected]>

* fix rprand typo

* fix linter warnings

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* readd patches

---------

Signed-off-by: Uilian Ries <[email protected]>
Co-authored-by: Abril Rincón Blanco <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants