godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.64k stars 497 forks source link

SCons v.4.8.0 - 'BoolVariable' is not defined #1518

Open lgxm3z opened 1 month ago

lgxm3z commented 1 month ago

Godot version

4.2.2.stable

godot-cpp version

4.2.2.stable

System information

Windows 11, Windows 10, macOS

Issue description

$ scons --version

SCons by Steven Knight et al.:
        SCons: v4.8.0.7c688f694c644b61342670ce92977bf4a396c0d4, Sun, 07 Jul 2024 16:52:07 -0700, by bdbaddog on M1Dog2021

$ scons

scons: Reading SConscript files ...
NameError: name 'BoolVariable' is not defined:
  File "C:\Documents\project\Project\SConstruct", line 52:
    env = SConscript("include/godot-cpp/SConstruct", {"env": env, "customs": customs})
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\SCons\Script\SConscript.py", line 684:
    return method(*args, **kw)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\SCons\Script\SConscript.py", line 620:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\SCons\Script\SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Documents\project\Project\include\godot-cpp\SConstruct", line 36:
    cpp_tool.options(opts, env)
  File "C:\Documents\project\Project\include\godot-cpp\tools\godotcpp.py", line 325:
    tool.options(opts)
  File "C:\Documents\project\Project\include\godot-cpp\tools\ios.py", line 24:
    opts.Add(BoolVariable("ios_simulator", "Target iOS Simulator", False))

Working with SCons v4.7.0 ✅️

pip uninstall scons && pip install scons==4.7.0
Faless commented 1 month ago

This is fixed by #1504 which (among many other things), did this change:

diff --git a/tools/ios.py b/tools/ios.py
index 75718684..d5767093 100644
--- a/tools/ios.py
+++ b/tools/ios.py
@@ -2,7 +2,7 @@ import os
 import sys
 import subprocess
 import common_compiler_flags
-from SCons.Variables import *
+from SCons.Variables import BoolVariable

 if sys.version_info < (3,):

diff --git a/tools/linux.py b/tools/linux.py
index 1783e060..95a5b92c 100644
--- a/tools/linux.py
+++ b/tools/linux.py
@@ -1,5 +1,5 @@
 import common_compiler_flags
-from SCons.Variables import *
+from SCons.Variables import BoolVariable
 from SCons.Tool import clang, clangxx

diff --git a/tools/windows.py b/tools/windows.py
index a263241a..d072b221 100644
--- a/tools/windows.py
+++ b/tools/windows.py
@@ -2,7 +2,7 @@ import sys
 import my_spawn
 import common_compiler_flags
 from SCons.Tool import msvc, mingw
-from SCons.Variables import *
+from SCons.Variables import BoolVariable

 def options(opts):

We might want to backport at least this change to 4.2 / 4.1 (CC @dsnopek )

Note: It's really weird that scons 4.8 broke all from SCons.Variables import * :/

dsnopek commented 1 month ago

We might want to backport at least this change to 4.2 / 4.1

It's tagged for cherry-picking! It'll get pulled in when I do the next round

Priton-CE commented 1 month ago

It appears like SCons/scons@9b4f2eb added a __all__ list to the SCons.Variables __init__ file which is causing the issue.

From what I am gathering from the commit message this might be an intentional change.