22
33import os
44
5- EnsureSConsVersion (3 , 1 , 2 )
6- EnsurePythonVersion (3 , 6 )
5+ EnsureSConsVersion (3 , 0 , 0 )
6+ EnsurePythonVersion (3 , 5 )
77
88opts = Variables ([], ARGUMENTS )
99
10- env = Environment (ENV = os .environ )
11-
12- # Define our options
13- opts .Add (PathVariable ("target_path" ,
14- "The path where the lib is installed." , "addons/godot-git-plugin/" ))
15- opts .Add (PathVariable ("target_name" , "The library name." ,
16- "libgit_plugin" , PathVariable .PathAccept ))
10+ env = Environment ()
1711
1812# Updates the environment with the option variables.
1913opts .Update (env )
@@ -23,28 +17,36 @@ if ARGUMENTS.get("custom_api_file", "") != "":
2317
2418ARGUMENTS ["target" ] = "editor"
2519env = SConscript ("godot-cpp/SConstruct" ).Clone ()
26- env .PrependENVPath ("PATH" , os .getenv ("PATH" )) # Prepend PATH, done upstream in recent godot-cpp verions.
2720
28- # Force linking with LTO on windows MSVC, silence the linker complaining that libgit uses LTO but we are not linking with it.
21+ # Prepend PATH to allow using custom toolchains, done upstream in recent godot-cpp verions.
22+ env .PrependENVPath ("PATH" , os .getenv ("PATH" ))
23+
2924if env ["platform" ] == "windows" and env .get ("is_msvc" , False ):
25+ # Force linking with LTO on windows MSVC, silence the linker complaining that libgit uses LTO but we are not linking with it.
3026 env .AppendUnique (LINKFLAGS = ["/LTCG" ])
27+ # Do not treat empty pdb as errors.
28+ env .AppendUnique (LINKFLAGS = ["/IGNORE:4099" ])
3129
3230env .Tool ("cmake" , toolpath = ["tools" ])
3331env .Tool ("mbedtls" , toolpath = ["tools" ])
3432env .Tool ("ssh2" , toolpath = ["tools" ])
3533env .Tool ("git2" , toolpath = ["tools" ])
3634
37- opts .Update (env )
38-
3935mbedtls = env .BuildMbedTLS ()
4036ssh2 = env .BuildSSH2 (mbedtls )
4137mbedtls += ssh2
4238git2 = env .BuildGIT2 (mbedtls )
4339
44- Export ("mbedtls" )
45- Export ("env" )
40+ env .Append (CPPPATH = ["." , "src/" ])
41+ env .Append (CPPPATH = ["#thirdparty/git2/libgit2/include/" ])
42+
43+ lib_sources = Glob ("src/*.cpp" )
44+ env .Depends (lib_sources , mbedtls )
4645
47- SConscript ("godot-git-plugin/SCsub" )
46+ library = env .SharedLibrary (
47+ target = "bin/addons/godot-git-plugin/lib/libgit_plugin{}{}" .format (env ["suffix" ], env ["SHLIBSUFFIX" ]),
48+ source = lib_sources
49+ )
50+ extension = env .InstallAs ("bin/addons/godot-git-plugin/git_plugin.gdextension" , "misc/git_plugin.gdextension" )
4851
49- # Generates help for the -h scons option.
50- Help (opts .GenerateHelpText (env ))
52+ Default (library + extension )
0 commit comments