From 901d8c94303d2d6e5d63ff915e1eb7c8b5c9c44b Mon Sep 17 00:00:00 2001 From: Erik Ogenvik Date: Mon, 30 Oct 2023 16:55:03 +0100 Subject: [PATCH] Added dependency on Worlds through Conan. We also allow for developers to specify a specific installation path using WORLDFORGE_WORLDS_PATH cmake variable. --- CMakeLists.txt | 16 +++++++++++++++- README.md | 7 +++---- conanfile.py | 7 ++++++- tools/cyphesis.vconf.in | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ca21e06e..f82d034f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,6 +92,20 @@ if (BT_USE_DOUBLE_PRECISION) add_definitions(-DBT_USE_DOUBLE_PRECISION=1) endif () +#You can specify an exernal installation of the Worlds though WORLDFORGE_WORLDS_PATH environment variable. If that's not specified, +#Worlds data will be installed as specified by the WORLDFORGE_WORLDS_SOURCE_PATH environment variable (which is set by Conan). +if (WORLDFORGE_WORLDS_PATH) + message(STATUS "An installation of the Worldforge Worlds has been specified through the WORLDFORGE_WORLDS_PATH environment variable: ${WORLDFORGE_WORLDS_PATH}.") +else () + set(WORLDFORGE_WORLDS_PATH "${CMAKE_INSTALL_PREFIX}/share/cyphesis/worlds") + + if (WORLDFORGE_WORLDS_SOURCE_PATH) + install(DIRECTORY ${WORLDFORGE_WORLDS_SOURCE_PATH}/ DESTINATION ${WORLDFORGE_WORLDS_PATH}) + message(STATUS "Added installation of the Worldforge Worlds from '${WORLDFORGE_WORLDS_SOURCE_PATH}' to the 'install' target.") + else () + message(STATUS "No Worldforge Worlds installation has been specified (through the WORLDFORGE_WORLDS_SOURCE_PATH environment variable); we will work on the assumption that there's an installation already at '${WORLDFORGE_WORLDS_PATH}'.") + endif () +endif () #add_custom_target(assets-download) #if (RSYNC_CMD) @@ -151,7 +165,7 @@ macro(wf_generate_stubs DIRECTORY) COMMAND ${CMAKE_COMMAND} -E echo "Generating stubs for ${FILE}\n" COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/scripts/generator/generate_stub.py ${FILE} ${STUB_DIRECTORY} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/src - ) + ) list(APPEND STUB_HEADERS ${STUB_FILE}) endforeach (FILE) diff --git a/README.md b/README.md index b8ed787e9..77b31c838 100644 --- a/README.md +++ b/README.md @@ -25,10 +25,9 @@ The simplest way to install all required dependencies is by using [Conan](https: ```bash conan remote add worldforge https://artifactory.ogenvik.org/artifactory/api/conan/conan -mkdir cmake-build && cd cmake-build -conan install .. --output-folder=. --build=missing -cmake --preset conan-release .. -DCMAKE_INSTALL_PREFIX=../cmake-install -make -j all mediarepo-checkout install +conan install . --build missing +cmake --preset conan-release -DCMAKE_INSTALL_PREFIX=./build/install/release +cmake --build --preset conan-release -j --target all --target mediarepo-checkout --target install ``` Alternatively you can use the [Hammer](http://wiki.worldforge.org/wiki/Hammer_Script "The Hammer script") tool. diff --git a/conanfile.py b/conanfile.py index a4ec2f1db..77caf6f89 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,3 +1,5 @@ +import os + from conan import ConanFile from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain @@ -19,6 +21,7 @@ def requirements(self): self.requires("wfmath/1.0.3@worldforge") self.requires("libxdg-basedir/1.2.3@worldforge") self.requires("squall/0.1.0@worldforge") + self.requires("worldforge-worlds/0.1.0@worldforge") self.requires("libsigcpp/3.0.7") self.requires("libgcrypt/1.8.4") self.requires("zlib/1.2.13") @@ -36,7 +39,9 @@ def generate(self): tc = CMakeToolchain(self) tc.variables["PYTHON_IS_STATIC"] = "TRUE" # The default CMake FindPython3 component will set the Python3_EXECUTABLE, which is then used in Cyphesis. Therefore do this here. - tc.variables["Python3_EXECUTABLE"] = self.dependencies["cpython"].package_folder + "/bin/python" + tc.variables["Python3_EXECUTABLE"] = os.path.join(self.dependencies["cpython"].package_folder, "bin/python") + tc.variables["WORLDFORGE_WORLDS_SOURCE_PATH"] = os.path.join( + self.dependencies["worldforge-worlds"].package_folder, "worlds") tc.preprocessor_definitions["PYTHONHOME"] = "\"{}\"".format(self.dependencies["cpython"].package_folder) tc.generate() diff --git a/tools/cyphesis.vconf.in b/tools/cyphesis.vconf.in index 76c59c053..ba9c1b891 100644 --- a/tools/cyphesis.vconf.in +++ b/tools/cyphesis.vconf.in @@ -82,4 +82,4 @@ assetsdir="@CMAKE_INSTALL_PREFIX@/share/cyphesis/assets" # Automatically import this world if the server is unpopulated. # The default value relies on the content of the "Worldforge World" project # being installed. -autoimport="@CMAKE_INSTALL_PREFIX@/share/worldforge/worlds/deeds/braga/world.xml" +autoimport="@WORLDFORGE_WORLDS_PATH@/deeds/braga/world.xml"