|
2 | 2 | import os |
3 | 3 | import sys |
4 | 4 |
|
5 | | -env = SConscript("godot-cpp/SConstruct") |
| 5 | +# You can find documentation for SCons and SConstruct files at: |
| 6 | +# https://scons.org/documentation.html |
6 | 7 |
|
7 | | -# For reference: |
8 | | -# - CCFLAGS are compilation flags shared between C and C++ |
9 | | -# - CFLAGS are for C-specific compilation flags |
10 | | -# - CXXFLAGS are for C++-specific compilation flags |
11 | | -# - CPPFLAGS are for pre-processor flags |
12 | | -# - CPPDEFINES are for pre-processor defines |
13 | | -# - LINKFLAGS are for linking flags |
| 8 | +# This lets SCons know that we're using godot-cpp, from the godot-cpp folder. |
| 9 | +env = SConscript("godot-cpp/SConstruct") |
14 | 10 |
|
15 | | -# tweak this if you want to use different folders, or more folders, to store your source code in. |
| 11 | +# Configures the 'src' directory as a source for header files. |
16 | 12 | env.Append(CPPPATH=["src/"]) |
| 13 | + |
| 14 | +# Collects all .cpp files in the 'src' folder as compile targets. |
17 | 15 | sources = Glob("src/*.cpp") |
18 | 16 |
|
19 | | -if env["platform"] == "macos": |
20 | | - library = env.SharedLibrary( |
21 | | - "demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format( |
22 | | - env["platform"], env["target"], env["platform"], env["target"] |
23 | | - ), |
24 | | - source=sources, |
25 | | - ) |
26 | | -elif env["platform"] == "ios": |
27 | | - if env["ios_simulator"]: |
28 | | - library = env.StaticLibrary( |
29 | | - "demo/bin/libgdexample.{}.{}.simulator.a".format(env["platform"], env["target"]), |
30 | | - source=sources, |
31 | | - ) |
32 | | - else: |
33 | | - library = env.StaticLibrary( |
34 | | - "demo/bin/libgdexample.{}.{}.a".format(env["platform"], env["target"]), |
35 | | - source=sources, |
36 | | - ) |
37 | | -else: |
38 | | - library = env.SharedLibrary( |
39 | | - "demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]), |
40 | | - source=sources, |
41 | | - ) |
| 17 | +# The filename for the dynamic library for this GDExtension. |
| 18 | +# $SHLIBPREFIX is a platform specific prefix for the dynamic library ('lib' on Unix, '' on Windows). |
| 19 | +# $SHLIBSUFFIX is the platform specific suffix for the dynamic library (for example '.dll' on Windows). |
| 20 | +# env["suffix"] includes the build's feature tags (e.g. '.windows.template_debug.x86_64') |
| 21 | +# (see https://docs.godotengine.org/en/stable/tutorials/export/feature_tags.html). |
| 22 | +# The final path should match a path in the '.gdextension' file. |
| 23 | +lib_filename = "{}gdexample{}{}".format(env.subst('$SHLIBPREFIX'), env["suffix"], env.subst('$SHLIBSUFFIX')) |
| 24 | + |
| 25 | +# Creates a SCons target for the path with our sources. |
| 26 | +library = env.SharedLibrary( |
| 27 | + "demo/bin/{}".format(lib_filename), |
| 28 | + source=sources, |
| 29 | +) |
42 | 30 |
|
| 31 | +# Selects the shared library as the default target. |
43 | 32 | Default(library) |
0 commit comments