-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Buildsystem: Use pkg-config for miniupnpc and mbedtls #99171
Conversation
DISCLAIMER: I haven't checked if it builds or not with system libraries at all. I've just noticed those strings and checked if the upstreams started to provide pkg-config files and if our required versions are higher than those versions which added pkg-config support |
To be clear, we don't require miniupnpc 2.2.8 or mbedtls 3.6.1. These are just the versions we have builtin, but Godot should still compile with earlier versions. But at least for miniupnpc the pkgconfig file was added in a somewhat old release so we can expect Linux distros will have caught up with it. For mbedtls, it might be an issue however, we still support mbedtls 2.28 and a lot of Linux distros still have that as their default version. So we might want to keep the old method there for the time being, or let Linux distros patch the |
Maybe we can do something like this instead to preserve support for mbedtls 2.28 LTS: diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 2fd573da75..e8c2f88435 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -279,16 +279,18 @@ def configure(env: "SConsEnvironment"):
env.ParseConfig("pkg-config libwebp --cflags --libs")
if not env["builtin_mbedtls"]:
- # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
- env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
+ # mbedTLS only provides a pkgconfig file since 3.6.0, but we still support 2.28.x,
+ # so fallback to manually specifying LIBS if it fails.
+ try:
+ env.ParseConfig("pkg-config mbedtls mbedcrypto mbedx509 --cflags --libs")
+ except:
+ env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
if not env["builtin_wslay"]:
env.ParseConfig("pkg-config libwslay --cflags --libs")
if not env["builtin_miniupnpc"]:
- # No pkgconfig file so far, hardcode default paths.
- env.Prepend(CPPPATH=["/usr/include/miniupnpc"])
- env.Append(LIBS=["miniupnpc"])
+ env.ParseConfig("pkg-config miniupnpc --cflags --libs")
# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimizations (Or if SCons provides a version of |
Looks reasonable but it didn't throw any exception even on empty command 😅 |
And later check if lib is available with |
Ohh... It looks like there is also another "bug" but I am not sure if it should be named so... For some libs we check if lib exist with |
It does throw an exception for me if there's no pkg-config file for mbedtls. But indeed diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 2fd573da75..c8202b147d 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -279,16 +279,18 @@ def configure(env: "SConsEnvironment"):
env.ParseConfig("pkg-config libwebp --cflags --libs")
if not env["builtin_mbedtls"]:
- # mbedTLS does not provide a pkgconfig config yet. See https://github.com/ARMmbed/mbedtls/issues/228
- env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
+ # mbedTLS only provides a pkgconfig file since 3.6.0, but we still support 2.28.x,
+ # so fallback to manually specifying LIBS if it fails.
+ if os.system("pkg-config --exists mbedtls") == 0: # 0 means found
+ env.ParseConfig("pkg-config mbedtls mbedcrypto mbedx509 --cflags --libs")
+ else:
+ env.Append(LIBS=["mbedtls", "mbedcrypto", "mbedx509"])
if not env["builtin_wslay"]:
env.ParseConfig("pkg-config libwslay --cflags --libs")
if not env["builtin_miniupnpc"]:
- # No pkgconfig file so far, hardcode default paths.
- env.Prepend(CPPPATH=["/usr/include/miniupnpc"])
- env.Append(LIBS=["miniupnpc"])
+ env.ParseConfig("pkg-config miniupnpc --cflags --libs")
# On Linux wchar_t should be 32-bits
# 16-bit library shouldn't be required due to compiler optimizations |
Miniupnpc added pkg-config files in 2.2.3 but we require 2.2.8 miniupnp/miniupnp@5a39800 MbedTLS added pkg-config files in 3.6.0 while we require 3.6.1 https://github.com/Mbed-TLS/mbedtls/blob/development/ChangeLog Signed-off-by: Yevhen Babiichuk (DustDFG) <dfgdust@gmail.com> Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Thanks! |
This PR breaks See #99196 |
Miniupnpc added pkg-config files in 2.2.3 but we require 2.2.8 miniupnp/miniupnp@5a39800
MbedTLS added pkg-config files in 3.6.0 while we require 3.6.1 https://github.com/Mbed-TLS/mbedtls/blob/development/ChangeLog