From ee538ca30d9403e94bc320fde938eab26b9ce1df Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Thu, 30 May 2024 11:41:49 -0600 Subject: [PATCH] linux: clone and build TGUI submodule if necessary --- README.md | 3 ++- SConstruct | 31 ++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6d4f34e0..fa2ebf03 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,8 @@ The following dependencies are required: - ZLib - This is included with the system on the Mac. For Linux builds, the following additional dependencies are required: -- [TGUI](https://tgui.eu/) - version 0.9 or later required +- [TGUI](https://tgui.eu/) - version 0.9, **built with C++14** as shown [here](./.github/workflows/scripts/linux/install-tgui.sh) + - or, if cmake is available when you call `scons`, TGUI will be built from source automatically - zenity command-line tools If you are using the Visual Studio toolset, we recommend installing diff --git a/SConstruct b/SConstruct index 5efb5c9d..82df67d1 100644 --- a/SConstruct +++ b/SConstruct @@ -221,12 +221,15 @@ if platform == 'darwin': # Sometimes it's easier just to copy the dependencies into the repo dir # We try to auto-detect this. if path.exists('deps/lib'): - env.Append(LIBPATH=['deps/lib']) + env.Append(LIBPATH=[os.getcwd() + '/deps/lib']) if platform == 'darwin': - env.Append(FRAMEWORKPATH=['deps/lib']) + env.Append(FRAMEWORKPATH=[os.getcwd() + '/deps/lib']) + +if path.exists('deps/lib64'): + env.Append(LIBPATH=[os.getcwd() + '/deps/lib64']) if path.exists('deps/include'): - env.Append(CPPPATH=['deps/include']) + env.Append(CPPPATH=[os.getcwd() + '/deps/include']) # Include directories @@ -299,6 +302,28 @@ if not env.GetOption('clean'): check_lib('sfml-audio', 'SFML-audio') check_lib('sfml-graphics', 'SFML-graphics') + # On Linux, build TGUI from the subtree if necessary + if platform == 'posix': + def check_tgui(conf, second_attempt=False): + if conf.CheckLib('libtgui', language='C++'): + return conf + else: + if second_attempt: + print('TGUI is missing, even after trying to build it!') + Exit(1) + else: + subprocess.call(["git", "submodule", "update", "--init", "deps/TGUI"]) + subprocess.call(["cmake", "-D", "TGUI_CXX_STANDARD=14", "-D", "CMAKE_INSTALL_PREFIX=../", "."], cwd="deps/TGUI") + subprocess.call(["make"], cwd="deps/TGUI") + subprocess.call(["make", "install"], cwd="deps/TGUI") + + env = conf.Finish() + env.Append(CPPPATH=[os.getcwd() + '/deps/include'], LIBPATH=[os.getcwd() + '/deps/lib', os.getcwd() + '/deps/lib64']) + conf = Configure(env) + return check_tgui(conf, True) + conf = check_tgui(conf) + + env = conf.Finish() env.Append(CPPDEFINES=["TIXML_USE_TICPP"])