From e5828c425a7ac2051edac05ed28b0287190df164 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 4 Dec 2024 20:53:11 +0100 Subject: [PATCH 1/3] vcpkg manifest tolua custom overlay --- .gitignore | 1 + CMakePresets.json | 13 +++++ INSTALL.md | 48 +++++++++++++++++++ custom-overlay/tolua/portfile.cmake | 73 +++++++++++++++++++++++++++++ custom-overlay/tolua/usage | 4 ++ custom-overlay/tolua/vcpkg.json | 13 +++++ vcpkg-configuration.json | 17 +++++++ vcpkg.json | 11 +++++ 8 files changed, 180 insertions(+) create mode 100644 CMakePresets.json create mode 100644 INSTALL.md create mode 100644 custom-overlay/tolua/portfile.cmake create mode 100644 custom-overlay/tolua/usage create mode 100644 custom-overlay/tolua/vcpkg.json create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json diff --git a/.gitignore b/.gitignore index e5cf00375..8ca35c107 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ out/ .vscode/ *.orig eressea.ini +CMakeUserPresets.json Debug Release diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..843d8b0b4 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "vcpkg", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + } + ] +} \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 000000000..6a3b45141 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,48 @@ +install lua from https://sourceforge.net/projects/luabinaries/ to c:\Program Files\Lua +install luarocks from http://luarocks.github.io/luarocks/releases/ to c:\Program Files\Lua +run luarocks install lunitx + +set environment variables: +LUA_PATH C:\Users\Enno\AppData\Roaming\Luarocks\share\lua\5.4\?.lua +ERESSEA_ROOT _ + +Visual Studio: +- File -> Open -> CMake ... + Open the CMakeLists.txt at the repositoy's base directory +- Project -> Delete Cache and Reconfigure +- Debug -> Debug and Launch settings ... + opens launch.vs.json + +{ + "version": "0.2.1", + "defaults": {}, + "configurations": [ + { + "type": "default", + "project": "CMakeLists.txt", + "projectTarget": "eressea.exe", + "args": [ + "-w0", + "-v1", + "-ce2", + "-re2", + "-D", + "-t", + "1349", + "${workspaceRoot}\\scripts\\run-turn.lua" + ], + "currentDir": "${env.ERESSEA_ROOT}", + "env": { + "LUA_PATH": "${workspaceRoot}\\scripts\\?.lua;${workspaceRoot}\\scripts\\?\\init.lua;${env.LUA_PATH}" + }, + "name": "eressea.exe" + }, + { + "type": "default", + "project": "CMakeLists.txt", + "projectTarget": "test_eressea.exe", + "name": "test_eressea.exe", + "args": [] + } + ] +} diff --git a/custom-overlay/tolua/portfile.cmake b/custom-overlay/tolua/portfile.cmake new file mode 100644 index 000000000..55d1f561e --- /dev/null +++ b/custom-overlay/tolua/portfile.cmake @@ -0,0 +1,73 @@ +# Common Ambient Variables: +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# CURRENT_PORT_DIR = ${VCPKG_ROOT_DIR}\ports\${PORT} +# CURRENT_INSTALLED_DIR = ${VCPKG_ROOT_DIR}\installed\${TRIPLET} +# DOWNLOADS = ${VCPKG_ROOT_DIR}\downloads +# PORT = current port name (zlib, etc) +# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc) +# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic) +# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic) +# VCPKG_ROOT_DIR = +# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm) +# VCPKG_TOOLCHAIN = ON OFF +# TRIPLET_SYSTEM_ARCH = arm x86 x64 +# BUILD_ARCH = "Win32" "x64" "ARM" +# MSBUILD_PLATFORM = "Win32"/"x64"/${TRIPLET_SYSTEM_ARCH} +# DEBUG_CONFIG = "Debug Static" "Debug Dll" +# RELEASE_CONFIG = "Release Static"" "Release DLL" +# VCPKG_TARGET_IS_WINDOWS +# VCPKG_TARGET_IS_UWP +# VCPKG_TARGET_IS_LINUX +# VCPKG_TARGET_IS_OSX +# VCPKG_TARGET_IS_FREEBSD +# VCPKG_TARGET_IS_ANDROID +# VCPKG_TARGET_IS_MINGW +# VCPKG_TARGET_EXECUTABLE_SUFFIX +# VCPKG_TARGET_STATIC_LIBRARY_SUFFIX +# VCPKG_TARGET_SHARED_LIBRARY_SUFFIX +# +# See additional helpful variables in /docs/maintainers/vcpkg_common_definitions.md + +# # Specifies if the port install should fail immediately given a condition +# vcpkg_fail_port_install(MESSAGE "tolua currently only supports Linux and Mac platforms" ON_TARGET "Windows") + +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO ennorehling/tolua + REF 097c40f49d0391851d800ce2be747eaf45af99b9 + SHA512 9ae24deee8e10c993a21c209e70795ee9216d7d629a69456924825e8fefd74d9bc1e08d75e8ff51f29e03d4c160d638385cd431cb76df32276f79fdea2234e28 + HEAD_REF master +) + +# # Check if one or more features are a part of a package installation. +# # See /docs/maintainers/vcpkg_check_features.md for more details +# vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS +# FEATURES # <- Keyword FEATURES is required because INVERTED_FEATURES are being used +# tbb WITH_TBB +# INVERTED_FEATURES +# tbb ROCKSDB_IGNORE_PACKAGE_TBB +# ) + +vcpkg_cmake_configure( + SOURCE_PATH ${SOURCE_PATH} + DISABLE_PARALLEL_CONFIGURE +) +vcpkg_cmake_install( + ADD_BIN_TO_PATH +) +vcpkg_copy_tools(TOOL_NAMES tolua AUTO_CLEAN) +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug/include" + "${CURRENT_PACKAGES_DIR}/debug/share" +) + +# # Moves all .cmake files from /debug/share/tolua/ to /share/tolua/ +# # See /docs/maintainers/vcpkg_fixup_cmake_targets.md for more details +# vcpkg_fixup_cmake_targets(CONFIG_PATH cmake TARGET_PATH share/tolua) + +# # Handle copyright + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/custom-overlay/tolua/usage b/custom-overlay/tolua/usage new file mode 100644 index 000000000..98f92e401 --- /dev/null +++ b/custom-overlay/tolua/usage @@ -0,0 +1,4 @@ +tolus provides CMake targets: + +find_package(tolus CONFIG REQUIRED) +target_link_libraries(main PRIVATE tolus::tolus) \ No newline at end of file diff --git a/custom-overlay/tolua/vcpkg.json b/custom-overlay/tolua/vcpkg.json new file mode 100644 index 000000000..44e1ddf51 --- /dev/null +++ b/custom-overlay/tolua/vcpkg.json @@ -0,0 +1,13 @@ +{ + "name": "tolua", + "version-string": "5.2.5", + "description": "tolua is a tool that greatly simplifies the integration of C/C++ code with Lua.", + "homepage": "http://webserver2.tecgraf.puc-rio.br/~celes/tolua/", + "dependencies": [ + "lua", + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 000000000..72ef8d2f1 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,17 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "3edabbe1407e2d4d8ce5b78bab8abf42cc966d10", + "repository": "https://github.com/microsoft/vcpkg" + }, + "overlay-ports": [ + "custom-overlay" + ], + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 000000000..72d4a5971 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,11 @@ +{ + "dependencies": [ + "cjson", + "expat", + "iniparser", + "pdcurses", + "sqlite3", + "tolua", + "utf8proc" + ] +} From 6206390d00162f1ea0630f65a48807d49b8c1f26 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 5 Dec 2024 19:49:06 +0100 Subject: [PATCH 2/3] set config.install default from command line argument we no longer need to set the installation directory in eressea.ini --- src/bindings.c | 33 ++++++++++++++++++++------------- src/main.c | 4 ++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 539bac6d9..299d57aaf 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -837,6 +837,26 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti int i; const char *arg; size_t len = strlen(section); + + /* defaults */ + arg = config_get("config.install"); + if (arg) { + lua_pushstring(L, "install"); + lua_pushstring(L, arg); + lua_rawset(L, -3); + } + lua_pushstring(L, "basepath"); + lua_pushstring(L, basepath()); + lua_rawset(L, -3); + lua_pushstring(L, "reportpath"); + lua_pushstring(L, reportpath()); + lua_rawset(L, -3); + arg = config_get("config.rules"); + if (arg) { + lua_pushstring(L, "rules"); + lua_pushstring(L, arg); + lua_rawset(L, -3); + } for (i = 0; d && i != d->n; ++i) { const char *key = d->key[i]; @@ -855,19 +875,6 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti } } - /* special case */ - lua_pushstring(L, "basepath"); - lua_pushstring(L, basepath()); - lua_rawset(L, -3); - lua_pushstring(L, "reportpath"); - lua_pushstring(L, reportpath()); - lua_rawset(L, -3); - arg = config_get("config.rules"); - if (arg) { - lua_pushstring(L, "rules"); - lua_pushstring(L, arg); - lua_rawset(L, -3); - } } static int lua_rng_default(lua_State *L) { diff --git a/src/main.c b/src/main.c index 766171bde..1d9bb79ae 100644 --- a/src/main.c +++ b/src/main.c @@ -199,6 +199,10 @@ static int parse_args(int argc, char **argv) case 'D': config_set("config.debug", "1"); break; + case 'i': + i = get_arg(argc, argv, 2, i, &arg, 0); + config_set("config.install", arg); + break; case 'c': i = get_arg(argc, argv, 2, i, &arg, 0); config_set("config.path", arg); From 9498d9c34ced1600ff02dc4909f49ea3e71c4c3c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 5 Dec 2024 20:04:02 +0100 Subject: [PATCH 3/3] update install guide --- INSTALL.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 6a3b45141..f6a052cf0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,7 +4,7 @@ run luarocks install lunitx set environment variables: LUA_PATH C:\Users\Enno\AppData\Roaming\Luarocks\share\lua\5.4\?.lua -ERESSEA_ROOT _ +ERESSEA_ROOT Visual Studio: - File -> Open -> CMake ... @@ -27,9 +27,11 @@ Visual Studio: "-ce2", "-re2", "-D", + "-i", + "${workspaceRoot}", "-t", "1349", - "${workspaceRoot}\\scripts\\run-turn.lua" + "${workspaceRoot}\\scripts\\run-turn.lua" ], "currentDir": "${env.ERESSEA_ROOT}", "env": {