use DLU_CONFIG_DIR envvar

This commit is contained in:
jadebenn 2024-11-16 21:03:37 -06:00
parent d1bfe9f15d
commit d7aa52a0fc
2 changed files with 57 additions and 49 deletions

View File

@ -113,31 +113,39 @@ make_directory(${CMAKE_BINARY_DIR}/resServer)
# Create a /logs directory # Create a /logs directory
make_directory(${CMAKE_BINARY_DIR}/logs) make_directory(${CMAKE_BINARY_DIR}/logs)
# Get DLU config directory
if(DEFINED ENV{DLU_CONFIG_DIR})
set(DLU_CONFIG_DIR $ENV{DLU_CONFIG_DIR})
else()
set(DLU_CONFIG_DIR ${PROJECT_BINARY_DIR})
endif()
message(STATUS "Variable: DLU_CONFIG_DIR = ${DLU_CONFIG_DIR}")
# Copy resource files on first build # Copy resource files on first build
set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf") set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blocklist.dcf")
message(STATUS "Checking resource file integrity") message(STATUS "Checking resource file integrity")
include(Utils) include(Utils)
UpdateConfigOption(${PROJECT_BINARY_DIR}/authconfig.ini "port" "auth_server_port") UpdateConfigOption(${DLU_CONFIG_DIR}/authconfig.ini "port" "auth_server_port")
UpdateConfigOption(${PROJECT_BINARY_DIR}/chatconfig.ini "port" "chat_server_port") UpdateConfigOption(${DLU_CONFIG_DIR}/chatconfig.ini "port" "chat_server_port")
UpdateConfigOption(${PROJECT_BINARY_DIR}/masterconfig.ini "port" "master_server_port") UpdateConfigOption(${DLU_CONFIG_DIR}/masterconfig.ini "port" "master_server_port")
foreach(resource_file ${RESOURCE_FILES}) foreach(resource_file ${RESOURCE_FILES})
set(file_size 0) set(file_size 0)
if(EXISTS ${PROJECT_BINARY_DIR}/${resource_file}) if(EXISTS ${DLU_CONFIG_DIR}/${resource_file})
file(SIZE ${PROJECT_BINARY_DIR}/${resource_file} file_size) file(SIZE ${DLU_CONFIG_DIR}/${resource_file} file_size)
endif() endif()
if(${file_size} EQUAL 0) if(${file_size} EQUAL 0)
configure_file( configure_file(
${CMAKE_SOURCE_DIR}/resources/${resource_file} ${PROJECT_BINARY_DIR}/${resource_file} ${CMAKE_SOURCE_DIR}/resources/${resource_file} ${DLU_CONFIG_DIR}/${resource_file}
COPYONLY COPYONLY
) )
message(STATUS "Moved " ${resource_file} " to project binary directory") message(STATUS "Moved " ${resource_file} " to DLU config directory")
elseif(resource_file MATCHES ".ini") elseif(resource_file MATCHES ".ini")
message(STATUS "Checking " ${resource_file} " for missing config options") message(STATUS "Checking " ${resource_file} " for missing config options")
file(READ ${PROJECT_BINARY_DIR}/${resource_file} current_file_contents) file(READ ${DLU_CONFIG_DIR}/${resource_file} current_file_contents)
string(REPLACE "\\\n" "" current_file_contents ${current_file_contents}) string(REPLACE "\\\n" "" current_file_contents ${current_file_contents})
string(REPLACE "\n" ";" current_file_contents ${current_file_contents}) string(REPLACE "\n" ";" current_file_contents ${current_file_contents})
set(parsed_current_file_contents "") set(parsed_current_file_contents "")
@ -168,10 +176,10 @@ foreach(resource_file ${RESOURCE_FILES})
set(line_to_add ${line_to_add} ${line}) set(line_to_add ${line_to_add} ${line})
foreach(line_to_append ${line_to_add}) foreach(line_to_append ${line_to_add})
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n" ${line_to_append}) file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n" ${line_to_append})
endforeach() endforeach()
file(APPEND ${PROJECT_BINARY_DIR}/${resource_file} "\n") file(APPEND ${DLU_CONFIG_DIR}/${resource_file} "\n")
endif() endif()
set(line_to_add "") set(line_to_add "")

View File

@ -11,6 +11,9 @@
"displayName": "Default configure step", "displayName": "Default configure step",
"description": "Use 'build' dir and Unix makefiles", "description": "Use 'build' dir and Unix makefiles",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"environment": {
"DLU_CONFIG_DIR": "${sourceDir}/build"
},
"generator": "Unix Makefiles" "generator": "Unix Makefiles"
}, },
{ {
@ -82,9 +85,6 @@
"type": "equals", "type": "equals",
"lhs": "${hostSystemName}", "lhs": "${hostSystemName}",
"rhs": "Linux" "rhs": "Linux"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS_INIT": "-Werror"
} }
}, },
{ {
@ -94,7 +94,7 @@
"clang-config", "clang-config",
"debug-config" "debug-config"
], ],
"displayName": "[Debug] Linux (Clang)", "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
"description": "Create a debug build using the Clang toolchain for Linux", "description": "Create a debug build using the Clang toolchain for Linux",
"binaryDir": "${sourceDir}/build/clang-debug" "binaryDir": "${sourceDir}/build/clang-debug"
}, },
@ -105,7 +105,7 @@
"clang-config", "clang-config",
"relwithdebinfo-config" "relwithdebinfo-config"
], ],
"displayName": "[RelWithDebInfo] Linux (Clang)", "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
"description": "Create a release build with debug info using the Clang toolchain for Linux", "description": "Create a release build with debug info using the Clang toolchain for Linux",
"binaryDir": "${sourceDir}/build/clang-relwithdebinfo" "binaryDir": "${sourceDir}/build/clang-relwithdebinfo"
}, },
@ -116,7 +116,7 @@
"clang-config", "clang-config",
"release-config" "release-config"
], ],
"displayName": "[Release] Linux (Clang)", "displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
"description": "Create a release build using the Clang toolchain for Linux", "description": "Create a release build using the Clang toolchain for Linux",
"binaryDir": "${sourceDir}/build/clang-release" "binaryDir": "${sourceDir}/build/clang-release"
}, },
@ -176,99 +176,99 @@
}, },
{ {
"name": "windows-msvc-debug", "name": "windows-msvc-debug",
"inherits": "default",
"configurePreset": "windows-msvc", "configurePreset": "windows-msvc",
"displayName": "[Debug] Windows (MSVC)", "displayName": "[Debug] Windows (MSVC)",
"description": "This preset is used to build in debug mode using the MSVC toolchain on Windows", "description": "This preset is used to build in debug mode using the MSVC toolchain on Windows",
"configuration": "Debug", "configuration": "Debug"
"jobs": 2
}, },
{ {
"name": "windows-msvc-relwithdebinfo", "name": "windows-msvc-relwithdebinfo",
"inherits": "default",
"configurePreset": "windows-msvc", "configurePreset": "windows-msvc",
"displayName": "[RelWithDebInfo] Windows (MSVC)", "displayName": "[RelWithDebInfo] Windows (MSVC)",
"description": "This preset is used to build in debug mode using the MSVC toolchain on Windows", "description": "This preset is used to build in debug mode using the MSVC toolchain on Windows",
"configuration": "RelWithDebInfo", "configuration": "RelWithDebInfo"
"jobs": 2
}, },
{ {
"name": "windows-msvc-release", "name": "windows-msvc-release",
"inherits": "default",
"configurePreset": "windows-msvc", "configurePreset": "windows-msvc",
"displayName": "[Release] Windows (MSVC)", "displayName": "[Release] Windows (MSVC)",
"description": "This preset is used to build in release mode using the MSVC toolchain on Windows", "description": "This preset is used to build in release mode using the MSVC toolchain on Windows",
"configuration": "Release", "configuration": "Release"
"jobs": 2
}, },
{ {
"name": "linux-clang-debug", "name": "linux-clang-debug",
"inherits": "default",
"configurePreset": "linux-clang-debug", "configurePreset": "linux-clang-debug",
"displayName": "[Debug] Linux (Clang)", "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
"description": "This preset is used to build in debug mode using the Clang toolchain on Linux", "description": "This preset is used to build in debug mode using the Clang toolchain on Linux",
"configuration": "Debug", "configuration": "Debug"
"jobs": 2
}, },
{ {
"name": "linux-clang-relwithdebinfo", "name": "linux-clang-relwithdebinfo",
"inherits": "default",
"configurePreset": "linux-clang-relwithdebinfo", "configurePreset": "linux-clang-relwithdebinfo",
"displayName": "[RelWithDebInfo] Linux (Clang)", "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
"description": "This preset is used to build in release mode with debug info using the Clang toolchain on Linux", "description": "This preset is used to build in release mode with debug info using the Clang toolchain on Linux",
"configuration": "RelWithDebInfo", "configuration": "RelWithDebInfo"
"jobs": 2
}, },
{ {
"name": "linux-clang-release", "name": "linux-clang-release",
"inherits": "default",
"configurePreset": "linux-clang-release", "configurePreset": "linux-clang-release",
"displayName": "[Release] Linux (Clang)", "displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
"description": "This preset is used to build in release mode using the Clang toolchain on Linux", "description": "This preset is used to build in release mode using the Clang toolchain on Linux",
"configuration": "Release", "configuration": "Release"
"jobs": 2
}, },
{ {
"name": "linux-gnu-debug", "name": "linux-gnu-debug",
"inherits": "default",
"configurePreset": "linux-gnu-debug", "configurePreset": "linux-gnu-debug",
"displayName": "[Debug] Linux (GNU)", "displayName": "[Debug] Linux (GNU)",
"description": "This preset is used to build in debug mode using the GNU toolchain on Linux", "description": "This preset is used to build in debug mode using the GNU toolchain on Linux",
"configuration": "Debug", "configuration": "Debug"
"jobs": 2
}, },
{ {
"name": "linux-gnu-relwithdebinfo", "name": "linux-gnu-relwithdebinfo",
"inherits": "default",
"configurePreset": "linux-gnu-relwithdebinfo", "configurePreset": "linux-gnu-relwithdebinfo",
"displayName": "[RelWithDebInfo] Linux (GNU)", "displayName": "[RelWithDebInfo] Linux (GNU)",
"description": "This preset is used to build in release mode with debug info using the GNU toolchain on Linux", "description": "This preset is used to build in release mode with debug info using the GNU toolchain on Linux",
"configuration": "RelWithDebInfo", "configuration": "RelWithDebInfo"
"jobs": 2
}, },
{ {
"name": "linux-gnu-release", "name": "linux-gnu-release",
"inherits": "default",
"configurePreset": "linux-gnu-release", "configurePreset": "linux-gnu-release",
"displayName": "[Release] Linux (GNU)", "displayName": "[Release] Linux (GNU)",
"description": "This preset is used to build in release mode using the GNU toolchain on Linux", "description": "This preset is used to build in release mode using the GNU toolchain on Linux",
"configuration": "Release", "configuration": "Release"
"jobs": 2
}, },
{ {
"name": "macos-debug", "name": "macos-debug",
"inherits": "default",
"configurePreset": "macos", "configurePreset": "macos",
"displayName": "[Debug] MacOS", "displayName": "[Debug] MacOS",
"description": "This preset is used to build in debug mode on MacOS", "description": "This preset is used to build in debug mode on MacOS",
"configuration": "Debug", "configuration": "Debug"
"jobs": 2
}, },
{ {
"name": "macos-relwithdebinfo", "name": "macos-relwithdebinfo",
"inherits": "default",
"configurePreset": "macos", "configurePreset": "macos",
"displayName": "[RelWithDebInfo] MacOS", "displayName": "[RelWithDebInfo] MacOS",
"description": "This preset is used to build in release mode with debug info on MacOS", "description": "This preset is used to build in release mode with debug info on MacOS",
"configuration": "RelWithDebInfo", "configuration": "RelWithDebInfo"
"jobs": 2
}, },
{ {
"name": "macos-release", "name": "macos-release",
"inherits": "default",
"configurePreset": "macos", "configurePreset": "macos",
"displayName": "[Release] MacOS", "displayName": "[Release] MacOS",
"description": "This preset is used to build in release mode on MacOS", "description": "This preset is used to build in release mode on MacOS",
"configuration": "Release", "configuration": "Release"
"jobs": 2
} }
], ],
"testPresets": [ "testPresets": [
@ -321,7 +321,7 @@
"name": "linux-clang-debug", "name": "linux-clang-debug",
"inherits": "default", "inherits": "default",
"configurePreset": "linux-clang-debug", "configurePreset": "linux-clang-debug",
"displayName": "[Debug] Linux (Clang)", "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
"description": "Runs all tests on a Linux Clang configuration", "description": "Runs all tests on a Linux Clang configuration",
"configuration": "Release" "configuration": "Release"
}, },
@ -329,7 +329,7 @@
"name": "linux-clang-relwithdebinfo", "name": "linux-clang-relwithdebinfo",
"inherits": "default", "inherits": "default",
"configurePreset": "linux-clang-relwithdebinfo", "configurePreset": "linux-clang-relwithdebinfo",
"displayName": "[RelWithDebInfo] Linux (Clang)", "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
"description": "Runs all tests on a Linux Clang configuration", "description": "Runs all tests on a Linux Clang configuration",
"configuration": "RelWithDebInfo" "configuration": "RelWithDebInfo"
}, },
@ -337,7 +337,7 @@
"name": "linux-clang-release", "name": "linux-clang-release",
"inherits": "default", "inherits": "default",
"configurePreset": "linux-clang-release", "configurePreset": "linux-clang-release",
"displayName": "[Release] Linux (Clang)", "displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
"description": "Runs all tests on a Linux Clang configuration", "description": "Runs all tests on a Linux Clang configuration",
"configuration": "Release" "configuration": "Release"
}, },
@ -524,7 +524,7 @@
}, },
{ {
"name": "linux-clang-debug", "name": "linux-clang-debug",
"displayName": "[Debug] Linux (Clang)", "displayName": "EXPERIMENTAL - [Debug] Linux (Clang)",
"description": "Clang debug workflow preset for Linux", "description": "Clang debug workflow preset for Linux",
"steps": [ "steps": [
{ {
@ -543,7 +543,7 @@
}, },
{ {
"name": "linux-clang-relwithdebinfo", "name": "linux-clang-relwithdebinfo",
"displayName": "[RelWithDebInfo] Linux (Clang)", "displayName": "EXPERIMENTAL - [RelWithDebInfo] Linux (Clang)",
"description": "Clang release with debug info workflow preset for Linux", "description": "Clang release with debug info workflow preset for Linux",
"steps": [ "steps": [
{ {
@ -562,7 +562,7 @@
}, },
{ {
"name": "linux-clang-release", "name": "linux-clang-release",
"displayName": "[Release] Linux (Clang)", "displayName": "EXPERIMENTAL - [Release] Linux (Clang)",
"description": "Clang release workflow preset for Linux", "description": "Clang release workflow preset for Linux",
"steps": [ "steps": [
{ {