22import os
33import sys
44
5+ # default values, adapt them to your setup
6+ default_library_name = "libgdexample"
7+ default_target_path = "demo/bin/"
8+
9+ # Local dependency paths, adapt them to your setup
10+ cpp_bindings_path = "../"
11+ # cpp_bindings_path = "godot-cpp/"
12+ godot_headers_path = cpp_bindings_path + "godot-headers/"
13+ cpp_library = "libgodot-cpp"
14+
515# Try to detect the host platform automatically.
616# This is used if no `platform` argument is passed
717if sys .platform .startswith ("linux" ):
818 host_platform = "linux"
19+ elif sys .platform .startswith ("freebsd" ):
20+ host_platform = "freebsd"
921elif sys .platform == "darwin" :
1022 host_platform = "osx"
1123elif sys .platform == "win32" or sys .platform == "msys" :
@@ -18,20 +30,22 @@ env = Environment(ENV=os.environ)
1830opts = Variables ([], ARGUMENTS )
1931
2032# Define our options
21- opts .Add (EnumVariable ("target" , "Compilation target" , "debug" , ["d" , "debug" , "r" , "release" ]))
22- opts .Add (EnumVariable ("platform" , "Compilation platform" , host_platform , ["" , "windows" , "x11" , "linux" , "osx" ]))
33+ opts .Add (EnumVariable ("target" , "Compilation target" , "debug" , allowed_values = ("debug" , "release" ), ignorecase = 2 ))
2334opts .Add (
24- EnumVariable ("p" , "Compilation target, alias for 'platform'" , host_platform , ["" , "windows" , "x11" , "linux" , "osx" ])
35+ EnumVariable (
36+ "platform" ,
37+ "Compilation platform" ,
38+ host_platform ,
39+ # We'll need to support these in due times
40+ # allowed_values=("linux", "freebsd", "osx", "windows", "android", "ios", "javascript"),
41+ allowed_values = ("linux" , "windows" ),
42+ ignorecase = 2 ,
43+ )
2544)
2645opts .Add (EnumVariable ("bits" , "Target platform bits" , "64" , ("32" , "64" )))
2746opts .Add (BoolVariable ("use_llvm" , "Use the LLVM / Clang compiler" , "no" ))
28- opts .Add (PathVariable ("target_path" , "The path where the lib is installed." , "demo/bin/" , PathVariable .PathAccept ))
29- opts .Add (PathVariable ("target_name" , "The library name." , "libgdexample" , PathVariable .PathAccept ))
30-
31- # Local dependency paths, adapt them to your setup
32- godot_headers_path = "../godot-headers/"
33- cpp_bindings_path = "../"
34- cpp_library = "libgodot-cpp"
47+ opts .Add (PathVariable ("target_path" , "The path where the lib is installed." , default_target_path , PathVariable .PathAccept ))
48+ opts .Add (PathVariable ("target_name" , "The library name." , default_library_name , PathVariable .PathAccept ))
3549
3650# only support 64 at this time..
3751bits = 64
@@ -57,9 +71,6 @@ if env["use_llvm"]:
5771 env ["CC" ] = "clang"
5872 env ["CXX" ] = "clang++"
5973
60- if env ["p" ] != "" :
61- env ["platform" ] = env ["p" ]
62-
6374if env ["platform" ] == "" :
6475 print ("No valid target platform selected." )
6576 quit ()
@@ -82,23 +93,21 @@ if env["platform"] == "osx":
8293 env .Append (CCFLAGS = ["-arch" , "x86_64" ])
8394 env .Append (CXXFLAGS = ["-std=c++17" ])
8495 env .Append (LINKFLAGS = ["-arch" , "x86_64" ])
85- if env ["target" ] in ( "debug" , "d" ) :
96+ if env ["target" ] == "debug" :
8697 env .Append (CCFLAGS = ["-g" , "-O2" ])
8798 else :
8899 env .Append (CCFLAGS = ["-g" , "-O3" ])
89100
90101elif env ["platform" ] in ("x11" , "linux" ):
91- env ["target_path" ] += "x11/"
92102 cpp_library += ".linux"
93103 env .Append (CCFLAGS = ["-fPIC" ])
94104 env .Append (CXXFLAGS = ["-std=c++17" ])
95- if env ["target" ] in ( "debug" , "d" ) :
105+ if env ["target" ] == "debug" :
96106 env .Append (CCFLAGS = ["-g3" , "-Og" ])
97107 else :
98108 env .Append (CCFLAGS = ["-g" , "-O3" ])
99109
100110elif env ["platform" ] == "windows" :
101- env ["target_path" ] += "win64/"
102111 cpp_library += ".windows"
103112 # This makes sure to keep the session environment variables on windows,
104113 # that way you can run scons in a vs 2017 prompt and it will find all the required tools
@@ -107,7 +116,7 @@ elif env["platform"] == "windows":
107116 env .Append (CPPDEFINES = ["WIN32" , "_WIN32" , "_WINDOWS" , "_CRT_SECURE_NO_WARNINGS" ])
108117 env .Append (CCFLAGS = ["-W3" , "-GR" ])
109118 env .Append (CXXFLAGS = ["-std:c++17" ])
110- if env ["target" ] in ( "debug" , "d" ) :
119+ if env ["target" ] == "debug" :
111120 env .Append (CPPDEFINES = ["_DEBUG" ])
112121 env .Append (CCFLAGS = ["-EHsc" , "-MDd" , "-ZI" , "-FS" ])
113122 env .Append (LINKFLAGS = ["-DEBUG" ])
@@ -118,12 +127,11 @@ elif env["platform"] == "windows":
118127 if not (env ["use_llvm" ]):
119128 env .Append (CPPDEFINES = ["TYPED_METHOD_BIND" ])
120129
121- if env ["target" ] in ("debug" , "d" ):
122- cpp_library += ".debug"
123- else :
124- cpp_library += ".release"
130+ # determine our architecture suffix
131+ arch_suffix = str (bits )
125132
126- cpp_library += "." + str (bits )
133+ # suffix our godot-cpp library
134+ cpp_library += "." + env ["target" ] + "." + arch_suffix
127135
128136# make sure our binding library is properly includes
129137env .Append (CPPPATH = ["." , godot_headers_path , cpp_bindings_path + "include/" , cpp_bindings_path + "gen/include/" ])
@@ -134,6 +142,8 @@ env.Append(LIBS=[cpp_library])
134142env .Append (CPPPATH = ["src/" ])
135143sources = Glob ("src/*.cpp" )
136144
137- library = env .SharedLibrary (target = env ["target_path" ] + env ["target_name" ], source = sources )
145+ target_name = "{}.{}.{}.{}" .format (env ["target_name" ], env ["platform" ], env ["target" ], arch_suffix )
146+ print (target_name )
147+ library = env .SharedLibrary (target = env ["target_path" ] + target_name , source = sources )
138148
139149Default (library )
0 commit comments