-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
Import env
if possible
#1170
Import env
if possible
#1170
Conversation
For unknown reasons, if I run |
Make sure you have the same version of
|
d23c1e4
to
1e3e304
Compare
@Faless It worked! Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just some nit picks to make the behavior clearer (I think?):
diff --git a/SConstruct b/SConstruct
index 0edf7fa..11ec4cf 100644
--- a/SConstruct
+++ b/SConstruct
@@ -4,19 +4,11 @@ import os
import platform
import sys
import subprocess
-from typing import TYPE_CHECKING
from binding_generator import scons_generate_bindings, scons_emit_files
-from SCons.Script import Environment
from SCons.Errors import UserError
-from SCons.Variables import BoolVariable, EnumVariable, PathVariable
EnsureSConsVersion(4, 0)
-try:
- Import("env")
-except:
- pass
-
def add_sources(sources, dir, extension):
for f in os.listdir(dir):
@@ -59,10 +51,13 @@ elif ARGUMENTS.get("platform", ""):
else:
raise ValueError("Could not detect platform automatically, please specify with platform=<platform>")
-# Default tools with no platform defaults to gnu toolchain.
-# We apply platform specific toolchains via our custom tools.
-if not "env" in globals() or TYPE_CHECKING:
+try:
+ Import("env")
+except:
+ # Default tools with no platform defaults to gnu toolchain.
+ # We apply platform specific toolchains via our custom tools.
env = Environment(tools=["default"], PLATFORM="")
+
env.PrependENVPath("PATH", os.getenv("PATH"))
# Default num_jobs to local cpu count if not user specified.
This PR make it possible to import `env` and use it instead of creating one from scratch every time. Handy because we encourage users to use the godot-cpp SConstruct file as a base to their projects (see the test project). So, if a project want to override specific settings, (eg. make a path local to their SConstruct file, not local to the godot-cpp/SConstruct file), it can do so.
1e3e304
to
8155f35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me! And Fabio's requested changes have been made
Discussed at the GDExtension meeting, and we think this makes sense. |
Thanks! |
This PR make it possible to import
env
and use it instead of creating one from scratch every time.Handy because we encourage users to use the godot-cpp SConstruct file as a base to their projects (see the test project). So, if a project want to override specific settings, (eg. make a path local to their SConstruct file, not local to the godot-cpp/SConstruct file), it can do so.