Add visual studio project generation to scons

This commit is contained in:
weil 2024-01-29 10:50:58 +01:00
parent aec78c782e
commit ad816f16dd
1 changed files with 27 additions and 7 deletions

View File

@ -1,24 +1,29 @@
#!/usr/bin/env python #!/usr/bin/env python
from glob import glob from glob import glob
from pathlib import Path from pathlib import Path
from SCons.Script import MSVSProject from SCons.Script import *
# Initialize environment and SCons script for godot-cpp
env = SConscript("godot-cpp/SConstruct") env = SConscript("godot-cpp/SConstruct")
env.Tool('msvs')
# Sources # Sources and include paths
env.Append(CPPPATH=["src/"]) env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp") sources = Glob("src/*.cpp")
sources += Glob("src/platform/win32/*.cpp")
# Opus (Windows x64) # Append additional library paths and libraries for Opus, Speex, and vpx
env.Append(CPPPATH=['#3rdparty/opus/include', '#3rdparty/speex/include']) env.Append(CPPPATH=['#3rdparty/opus/include', '#3rdparty/speex/include', '#3rdparty/libvpx/include'])
env.Append(LIBPATH=['#3rdparty/opus/lib', '#3rdparty/speex/lib']) env.Append(LIBPATH=['#3rdparty/opus/lib', '#3rdparty/speex/lib', '#3rdparty/libvpx/lib/x64'])
env.Append(LIBS=['opus', 'libspeex', 'libspeexdsp']) env.Append(LIBS=['opus', 'libspeex', 'libspeexdsp', 'vpx'])
# Determine extension and addon path
(extension_path,) = glob("export/addons/*/*.gdextension") (extension_path,) = glob("export/addons/*/*.gdextension")
addon_path = Path(extension_path).parent addon_path = Path(extension_path).parent
project_name = Path(extension_path).stem project_name = Path(extension_path).stem
debug_or_release = "release" if env["target"] == "template_release" else "debug" debug_or_release = "release" if env["target"] == "template_release" else "debug"
# Generate library based on platform
if env["platform"] == "macos": if env["platform"] == "macos":
library = env.SharedLibrary( library = env.SharedLibrary(
"{0}/lib/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format( "{0}/lib/lib{1}.{2}.{3}.framework/{1}.{2}.{3}".format(
@ -42,4 +47,19 @@ else:
source=sources, source=sources,
) )
Default(library) srcs = []
for s in sources:
srcs.append(s.abspath)
msvs_project = env.MSVSProject(
target = project_name + env['MSVSPROJECTSUFFIX'],
srcs = srcs,
include_dirs = env['CPPPATH'],
lib_dirs = env['LIBPATH'],
libs = env['LIBS'],
variant = 'Debug|x64',
)
# Make sure the default build includes the Visual Studio project
Default(library, msvs_project)