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

[SFML] the wrap dont have the same name than pkg-config #1527

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

nda-cunh
Copy link

close #1526

@nda-cunh nda-cunh marked this pull request as draft May 23, 2024 15:06
@nda-cunh
Copy link
Author

In my project it works, except if I use dependency('sfml-all') it doesn't want to build it, should I create a fake sfml-all option to bypass that?

@benoit-pierre
Copy link
Contributor

What's the exact error?

@nda-cunh
Copy link
Author

What's the exact error?

image

@benoit-pierre
Copy link
Contributor

Also, don't forget to update:

subprojects/packagefiles/imgui-sfml/meson.build:10: sfml_dep = dependency('sfml')

(and associated revision bump in releases.json)

@benoit-pierre
Copy link
Contributor

What's the exact error?

image

And you're sure subprojects/SFML-2.6.1 is updated with all your changes?

@nda-cunh
Copy link
Author

What's the exact error?

image

And you're sure subprojects/SFML-2.6.1 is updated with all your changes?

yes because i work only in this project i use a bash script for copy in wrapdb

@nda-cunh
Copy link
Author

maybe if all options is false we need enable sfml-all ?

@nda-cunh
Copy link
Author

maybe if all options is false we need enable sfml-all ?

sfml-all don't enable sfml-audio

@benoit-pierre
Copy link
Contributor

maybe if all options is false we need enable sfml-all ?

sfml-all don't enable sfml-audio

Why do you mean?

▹ cat /usr/share/pkgconfig/sfml-all.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: SFML-all
Description: The Simple and Fast Multimedia Library, all modules.
URL: http://www.sfml-dev.org
Version: 2.6.1
Requires: sfml-system, sfml-window, sfml-graphics, sfml-audio, sfml-network

@nda-cunh
Copy link
Author

maybe if all options is false we need enable sfml-all ?

sfml-all don't enable sfml-audio
I meant in the project I'm testing. Sorry, I'm having trouble expressing myself in English!

@benoit-pierre
Copy link
Contributor

Anyway, I'm not sure how to handle the fact that those dependencies are optional. Use a dependency('', required: false) fallback?

@eli-schwartz: dependencies declared in a wrap provide section are always mandatory, how do handle the case where the project would actually optionally build them?

@nda-cunh
Copy link
Author

how does the meson wrap know to call sfml-audio with sfml-all?

Anyway, I'm not sure how to handle the fact that those dependencies are optional. Use a dependency('', required: false) fallback?

@eli-schwartz: dependencies declared in a wrap provide section are always mandatory, how do handle the case where the project would actually optionally build them?

how does the meson wrap know to call sfml-audio with sfml-all?

@benoit-pierre
Copy link
Contributor

maybe if all options is false we need enable sfml-all ?

sfml-all don't enable sfml-audio
I meant in the project I'm testing. Sorry, I'm having trouble expressing myself in English!

If the project you're testing does not need sfml-audio, then I don't think it should use sfml-all.

@nda-cunh
Copy link
Author

nda-cunh commented May 23, 2024

if would adding the pkg-config module work?

@eli-schwartz
Copy link
Member

Anyway, I'm not sure how to handle the fact that those dependencies are optional. Use a dependency('', required: false) fallback?

@eli-schwartz: dependencies declared in a wrap provide section are always mandatory, how do handle the case where the project would actually optionally build them?

I guess the other project could make sure it's enabled by passing default_options to the dependency() lookup.

@benoit-pierre
Copy link
Contributor

@eli-schwartz: yeah, thanks.

@nda-cunh: going back to your issue, can you share your super-project meson.build?

@nda-cunh
Copy link
Author

@eli-schwartz: yeah, thanks.

@nda-cunh: going back to your issue, can you share your super-project meson.build?

all my project ?

@benoit-pierre
Copy link
Contributor

At least the dependency(…) call.

@nda-cunh
Copy link
Author

i juste call dependency('sfml-graphics')

https://gitlab.com/nda-cunh/nibbler/-/blob/master/sfml/meson.build?ref_type=heads#L2

@benoit-pierre
Copy link
Contributor

It works fine for me. Using your latest commit with:

 subprojects/packagefiles | 1 +
 subprojects/sfml.wrap    | 8 ++------
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git c/subprojects/packagefiles i/subprojects/packagefiles
new file mode 120000
index 0000000..79b6f6a
--- /dev/null
+++ i/subprojects/packagefiles
@@ -0,0 +1 @@
+../../wrapdb/subprojects/packagefiles
\ No newline at end of file
diff --git c/subprojects/sfml.wrap i/subprojects/sfml.wrap
index 7f06448..245c9b7 100644
--- c/subprojects/sfml.wrap
+++ i/subprojects/sfml.wrap
@@ -3,11 +3,7 @@ directory = SFML-2.6.1
 source_url = https://github.com/SFML/SFML/archive/refs/tags/2.6.1.tar.gz
 source_filename = 2.6.1.tar.gz
 source_hash = 82535db9e57105d4f3a8aedabd138631defaedc593cab589c924b7d7a11ffb9d
-patch_filename = sfml_2.6.1-1_patch.zip
-patch_url = https://wrapdb.mesonbuild.com/v2/sfml_2.6.1-1/get_patch
-patch_hash = 10367d927ec489dc575491de0059945a63ba08eef3f6fc146e6ba339176c9f18
-source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sfml_2.6.1-1/2.6.1.tar.gz
-wrapdb_version = 2.6.1-1
+patch_directory = sfml
 
 [provide]
-dependency_names = sfml-all, sfml-graphics, sfml-windows, sfml-system, sfml-audio, sfml-network
+dependency_names = sfml-all, sfml-audio, sfml-graphics, sfml-network, sfml-system, sfml-window

(subprojects/packagefiles symlinked to the one in wrapdb 14c8ff2)

@nda-cunh
Copy link
Author

it works for me too, but it's just a sad that dependency('sfml-graphics') forces the creation of sfml-audio

@benoit-pierre
Copy link
Contributor

benoit-pierre commented May 23, 2024

You can disable it at setup time (meson setup -Dsfml:audio=disabled).

@benoit-pierre
Copy link
Contributor

Or in meson.build:

 meson.build | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git i/meson.build w/meson.build
index 29749d3..236738e 100644
--- i/meson.build
+++ w/meson.build
@@ -1,4 +1,13 @@
-project('nibbler', ['cpp', 'vala'], default_options : ['warning_level=3', 'cpp_std=c++17', 'optimization=2'])
+project(
+  'nibbler',
+  ['cpp', 'vala'],
+  default_options: [
+    'warning_level=3',
+    'cpp_std=c++17',
+    'optimization=2',
+    'sfml:audio=disabled',
+  ],
+)
 
 subdir('core')
 subdir('sfml')

@nda-cunh
Copy link
Author

nda-cunh commented May 23, 2024

it good for me! Thank you for guiding me through this MergeRequest :)

@benoit-pierre
Copy link
Contributor

benoit-pierre commented May 23, 2024

You're not done ;):

  • the examples still need to be updated (they still use sfml_dep), and at least enabled on the CI
  • do the same things for other subsystems as for audio: force require dependencies if the option is enabled, switch said option from auto to disabled if a dependency is missing

@nda-cunh
Copy link
Author

You're not done ;):

  • the examples still need to be updated (they still use sfml_dep), and at least enabled on the CI
  • do the same things for other subsystems as for audio: force require dependencies if the option is enabled, switch said option from auto to disabled if a dependency is missing

Haha I'll do that tomorrow it's late ;P , I'll see why not add csfml.wrap too.

@nda-cunh
Copy link
Author

@benoit-pierre Are we required to include the examples? Is it the job of the wraps to provide this kind of thing? Because it's broken and doesn't even work, I'm not interested in fixing it.
can i remove it ?

@benoit-pierre
Copy link
Contributor

Yes, since the tests are not built, it's a good way to ensure the port is somewhat functional. Here's a diff to get you started:

 .../sfml/examples/joystick/meson.build             |  2 +-
 .../packagefiles/sfml/examples/sound/meson.build   |  2 +-
 subprojects/packagefiles/sfml/meson.build          | 45 ++++++++++------------
 subprojects/packagefiles/sfml/meson_options.txt    |  2 +-
 .../packagefiles/sfml/src/SFML/Audio/meson.build   |  1 +
 .../sfml/src/SFML/Graphics/meson.build             |  2 +-
 .../packagefiles/sfml/src/SFML/Network/meson.build |  1 +
 .../packagefiles/sfml/src/SFML/Window/meson.build  |  1 +
 subprojects/packagefiles/sfml/src/SFML/meson.build | 10 ++++-
 9 files changed, 37 insertions(+), 29 deletions(-)

diff --git i/subprojects/packagefiles/sfml/examples/joystick/meson.build w/subprojects/packagefiles/sfml/examples/joystick/meson.build
index a2f82696..e626f550 100644
--- i/subprojects/packagefiles/sfml/examples/joystick/meson.build
+++ w/subprojects/packagefiles/sfml/examples/joystick/meson.build
@@ -1,3 +1,3 @@
 subdir('resources')
 
-executable('joystick', 'Joystick.cpp', dependencies: sfml_dep)
+executable('joystick', 'Joystick.cpp', dependencies: sfml_graphics_dep)
diff --git i/subprojects/packagefiles/sfml/examples/sound/meson.build w/subprojects/packagefiles/sfml/examples/sound/meson.build
index 8b199d84..e8810a1d 100644
--- i/subprojects/packagefiles/sfml/examples/sound/meson.build
+++ w/subprojects/packagefiles/sfml/examples/sound/meson.build
@@ -1,3 +1,3 @@
 subdir('resources')
 
-executable('sound', 'Sound.cpp', dependencies: sfml_dep)
+executable('sound', 'Sound.cpp', dependencies: sfml_audio_dep)
diff --git i/subprojects/packagefiles/sfml/meson.build w/subprojects/packagefiles/sfml/meson.build
index 8f21682c..1f68596f 100644
--- i/subprojects/packagefiles/sfml/meson.build
+++ w/subprojects/packagefiles/sfml/meson.build
@@ -16,6 +16,11 @@ audio_opt = get_option('audio')
 window_opt = get_option('window')
 network_opt = get_option('network')
 
+graphics_opt = graphics_opt.require(
+  window_opt.allowed(),
+  error_message: 'Feature window is disabled',
+)
+
 gl_dep = dependency('gl')
 winmm_dep = cpp.find_library('winmm', required: host_machine.system() == 'windows')
 w32_dep = cpp.find_library('ws2_32', required: host_machine.system() == 'windows')
@@ -42,10 +47,10 @@ priv_inc = include_directories('src')
 
 summary(
   {
-    'audio'   : get_option('audio').allowed(),
-    'graphics': get_option('graphics').allowed(),
-    'network' : get_option('network').allowed(),
-    'window'  : get_option('window').allowed(),
+    'audio'   : audio_opt.allowed(),
+    'graphics': graphics_opt.allowed(),
+    'network' : network_opt.allowed(),
+    'window'  : window_opt.allowed(),
   },
   bool_yn: true,
   section: 'Features',
@@ -53,27 +58,19 @@ summary(
 
 subdir('src/SFML')
 
-if (
-  (
-  audio_opt.allowed()
-  and graphics_opt.allowed()
-  and network_opt.allowed()
-  and window_opt.allowed()
-  ) 
+sfml_all_dep = declare_dependency(
+  include_directories: pub_inc,
+  link_with: [host_machine.system() == 'windows' ? main_lib : []],
+  dependencies: [
+    sfml_audio_dep,
+    sfml_graphics_dep,
+    sfml_network_dep,
+    sfml_window_dep,
+    sfml_system_dep,
+  ],
 )
-  sfml_all_dep = declare_dependency(
-    include_directories: pub_inc,
-    link_with: [host_machine.system() == 'windows' ? main_lib : []],
-    dependencies: [
-      sfml_audio_dep,
-      sfml_graphics_dep,
-      sfml_network_dep,
-      sfml_window_dep,
-      sfml_system_dep,
-    ],
-  )
-  meson.override_dependency('sfml-all', sfml_all_dep)
-endif
+
+meson.override_dependency('sfml-all', sfml_all_dep)
 
 if get_option('examples')
   subdir('examples')
diff --git i/subprojects/packagefiles/sfml/meson_options.txt w/subprojects/packagefiles/sfml/meson_options.txt
index 65c33d46..4af17e17 100644
--- i/subprojects/packagefiles/sfml/meson_options.txt
+++ w/subprojects/packagefiles/sfml/meson_options.txt
@@ -1,4 +1,4 @@
-option('examples', type : 'boolean', value : false)
+option('examples', type: 'boolean', value: true)
 option('graphics', type: 'feature')
 option('window', type: 'feature')
 option('audio', type: 'feature')
diff --git i/subprojects/packagefiles/sfml/src/SFML/Audio/meson.build w/subprojects/packagefiles/sfml/src/SFML/Audio/meson.build
index fce10eb4..a790b3d3 100644
--- i/subprojects/packagefiles/sfml/src/SFML/Audio/meson.build
+++ w/subprojects/packagefiles/sfml/src/SFML/Audio/meson.build
@@ -35,6 +35,7 @@ sfml_audio_dep = declare_dependency(
   include_directories: pub_inc,
   link_with: audio_lib,
   compile_args: get_option('default_library') == 'static' ? '-DSFML_STATIC' : [],
+  dependencies: sfml_system_dep,
 )
 
 meson.override_dependency('sfml-audio', sfml_audio_dep)
diff --git i/subprojects/packagefiles/sfml/src/SFML/Graphics/meson.build w/subprojects/packagefiles/sfml/src/SFML/Graphics/meson.build
index de38116f..3c4bf67f 100644
--- i/subprojects/packagefiles/sfml/src/SFML/Graphics/meson.build
+++ w/subprojects/packagefiles/sfml/src/SFML/Graphics/meson.build
@@ -54,7 +54,7 @@ sfml_graphics_dep = declare_dependency(
   include_directories: pub_inc,
   link_with: graphics_lib,
   compile_args: get_option('default_library') == 'static' ? '-DSFML_STATIC' : [],
-  dependencies: [sfml_window_dep, sfml_system_dep]
+  dependencies: [sfml_system_dep, sfml_window_dep]
 )
 
 meson.override_dependency('sfml-graphics', sfml_graphics_dep)
diff --git i/subprojects/packagefiles/sfml/src/SFML/Network/meson.build w/subprojects/packagefiles/sfml/src/SFML/Network/meson.build
index 981901b4..d7dee47f 100644
--- i/subprojects/packagefiles/sfml/src/SFML/Network/meson.build
+++ w/subprojects/packagefiles/sfml/src/SFML/Network/meson.build
@@ -25,6 +25,7 @@ sfml_network_dep = declare_dependency(
   include_directories: pub_inc,
   link_with: network_lib,
   compile_args: get_option('default_library') == 'static' ? '-DSFML_STATIC' : [],
+  dependencies: sfml_system_dep,
 )
 
 meson.override_dependency('sfml-network', sfml_network_dep)
diff --git i/subprojects/packagefiles/sfml/src/SFML/Window/meson.build w/subprojects/packagefiles/sfml/src/SFML/Window/meson.build
index e1759ceb..f6f71f97 100644
--- i/subprojects/packagefiles/sfml/src/SFML/Window/meson.build
+++ w/subprojects/packagefiles/sfml/src/SFML/Window/meson.build
@@ -95,6 +95,7 @@ sfml_window_dep = declare_dependency(
   include_directories: pub_inc,
   link_with: window_lib,
   compile_args: get_option('default_library') == 'static' ? '-DSFML_STATIC' : [],
+  dependencies: sfml_system_dep,
 )
 
 meson.override_dependency('sfml-window', sfml_window_dep)
diff --git i/subprojects/packagefiles/sfml/src/SFML/meson.build w/subprojects/packagefiles/sfml/src/SFML/meson.build
index b4a80640..ec6c02cc 100644
--- i/subprojects/packagefiles/sfml/src/SFML/meson.build
+++ w/subprojects/packagefiles/sfml/src/SFML/meson.build
@@ -1,18 +1,26 @@
 subdir('Main')
 subdir('System')
 
-if window_opt.allowed() or graphics_opt.allowed()
+if window_opt.allowed()
   subdir('Window')
+else
+  sfml_window_dep = disabler()
 endif
 
 if network_opt.allowed()
   subdir('Network')
+else
+  sfml_network_dep = disabler()
 endif
 
 if graphics_opt.allowed()
   subdir('Graphics')
+else
+  sfml_graphics_dep = disabler()
 endif
 
 if audio_opt.allowed()
   subdir('Audio')
+else
+  sfml_audio_dep = disabler()
 endif

@benoit-pierre
Copy link
Contributor

TODO (no necessarily as part of this PR):

  • library versions
  • install pkgconfig entries
  • tests

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.

[SFML] the wrap dont have the same name than pkg-config
3 participants