Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcpkg manifest mode #1099

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ out/
.vscode/
*.orig
eressea.ini
CMakeUserPresets.json
Debug
Release

Expand Down
13 changes: 13 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
50 changes: 50 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 <where the orders and data files are>

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",
"-i",
"${workspaceRoot}",
"-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": []
}
]
}
73 changes: 73 additions & 0 deletions custom-overlay/tolua/portfile.cmake
Original file line number Diff line number Diff line change
@@ -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 = <C:\path\to\current\vcpkg>
# 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)
4 changes: 4 additions & 0 deletions custom-overlay/tolua/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tolus provides CMake targets:

find_package(tolus CONFIG REQUIRED)
target_link_libraries(main PRIVATE tolus::tolus)
13 changes: 13 additions & 0 deletions custom-overlay/tolua/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
33 changes: 20 additions & 13 deletions src/bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
11 changes: 11 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"dependencies": [
"cjson",
"expat",
"iniparser",
"pdcurses",
"sqlite3",
"tolua",
"utf8proc"
]
}
Loading