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

[sdl2, sdl2-*] allow disabling transitive dependencies #35311

Closed
ahrbe1 opened this issue Nov 24, 2023 · 8 comments · Fixed by #35394
Closed

[sdl2, sdl2-*] allow disabling transitive dependencies #35311

ahrbe1 opened this issue Nov 24, 2023 · 8 comments · Fixed by #35394
Assignees
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist

Comments

@ahrbe1
Copy link

ahrbe1 commented Nov 24, 2023

Is your feature request related to a problem? Please describe.

I recently discovered that on Linux, it seems impossible for users to disable some transitive dependencies of interdependent SDL2 libraries, because the sdl2-* ports depend on "sdl2" which overrides any "default-features": false setting by the user in their vcpkg.json file.

For example, I'd like to build sdl without wayland support, but as soon as I pull in another library, like sdl2-image (which depends on "sdl2"), wayland support is now required.

Similarly, sdl2 has a default dependency on dbus, which has a default dependency on systemd. Systemd needs a lot of external/system packages installed in order to build, so it'd be nice to be able to disable systemd support for dbus in this case.

As I understand, neither of these things are really possible without patching the vcpkg.json port files.

Proposed solution

I would suggest replacing the named "sdl2" dependency with this:

-    "sdl2",
+    {
+      "name": "sdl2",
+      "default-features": false
+    },

for the sdl2-gfx, sdl2-image, sdl2-mixer, sdl2-mixer-ext, sdl2-net, and sdl2-ttf libraries.

and a similar patch for the sdl2 port's dependency on dbus:

     {
       "name": "dbus",
+      "default-features": false,
       "platform": "linux"
     },

Describe alternatives you've considered

I am not aware of any other ways to resolve this issue at the present time due to how default-features work.

Additional context

No response

@ahrbe1 ahrbe1 added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label Nov 24, 2023
@chrismile
Copy link
Contributor

First of all, thanks a lot for bringing this up! I am also having problems with sdl2's transitive dependency on systemd via dbus. I tried testing the fixes by @jimwang118 on GitHub actions via

    - name: Setup vcpkg
      uses: lukka/run-vcpkg@v11
      with:
        vcpkgGitURL: 'https://github.com/jimwang118/vcpkg.git'
        vcpkgGitCommitId: 'c9073038fe5313bc8a76982d632ceaf896695597'
        doNotCacheOnWorkflowFailure: true

However, systemd (and in turn libmount) are still fetched even if I use the following vcpkg.json file:

{
    "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
    "name": "actions-test",
    "version": "0.1.0",
    "dependencies": [
        {
            "name": "dbus",
            "default-features": false,
            "features": [],
            "platform": "linux"
        },
        {
            "name": "sdl2",
            "features": [ "x11", "wayland" ],
            "platform": "linux"
        },
        {
            "name": "sdl2",
            "platform": "!linux"
        },
        "sdl2-image"
    ]
}

Am I using doing something wrong in disabling the transitive dependency on systemd? You can find a test repo reproducing this issue here: https://github.com/chrismile/ActionsTestRepo2

@ahrbe1
Copy link
Author

ahrbe1 commented Nov 30, 2023

Looking through that MR it patches SDL2PP, but not SDL2. This file also needs patched

https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/vcpkg.json

(Specifically for DBus.)

@jimwang118
Copy link
Contributor

Looking through that MR it patches SDL2PP, but not SDL2. This file also needs patched

https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/vcpkg.json

(Specifically for DBus.)

I don't quite understand what you mean by repairing dbus? Can you elaborate on that? Do I need to add any restrictions to the dbus that sdl2 depends on?

@ahrbe1
Copy link
Author

ahrbe1 commented Dec 1, 2023

Yes, something like this

--- a/ports/sdl2/vcpkg.json
+++ b/ports/sdl2/vcpkg.json
@@ -8,7 +8,8 @@
   "dependencies": [
     {
       "name": "dbus",
-      "platform": "linux"
+      "platform": "linux",
+      "default-features": false
     },
     {
       "name": "vcpkg-cmake",

@jimwang118
Copy link
Contributor

Yes, something like this

--- a/ports/sdl2/vcpkg.json
+++ b/ports/sdl2/vcpkg.json
@@ -8,7 +8,8 @@
   "dependencies": [
     {
       "name": "dbus",
-      "platform": "linux"
+      "platform": "linux",
+      "default-features": false
     },
     {
       "name": "vcpkg-cmake",

However, vcpkg's dbus does not have default-features, so adding default-features: false has no practical significance.

@ahrbe1
Copy link
Author

ahrbe1 commented Dec 1, 2023

Really? I see this in the dbus vcpkg.json:

https://github.com/microsoft/vcpkg/blob/master/ports/dbus/vcpkg.json#L20

  "default-features": [
    {
      "name": "systemd",
      "platform": "linux"
    }
  ],

@dg0yt
Copy link
Contributor

dg0yt commented Dec 1, 2023

dbus[systemd] was added a few days ago.

@jimwang118
Copy link
Contributor

dbus[systemd] was added a few days ago.

Yes, I have not updated the master library locally, so it is not displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants