Skip to content

Commit

Permalink
Add GODOT_CPP_PATH and use pkg-config for dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowApex committed Aug 8, 2024
1 parent 10d0fd3 commit 2570a15
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env python
from SCons import __version__ as scons_raw_version
import os
import sys

ext_name = "xlib"

env = SConscript("godot-cpp/SConstruct")
# Load the environment from godot-cpp
godot_cpp_path = "godot-cpp"
if 'GODOT_CPP_PATH' in os.environ:
godot_cpp_path = os.environ['GODOT_CPP_PATH']
env = SConscript(godot_cpp_path + "/SConstruct")

# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
Expand All @@ -19,11 +24,13 @@ env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")

# Include dependency libraries for the extension
env.Append(LIBS=["X11", "XRes", "Xtst"])

if 'PKG_CONFIG_PATH' in os.environ:
env['ENV']['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
env.ParseConfig("pkg-config x11 --cflags --libs")
env.ParseConfig("pkg-config xres --cflags --libs")
env.ParseConfig("pkg-config xtst --cflags --libs")

# Generating the compilation DB (`compile_commands.json`) requires SCons 4.0.0 or later.
from SCons import __version__ as scons_raw_version

scons_ver = env._get_major_minor_revision(scons_raw_version)
if scons_ver < (4, 0, 0):
Expand All @@ -39,7 +46,8 @@ env.Alias("compiledb", env.CompilationDatabase())

# Build the shared library
library = env.SharedLibrary(
"addons/{}/bin/lib{}{}{}".format(ext_name, ext_name, env["suffix"], env["SHLIBSUFFIX"]),
"addons/{}/bin/lib{}{}{}".format(ext_name,
ext_name, env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)

Expand Down

0 comments on commit 2570a15

Please sign in to comment.