godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 573 forks source link

GDNative SConstruct - fails on FreeBSD #312

Closed atari83 closed 1 year ago

atari83 commented 5 years ago

Hello there, I was following this tutorial (https://docs.godotengine.org/en/3.1/tutorials/plugins/gdnative/gdnative-cpp-example.html) to build and prepare my environment for GDNative on my FreeBSD machine. But when it came to 'sconf', I faced this error:

[user1@host /usr/home/user1/godot-cpp]$ scons platform=x11 generate_bindings=yes scons: Reading SConscript files ... ValueError: Could not detect platform automatically, please specify with platform=: File "/usr/home/user1/godot-cpp/SConstruct", line 20: raise ValueError('Could not detect platform automatically, please specify with platform=')

It seems it doesnt care about input arguments as well ..

ps: FreeBSD host 12.0-RELEASE-p6 FreeBSD 12.0-RELEASE-p6 GENERIC amd64

bruvzg commented 5 years ago

Unlike Godot itself platform for godot-cpp should be linux not x11. In case it won't help comment out platform detection code (lines 15...25 of SConstruct).

atari83 commented 5 years ago

Hello @bruvzg , Thanks for reply. As I shown in error log, sconf has just tried to automatically detect the Operating system which obviously failed but it also didn't recognize my input parameter for "platform=" which is odd! I tried 'linux' and other keywords as well but failed with same error message.

Update: same issue for other parameters (ex: bits, ..)

bruvzg commented 5 years ago

It's trying to detect system before checking your input platform= and failing if it's not detected regardless of other arguments, try following patch:

diff --git a/SConstruct b/SConstruct
index 99475e4..4f104bf 100644
--- a/SConstruct
+++ b/SConstruct
@@ -12,12 +12,17 @@ def add_sources(sources, dir, extension):

 # Try to detect the host platform automatically.
 # This is used if no `platform` argument is passed
-if sys.platform.startswith('linux'):
+
+platform_arg = ARGUMENTS.get("platform", ARGUMENTS.get("p", ""))
+
+if sys.platform.startswith('linux') or sys.platform.startswith('freebsd'):
     host_platform = 'linux'
-elif sys.platform == 'darwin':
+elif sys.platform == 'darwin':
     host_platform = 'osx'
 elif sys.platform == 'win32':
     host_platform = 'windows'
+elif platform_arg != "":
+    host_platform = platform_arg
 else:
     raise ValueError(
         'Could not detect platform automatically, please specify with '
atari83 commented 5 years ago

It worked !! :D Thank you @bruvzg

I didn't study SConstruct script, you were right, it wouldn't proceed if it cannot be automatically detected :) Could we merge this patch to address this issue ?

Thanks

Calinou commented 5 years ago

It would make sense to backport this fix to the Godot repository as well :slightly_smiling_face:

Gastronok commented 5 years ago

I'd also argue that the platform naming convention should be returned to "x11" as opposed to "linux" as (hopefully) Godot is not trying to become platform-specific.

If you wanted to get really pedantic "unix-like" may be more appropriate if you support different windowing systems like wayland.

vnen commented 3 years ago

Is this fixed with #517?