initial changes
This commit is contained in:
parent
7a3028c7fc
commit
474e3c43a7
127
.clang-format
Normal file
127
.clang-format
Normal file
@ -0,0 +1,127 @@
|
||||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 80
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||
Priority: 3
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
30
.clang-tidy
Normal file
30
.clang-tidy
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
Checks: [
|
||||
'-*',
|
||||
'clang-diagnostic-*',
|
||||
'clang-analyzer-*',
|
||||
'bugprone-*',
|
||||
'concurrency-*',
|
||||
'cppcoreguidelines-*',
|
||||
'modernize-*',
|
||||
'readability-*',
|
||||
'-readability-redundant-access-specifiers',
|
||||
'-readability-function-cognitive-complexity'
|
||||
]
|
||||
ExtraArgs: ['-Wno-unknown-warning-option']
|
||||
FormatStyle: none
|
||||
HeaderFileExtensions: ['', 'h','hh','hpp','hxx']
|
||||
HeaderFilterRegex: ''
|
||||
ImplementationFileExtensions: ['c','cc','cpp','cxx']
|
||||
CheckOptions:
|
||||
- key: MinimumExceptionNameLength
|
||||
value: 1
|
||||
- key: MinimumLoopCounterNameLength
|
||||
value: 3
|
||||
- key: MinimumParameterNameLength
|
||||
value: 3
|
||||
- key: MinimumVariableNameLength
|
||||
value: 3
|
||||
User: 'scott.e.graves@protonmail.com'
|
||||
WarningsAsErrors: ''
|
||||
...
|
5
.clangd
Normal file
5
.clangd
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"CompileFlags": {
|
||||
"Remove": ["-flarge-source-files", "-fext-numeric-literals"]
|
||||
}
|
||||
}
|
225
.cspell/words.txt
Normal file
225
.cspell/words.txt
Normal file
@ -0,0 +1,225 @@
|
||||
aarch64
|
||||
advapi32
|
||||
armv8
|
||||
autogen
|
||||
backwardcpp_project
|
||||
bcrypt
|
||||
binutils_version
|
||||
bitcoinsystem
|
||||
boost_asio_has_std_string_view
|
||||
bugprone
|
||||
cflags
|
||||
chrono
|
||||
cmake_current_source_dir
|
||||
cmake_host_win32
|
||||
comdlg32
|
||||
cpp_httplib_hash
|
||||
cppcoreguidelines
|
||||
cppdbg
|
||||
cppflags
|
||||
cpphttplib
|
||||
cppvsdbg
|
||||
crypto_aead_xchacha20poly1305_ietf_npubbytes
|
||||
cstdint
|
||||
cxxflags
|
||||
cxxopts_project
|
||||
cxxstd
|
||||
d_largefile64_source
|
||||
d_largefile_source
|
||||
d_ndebug
|
||||
dbackward_has_dwarf
|
||||
dbackward_shared
|
||||
dbghelp
|
||||
dbinaries
|
||||
dboost_root
|
||||
dbuild_shared_libs
|
||||
dcli11_warnings_as_errors
|
||||
dcmake_cxx_flags
|
||||
dcpphttplib_openssl_support
|
||||
dcpphttplib_tcp_nodelay
|
||||
dcurl_ca_bundle
|
||||
dcurl_ca_fallback
|
||||
dcurl_disable_ldap
|
||||
dcurl_staticlib
|
||||
dcurl_use_libpsl
|
||||
dcurl_use_libssh2
|
||||
dcurl_zlib
|
||||
dcxxopts_build_examples
|
||||
dcxxopts_build_tests
|
||||
dcxxopts_enable_install
|
||||
dcxxopts_enable_warnings
|
||||
dcxxopts_use_unicode_help
|
||||
ddebug
|
||||
ddefault_library
|
||||
decmult_gen_prec_bits
|
||||
decmult_window_size
|
||||
degl
|
||||
denable_threaded_resolver
|
||||
deps
|
||||
devent__disable_openssl
|
||||
devent__disable_tests
|
||||
devent__library_type
|
||||
dfail_on_warnings
|
||||
dfuse_use_version
|
||||
dgles1
|
||||
dgles2
|
||||
dhas_setxattr
|
||||
dhttplib_require_brotli
|
||||
dhttplib_require_openssl
|
||||
dhttplib_require_zlib
|
||||
dinstall_manpages
|
||||
djson_buildtests
|
||||
dnana_cmake_enable_audio
|
||||
dnana_cmake_enable_jpeg
|
||||
dnana_cmake_enable_png
|
||||
dnana_cmake_install
|
||||
dndebug
|
||||
dopengl
|
||||
dopenssl_root_dir
|
||||
dopenssl_use_static_libs
|
||||
dpng_shared
|
||||
dpng_static
|
||||
dpng_tests
|
||||
dpng_tools
|
||||
dportable
|
||||
dproject_enable_backward_cpp
|
||||
dproject_static_link
|
||||
drocksdb_install_on_windows
|
||||
dshared
|
||||
dspdlog_fmt_external
|
||||
dthreads_prefer_pthread_flag
|
||||
duse_libidn2
|
||||
duuid_build_tests
|
||||
dwith_benchmark
|
||||
dwith_gflags
|
||||
dwith_iostats_context
|
||||
dwxuse_opengl
|
||||
dzlib_use_static_libs
|
||||
ecdh
|
||||
endforeach
|
||||
endfunction
|
||||
eventlib
|
||||
fext
|
||||
fifthgrid
|
||||
flac_version
|
||||
flarge
|
||||
fontconfig_version
|
||||
freetype2_version
|
||||
glapi
|
||||
gmock
|
||||
googletest
|
||||
gpath
|
||||
gtest_version
|
||||
has_setxattr
|
||||
httpapi
|
||||
httplib
|
||||
icudata
|
||||
icui18n
|
||||
icuuc
|
||||
iostreams
|
||||
iphlpapi
|
||||
istream_reader
|
||||
libbitcoin
|
||||
libbitcoinsystem
|
||||
libcurl
|
||||
libevent
|
||||
libexample
|
||||
libfuse3
|
||||
libgmock
|
||||
libgtest
|
||||
libiconv_version
|
||||
libjpeg
|
||||
libmonitarr
|
||||
libpcre2_version
|
||||
libpng_project
|
||||
librocksdb
|
||||
libsecp256k1
|
||||
libsfml
|
||||
libsodium_type
|
||||
libspdlog
|
||||
libuuid
|
||||
libuuid_include_dirs
|
||||
libvlc_include_dirs
|
||||
libvlc_libraries
|
||||
libvlccore
|
||||
libvorbis
|
||||
linkflags
|
||||
mbig
|
||||
monitarr
|
||||
msvc
|
||||
msvcr120
|
||||
msvcr90
|
||||
mswsock
|
||||
mtune
|
||||
mwindows
|
||||
nana
|
||||
ncrypt
|
||||
nlohmann_json
|
||||
nmakeprg
|
||||
nominmax
|
||||
nuspell_version
|
||||
oleaut32
|
||||
openal_version
|
||||
openssldir
|
||||
ostream_writer
|
||||
pkgconfig
|
||||
println
|
||||
project_enable_cxxopts
|
||||
project_enable_fontconfig
|
||||
project_enable_gtkmm
|
||||
project_enable_libdsm
|
||||
project_enable_libiconv
|
||||
project_enable_libtasn1
|
||||
project_enable_winfsp
|
||||
propgrid
|
||||
pugi
|
||||
pugixml_project
|
||||
richtext
|
||||
rocksdb_library
|
||||
rpcrt4
|
||||
sdl2_no_mwindows
|
||||
secp256k1
|
||||
secur32
|
||||
sfml_project
|
||||
shlwapi
|
||||
smb_stat_wtime
|
||||
source_subdir
|
||||
spdlog
|
||||
spdlog_project
|
||||
st_ctim
|
||||
static-libgcc
|
||||
static-libstdc++
|
||||
stduuid_project
|
||||
stod
|
||||
strequal
|
||||
uring
|
||||
userenv
|
||||
vorbis_version
|
||||
wall
|
||||
wcast-align
|
||||
wconversion
|
||||
wdouble-promotion
|
||||
wduplicated-branches
|
||||
wduplicated-cond
|
||||
wextra
|
||||
wformat=2
|
||||
win32_find_dataa
|
||||
winfsp
|
||||
winhttp
|
||||
wininet
|
||||
winspool
|
||||
wlogical-op
|
||||
wmisleading-indentation
|
||||
wno-useless-cast
|
||||
wnon-virtual-dtor
|
||||
wnull-dereference
|
||||
wold-style-cast
|
||||
woverloaded-virtual
|
||||
wpedantic
|
||||
wserialization
|
||||
wshadow
|
||||
wsign-conversion
|
||||
wunused
|
||||
wxwidgets_version
|
||||
xattr
|
||||
xcursor
|
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
.cache/
|
||||
.vs/
|
||||
build*/
|
||||
compile_commands.json
|
||||
cspell.json
|
||||
deps/
|
||||
dist/
|
||||
override.sh
|
||||
scripts/cleanup.cmd
|
||||
scripts/cleanup.sh
|
||||
support/Dockerfile
|
||||
version.cpp
|
||||
version.rc
|
69
.jenkins_builds
Normal file
69
.jenkins_builds
Normal file
@ -0,0 +1,69 @@
|
||||
#!groovy
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
environment {
|
||||
PROJECT_TEST_CONFIG_DIR = "/.ci/monitarr/test_config"
|
||||
}
|
||||
|
||||
options {
|
||||
disableConcurrentBuilds()
|
||||
retry(2)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('linux_x86_64') {
|
||||
agent any
|
||||
|
||||
steps {
|
||||
retry(2) {
|
||||
sleep time: 5, unit: 'SECONDS'
|
||||
sh 'scripts/make_unix.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('mingw64') {
|
||||
agent any
|
||||
|
||||
steps {
|
||||
retry(2) {
|
||||
sleep time: 5, unit: 'SECONDS'
|
||||
sh 'scripts/make_win32.sh'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('linux_aarch64') {
|
||||
agent any
|
||||
|
||||
steps {
|
||||
retry(2) {
|
||||
sleep time: 5, unit: 'SECONDS'
|
||||
sh 'scripts/make_unix.sh aarch64'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('test') {
|
||||
agent any
|
||||
|
||||
steps {
|
||||
sh 'scripts/test.sh'
|
||||
sh 'scripts/test.sh "" "" "" "" 1 1'
|
||||
sh 'scripts/test.sh aarch64'
|
||||
}
|
||||
}
|
||||
|
||||
stage('deliver') {
|
||||
agent any
|
||||
|
||||
steps {
|
||||
sh 'scripts/deliver.sh /mnt/monitarr "" "" "" "" 1 1'
|
||||
sh 'scripts/deliver.sh /mnt/monitarr "" aarch64'
|
||||
sh 'scripts/deliver.sh /mnt/monitarr'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
47
.nvimrc
Normal file
47
.nvimrc
Normal file
@ -0,0 +1,47 @@
|
||||
if has('win32') || has('win64')
|
||||
let &makeprg=".\\scripts\\make_win32.cmd"
|
||||
let g:nmakeprg=".\\scripts\\make_win32.cmd"
|
||||
" let g:gtest#gtest_command = "cd build2 && .\\unittests"
|
||||
else
|
||||
let &makeprg="./scripts/make_unix.sh"
|
||||
let g:nmakeprg="./scripts/make_unix.sh"
|
||||
" let g:gtest#gtest_command = "cd build && ./unittests"
|
||||
endif
|
||||
set path+=.,monitarr/**
|
||||
|
||||
lua << EOF
|
||||
if vim.env.NV_DARCULA_ENABLE_DAP then
|
||||
local dap = require("dap")
|
||||
local g = require("nvim-goodies")
|
||||
local gos = require("nvim-goodies.os")
|
||||
local gpath = require("nvim-goodies.path")
|
||||
|
||||
local externalConsole = gos.is_windows
|
||||
local type = "cppdbg"
|
||||
local cwd = gpath.create_path("./build")
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = "Main",
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "monitarr")
|
||||
end,
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
externalConsole=externalConsole,
|
||||
},
|
||||
{
|
||||
name = "Test",
|
||||
type = type,
|
||||
request = "launch",
|
||||
program = function()
|
||||
return gpath.create_path(cwd, "monitarr_tests")
|
||||
end,
|
||||
cwd = cwd,
|
||||
stopAtEntry = true,
|
||||
externalConsole=externalConsole,
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
177
CMakeLists.txt
Normal file
177
CMakeLists.txt
Normal file
@ -0,0 +1,177 @@
|
||||
cmake_minimum_required(VERSION 3.27)
|
||||
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
cmake_policy(SET CMP0144 NEW)
|
||||
|
||||
if (NOT PROJECT_INTERFACE)
|
||||
message(FATAL_ERROR "Project must be compiled via 'make_win32.cmd'/'make_win32.sh' or 'make_unix.sh' build scripts. Invoking 'cmake' directly is not supported.")
|
||||
endif()
|
||||
|
||||
project(${PROJECT_NAME}
|
||||
DESCRIPTION ${PROJECT_DESC}
|
||||
HOMEPAGE_URL ${PROJECT_URL}
|
||||
VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_REVISION_VERSION}
|
||||
)
|
||||
|
||||
include(CheckIncludeFileCXX)
|
||||
include(CheckIncludeFiles)
|
||||
include(ExternalProject)
|
||||
|
||||
check_include_files(sys/xattr.h HAS_SETXATTR)
|
||||
if(HAS_SETXATTR)
|
||||
add_definitions(-DHAS_SETXATTR)
|
||||
endif()
|
||||
|
||||
include(cmake/hashes.cmake)
|
||||
|
||||
include(cmake/versions.cmake)
|
||||
include(cmake/arch.cmake)
|
||||
include(cmake/os.cmake)
|
||||
include(cmake/options.cmake)
|
||||
|
||||
option(PROJECT_REQUIRE_ALPINE "Require Alpine Linux as build system" OFF)
|
||||
option(PROJECT_STATIC_LINK "Static link executables" OFF)
|
||||
|
||||
if(PROJECT_STATIC_LINK)
|
||||
add_definitions(-DPROJECT_STATIC_LINK)
|
||||
endif()
|
||||
|
||||
if(PROJECT_IS_MINGW)
|
||||
add_definitions(-DPROJECT_IS_MINGW)
|
||||
if(PROJECT_IS_MINGW_UNIX)
|
||||
add_definitions(-DPROJECT_IS_MINGW_UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PROJECT_REQUIRE_ALPINE)
|
||||
add_definitions(-DPROJECT_REQUIRE_ALPINE)
|
||||
endif()
|
||||
|
||||
if(PROJECT_IS_ARM64)
|
||||
add_definitions(-DPROJECT_IS_ARM64)
|
||||
endif()
|
||||
|
||||
if(PROJECT_IS_MINGW)
|
||||
option(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES "Enable path sizes of 32767 characters on Windows" OFF)
|
||||
if(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
|
||||
add_definitions(-DPROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(cmake/settings.cmake)
|
||||
|
||||
include(cmake/flags.cmake)
|
||||
include(cmake/functions.cmake)
|
||||
|
||||
include(cmake/libraries.cmake)
|
||||
|
||||
if(PROJECT_BUILD)
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp "")
|
||||
|
||||
if (PROJECT_IS_MINGW)
|
||||
set(PROJECT_WINDOWS_VERSION_RC ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.rc)
|
||||
file(WRITE ${PROJECT_WINDOWS_VERSION_RC} "")
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE ADDITIONAL_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp
|
||||
${PROJECT_SUPPORT_DIR}/src/*.c
|
||||
${PROJECT_SUPPORT_DIR}/src/*.cpp
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_ADDITIONAL_SOURCES
|
||||
${ADDITIONAL_SOURCES}
|
||||
)
|
||||
|
||||
include(project.cmake)
|
||||
|
||||
string(REPLACE "\\<" "<" PROJECT_COMPANY_NAME "${PROJECT_COMPANY_NAME}")
|
||||
string(REPLACE "\\<" "<" PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT}")
|
||||
string(REPLACE "\\<" "<" PROJECT_DESC "${PROJECT_DESC}")
|
||||
string(REPLACE "\\>" ">" PROJECT_COMPANY_NAME "${PROJECT_COMPANY_NAME}")
|
||||
string(REPLACE "\\>" ">" PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT}")
|
||||
string(REPLACE "\\>" ">" PROJECT_DESC "${PROJECT_DESC}")
|
||||
|
||||
if (PROJECT_IS_MINGW)
|
||||
if ("${PROJECT_RELEASE_ITER}" STREQUAL "release")
|
||||
set(PROJECT_PRERELEASE 0)
|
||||
else()
|
||||
set(PROJECT_PRERELEASE VS_FF_PRERELEASE)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.rc.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.rc
|
||||
@ONLY
|
||||
)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/version.cpp
|
||||
@ONLY
|
||||
)
|
||||
else()
|
||||
message(STATUS "-=[CMake Settings]=-")
|
||||
message(STATUS " C standard: ${CMAKE_C_STANDARD}")
|
||||
message(STATUS " C++ standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS " CPU architecture: ${PROJECT_MARCH}")
|
||||
if(PROJECT_ENABLE_FUSE)
|
||||
message(STATUS " FUSE version: ${PROJECT_FUSE}")
|
||||
endif()
|
||||
|
||||
string(REPLACE "<" "\\<" PROJECT_COMPANY_NAME "${PROJECT_COMPANY_NAME}")
|
||||
string(REPLACE "<" "\\<" PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT}")
|
||||
string(REPLACE "<" "\\<" PROJECT_DESC "${PROJECT_DESC}")
|
||||
string(REPLACE ">" "\\>" PROJECT_COMPANY_NAME "${PROJECT_COMPANY_NAME}")
|
||||
string(REPLACE ">" "\\>" PROJECT_COPYRIGHT "${PROJECT_COPYRIGHT}")
|
||||
string(REPLACE ">" "\\>" PROJECT_DESC "${PROJECT_DESC}")
|
||||
|
||||
add_custom_target(project ALL
|
||||
DEPENDS ${PROJECT_DEPENDENCIES}
|
||||
COMMAND cd build && cmake
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
-DPROJECT_3RD_PARTY_DIR=${PROJECT_3RD_PARTY_DIR}
|
||||
-DPROJECT_BUILD=ON
|
||||
-DPROJECT_BUILD_ARCH=${PROJECT_BUILD_ARCH}
|
||||
-DPROJECT_BUILD_DIR=${PROJECT_BUILD_DIR}
|
||||
-DPROJECT_BUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DPROJECT_CMAKE_BUILD_TYPE=${PROJECT_CMAKE_BUILD_TYPE}
|
||||
-DPROJECT_COMPANY_NAME=${PROJECT_COMPANY_NAME}
|
||||
-DPROJECT_COPYRIGHT=${PROJECT_COPYRIGHT}
|
||||
-DPROJECT_DESC=${PROJECT_DESC}
|
||||
-DPROJECT_DIST_DIR=${PROJECT_DIST_DIR}
|
||||
-DPROJECT_ENABLE_WIN32_LONG_PATH_NAMES=${PROJECT_ENABLE_WIN32_LONG_PATH_NAMES}
|
||||
-DPROJECT_ENABLE_BACKWARD_CPP=${PROJECT_ENABLE_BACKWARD_CPP}
|
||||
-DPROJECT_ENABLE_CPP_HTTPLIB=${PROJECT_ENABLE_CPP_HTTPLIB}
|
||||
-DPROJECT_ENABLE_CURL=${PROJECT_ENABLE_CURL}
|
||||
-DPROJECT_ENABLE_JSON=${PROJECT_ENABLE_JSON}
|
||||
-DPROJECT_ENABLE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
|
||||
-DPROJECT_ENABLE_ROCKSDB=${PROJECT_ENABLE_ROCKSDB}
|
||||
-DPROJECT_ENABLE_SPDLOG=${PROJECT_ENABLE_SPDLOG}
|
||||
-DPROJECT_ENABLE_TESTING=${PROJECT_ENABLE_TESTING}
|
||||
-DPROJECT_EXTERNAL_BUILD_ROOT=${PROJECT_EXTERNAL_BUILD_ROOT}
|
||||
-DPROJECT_FUSE=${PROJECT_FUSE}
|
||||
-DPROJECT_FUSE_INCLUDE_DIRS=${PROJECT_FUSE_INCLUDE_DIRS}
|
||||
-DPROJECT_GIT_REV=${PROJECT_GIT_REV}
|
||||
-DPROJECT_INTERFACE=1
|
||||
-DPROJECT_IS_ALPINE=${PROJECT_IS_ALPINE}
|
||||
-DPROJECT_IS_ARM64=${PROJECT_IS_ARM64}
|
||||
-DPROJECT_IS_MINGW=${PROJECT_IS_MINGW}
|
||||
-DPROJECT_IS_MINGW_UNIX=${PROJECT_IS_MINGW_UNIX}
|
||||
-DPROJECT_MAJOR_VERSION=${PROJECT_MAJOR_VERSION}
|
||||
-DPROJECT_MINOR_VERSION=${PROJECT_MINOR_VERSION}
|
||||
-DPROJECT_NAME=${PROJECT_NAME}
|
||||
-DPROJECT_RELEASE_ITER=${PROJECT_RELEASE_ITER}
|
||||
-DPROJECT_RELEASE_NUM=${PROJECT_RELEASE_NUM}
|
||||
-DPROJECT_REQUIRE_ALPINE=${PROJECT_REQUIRE_ALPINE}
|
||||
-DPROJECT_REVISION_VERSION=${PROJECT_REVISION_VERSION}
|
||||
-DPROJECT_STATIC_LINK=${PROJECT_STATIC_LINK}
|
||||
-DPROJECT_SUPPORT_DIR=${PROJECT_SUPPORT_DIR}
|
||||
-DPROJECT_TOOLCHAIN_FILE_CMAKE=${PROJECT_TOOLCHAIN_FILE_CMAKE}
|
||||
-DPROJECT_TOOLCHAIN_FILE_MESON=${PROJECT_TOOLCHAIN_FILE_MESON}
|
||||
-DPROJECT_URL=${PROJECT_URL}
|
||||
)
|
||||
endif()
|
16
cmake/arch.cmake
Normal file
16
cmake/arch.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
|
||||
message(FATAL_ERROR "32-bit compilation is not supported")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)")
|
||||
set(IS_ARM_SYSTEM 1)
|
||||
endif()
|
||||
|
||||
if(PROJECT_IS_ARM64 AND NOT IS_ARM_SYSTEM AND NOT PROJECT_REQUIRE_ALPINE)
|
||||
message(FATAL_ERROR "aarch64 cross-compile is not supported")
|
||||
endif()
|
||||
|
||||
string(REPLACE "_" "-" PROJECT_MARCH ${PROJECT_BUILD_ARCH})
|
||||
if("${PROJECT_BUILD_ARCH}" STREQUAL "aarch64")
|
||||
set(PROJECT_MARCH armv8-a)
|
||||
endif()
|
114
cmake/flags.cmake
Normal file
114
cmake/flags.cmake
Normal file
@ -0,0 +1,114 @@
|
||||
list(APPEND PROJECT_COMMON_FLAG_LIST
|
||||
-D_FILE_OFFSET_BITS=64
|
||||
-D_GNU_SOURCE
|
||||
-D_LARGEFILE64_SOURCE
|
||||
-D_LARGEFILE_SOURCE
|
||||
-D_TIME_BITS=64
|
||||
-march=${PROJECT_MARCH}
|
||||
-mtune=generic
|
||||
)
|
||||
|
||||
if(PROJECT_IS_MINGW)
|
||||
list(APPEND PROJECT_COMMON_FLAG_LIST
|
||||
${PROJECT_COMMON_FLAG_LIST}
|
||||
-Wa,-mbig-obj
|
||||
-flarge-source-files
|
||||
)
|
||||
endif()
|
||||
|
||||
list(APPEND PROJECT_DEBUG_FLAG_LIST
|
||||
-DDEBUG
|
||||
-D_DEBUG
|
||||
-Og
|
||||
-fno-omit-frame-pointer
|
||||
-g
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_RELEASE_FLAG_LIST
|
||||
-DNDEBUG
|
||||
-D_NDEBUG
|
||||
-O3
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_CXXFLAGS_LIST
|
||||
-Wall
|
||||
-Wcast-align
|
||||
-Wconversion
|
||||
-Wdouble-promotion
|
||||
-Wduplicated-branches
|
||||
-Wduplicated-cond
|
||||
-Wextra
|
||||
-Wformat=2
|
||||
-Wlogical-op
|
||||
-Wmisleading-indentation
|
||||
-Wno-useless-cast
|
||||
-Wnon-virtual-dtor
|
||||
-Wnull-dereference
|
||||
-Wold-style-cast
|
||||
-Woverloaded-virtual
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wsign-conversion
|
||||
-Wunused
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_CFLAGS_LIST
|
||||
${PROJECT_COMMON_FLAG_LIST}
|
||||
-std=c${CMAKE_C_STANDARD}
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_CXXFLAGS_LIST
|
||||
${PROJECT_COMMON_FLAG_LIST}
|
||||
-std=gnu++${CMAKE_CXX_STANDARD}
|
||||
)
|
||||
|
||||
if(PROJECT_STATIC_LINK)
|
||||
list(APPEND PROJECT_CMAKE_EXE_LINKER_FLAGS
|
||||
-static-libgcc
|
||||
-static-libstdc++
|
||||
-static
|
||||
)
|
||||
endif()
|
||||
|
||||
list(JOIN PROJECT_COMMON_FLAG_LIST " " PROJECT_COMMON_FLAG_LIST)
|
||||
list(JOIN PROJECT_DEBUG_FLAG_LIST " " PROJECT_DEBUG_FLAG_LIST)
|
||||
list(JOIN PROJECT_RELEASE_FLAG_LIST " " PROJECT_RELEASE_FLAG_LIST)
|
||||
|
||||
list(JOIN PROJECT_CFLAGS_LIST " " PROJECT_CFLAGS_LIST)
|
||||
list(JOIN PROJECT_CXXFLAGS_LIST " " PROJECT_CXXFLAGS_LIST)
|
||||
|
||||
list(JOIN PROJECT_CMAKE_EXE_LINKER_FLAGS " " PROJECT_CMAKE_EXE_LINKER_FLAGS)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROJECT_CFLAGS_LIST}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${PROJECT_DEBUG_FLAG_LIST}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${PROJECT_RELEASE_FLAG_LIST}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-include cstdint -include utility ${CMAKE_CXX_FLAGS} ${PROJECT_CXXFLAGS_LIST}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${PROJECT_DEBUG_FLAG_LIST}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${PROJECT_RELEASE_FLAG_LIST}")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${PROJECT_CMAKE_EXE_LINKER_FLAGS}")
|
||||
|
||||
set(EXTERNAL_CMAKE_CXX_FLAGS "-include cstdint -include utility -fext-numeric-literals ${PROJECT_COMMON_FLAG_LIST}")
|
||||
list(APPEND PROJECT_EXTERNAL_CMAKE_FLAGS
|
||||
-DCMAKE_BUILD_TYPE=${PROJECT_CMAKE_BUILD_TYPE}
|
||||
-DCMAKE_COLOR_MAKEFILE=${CMAKE_COLOR_MAKEFILE}
|
||||
-DCMAKE_CXX_FLAGS=${EXTERNAL_CMAKE_CXX_FLAGS}
|
||||
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
|
||||
-DCMAKE_C_FLAGS=${PROJECT_COMMON_FLAG_LIST}
|
||||
-DCMAKE_C_STANDARD=${CMAKE_C_STANDARD}
|
||||
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||
-DCMAKE_INSTALL_PREFIX=${PROJECT_EXTERNAL_BUILD_ROOT}
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
|
||||
)
|
||||
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
list(APPEND PROJECT_EXTERNAL_CMAKE_FLAGS
|
||||
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
|
||||
)
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" "|" CMAKE_PREFIX_PATH_ALT_SEP "${CMAKE_PREFIX_PATH}")
|
||||
list(APPEND PROJECT_EXTERNAL_CMAKE_FLAGS
|
||||
-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH_ALT_SEP}
|
||||
)
|
153
cmake/functions.cmake
Normal file
153
cmake/functions.cmake
Normal file
@ -0,0 +1,153 @@
|
||||
function(set_common_target_options name)
|
||||
target_compile_definitions(${name} PUBLIC
|
||||
${PROJECT_DEFINITIONS}
|
||||
${${name}_DEFINITIONS}
|
||||
)
|
||||
|
||||
target_include_directories(${name} BEFORE PUBLIC
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/include
|
||||
)
|
||||
|
||||
target_link_directories(${name} BEFORE PUBLIC
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/lib
|
||||
)
|
||||
|
||||
target_include_directories(${name} AFTER PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include
|
||||
${name}_INCLUDES
|
||||
)
|
||||
|
||||
if(PROJECT_DEPENDENCIES)
|
||||
add_dependencies(${name} ${PROJECT_DEPENDENCIES})
|
||||
endif()
|
||||
|
||||
if(PROJECT_STATIC_LINK)
|
||||
set_property(TARGET ${name} PROPERTY LINK_SEARCH_START_STATIC 1)
|
||||
endif()
|
||||
endfunction(set_common_target_options)
|
||||
|
||||
function(add_project_executable2 name dependencies libraries headers sources is_win32)
|
||||
if (PROJECT_WINDOWS_VERSION_RC)
|
||||
list(APPEND sources ${PROJECT_WINDOWS_VERSION_RC})
|
||||
endif()
|
||||
|
||||
add_executable(${name}
|
||||
${headers}
|
||||
${sources}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/main.cpp
|
||||
)
|
||||
|
||||
foreach(dependency ${dependencies})
|
||||
set_common_target_options(${dependency})
|
||||
endforeach()
|
||||
|
||||
set_common_target_options(${name})
|
||||
|
||||
if(dependencies)
|
||||
add_dependencies(${name} ${dependencies})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${name} PRIVATE ${libraries})
|
||||
|
||||
if(PROJECT_ENABLE_SDL AND PROJECT_IS_MINGW)
|
||||
target_link_libraries(${name} PRIVATE SDL2::SDL2main)
|
||||
endif ()
|
||||
|
||||
if (is_win32 AND PROJECT_IS_MINGW)
|
||||
target_link_options(${name} PRIVATE -mwindows)
|
||||
endif()
|
||||
endfunction(add_project_executable2)
|
||||
|
||||
function(add_project_executable name dependencies libraries)
|
||||
file(GLOB_RECURSE headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.hh
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.hxx
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cxx
|
||||
)
|
||||
|
||||
if(PROJECT_ENABLE_WXWIDGETS OR PROJECT_ENABLE_SDL OR PROJECT_ENABLE_SFML OR PROJECT_ENABLE_NANA)
|
||||
set(IS_WIN32 ON)
|
||||
endif()
|
||||
|
||||
add_project_executable2(${name} "${dependencies}" "${libraries}" "${headers}" "${sources}" "${IS_WIN32}")
|
||||
|
||||
if(PROJECT_ENABLE_WXWIDGETS)
|
||||
target_link_libraries(${name} PRIVATE ${wxWidgets_LIBRARIES})
|
||||
endif()
|
||||
endfunction(add_project_executable)
|
||||
|
||||
function(add_project_library name dependencies libraries additional_sources)
|
||||
file(GLOB_RECURSE headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.hh
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/${name}/include/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/${name}/include/${name}/include/*.hxx
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
${additional_sources}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cxx
|
||||
)
|
||||
|
||||
add_library(${name} STATIC
|
||||
${headers}
|
||||
${sources}
|
||||
)
|
||||
|
||||
set_common_target_options(${name})
|
||||
|
||||
set_target_properties(${name} PROPERTIES PREFIX "")
|
||||
target_link_libraries(${name} PRIVATE ${libraries})
|
||||
endfunction(add_project_library)
|
||||
|
||||
function(add_project_test_executable name dependencies libraries)
|
||||
if(PROJECT_ENABLE_TESTING)
|
||||
find_package(GTest ${GTEST_VERSION} REQUIRED)
|
||||
enable_testing()
|
||||
|
||||
file(GLOB_RECURSE headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/${name}/include/${name}/include/*.hxx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/${name}/include/*.hpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/include/*.hh
|
||||
${PROJECT_SUPPORT_DIR}/test/include/*.hpp
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${name}/src/*.cxx
|
||||
${PROJECT_SUPPORT_DIR}/test/src/*.cpp
|
||||
${additional_sources}
|
||||
)
|
||||
|
||||
add_project_executable2(${name} "${dependencies}" "${libraries}" "${headers}" "${sources}" OFF)
|
||||
|
||||
target_compile_definitions(${name} PRIVATE -DPROJECT_TESTING)
|
||||
|
||||
target_include_directories(${name} SYSTEM BEFORE
|
||||
${GTEST_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(${name} AFTER PRIVATE
|
||||
${PROJECT_SUPPORT_DIR}/test/include
|
||||
)
|
||||
|
||||
target_link_libraries(${name} PRIVATE
|
||||
GTest::gtest
|
||||
GTest::gmock
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
14
cmake/hashes.cmake
Normal file
14
cmake/hashes.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
set(BINUTILS_HASH b53606f443ac8f01d1d5fc9c39497f2af322d99e14cea5c0b4b124d630379365)
|
||||
set(CPP_HTTPLIB_HASH 405abd8170f2a446fc8612ac635d0db5947c0d2e156e32603403a4496255ff00)
|
||||
set(CURL_HASH 5a231145114589491fc52da118f9c7ef8abee885d1cb1ced99c7290e9a352f07)
|
||||
set(EXPAT_HASH 372b18f6527d162fa9658f1c74d22a37429b82d822f5a1e1fc7e00f6045a06a2)
|
||||
set(GCC_HASH 7d376d445f93126dc545e2c0086d0f647c3094aae081cdb78f42ce2bc25e7293)
|
||||
set(GTEST_HASH 7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926)
|
||||
set(ICU_HASH a2c443404f00098e9e90acf29dc318e049d2dc78d9ae5f46efb261934a730ce2)
|
||||
set(JSON_HASH 0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406)
|
||||
set(MINGW_HASH 30e5aad2c48dd318150f79cff47661232c4175876d6b4d6b270961cf2b49a48b)
|
||||
set(OPENSSL_HASH e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf)
|
||||
set(PKG_CONFIG_HASH 6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591)
|
||||
set(ROCKSDB_HASH 9b810c81731835fda0d4bbdb51d3199d901fa4395733ab63752d297da84c5a47)
|
||||
set(SPDLOG_HASH 9962648c9b4f1a7bbc76fd8d9172555bad1871fdb14ff4f842ef87949682caa5)
|
||||
set(ZLIB_HASH 17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c)
|
61
cmake/libraries.cmake
Normal file
61
cmake/libraries.cmake
Normal file
@ -0,0 +1,61 @@
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ${PROJECT_STATIC_LINK})
|
||||
set(CURL_USE_STATIC_LIBS ${PROJECT_STATIC_LINK})
|
||||
set(OPENSSL_USE_STATIC_LIBS ${PROJECT_STATIC_LINK})
|
||||
set(SFML_STATIC_LIBRARIES ${PROJECT_STATIC_LINK})
|
||||
set(ZLIB_USE_STATIC_LIBS ${PROJECT_STATIC_LINK})
|
||||
set(wxWidgets_USE_STATIC ${PROJECT_STATIC_LINK})
|
||||
|
||||
include(cmake/libraries/openssl.cmake)
|
||||
|
||||
|
||||
include(cmake/libraries/backward_cpp.cmake)
|
||||
include(cmake/libraries/cpp_httplib.cmake)
|
||||
include(cmake/libraries/curl.cmake)
|
||||
include(cmake/libraries/json.cmake)
|
||||
include(cmake/libraries/rocksdb.cmake)
|
||||
include(cmake/libraries/spdlog.cmake)
|
||||
include(cmake/libraries/testing.cmake)
|
||||
|
||||
if(PROJECT_BUILD)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
include_directories(BEFORE SYSTEM ${ZLIB_INCLUDE_DIRS})
|
||||
link_libraries(${ZLIB_LIBRARIES})
|
||||
|
||||
if(PROJECT_IS_MINGW)
|
||||
link_libraries(
|
||||
advapi32
|
||||
bcrypt
|
||||
comdlg32
|
||||
crypt32
|
||||
dbghelp
|
||||
gdi32
|
||||
httpapi
|
||||
iphlpapi
|
||||
kernel32
|
||||
mswsock
|
||||
ncrypt
|
||||
ole32
|
||||
oleaut32
|
||||
rpcrt4
|
||||
secur32
|
||||
shell32
|
||||
shlwapi
|
||||
user32
|
||||
userenv
|
||||
uuid
|
||||
version
|
||||
winhttp
|
||||
wininet
|
||||
winspool
|
||||
ws2_32
|
||||
)
|
||||
else()
|
||||
link_libraries(
|
||||
uring
|
||||
)
|
||||
endif()
|
||||
endif()
|
11
cmake/libraries/backward_cpp.cmake
Normal file
11
cmake/libraries/backward_cpp.cmake
Normal file
@ -0,0 +1,11 @@
|
||||
if(PROJECT_ENABLE_BACKWARD_CPP AND PROJECT_BUILD)
|
||||
if(PROJECT_IS_MINGW)
|
||||
add_definitions(-DPROJECT_ENABLE_BACKWARD_CPP)
|
||||
|
||||
link_libraries(msvcr90)
|
||||
else()
|
||||
add_definitions(-DBACKWARD_HAS_BFD)
|
||||
|
||||
link_libraries(bfd)
|
||||
endif()
|
||||
endif()
|
32
cmake/libraries/cpp_httplib.cmake
Normal file
32
cmake/libraries/cpp_httplib.cmake
Normal file
@ -0,0 +1,32 @@
|
||||
if(PROJECT_ENABLE_CPP_HTTPLIB)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(
|
||||
-DCPPHTTPLIB_OPENSSL_SUPPORT
|
||||
-DCPPHTTPLIB_TCP_NODELAY=true
|
||||
-DCPPHTTPLIB_ZLIB_SUPPORT
|
||||
-DPROJECT_ENABLE_CPP_HTTPLIB
|
||||
)
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(cpphttplib_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/cpp-httplib-${CPP_HTTPLIB_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${CPP_HTTPLIB_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DHTTPLIB_REQUIRE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
|
||||
-DHTTPLIB_REQUIRE_ZLIB=ON
|
||||
-DHTTPLIB_REQUIRE_BROTLI=OFF
|
||||
-DHTTPLIB_TEST=OFF
|
||||
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES cpphttplib_project)
|
||||
|
||||
add_dependencies(cpphttplib_project curl_project)
|
||||
if (NOT CMAKE_HOST_WIN32)
|
||||
add_dependencies(cpphttplib_project openssl_project)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
52
cmake/libraries/curl.cmake
Normal file
52
cmake/libraries/curl.cmake
Normal file
@ -0,0 +1,52 @@
|
||||
if(PROJECT_ENABLE_CURL)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_CURL)
|
||||
|
||||
find_package(CURL ${CURL_VERSION} REQUIRED)
|
||||
|
||||
include_directories(BEFORE SYSTEM ${CURL_INCLUDE_DIRS})
|
||||
|
||||
link_libraries(CURL::libcurl)
|
||||
|
||||
if (EXISTS ${PROJECT_DIST_DIR}/cacert.pem)
|
||||
file(REMOVE ${PROJECT_DIST_DIR}/cacert.pem)
|
||||
endif()
|
||||
file(DOWNLOAD https://curl.haxx.se/ca/cacert.pem ${PROJECT_DIST_DIR}/cacert.pem)
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(curl_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/curl-${CURL_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${CURL_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS
|
||||
${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_CURL_EXE=OFF
|
||||
-DBUILD_LIBCURL_DOCS=OFF
|
||||
-DBUILD_MISC_DOCS=OFF
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DBUILD_STATIC_CURL=ON
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DBUILD_TESTING=OFF
|
||||
-DCURL_CA_BUNDLE=./cacert.pem
|
||||
-DCURL_CA_FALLBACK=ON
|
||||
-DCURL_DISABLE_LDAP=ON
|
||||
-DCURL_USE_LIBPSL=OFF
|
||||
-DCURL_USE_LIBSSH2=OFF
|
||||
-DCURL_USE_OPENSSL=${PROJECT_ENABLE_OPENSSL}
|
||||
-DCURL_ZLIB=ON
|
||||
-DENABLE_CURL_MANUAL=OFF
|
||||
-DENABLE_THREADED_RESOLVER=ON
|
||||
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
|
||||
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}
|
||||
-DUSE_LIBIDN2=OFF
|
||||
-DZLIB_USE_STATIC_LIBS=${ZLIB_USE_STATIC_LIBS}
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES curl_project)
|
||||
|
||||
if (NOT CMAKE_HOST_WIN32)
|
||||
add_dependencies(curl_project openssl_project)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
28
cmake/libraries/json.cmake
Normal file
28
cmake/libraries/json.cmake
Normal file
@ -0,0 +1,28 @@
|
||||
if(PROJECT_ENABLE_JSON)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_JSON)
|
||||
|
||||
find_package(nlohmann_json ${JSON_VERSION} REQUIRED)
|
||||
|
||||
if(PROJECT_IS_MINGW AND PROJECT_IS_MINGW_UNIX)
|
||||
include_directories(BEFORE SYSTEM /mingw64/include/nlohmann)
|
||||
else()
|
||||
include_directories(BEFORE SYSTEM ${PROJECT_EXTERNAL_BUILD_ROOT}/include/nlohmann)
|
||||
endif()
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(json_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/json-${JSON_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${JSON_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DJSON_BuildTests=OFF
|
||||
-DJSON_Install=ON
|
||||
-DJSON_MultipleHeaders=OFF
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES json_project)
|
||||
endif()
|
||||
endif()
|
53
cmake/libraries/openssl.cmake
Normal file
53
cmake/libraries/openssl.cmake
Normal file
@ -0,0 +1,53 @@
|
||||
set(OPENSSL_ROOT_DIR $ENV{OPENSSL_ROOT_DIR})
|
||||
|
||||
if(PROJECT_ENABLE_OPENSSL)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_OPENSSL)
|
||||
|
||||
find_package(OpenSSL ${OPENSSL_VERSION} REQUIRED)
|
||||
|
||||
include_directories(BEFORE SYSTEM ${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
link_libraries(
|
||||
OpenSSL::Crypto
|
||||
OpenSSL::SSL
|
||||
)
|
||||
elseif(NOT PROJECT_IS_MINGW)
|
||||
if(PROJECT_IS_MINGW)
|
||||
set(OPENSSL_COMPILE_TYPE mingw64)
|
||||
elseif(PROJECT_IS_ARM64)
|
||||
set(OPENSSL_COMPILE_TYPE linux-aarch64)
|
||||
else()
|
||||
set(OPENSSL_COMPILE_TYPE linux-x86_64)
|
||||
endif()
|
||||
|
||||
if(PROJECT_IS_MINGW_UNIX)
|
||||
set(OPENSSL_CROSS_PREFIX "--cross-compile-prefix=x86_64-w64-mingw32-")
|
||||
endif()
|
||||
|
||||
if(PROJECT_BUILD_SHARED_LIBS)
|
||||
set(OPENSSL_NO_SHARED shared)
|
||||
else()
|
||||
set(OPENSSL_NO_SHARED no-shared)
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(openssl_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/openssl-${OPENSSL_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${OPENSSL_HASH}
|
||||
BUILD_IN_SOURCE 1
|
||||
LIST_SEPARATOR |
|
||||
CONFIGURE_COMMAND ./Configure
|
||||
${OPENSSL_COMPILE_TYPE}
|
||||
${OPENSSL_CROSS_PREFIX}
|
||||
--prefix=${PROJECT_EXTERNAL_BUILD_ROOT}
|
||||
no-apps
|
||||
no-docs
|
||||
${OPENSSL_NO_SHARED}
|
||||
BUILD_COMMAND make -j1
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES openssl_project)
|
||||
endif()
|
||||
endif()
|
34
cmake/libraries/rocksdb.cmake
Normal file
34
cmake/libraries/rocksdb.cmake
Normal file
@ -0,0 +1,34 @@
|
||||
if(PROJECT_ENABLE_ROCKSDB)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_ROCKSDB)
|
||||
find_library(ROCKSDB_LIBRARY NAMES librocksdb.a REQUIRED)
|
||||
link_libraries(${ROCKSDB_LIBRARY})
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(rocksdb_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/rocksdb-${ROCKSDB_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${ROCKSDB_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=OFF
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
-DFAIL_ON_WARNINGS=OFF
|
||||
-DPORTABLE=1
|
||||
-DROCKSDB_BUILD_SHARED=OFF
|
||||
-DROCKSDB_INSTALL_ON_WINDOWS=ON
|
||||
-DWITH_BENCHMARK=OFF
|
||||
-DWITH_BENCHMARK_TOOLS=OFF
|
||||
-DWITH_CORE_TOOLS=OFF
|
||||
-DWITH_EXAMPLES=OFF
|
||||
-DWITH_GFLAGS=OFF
|
||||
-DWITH_IOSTATS_CONTEXT=OFF
|
||||
-DWITH_PERF_CONTEXT=OFF
|
||||
-DWITH_TESTS=OFF
|
||||
-DWITH_TOOLS=OFF
|
||||
-DWITH_TRACE_TOOLS=OFF
|
||||
-DWITH_ZLIB=ON
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES rocksdb_project)
|
||||
endif()
|
||||
endif()
|
25
cmake/libraries/spdlog.cmake
Normal file
25
cmake/libraries/spdlog.cmake
Normal file
@ -0,0 +1,25 @@
|
||||
if(PROJECT_ENABLE_SPDLOG)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_SPDLOG)
|
||||
|
||||
find_package(spdlog ${SPDLOG_VERSION} REQUIRED)
|
||||
|
||||
include_directories(BEFORE SYSTEM ${SPDLOG_INCLUDE_DIRS})
|
||||
|
||||
link_libraries(spdlog::spdlog)
|
||||
elseif(NOT PROJECT_IS_MINGW OR CMAKE_HOST_WIN32)
|
||||
ExternalProject_Add(spdlog_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/spdlog-${SPDLOG_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${SPDLOG_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DSPDLOG_BUILD_EXAMPLE=OFF
|
||||
-DSPDLOG_FMT_EXTERNAL=OFF
|
||||
-DSPDLOG_FMT_EXTERNAL_HO=OFF
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES spdlog_project)
|
||||
endif()
|
||||
endif()
|
17
cmake/libraries/testing.cmake
Normal file
17
cmake/libraries/testing.cmake
Normal file
@ -0,0 +1,17 @@
|
||||
if (PROJECT_ENABLE_TESTING)
|
||||
if(PROJECT_BUILD)
|
||||
add_definitions(-DPROJECT_ENABLE_TESTING)
|
||||
elseif(NOT PROJECT_IS_MINGW)
|
||||
ExternalProject_Add(gtest_project
|
||||
PREFIX external
|
||||
URL ${PROJECT_3RD_PARTY_DIR}/googletest-${GTEST_VERSION}.tar.gz
|
||||
URL_HASH SHA256=${GTEST_HASH}
|
||||
LIST_SEPARATOR |
|
||||
CMAKE_ARGS ${PROJECT_EXTERNAL_CMAKE_FLAGS}
|
||||
-DBUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS}
|
||||
-DBUILD_STATIC_LIBS=ON
|
||||
)
|
||||
|
||||
list(APPEND PROJECT_DEPENDENCIES gtest_project)
|
||||
endif()
|
||||
endif()
|
8
cmake/options.cmake
Normal file
8
cmake/options.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
option(PROJECT_ENABLE_BACKWARD_CPP "Enable backward-cpp" ON)
|
||||
option(PROJECT_ENABLE_CPP_HTTPLIB "Enable cpp-httplib" ON)
|
||||
option(PROJECT_ENABLE_CURL "Enable curl library" ON)
|
||||
option(PROJECT_ENABLE_JSON "Enable JSON for Modern C++ library" ON)
|
||||
option(PROJECT_ENABLE_OPENSSL "Enable OpenSSL library" ON)
|
||||
option(PROJECT_ENABLE_ROCKSDB "Enable RocksDB library" ON)
|
||||
option(PROJECT_ENABLE_SPDLOG "Enable spdlog library" ON)
|
||||
option(PROJECT_ENABLE_TESTING "Enable building unit tests" ON)
|
15
cmake/os.cmake
Normal file
15
cmake/os.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
if(MSVC)
|
||||
message(FATAL_ERROR "MSVC will not be supported")
|
||||
endif()
|
||||
|
||||
if(UNIX AND APPLE)
|
||||
message(FATAL_ERROR "Apple is not currently supported")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
||||
message(FATAL_ERROR "FreeBSD is not currently supported")
|
||||
endif()
|
||||
|
||||
if(PROJECT_REQUIRE_ALPINE AND NOT PROJECT_IS_ALPINE AND PROJECT_IS_MINGW AND PROJECT_IS_MINGW_UNIX)
|
||||
message(FATAL_ERROR "Project requires Alpine Linux to build")
|
||||
endif()
|
51
cmake/settings.cmake
Normal file
51
cmake/settings.cmake
Normal file
@ -0,0 +1,51 @@
|
||||
set(CMAKE_COLOR_MAKEFILE OFF)
|
||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if(PROJECT_STATIC_LINK)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||
else()
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
set(CMAKE_BUILD_TYPE ${PROJECT_CMAKE_BUILD_TYPE})
|
||||
|
||||
file(MAKE_DIRECTORY ${PROJECT_EXTERNAL_BUILD_ROOT}/lib)
|
||||
file(CREATE_LINK ${PROJECT_EXTERNAL_BUILD_ROOT}/lib ${PROJECT_EXTERNAL_BUILD_ROOT}/lib64 SYMBOLIC)
|
||||
|
||||
list(PREPEND CMAKE_PREFIX_PATH
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/share
|
||||
)
|
||||
|
||||
if(PROJECT_IS_MINGW)
|
||||
list(PREPEND CMAKE_PREFIX_PATH
|
||||
/mingw64
|
||||
)
|
||||
|
||||
include_directories(BEFORE
|
||||
/mingw64/include
|
||||
)
|
||||
|
||||
link_directories(BEFORE
|
||||
/mingw64/lib
|
||||
/mingw64/lib64
|
||||
)
|
||||
endif()
|
||||
|
||||
include_directories(BEFORE SYSTEM
|
||||
${PROJECT_SUPPORT_DIR}/include
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/include
|
||||
)
|
||||
|
||||
link_directories(BEFORE
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/lib
|
||||
${PROJECT_EXTERNAL_BUILD_ROOT}/lib64
|
||||
)
|
23
cmake/versions.cmake
Normal file
23
cmake/versions.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
set(BINUTILS_VERSION 2.43)
|
||||
set(BOOST2_MAJOR_VERSION 1)
|
||||
set(BOOST2_MINOR_VERSION 76)
|
||||
set(BOOST2_PATCH_VERSION 0)
|
||||
set(BOOST_MAJOR_VERSION 1)
|
||||
set(BOOST_MINOR_VERSION 87)
|
||||
set(BOOST_PATCH_VERSION 0)
|
||||
set(CPP_HTTPLIB_VERSION 0.18.1)
|
||||
set(CURL2_VERSION 8_11_0)
|
||||
set(CURL_VERSION 8.11.0)
|
||||
set(EXPAT2_VERSION 2_6_4)
|
||||
set(EXPAT_VERSION 2.6.4)
|
||||
set(GCC_VERSION 14.2.0)
|
||||
set(GTEST_VERSION 1.15.2)
|
||||
set(ICU_VERSION 76-1)
|
||||
set(JSON_VERSION 3.11.3)
|
||||
set(MESA_VERSION 23.3.3)
|
||||
set(MINGW_VERSION 12.0.0)
|
||||
set(OPENSSL_VERSION 3.4.0)
|
||||
set(PKG_CONFIG_VERSION 0.29.2)
|
||||
set(ROCKSDB_VERSION 9.7.4)
|
||||
set(SPDLOG_VERSION 1.15.0)
|
||||
set(ZLIB_VERSION 1.3.1)
|
80
config.sh
Normal file
80
config.sh
Normal file
@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_NAME="monitarr"
|
||||
|
||||
PROJECT_COMPANY_NAME=""
|
||||
PROJECT_COPYRIGHT=""
|
||||
PROJECT_DESC=""
|
||||
PROJECT_URL=""
|
||||
|
||||
PROJECT_MAJOR_VERSION=0
|
||||
PROJECT_MINOR_VERSION=0
|
||||
PROJECT_REVISION_VERSION=1
|
||||
PROJECT_RELEASE_NUM=0
|
||||
PROJECT_RELEASE_ITER=alpha
|
||||
|
||||
PROJECT_APP_LIST=(${PROJECT_NAME})
|
||||
|
||||
PROJECT_PRIVATE_KEY=${DEVELOPER_PRIVATE_KEY}
|
||||
PROJECT_PUBLIC_KEY=${DEVELOPER_PUBLIC_KEY}
|
||||
|
||||
PROJECT_STATIC_LINK=ON
|
||||
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=()
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=()
|
||||
|
||||
PROJECT_ENABLE_WIN32_LONG_PATH_NAMES=OFF
|
||||
|
||||
PROJECT_ENABLE_BACKWARD_CPP=OFF
|
||||
PROJECT_ENABLE_BOOST=OFF
|
||||
PROJECT_ENABLE_CLI11=OFF
|
||||
PROJECT_ENABLE_CPP_HTTPLIB=ON
|
||||
PROJECT_ENABLE_CURL=ON
|
||||
PROJECT_ENABLE_CXXOPTS=OFF
|
||||
PROJECT_ENABLE_DTL=OFF
|
||||
PROJECT_ENABLE_FLAC=OFF
|
||||
PROJECT_ENABLE_FMT=OFF
|
||||
PROJECT_ENABLE_FONTCONFIG=OFF
|
||||
PROJECT_ENABLE_FREETYPE2=OFF
|
||||
PROJECT_ENABLE_FUSE=OFF
|
||||
PROJECT_ENABLE_FZF=OFF
|
||||
PROJECT_ENABLE_GTKMM=OFF
|
||||
PROJECT_ENABLE_JSON=ON
|
||||
PROJECT_ENABLE_LIBBITCOIN_SYSTEM=OFF
|
||||
PROJECT_ENABLE_LIBDSM=OFF
|
||||
PROJECT_ENABLE_LIBEVENT=OFF
|
||||
PROJECT_ENABLE_LIBICONV=OFF
|
||||
PROJECT_ENABLE_LIBJPEG_TURBO=OFF
|
||||
PROJECT_ENABLE_LIBPNG=OFF
|
||||
PROJECT_ENABLE_LIBSODIUM=OFF
|
||||
PROJECT_ENABLE_LIBTASN=OFF
|
||||
PROJECT_ENABLE_NANA=OFF
|
||||
PROJECT_ENABLE_NUSPELL=OFF
|
||||
PROJECT_ENABLE_OGG=OFF
|
||||
PROJECT_ENABLE_OPENAL=OFF
|
||||
PROJECT_ENABLE_OPENSSL=ON
|
||||
PROJECT_ENABLE_PUGIXML=OFF
|
||||
PROJECT_ENABLE_ROCKSDB=ON
|
||||
PROJECT_ENABLE_SAGO_PLATFORM_FOLDERS=OFF
|
||||
PROJECT_ENABLE_SDL=OFF
|
||||
PROJECT_ENABLE_SECP256K1=OFF
|
||||
PROJECT_ENABLE_SFML=OFF
|
||||
PROJECT_ENABLE_SPDLOG=ON
|
||||
PROJECT_ENABLE_SQLITE=OFF
|
||||
PROJECT_ENABLE_STDUUID=OFF
|
||||
PROJECT_ENABLE_TESTING=ON
|
||||
PROJECT_ENABLE_TPL=OFF
|
||||
PROJECT_ENABLE_VLC=OFF
|
||||
PROJECT_ENABLE_VORBIS=OFF
|
||||
PROJECT_ENABLE_WINFSP=OFF
|
||||
PROJECT_ENABLE_WXWIDGETS=OFF
|
||||
|
||||
PROJECT_KEEP_BACKWARD_CPP=1
|
||||
|
||||
if [ "${PROJECT_ENABLE_TESTING}" == "ON" ]; then
|
||||
PROJECT_APP_LIST+=(${PROJECT_NAME}_test)
|
||||
fi
|
||||
|
||||
if [ -f "./override.sh" ]; then
|
||||
. ./override.sh
|
||||
fi
|
86
docker/aarch64/alpine
Normal file
86
docker/aarch64/alpine
Normal file
@ -0,0 +1,86 @@
|
||||
#comment
|
||||
FROM arm64v8/alpine:3.21.3
|
||||
MAINTAINER Scott E. Graves <scott.e.graves@protonmail.com>
|
||||
CMD bash
|
||||
|
||||
RUN apk update
|
||||
RUN apk upgrade
|
||||
RUN apk add \
|
||||
autoconf \
|
||||
automake \
|
||||
bash \
|
||||
binutils \
|
||||
binutils-dev \
|
||||
bison \
|
||||
boost-dev \
|
||||
bzip2-static \
|
||||
cmake \
|
||||
diffutils \
|
||||
elfutils-dev \
|
||||
file \
|
||||
fontconfig-dev \
|
||||
fontconfig-static \
|
||||
freetype \
|
||||
freetype-dev \
|
||||
freetype-static \
|
||||
fuse3 \
|
||||
fuse3-dev \
|
||||
fuse3-static \
|
||||
g++ \
|
||||
gcc \
|
||||
gflags \
|
||||
gflags-dev \
|
||||
git \
|
||||
icu-dev \
|
||||
icu-libs \
|
||||
icu-static \
|
||||
libogg-dev \
|
||||
libogg-static \
|
||||
libtool \
|
||||
libudev-zero \
|
||||
libudev-zero-dev \
|
||||
libunwind \
|
||||
libunwind-dev \
|
||||
libunwind-static \
|
||||
liburing \
|
||||
liburing-dev \
|
||||
libvorbis-dev \
|
||||
libvorbis-static \
|
||||
libx11-dev \
|
||||
libx11-static \
|
||||
libxcursor \
|
||||
libxcursor-dev \
|
||||
libxrandr \
|
||||
libxrandr-dev \
|
||||
linux-headers \
|
||||
make \
|
||||
mesa \
|
||||
mesa-dev \
|
||||
meson \
|
||||
musl-dev \
|
||||
ninja \
|
||||
openal-soft-dev \
|
||||
openal-soft-libs \
|
||||
openssl \
|
||||
patch \
|
||||
perl \
|
||||
pkgconfig \
|
||||
rsync \
|
||||
tcl \
|
||||
tcl-dev \
|
||||
texinfo \
|
||||
wget \
|
||||
xz \
|
||||
xz-dev \
|
||||
xz-libs \
|
||||
zlib \
|
||||
zlib-dev \
|
||||
zlib-static \
|
||||
zstd \
|
||||
zstd-dev \
|
||||
zstd-libs \
|
||||
zstd-static \
|
||||
xz-static
|
||||
|
||||
RUN ln -sf /usr/bin/aclocal-1.17 /usr/bin/aclocal-1.16
|
||||
RUN ln -sf /usr/bin/automake-1.17 /usr/bin/automake-1.16
|
86
docker/x86_64/alpine
Normal file
86
docker/x86_64/alpine
Normal file
@ -0,0 +1,86 @@
|
||||
#comment
|
||||
FROM alpine:3.21.3
|
||||
MAINTAINER Scott E. Graves <scott.e.graves@protonmail.com>
|
||||
CMD bash
|
||||
|
||||
RUN apk update
|
||||
RUN apk upgrade
|
||||
RUN apk add \
|
||||
autoconf \
|
||||
automake \
|
||||
bash \
|
||||
binutils \
|
||||
binutils-dev \
|
||||
bison \
|
||||
boost-dev \
|
||||
bzip2-static \
|
||||
cmake \
|
||||
diffutils \
|
||||
elfutils-dev \
|
||||
file \
|
||||
fontconfig-dev \
|
||||
fontconfig-static \
|
||||
freetype \
|
||||
freetype-dev \
|
||||
freetype-static \
|
||||
fuse3 \
|
||||
fuse3-dev \
|
||||
fuse3-static \
|
||||
g++ \
|
||||
gcc \
|
||||
gflags \
|
||||
gflags-dev \
|
||||
git \
|
||||
icu-dev \
|
||||
icu-libs \
|
||||
icu-static \
|
||||
libogg-dev \
|
||||
libogg-static \
|
||||
libtool \
|
||||
libudev-zero \
|
||||
libudev-zero-dev \
|
||||
libunwind \
|
||||
libunwind-dev \
|
||||
libunwind-static \
|
||||
liburing \
|
||||
liburing-dev \
|
||||
libvorbis-dev \
|
||||
libvorbis-static \
|
||||
libx11-dev \
|
||||
libx11-static \
|
||||
libxcursor \
|
||||
libxcursor-dev \
|
||||
libxrandr \
|
||||
libxrandr-dev \
|
||||
linux-headers \
|
||||
make \
|
||||
mesa \
|
||||
mesa-dev \
|
||||
meson \
|
||||
musl-dev \
|
||||
ninja \
|
||||
openal-soft-dev \
|
||||
openal-soft-libs \
|
||||
openssl \
|
||||
patch \
|
||||
perl \
|
||||
pkgconfig \
|
||||
rsync \
|
||||
tcl \
|
||||
tcl-dev \
|
||||
texinfo \
|
||||
wget \
|
||||
xz \
|
||||
xz-dev \
|
||||
xz-libs \
|
||||
zlib \
|
||||
zlib-dev \
|
||||
zlib-static \
|
||||
zstd \
|
||||
zstd-dev \
|
||||
zstd-libs \
|
||||
zstd-static \
|
||||
xz-static
|
||||
|
||||
RUN ln -sf /usr/bin/aclocal-1.17 /usr/bin/aclocal-1.16
|
||||
RUN ln -sf /usr/bin/automake-1.17 /usr/bin/automake-1.16
|
1119
docker/x86_64/mingw64
Normal file
1119
docker/x86_64/mingw64
Normal file
File diff suppressed because it is too large
Load Diff
67
monitarr/libmonitarr/include/data_db.hpp
Normal file
67
monitarr/libmonitarr/include/data_db.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef LIBMONITARR_INCLUDE_DATA_DB_HPP_
|
||||
#define LIBMONITARR_INCLUDE_DATA_DB_HPP_
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace monitarr {
|
||||
struct data_entry final {
|
||||
std::string download_id;
|
||||
std::uint64_t last_check{};
|
||||
std::uint64_t size_left{};
|
||||
};
|
||||
|
||||
class data_db final {
|
||||
public:
|
||||
data_db() noexcept = default;
|
||||
data_db(const data_db &) noexcept = default;
|
||||
data_db(data_db &&) noexcept = default;
|
||||
|
||||
auto operator=(const data_db &) noexcept -> data_db & = default;
|
||||
auto operator=(data_db &&) noexcept -> data_db & = default;
|
||||
|
||||
~data_db() noexcept;
|
||||
|
||||
private:
|
||||
std::shared_ptr<rocksdb::TransactionDB> db_;
|
||||
|
||||
private:
|
||||
[[nodiscard]] auto
|
||||
perform_action(std::string_view function_name,
|
||||
std::function<rocksdb::Status(rocksdb::TransactionDB *tx_db)>
|
||||
action) const -> bool;
|
||||
|
||||
[[nodiscard]] auto perform_action(
|
||||
std::string_view function_name,
|
||||
std::function<rocksdb::Status(rocksdb::Transaction *txn)> action) -> bool;
|
||||
|
||||
public:
|
||||
void close();
|
||||
|
||||
[[nodiscard]] auto get(std::string_view download_id) const
|
||||
-> std::optional<data_entry>;
|
||||
|
||||
void open(std::string_view data_dir);
|
||||
|
||||
void remove(std::string_view download_id);
|
||||
|
||||
void set(const data_entry &entry);
|
||||
};
|
||||
} // namespace monitarr
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN template <>
|
||||
struct adl_serializer<monitarr::data_entry> {
|
||||
static void to_json(json &data, const monitarr::data_entry &value) {
|
||||
data["download_id"] = value.download_id;
|
||||
data["last_check"] = value.last_check;
|
||||
data["size_left"] = value.size_left;
|
||||
}
|
||||
|
||||
static void from_json(const json &data, monitarr::data_entry &value) {
|
||||
data.at("download_id").get_to(value.download_id);
|
||||
data.at("last_check").get_to(value.last_check);
|
||||
data.at("size_left").get_to(value.size_left);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // LIBMONITARR_INCLUDE_DATA_DB_HPP_
|
10
monitarr/libmonitarr/include/initialize.hpp
Normal file
10
monitarr/libmonitarr/include/initialize.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef LIBMONITARR_INCLUDE_INITIALIZE_HPP_
|
||||
#define LIBMONITARR_INCLUDE_INITIALIZE_HPP_
|
||||
|
||||
namespace monitarr {
|
||||
void project_cleanup();
|
||||
|
||||
[[nodiscard]] auto project_initialize() -> bool;
|
||||
} // namespace monitarr
|
||||
|
||||
#endif // LIBMONITARR_INCLUDE_INITIALIZE_HPP_
|
89
monitarr/libmonitarr/include/settings.hpp
Normal file
89
monitarr/libmonitarr/include/settings.hpp
Normal file
@ -0,0 +1,89 @@
|
||||
#ifndef LIBMONITARR_INCLUDE_SETTINGS_HPP_
|
||||
#define LIBMONITARR_INCLUDE_SETTINGS_HPP_
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace monitarr {
|
||||
inline constexpr const auto default_interval{
|
||||
std::chrono::minutes{5U},
|
||||
};
|
||||
|
||||
inline constexpr const auto default_timeout{
|
||||
std::chrono::minutes{24U * 60U},
|
||||
};
|
||||
|
||||
struct server_cfg final {
|
||||
std::string id;
|
||||
std::string api_key;
|
||||
std::string api_version;
|
||||
std::chrono::minutes timeout{default_timeout};
|
||||
std::string url;
|
||||
};
|
||||
|
||||
struct app_config final {
|
||||
std::chrono::minutes check_interval{default_interval};
|
||||
std::vector<server_cfg> server_list{
|
||||
server_cfg{
|
||||
"lidarr",
|
||||
"7228e4739091469db81acfe2b97aa973",
|
||||
"v1",
|
||||
std::chrono::minutes(1440),
|
||||
"http://192.168.1.60:8686",
|
||||
},
|
||||
server_cfg{
|
||||
"radarr",
|
||||
"affa8c547cee48e0b8c49994c0aaa931",
|
||||
"v3",
|
||||
std::chrono::minutes(1440),
|
||||
"http://192.168.1.60:7878",
|
||||
},
|
||||
server_cfg{
|
||||
"sonarr",
|
||||
"ead2cdf34f774ad1b8185271c733c5ad",
|
||||
"v3",
|
||||
std::chrono::minutes(1440),
|
||||
"http://192.168.1.60:8989",
|
||||
},
|
||||
};
|
||||
|
||||
void load(std::string_view file_path);
|
||||
|
||||
void save(std::string_view file_path) const;
|
||||
};
|
||||
} // namespace monitarr
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
template <> struct adl_serializer<monitarr::server_cfg> {
|
||||
static void to_json(json &data, const monitarr::server_cfg &value) {
|
||||
data["id"] = value.id;
|
||||
data["api_key"] = value.api_key;
|
||||
data["api_version"] = value.api_version;
|
||||
data["timeout_minutes"] = value.timeout.count();
|
||||
data["url"] = value.url;
|
||||
}
|
||||
|
||||
static void from_json(const json &data, monitarr::server_cfg &value) {
|
||||
data.at("id").get_to(value.id);
|
||||
data.at("api_key").get_to(value.api_key);
|
||||
data.at("api_version").get_to(value.api_version);
|
||||
value.timeout =
|
||||
std::chrono::minutes(data.at("timeout_minutes").get<std::int32_t>());
|
||||
data.at("url").get_to(value.url);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct adl_serializer<monitarr::app_config> {
|
||||
static void to_json(json &data, const monitarr::app_config &value) {
|
||||
data["check_interval_minutes"] = value.check_interval.count();
|
||||
data["server_list"] = value.server_list;
|
||||
}
|
||||
|
||||
static void from_json(const json &data, monitarr::app_config &value) {
|
||||
value.check_interval = std::chrono::minutes(
|
||||
data.at("check_interval_minutes").get<std::int32_t>());
|
||||
data.at("server_list").get_to(value.server_list);
|
||||
}
|
||||
};
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
|
||||
#endif // LIBMONITARR_INCLUDE_SETTINGS_HPP_
|
12
monitarr/libmonitarr/include/version.hpp
Normal file
12
monitarr/libmonitarr/include/version.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef LIBMONITARR_INCLUDE_VERSION_HPP_
|
||||
#define LIBMONITARR_INCLUDE_VERSION_HPP_
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace monitarr {
|
||||
[[nodiscard]] auto project_get_git_rev() -> std::string_view;
|
||||
|
||||
[[nodiscard]] auto project_get_version() -> std::string_view;
|
||||
} // namespace monitarr
|
||||
|
||||
#endif // LIBMONITARR_INCLUDE_VERSION_HPP_
|
131
monitarr/libmonitarr/src/data_db.cpp
Normal file
131
monitarr/libmonitarr/src/data_db.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
#include "data_db.hpp"
|
||||
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/path.hpp"
|
||||
|
||||
namespace monitarr {
|
||||
data_db::~data_db() noexcept { close(); }
|
||||
|
||||
void data_db::close() {
|
||||
if (db_) {
|
||||
db_->Close();
|
||||
db_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
auto data_db::get(std::string_view download_id) const
|
||||
-> std::optional<data_entry> {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
std::optional<data_entry> ret;
|
||||
if (not perform_action(
|
||||
function_name,
|
||||
[&download_id, &ret](rocksdb::TransactionDB *txn_db) -> auto {
|
||||
std::string value;
|
||||
auto res = txn_db->Get(rocksdb::ReadOptions{}, download_id, &value);
|
||||
if (res.ok()) {
|
||||
ret = nlohmann::json::parse(value).get<data_entry>();
|
||||
}
|
||||
|
||||
return res.IsNotFound() ? rocksdb::Status{} : res;
|
||||
})) {
|
||||
fmt::println("failed to get|{}", download_id);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void data_db::open(std::string_view data_dir) {
|
||||
auto db_path = utils::path::combine(data_dir, {"state_db"});
|
||||
fmt::println("opening database|{}", db_path);
|
||||
|
||||
rocksdb::Options options{};
|
||||
options.create_if_missing = true;
|
||||
options.create_missing_column_families = true;
|
||||
options.db_log_dir = data_dir;
|
||||
options.keep_log_file_num = 10;
|
||||
|
||||
rocksdb::TransactionDB *ptr{};
|
||||
auto status = rocksdb::TransactionDB::Open(
|
||||
options, rocksdb::TransactionDBOptions{}, db_path, &ptr);
|
||||
if (not status.ok()) {
|
||||
throw std::runtime_error(fmt::format("failed to open database|{}|{}",
|
||||
db_path, status.ToString()));
|
||||
}
|
||||
|
||||
db_ = std::shared_ptr<rocksdb::TransactionDB>(ptr);
|
||||
}
|
||||
|
||||
auto data_db::perform_action(
|
||||
std::string_view function_name,
|
||||
std::function<rocksdb::Status(rocksdb::TransactionDB *tx_db)> action) const
|
||||
-> bool {
|
||||
try {
|
||||
auto res = action(db_.get());
|
||||
if (not res.ok()) {
|
||||
utils::error::handle_error(function_name, res.ToString());
|
||||
}
|
||||
|
||||
return res.ok();
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::handle_exception(function_name, ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
auto data_db::perform_action(
|
||||
std::string_view function_name,
|
||||
std::function<rocksdb::Status(rocksdb::Transaction *txn)> action) -> bool {
|
||||
std::unique_ptr<rocksdb::Transaction> txn{
|
||||
db_->BeginTransaction(rocksdb::WriteOptions{},
|
||||
rocksdb::TransactionOptions{}),
|
||||
};
|
||||
|
||||
try {
|
||||
auto res = action(txn.get());
|
||||
if (res.ok()) {
|
||||
auto commit_res = txn->Commit();
|
||||
if (commit_res.ok()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
utils::error::handle_error(function_name,
|
||||
"rocksdb commit failed|" + res.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
utils::error::handle_error(function_name,
|
||||
"rocksdb action failed|" + res.ToString());
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::handle_exception(function_name, ex);
|
||||
}
|
||||
|
||||
auto rollback_res = txn->Rollback();
|
||||
utils::error::handle_error(function_name, "rocksdb rollback failed|" +
|
||||
rollback_res.ToString());
|
||||
return false;
|
||||
}
|
||||
|
||||
void data_db::remove(std::string_view download_id) {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
if (not perform_action(function_name,
|
||||
[&download_id](rocksdb::Transaction *txn) -> auto {
|
||||
return txn->Delete(download_id);
|
||||
})) {
|
||||
fmt::println("failed to remove|{}", download_id);
|
||||
}
|
||||
}
|
||||
|
||||
void data_db::set(const data_entry &entry) {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
if (not perform_action(
|
||||
function_name, [&entry](rocksdb::Transaction *txn) -> auto {
|
||||
return txn->Put(entry.download_id, nlohmann::json(entry).dump());
|
||||
})) {
|
||||
fmt::println("failed to set|{}", nlohmann::json(entry).dump(2));
|
||||
}
|
||||
}
|
||||
} // namespace monitarr
|
90
monitarr/libmonitarr/src/initialize.cpp
Normal file
90
monitarr/libmonitarr/src/initialize.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
#include "curl/curl.h"
|
||||
#endif // defined(PROJECT_ENABLE_CURL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_OPENSSL)
|
||||
#include "openssl/ssl.h"
|
||||
#endif // defined(PROJECT_ENABLE_OPENSSL)
|
||||
|
||||
#if defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
|
||||
#include <filesystem>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#endif // defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "sodium.h"
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#include "sqlite3.h"
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#include "initialize.hpp"
|
||||
|
||||
#if defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
|
||||
#include "utils/path.hpp"
|
||||
#endif // defined(PROJECT_REQUIRE_ALPINE) && !defined (PROJECT_IS_MINGW)
|
||||
|
||||
namespace monitarr {
|
||||
auto project_initialize() -> bool {
|
||||
#if defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
|
||||
{
|
||||
static constexpr const auto guard_size{4096U};
|
||||
static constexpr const auto stack_size{8U * 1024U * 1024U};
|
||||
|
||||
pthread_attr_t attr{};
|
||||
pthread_attr_setstacksize(&attr, stack_size);
|
||||
pthread_attr_setguardsize(&attr, guard_size);
|
||||
pthread_setattr_default_np(&attr);
|
||||
|
||||
setenv("ICU_DATA", utils::path::combine(".", {"/icu"}).c_str(), 1);
|
||||
}
|
||||
#endif // defined(PROJECT_REQUIRE_ALPINE) && !defined(PROJECT_IS_MINGW)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
{
|
||||
if (sodium_init() == -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
#if defined(PROJECT_ENABLE_OPENSSL)
|
||||
{ SSL_library_init(); }
|
||||
#endif // defined(PROJECT_ENABLE_OPENSSL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
{
|
||||
auto res = curl_global_init(CURL_GLOBAL_ALL);
|
||||
if (res != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_CURL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
{
|
||||
auto res = sqlite3_initialize();
|
||||
if (res != SQLITE_OK) {
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
curl_global_cleanup();
|
||||
#endif // defined(PROJECT_ENABLE_CURL)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void project_cleanup() {
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
curl_global_cleanup();
|
||||
#endif // defined(PROJECT_ENABLE_CURL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
sqlite3_shutdown();
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
}
|
||||
} // namespace monitarr
|
18
monitarr/libmonitarr/src/settings.cpp
Normal file
18
monitarr/libmonitarr/src/settings.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "utils/file.hpp"
|
||||
|
||||
namespace monitarr {
|
||||
void app_config::load(std::string_view file_path) {
|
||||
nlohmann::json data;
|
||||
if (utils::file::read_json_file(file_path, data)) {
|
||||
*this = data.get<app_config>();
|
||||
}
|
||||
}
|
||||
|
||||
void app_config::save(std::string_view file_path) const {
|
||||
if (utils::file::write_json_file(file_path, nlohmann::json(*this))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace monitarr
|
260
monitarr/monitarr/main.cpp
Normal file
260
monitarr/monitarr/main.cpp
Normal file
@ -0,0 +1,260 @@
|
||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
#include "backward.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
|
||||
#include <execution>
|
||||
|
||||
#include "initialize.hpp"
|
||||
|
||||
#include "data_db.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/config.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/path.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#include "utils/unix.hpp"
|
||||
#include "utils/windows.hpp"
|
||||
|
||||
namespace monitarr {
|
||||
static void remove_stalled(std::string_view download_id, std::string_view title,
|
||||
std::uint64_t episode_id, std::uint64_t movie_id,
|
||||
const server_cfg &server, data_db &state_db) {
|
||||
fmt::println("remove and block {}|{}", download_id, title);
|
||||
state_db.remove(download_id);
|
||||
|
||||
httplib::Client cli{server.url};
|
||||
cli.set_default_headers({
|
||||
{"X-Api-Key", server.api_key},
|
||||
});
|
||||
|
||||
auto response = cli.Delete(
|
||||
fmt::format("/api/{}/queue/{}?blocklist=true&skipRedownload=false",
|
||||
server.api_version,
|
||||
utils::string::split(download_id, '/', false).at(1U)));
|
||||
if (response->status != httplib::StatusCode::OK_200) {
|
||||
fmt::println("remove and block result|{}|{}", server.url, response->status);
|
||||
return;
|
||||
}
|
||||
|
||||
if (utils::string::contains("radarr", server.id)) {
|
||||
nlohmann::json data({
|
||||
{"name", "MoviesSearch"},
|
||||
{"movieIds", {movie_id}},
|
||||
});
|
||||
|
||||
response = cli.Post("/api/{}/command", data.dump(), "application/json");
|
||||
if (response->status != httplib::StatusCode::OK_200) {
|
||||
fmt::println("failed to search radarr|{}|{}", server.url,
|
||||
response->status);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (utils::string::contains("sonarr", server.id)) {
|
||||
nlohmann::json data({
|
||||
{"name", "EpisodeSearch"},
|
||||
{"episodeIds", {episode_id}},
|
||||
});
|
||||
|
||||
response = cli.Post("/api/{}/command", data.dump(), "application/json");
|
||||
if (response->status != httplib::StatusCode::OK_200) {
|
||||
fmt::println("failed to search sonarr|{}|{}", server.url,
|
||||
response->status);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void check_server(const server_cfg &server, data_db &state_db) {
|
||||
httplib::Client cli{server.url};
|
||||
cli.set_default_headers({
|
||||
{"X-Api-Key", server.api_key},
|
||||
});
|
||||
|
||||
std::uint16_t page{0U};
|
||||
while (++page != 0U) {
|
||||
httplib::Params params;
|
||||
params.emplace("page", std::to_string(page));
|
||||
params.emplace("pageSize", "50");
|
||||
|
||||
auto response =
|
||||
cli.Get(fmt::format("/api/{}/queue", server.api_version), params, {});
|
||||
if (response->status != httplib::StatusCode::OK_200) {
|
||||
fmt::println("check server request failed|{}|{}", server.url,
|
||||
response->status);
|
||||
break;
|
||||
}
|
||||
|
||||
auto json_data = nlohmann::json::parse(response->body);
|
||||
if (json_data.at("page").get<std::uint32_t>() != page) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto now = utils::time::get_time_now();
|
||||
|
||||
for (const auto &record : json_data.at("records")) {
|
||||
auto download_id = fmt::format(
|
||||
"{}/{}", server.id, record.at("downloadId").get<std::string>());
|
||||
auto episode_id = record.contains("episodeId")
|
||||
? record["episodeId"].get<std::uint64_t>()
|
||||
: std::uint64_t{0U};
|
||||
auto movie_id = record.contains("movieId")
|
||||
? record["movieId"].get<std::uint64_t>()
|
||||
: std::uint64_t{0U};
|
||||
auto size_left = record.at("sizeleft").get<std::uint64_t>();
|
||||
auto title = record.at("title").get<std::string>();
|
||||
|
||||
auto data = state_db.get(download_id);
|
||||
const auto update_entry = [&download_id, &now, &size_left, &state_db,
|
||||
&title, url = server.url]() {
|
||||
if (size_left == 0U) {
|
||||
state_db.remove(download_id);
|
||||
return;
|
||||
}
|
||||
|
||||
fmt::println("updating {}|{}|{}|{}", download_id, title, now,
|
||||
size_left);
|
||||
state_db.set(data_entry{
|
||||
download_id,
|
||||
now,
|
||||
size_left,
|
||||
});
|
||||
};
|
||||
|
||||
if (data.has_value()) {
|
||||
if (std::chrono::nanoseconds(now - data->last_check) >=
|
||||
server.timeout) {
|
||||
if (size_left == data->size_left) {
|
||||
remove_stalled(download_id, title, episode_id, movie_id, server,
|
||||
state_db);
|
||||
} else {
|
||||
update_entry();
|
||||
}
|
||||
} else if (size_left == 0U) {
|
||||
state_db.remove(download_id);
|
||||
}
|
||||
} else {
|
||||
update_entry();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] static auto load_config(std::string &cfg_file) -> app_config {
|
||||
auto cfg_dir = utils::get_environment_variable("MONITARR_CFG_DIR");
|
||||
if (cfg_dir.empty()) {
|
||||
cfg_dir = utils::path::combine(".", {"config"});
|
||||
}
|
||||
|
||||
if (not utils::file::directory{cfg_dir}.create_directory()) {
|
||||
throw std::runtime_error(fmt::format("failed to create config dir|{}",
|
||||
cfg_dir,
|
||||
utils::get_last_error_code()));
|
||||
}
|
||||
|
||||
cfg_file = utils::path::combine(cfg_dir, {"monitarr.json"});
|
||||
|
||||
fmt::println("loading config|{}", cfg_file);
|
||||
app_config cfg{};
|
||||
cfg.load(cfg_file);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
[[nodiscard]] static auto load_db() -> data_db {
|
||||
auto data_dir = utils::get_environment_variable("MONITARR_DATA_DIR");
|
||||
if (data_dir.empty()) {
|
||||
data_dir = utils::path::combine(".", {"data"});
|
||||
}
|
||||
|
||||
if (not utils::file::directory{data_dir}.create_directory()) {
|
||||
throw std::runtime_error(fmt::format("failed to create data dir|{}",
|
||||
data_dir,
|
||||
utils::get_last_error_code()));
|
||||
}
|
||||
|
||||
data_db state_db{};
|
||||
state_db.open(data_dir);
|
||||
return state_db;
|
||||
}
|
||||
} // namespace monitarr
|
||||
|
||||
using namespace monitarr;
|
||||
|
||||
auto main(int /* argc */, char ** /* argv */) -> int {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
static backward::SignalHandling sh;
|
||||
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
|
||||
if (not monitarr::project_initialize()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static std::mutex mtx;
|
||||
static std::condition_variable notify;
|
||||
static stop_type stop_requested{false};
|
||||
|
||||
static const auto quit_handler = [](int sig) {
|
||||
fmt::println("stop requested|{}", sig);
|
||||
stop_requested = true;
|
||||
|
||||
mutex_lock lock(mtx);
|
||||
notify.notify_all();
|
||||
};
|
||||
|
||||
std::signal(SIGINT, quit_handler);
|
||||
std::signal(SIGQUIT, quit_handler);
|
||||
std::signal(SIGTERM, quit_handler);
|
||||
|
||||
auto ret{0};
|
||||
|
||||
try {
|
||||
std::string cfg_file;
|
||||
auto cfg{load_config(cfg_file)};
|
||||
auto state_db{load_db()};
|
||||
|
||||
if (cfg.server_list.empty()) {
|
||||
fmt::println("no servers have been configured");
|
||||
ret = 3;
|
||||
} else {
|
||||
while (not stop_requested) {
|
||||
std::for_each(std::execution::par, cfg.server_list.begin(),
|
||||
cfg.server_list.end(), [&state_db](auto &&server) {
|
||||
if (stop_requested) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
check_server(server, state_db);
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::handle_exception(function_name, ex);
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
}
|
||||
});
|
||||
unique_mutex_lock lock(mtx);
|
||||
if (stop_requested) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fmt::println("waiting for next check|{}", cfg.check_interval);
|
||||
notify.wait_for(lock, cfg.check_interval);
|
||||
}
|
||||
}
|
||||
|
||||
cfg.save(cfg_file);
|
||||
state_db.close();
|
||||
} catch (const std::exception &ex) {
|
||||
utils::error::handle_exception(function_name, ex);
|
||||
ret = 2;
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
ret = 2;
|
||||
}
|
||||
|
||||
fmt::println("terminating application|{}", ret);
|
||||
monitarr::project_cleanup();
|
||||
return ret;
|
||||
}
|
29
monitarr/monitarr_test/main.cpp
Normal file
29
monitarr/monitarr_test/main.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
#include "backward.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "initialize.hpp"
|
||||
#include "utils/config.hpp"
|
||||
|
||||
using namespace monitarr;
|
||||
|
||||
int PROJECT_TEST_RESULT{0};
|
||||
|
||||
auto main(int argc, char **argv) -> int {
|
||||
#if defined(PROJECT_ENABLE_BACKWARD_CPP)
|
||||
static backward::SignalHandling sh;
|
||||
#endif
|
||||
|
||||
if (not monitarr::project_initialize()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
PROJECT_TEST_RESULT = RUN_ALL_TESTS();
|
||||
|
||||
monitarr::project_cleanup();
|
||||
|
||||
return PROJECT_TEST_RESULT;
|
||||
}
|
14
monitarr/version.cpp.in
Normal file
14
monitarr/version.cpp.in
Normal file
@ -0,0 +1,14 @@
|
||||
#include "version.hpp"
|
||||
|
||||
namespace {
|
||||
static constexpr const std::string_view git_rev = "@PROJECT_GIT_REV@";
|
||||
static constexpr const std::string_view version =
|
||||
"@PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@"
|
||||
"-@PROJECT_RELEASE_ITER@";
|
||||
} // namespace
|
||||
|
||||
namespace monitarr {
|
||||
auto project_get_git_rev() -> std::string_view { return git_rev; }
|
||||
|
||||
auto project_get_version() -> std::string_view { return version; }
|
||||
} // namespace monitarr
|
64
monitarr/version.rc.in
Normal file
64
monitarr/version.rc.in
Normal file
@ -0,0 +1,64 @@
|
||||
#include <windows.h>
|
||||
#define VER_FILEVERSION @PROJECT_MAJOR_VERSION@,@PROJECT_MINOR_VERSION@,@PROJECT_REVISION_VERSION@,@PROJECT_RELEASE_NUM@
|
||||
#define VER_FILEVERSION_STR "@PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@-@PROJECT_RELEASE_ITER@_@PROJECT_GIT_REV@\0"
|
||||
|
||||
#define VER_PRODUCTVERSION @PROJECT_MAJOR_VERSION@,@PROJECT_MINOR_VERSION@,@PROJECT_REVISION_VERSION@,@PROJECT_RELEASE_NUM@
|
||||
#define VER_PRODUCTVERSION_STR "@PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@-@PROJECT_RELEASE_ITER@_@PROJECT_GIT_REV@\0"
|
||||
|
||||
#define VER_COMPANYNAME_STR "@PROJECT_COMPANY_NAME@\0"
|
||||
#define VER_INTERNALNAME_STR "@PROJECT_NAME@ @PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@-@PROJECT_RELEASE_ITER@_@PROJECT_GIT_REV@\0"
|
||||
#define VER_LEGALCOPYRIGHT_STR "@PROJECT_COPYRIGHT@\0"
|
||||
#define VER_ORIGINALFILENAME_STR "@PROJECT_NAME@.exe\0"
|
||||
#define VER_LEGALTRADEMARKS1_STR "\0"
|
||||
#define VER_LEGALTRADEMARKS2_STR "\0"
|
||||
#define VER_FILEDESCRIPTION_STR "@PROJECT_DESC@\0"
|
||||
#define VER_PRODUCTNAME_STR "@PROJECT_NAME@ @PROJECT_MAJOR_VERSION@.@PROJECT_MINOR_VERSION@.@PROJECT_REVISION_VERSION@-@PROJECT_RELEASE_ITER@_@PROJECT_GIT_REV@\0"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define VER_DEBUG VS_FF_DEBUG
|
||||
#else
|
||||
#define VER_DEBUG 0
|
||||
#endif
|
||||
|
||||
#define VER_PRERELEASE @PROJECT_PRERELEASE@
|
||||
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VER_FILEVERSION
|
||||
PRODUCTVERSION VER_PRODUCTVERSION
|
||||
FILEFLAGSMASK (VS_FF_DEBUG|VS_FF_PRERELEASE)
|
||||
FILEFLAGS (VER_DEBUG|VER_PRERELEASE)
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", VER_COMPANYNAME_STR
|
||||
VALUE "FileDescription", VER_FILEDESCRIPTION_STR
|
||||
VALUE "FileVersion", VER_FILEVERSION_STR
|
||||
VALUE "InternalName", VER_INTERNALNAME_STR
|
||||
VALUE "LegalCopyright", VER_LEGALCOPYRIGHT_STR
|
||||
VALUE "LegalTrademarks1", VER_LEGALTRADEMARKS1_STR
|
||||
VALUE "LegalTrademarks2", VER_LEGALTRADEMARKS2_STR
|
||||
VALUE "OriginalFilename", VER_ORIGINALFILENAME_STR
|
||||
VALUE "ProductName", VER_PRODUCTNAME_STR
|
||||
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
|
||||
END
|
||||
END
|
||||
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
/* The following line should only be modified for localized versions. */
|
||||
/* It consists of any number of WORD,WORD pairs, with each pair */
|
||||
/* describing a language,codepage combination supported by the file. */
|
||||
/* */
|
||||
/* For example, a file might have values "0x409,1252" indicating that it */
|
||||
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
|
||||
|
||||
VALUE "Translation", 0x409, 1252
|
||||
|
||||
END
|
||||
END
|
5
project.cmake
Normal file
5
project.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
add_project_library(lib${PROJECT_NAME} "" "" "${PROJECT_ADDITIONAL_SOURCES}")
|
||||
|
||||
add_project_executable(${PROJECT_NAME} lib${PROJECT_NAME} lib${PROJECT_NAME})
|
||||
|
||||
add_project_test_executable(${PROJECT_NAME}_test lib${PROJECT_NAME} lib${PROJECT_NAME})
|
206
scripts/copy_mingw64_deps.sh
Executable file
206
scripts/copy_mingw64_deps.sh
Executable file
@ -0,0 +1,206 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES=()
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 1>/dev/null 2>&1
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_STATIC_LINK}" == "OFF" ]; then
|
||||
mkdir -p "${PROJECT_DIST_DIR}"
|
||||
rm -f ${PROJECT_DIST_DIR}/*.dll
|
||||
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libgcc_s_seh-1.dll
|
||||
/mingw64/bin/libstdc++-6.dll
|
||||
/mingw64/bin/libwinpthread-1.dll
|
||||
/mingw64/bin/libzlib1.dll
|
||||
/mingw64/bin/zlib1.dll
|
||||
)
|
||||
|
||||
if [ "${PROJECT_ENABLE_BACKWARD_CPP}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/msvcr90.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_BOOST}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libboost*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CLI11}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libcli11*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CURL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libcurl*.dll
|
||||
/mingw64/bin/libnghttp2-*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FLAC}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libFLAC*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FMT}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libfmt*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FONTCONFIG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libexpat*.dll
|
||||
/mingw64/bin/libfontconfig*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FREETYPE2}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libfreetype*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBDSM}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libdsm.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBEVENT}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libevent*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBICONV}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libiconv.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBJPEG_TURBO}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libjpeg*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libturbo*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBPNG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpng*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBSODIUM}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsodium*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_NANA}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libnana*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_NUSPELL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libnuspell-*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OGG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libogg*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OPENAL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libopenal*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OPENSSL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libssl*.dll
|
||||
/mingw64/bin/libcrypt*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_PUGIXML}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpugi*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SDL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/SDL2*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SECP256K1}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsecp256k1*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SFML}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsfml*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SPDLOG}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libspdlog*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SQLITE}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsqlite3-*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TASN}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtasn1.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TESTING}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libgtest*.dll
|
||||
/mingw64/bin/libgmock*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TPL}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtiny-process*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_VORBIS}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libvorbis*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libLerc.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libsharpyuv-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libdeflate.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libglib-2*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libgraphite2.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libharfbuzz-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libjbig-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libpcre2-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libtiff-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwebp-*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/libwxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/wxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/bin/wxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/libwxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/libwxm*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/wxbase*.dll)
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(/mingw64/lib/gcc_x64_dll/wxm*.dll)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SDL}" == "ON" ] || [ "${PROJECT_ENABLE_SFML}" == "ON" ] ||
|
||||
[ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ] || [ "${PROJECT_ENABLE_NANA}" == "ON" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(
|
||||
/mingw64/bin/libOpenCL*.dll
|
||||
/mingw64/bin/libopencl*.dll
|
||||
/mingw64/bin/libgallium_wgl.dll
|
||||
/mingw64/bin/libva*.dll
|
||||
/mingw64/bin/opengl*.dll
|
||||
/mingw64/bin/vulkan*.dll
|
||||
)
|
||||
fi
|
||||
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/bin/*.dll "${PROJECT_DIST_DIR}/"
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/lib/*.dll "${PROJECT_DIST_DIR}/"
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/lib/gcc_x64_dll/*.dll "${PROJECT_DIST_DIR}/"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_WINFSP}" == "ON" ]; then
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "x86_64" ]; then
|
||||
WINFSP_DLL_PART=x64
|
||||
fi
|
||||
|
||||
if [ "${WINFSP_DLL_PART}" != "" ]; then
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES+=(${PROJECT_3RD_PARTY_DIR}/winfsp-2.0/bin/winfsp-${WINFSP_DLL_PART}.dll)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_VLC}" == "ON" ]; then
|
||||
rsync -av --progress ${PROJECT_3RD_PARTY_DIR}/vlc/ "${PROJECT_DIST_DIR}/vlc/"
|
||||
fi
|
||||
|
||||
for PROJECT_DEPENDENCY in "${PROJECT_MINGW64_COPY_DEPENDENCIES[@]}"; do
|
||||
rsync -av --progress ${PROJECT_DEPENDENCY} "${PROJECT_DIST_DIR}/"
|
||||
done
|
25
scripts/create_containers.sh
Executable file
25
scripts/create_containers.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 1 1>/dev/null 2>&1
|
||||
|
||||
if [ -f "${PROJECT_SCRIPTS_DIR}/cleanup.sh" ]; then
|
||||
. "${PROJECT_SCRIPTS_DIR}/cleanup.sh" "$1" "$2" "$3" "$4" "$5"
|
||||
rm ${PROJECT_SCRIPTS_DIR}/cleanup.*
|
||||
fi
|
||||
|
||||
function create_containers() {
|
||||
BUILD_TYPE=$1
|
||||
|
||||
for FILE in "${PROJECT_SOURCE_DIR}/docker/${BUILD_TYPE}/*"; do
|
||||
DOCKER_CREATE_ONLY=1
|
||||
DOCKER_NAME=$(basename ${FILE})
|
||||
DOCKER_TAG=${PROJECT_NAME}:${DOCKER_NAME}
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/docker_common.sh"
|
||||
done
|
||||
}
|
||||
|
||||
create_containers aarch64
|
||||
create_containers x86_64
|
13
scripts/deliver.cmd
Normal file
13
scripts/deliver.cmd
Normal file
@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set DEST=%~1
|
||||
set DIST=%~2
|
||||
set ARG1=%~3
|
||||
set ARG2=%~4
|
||||
set ARG3=%~5
|
||||
|
||||
pushd "%~dp0%"
|
||||
call mingw64 -no-start ./deliver.sh "%DEST%" "%DIST%" "%ARG1%" "%ARG2%" "%ARG3%" 1 0 || exit 1
|
||||
popd
|
69
scripts/deliver.sh
Executable file
69
scripts/deliver.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEST_DIR=$1
|
||||
DIST_DIR=$2
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$3" "$4" "$5" "$6" "$7"
|
||||
|
||||
function error_exit() {
|
||||
echo $1
|
||||
exit $2
|
||||
}
|
||||
|
||||
if [ ! -d "${PROJECT_DIST_DIR}" ]; then
|
||||
error_exit "dist directory not found: ${PROJECT_DIST_DIR}" 2
|
||||
fi
|
||||
|
||||
if [ "${DIST_DIR}" == "" ]; then
|
||||
DIST_DIR="${PROJECT_DIST_DIR}"
|
||||
fi
|
||||
DIST_DIR=$(realpath "${DIST_DIR}")
|
||||
|
||||
if [ ! -d "${DIST_DIR}" ]; then
|
||||
error_exit "dist directory not found: ${DIST_DIR}" 2
|
||||
fi
|
||||
|
||||
if [ "${DEST_DIR}" == "" ]; then
|
||||
error_exit "dest directory not set" 2
|
||||
fi
|
||||
|
||||
if [ ! -d "${DEST_DIR}" ]; then
|
||||
error_exit "dest directory not found: ${DEST_DIR}" 2
|
||||
fi
|
||||
|
||||
pushd "${PROJECT_SOURCE_DIR}"
|
||||
BRANCH=$(git branch --show-current)
|
||||
RELEASE=$(grep PROJECT_RELEASE_ITER= ./config.sh | sed s/PROJECT_RELEASE_ITER=//g)
|
||||
popd
|
||||
|
||||
if [ "${BRANCH}" == "master" ] || [ "${BRANCH}" == "alpha" ] || [ "${BRANCH}" == "beta" ] || [ "${BRANCH}" == "rc" ]; then
|
||||
DEST_DIR=${DEST_DIR}/${RELEASE}
|
||||
else
|
||||
DEST_DIR=${DEST_DIR}/nightly
|
||||
fi
|
||||
|
||||
echo ${DEST_DIR}
|
||||
|
||||
pushd "${DIST_DIR}"
|
||||
if [ ! -f "./${PROJECT_OUT_FILE}" ]; then
|
||||
error_exit "failed to find file: ${PROJECT_OUT_FILE}" 1
|
||||
fi
|
||||
|
||||
if [ ! -f "./${PROJECT_OUT_FILE}.sha256" ]; then
|
||||
error_exit "failed to find file: ${PROJECT_OUT_FILE}.sha256" 1
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_PRIVATE_KEY}" != "" ] && [ ! -f "./${PROJECT_OUT_FILE}.sig" ]; then
|
||||
error_exit "failed to find file: ${PROJECT_OUT_FILE}.sig" 1
|
||||
fi
|
||||
|
||||
cp -f ./${PROJECT_OUT_FILE} ${DEST_DIR} || error_exit "failed to deliver file: ${PROJECT_OUT_FILE}" 1
|
||||
cp -f ./${PROJECT_OUT_FILE}.sha256 ${DEST_DIR} || error_exit "failed to deliver file: ${PROJECT_OUT_FILE}.sha256" 1
|
||||
if [ "${PROJECT_PRIVATE_KEY}" != "" ]; then
|
||||
cp -f ./${PROJECT_OUT_FILE}.sig ${DEST_DIR} || error_exit "failed to deliver file: ${PROJECT_OUT_FILE}.sig" 1
|
||||
fi
|
||||
popd
|
||||
|
||||
error_exit "delivered ${PROJECT_FILE_PART}" 0
|
60
scripts/docker_common.sh
Executable file
60
scripts/docker_common.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "aarch64" ]; then
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
fi
|
||||
|
||||
if [ "${DOCKER_NAME}" == "mingw64" ]; then
|
||||
APP_VERSION_BUILD_ARGS=${PROJECT_MINGW64_DOCKER_BUILD_ARGS}
|
||||
IS_MINGW=1
|
||||
IS_UNIX=1
|
||||
else
|
||||
IS_MINGW=0
|
||||
IS_UNIX=0
|
||||
fi
|
||||
|
||||
if [ "${DOCKER_CREATE_ONLY}" != "1" ]; then
|
||||
docker stop ${DOCKER_CONTAINER}
|
||||
docker rm ${DOCKER_CONTAINER}
|
||||
fi
|
||||
|
||||
pushd "${PROJECT_SOURCE_DIR}/support"
|
||||
cp -f ${PROJECT_SOURCE_DIR}/docker/${PROJECT_BUILD_ARCH}/${DOCKER_NAME} Dockerfile
|
||||
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "aarch64" ]; then
|
||||
docker build ${APP_VERSION_BUILD_ARGS} \
|
||||
--platform linux/arm64 \
|
||||
--build-arg NUM_JOBS=${NUM_JOBS} \
|
||||
-t ${DOCKER_TAG} . || exit 1
|
||||
else
|
||||
docker build ${APP_VERSION_BUILD_ARGS} \
|
||||
--build-arg NUM_JOBS=${NUM_JOBS} \
|
||||
-t ${DOCKER_TAG} . || exit 1
|
||||
fi
|
||||
rm Dockerfile
|
||||
popd
|
||||
|
||||
if [ "${DOCKER_CREATE_ONLY}" != "1" ]; then
|
||||
docker run -td \
|
||||
--env DEVELOPER_PRIVATE_KEY=${DEVELOPER_PRIVATE_KEY} \
|
||||
--env DEVELOPER_PUBLIC_KEY=${DEVELOPER_PUBLIC_KEY} \
|
||||
--env MY_NUM_JOBS=${NUM_JOBS} \
|
||||
--name ${DOCKER_CONTAINER} \
|
||||
-u $(id -u):$(id -g) \
|
||||
-v /.ci/${PROJECT_NAME}:/.ci/${PROJECT_NAME}:ro \
|
||||
-v ${PROJECT_SOURCE_DIR}:${PROJECT_SOURCE_DIR}:rw,z \
|
||||
-w ${PROJECT_SOURCE_DIR} \
|
||||
${DOCKER_TAG} || exit 1
|
||||
|
||||
if [ "${DOCKER_SHELL}" == "1" ]; then
|
||||
docker exec -it ${DOCKER_CONTAINER} /bin/bash
|
||||
else
|
||||
docker exec \
|
||||
${DOCKER_CONTAINER} \
|
||||
/bin/bash -c \
|
||||
"${PROJECT_SOURCE_DIR}/scripts/make_common.sh \"${PROJECT_BUILD_ARCH}\" \"${PROJECT_CMAKE_BUILD_TYPE}\" \"${PROJECT_BUILD_CLEAN}\" ${IS_MINGW} ${IS_UNIX}" || exit 1
|
||||
fi
|
||||
|
||||
docker stop ${DOCKER_CONTAINER}
|
||||
docker rm ${DOCKER_CONTAINER}
|
||||
fi
|
391
scripts/env.sh
Executable file
391
scripts/env.sh
Executable file
@ -0,0 +1,391 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_BUILD_ARCH=$1
|
||||
PROJECT_CMAKE_BUILD_TYPE=$2
|
||||
PROJECT_BUILD_CLEAN=$3
|
||||
PROJECT_IS_MINGW=$4
|
||||
PROJECT_IS_MINGW_UNIX=$5
|
||||
DISABLE_CREATE_DIRS=$6
|
||||
|
||||
PROJECT_SOURCE_DIR=${PROJECT_SCRIPTS_DIR}/..
|
||||
PROJECT_SOURCE_DIR=$(realpath "${PROJECT_SOURCE_DIR}")
|
||||
|
||||
NUM_JOBS=${MY_NUM_JOBS}
|
||||
if [[ -z "${NUM_JOBS}" ]]; then
|
||||
NUM_JOBS=$(getconf _NPROCESSORS_ONLN 2>/dev/null ||
|
||||
getconf NPROCESSORS_ONLN 2>/dev/null || echo 1)
|
||||
if [ "${NUM_JOBS}" -gt "4" ]; then
|
||||
NUM_JOBS=$(expr ${NUM_JOBS} - 2)
|
||||
elif [ "${NUM_JOBS}" -gt "1" ]; then
|
||||
NUM_JOBS=$(expr ${NUM_JOBS} - 1)
|
||||
fi
|
||||
fi
|
||||
|
||||
pushd "${PROJECT_SOURCE_DIR}"
|
||||
|
||||
PROJECT_GIT_REV=$(git rev-parse --short HEAD)
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/versions.sh"
|
||||
. "${PROJECT_SCRIPTS_DIR}/libraries.sh"
|
||||
|
||||
for PROJECT_LIBRARY in "${PROJECT_LIBRARIES[@]}"; do
|
||||
ENABLE_NAME=PROJECT_ENABLE_${PROJECT_LIBRARY}
|
||||
KEEP_NAME=PROJECT_KEEP_${PROJECT_LIBRARY}
|
||||
if [ "${PROJECT_LIBRARY}" == "TESTING" ]; then
|
||||
export ${ENABLE_NAME}=ON
|
||||
else
|
||||
export ${ENABLE_NAME}=OFF
|
||||
fi
|
||||
export ${KEEP_NAME}=0
|
||||
done
|
||||
|
||||
PROJECT_APP_LIST=()
|
||||
PROJECT_CMAKE_OPTS=""
|
||||
PROJECT_ENABLE_WIN32_LONG_PATH_NAMES=OFF
|
||||
PROJECT_IS_ALPINE=0
|
||||
PROJECT_IS_ARM64=0
|
||||
PROJECT_MINGW64_COPY_DEPENDENCIES=()
|
||||
PROJECT_MSYS2_PACKAGE_LIST=()
|
||||
PROJECT_REQUIRE_ALPINE=OFF
|
||||
PROJECT_STATIC_LINK=OFF
|
||||
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "" ]; then
|
||||
PROJECT_BUILD_ARCH=x86_64
|
||||
elif [ "${PROJECT_BUILD_ARCH}" == "aarch64" ]; then
|
||||
PROJECT_IS_ARM64=1
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_BUILD_ARCH}" == "x86_64" ]; then
|
||||
PROJECT_BUILD_ARCH2="x86-64"
|
||||
else
|
||||
PROJECT_BUILD_ARCH2="${PROJECT_BUILD_ARCH}"
|
||||
fi
|
||||
|
||||
if [ -f /etc/alpine-release ]; then
|
||||
PROJECT_IS_ALPINE=1
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "" ]; then
|
||||
PROJECT_IS_MINGW=0
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW_UNIX}" == "" ]; then
|
||||
PROJECT_IS_MINGW_UNIX=0
|
||||
fi
|
||||
|
||||
. "${PROJECT_SOURCE_DIR}/config.sh"
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "0" ]; then
|
||||
PROJECT_ENABLE_WIN32_LONG_PATH_NAMES=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SFML}" == "ON" ]; then
|
||||
PROJECT_ENABLE_FLAC=ON
|
||||
PROJECT_ENABLE_FONTCONFIG=ON
|
||||
PROJECT_ENABLE_FREETYPE2=ON
|
||||
PROJECT_ENABLE_OGG=ON
|
||||
PROJECT_ENABLE_OPENAL=ON
|
||||
PROJECT_ENABLE_VORBIS=ON
|
||||
PROJECT_STATIC_LINK=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CPP_HTTPLIB}" == "ON" ]; then
|
||||
PROJECT_ENABLE_CURL=ON
|
||||
PROJECT_ENABLE_OPENSSL=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CURL}" == "ON" ]; then
|
||||
PROJECT_ENABLE_OPENSSL=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBBITCOIN_SYSTEM}" == "ON" ]; then
|
||||
PROJECT_ENABLE_BOOST=ON
|
||||
PROJECT_ENABLE_SECP256K1=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FONTCONFIG}" == "ON" ]; then
|
||||
PROJECT_ENABLE_FREETYPE2=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
PROJECT_ENABLE_CURL=ON
|
||||
PROJECT_STATIC_LINK=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SPDLOG}" == "ON" ]; then
|
||||
PROJECT_ENABLE_FMT=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_VORBIS}" == "ON" ]; then
|
||||
PROJECT_ENABLE_OGG=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FLAC}" == "ON" ]; then
|
||||
PROJECT_ENABLE_LIBICONV=ON
|
||||
PROJECT_ENABLE_OGG=ON
|
||||
PROJECT_ENABLE_VORBIS=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_BOOST}" == "ON" ]; then
|
||||
PROJECT_ENABLE_OPENSSL=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FONTCONFIG}" == "ON" ] || [ "${PROJECT_ENABLE_NANA}" == "ON" ] ||
|
||||
[ "${PROJECT_ENABLE_SFML}" == "ON" ] || [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ] ||
|
||||
[ "${PROJECT_ENABLE_SDL}" == "ON" ]; then
|
||||
PROJECT_ENABLE_LIBJPEG_TURBO=ON
|
||||
PROJECT_ENABLE_LIBPNG=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
PROJECT_ENABLE_BACKWARD_CPP=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBDSM}" == "ON" ]; then
|
||||
PROJECT_ENABLE_LIBICONV=ON
|
||||
PROJECT_ENABLE_LIBTASN=ON
|
||||
PROJECT_ENABLE_OPENSSL=ON
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_CMAKE_BUILD_TYPE}" == "" ]; then
|
||||
PROJECT_CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
fi
|
||||
|
||||
PROJECT_CMAKE_BUILD_TYPE_LOWER=$(echo "${PROJECT_CMAKE_BUILD_TYPE}" | tr '[:upper:]' '[:lower:]')
|
||||
if [ "${PROJECT_CMAKE_BUILD_TYPE_LOWER}" == "release" ]; then
|
||||
PROJECT_CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
elif [ "${PROJECT_CMAKE_BUILD_TYPE_LOWER}" == "debug" ]; then
|
||||
PROJECT_CMAKE_BUILD_TYPE=Debug
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_IS_MINGW_UNIX}" != "1" ]; then
|
||||
PROJECT_STATIC_LINK=OFF
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_STATIC_LINK}" == "ON" ]; then
|
||||
PROJECT_BUILD_SHARED_LIBS=OFF
|
||||
PROJECT_ENABLE_BACKWARD_CPP=OFF
|
||||
PROJECT_LINK_TYPE=static
|
||||
PROJECT_REQUIRE_ALPINE=ON
|
||||
else
|
||||
PROJECT_BUILD_SHARED_LIBS=ON
|
||||
PROJECT_LINK_TYPE=shared
|
||||
PROJECT_REQUIRE_ALPINE=OFF
|
||||
fi
|
||||
|
||||
PROJECT_BUILD_DIR=${PROJECT_SOURCE_DIR}/build/${PROJECT_CMAKE_BUILD_TYPE_LOWER}/${PROJECT_LINK_TYPE}
|
||||
PROJECT_DIST_DIR=${PROJECT_SOURCE_DIR}/dist/${PROJECT_CMAKE_BUILD_TYPE_LOWER}/${PROJECT_LINK_TYPE}
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
PROJECT_DIST_DIR=${PROJECT_DIST_DIR}/win32
|
||||
PROJECT_BUILD_DIR=${PROJECT_BUILD_DIR}/win32
|
||||
else
|
||||
PROJECT_DIST_DIR=${PROJECT_DIST_DIR}/linux
|
||||
PROJECT_BUILD_DIR=${PROJECT_BUILD_DIR}/linux
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_ARM64}" == "1" ]; then
|
||||
PROJECT_DIST_DIR=${PROJECT_DIST_DIR}/aarch64
|
||||
PROJECT_BUILD_DIR=${PROJECT_BUILD_DIR}/aarch64
|
||||
else
|
||||
PROJECT_DIST_DIR=${PROJECT_DIST_DIR}/x86_64
|
||||
PROJECT_BUILD_DIR=${PROJECT_BUILD_DIR}/x86_64
|
||||
fi
|
||||
|
||||
PROJECT_DIST_DIR=${PROJECT_DIST_DIR}/${PROJECT_NAME}
|
||||
PROJECT_EXTERNAL_BUILD_ROOT=${PROJECT_BUILD_DIR}/deps
|
||||
|
||||
PROJECT_SUPPORT_DIR=${PROJECT_SOURCE_DIR}/support
|
||||
PROJECT_3RD_PARTY_DIR=${PROJECT_SUPPORT_DIR}/3rd_party
|
||||
|
||||
if [ "${PROJECT_ENABLE_OPENSSL}" == "ON" ]; then
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
OPENSSL_ROOT_DIR=/mingw64
|
||||
else
|
||||
OPENSSL_ROOT_DIR=${PROJECT_EXTERNAL_BUILD_ROOT}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_IS_MINGW_UNIX}" == "1" ]; then
|
||||
PROJECT_TOOLCHAIN_FILE_CMAKE=/cmake_toolchain.cmake
|
||||
PROJECT_TOOLCHAIN_FILE_MESON=/meson_cross_file.txt
|
||||
PROJECT_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=${PROJECT_TOOLCHAIN_FILE_CMAKE} ${PROJECT_CMAKE_OPTS}"
|
||||
fi
|
||||
|
||||
if [ -f "${PROJECT_SOURCE_DIR}/cmake/versions.cmake" ]; then
|
||||
VERSIONS=($(sed -e s/\ /=/g -e s/set\(//g -e s/\)//g "${PROJECT_SOURCE_DIR}/cmake/versions.cmake"))
|
||||
|
||||
PROJECT_MINGW64_DOCKER_BUILD_ARGS=()
|
||||
|
||||
for VERSION in "${VERSIONS[@]}"; do
|
||||
LOOKUP_NAME=$(echo ${VERSION} | sed s/_VERSION.*// | sed s/GTEST/TESTING/g)
|
||||
ENABLE_NAME=PROJECT_ENABLE_${LOOKUP_NAME}
|
||||
if [ "${!ENABLE_NAME}" != "OFF" ]; then
|
||||
PROJECT_MINGW64_DOCKER_BUILD_ARGS+=("--build-arg ${VERSION}")
|
||||
fi
|
||||
done
|
||||
|
||||
PROJECT_MINGW64_DOCKER_BUILD_ARGS=${PROJECT_MINGW64_DOCKER_BUILD_ARGS[*]}
|
||||
fi
|
||||
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_3RD_PARTY_DIR=${PROJECT_3RD_PARTY_DIR} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_BUILD_ARCH=${PROJECT_BUILD_ARCH} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_BUILD_DIR=${PROJECT_BUILD_DIR} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_BUILD_SHARED_LIBS=${PROJECT_BUILD_SHARED_LIBS} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_CMAKE_BUILD_TYPE=${PROJECT_CMAKE_BUILD_TYPE} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_DIST_DIR=${PROJECT_DIST_DIR} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_ENABLE_WIN32_LONG_PATH_NAMES=${PROJECT_ENABLE_WIN32_LONG_PATH_NAMES} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_EXTERNAL_BUILD_ROOT=${PROJECT_EXTERNAL_BUILD_ROOT} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_GIT_REV=${PROJECT_GIT_REV} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_IS_ALPINE=${PROJECT_IS_ALPINE} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_IS_ARM64=${PROJECT_IS_ARM64} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_IS_MINGW=${PROJECT_IS_MINGW} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_IS_MINGW_UNIX=${PROJECT_IS_MINGW_UNIX} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_MAJOR_VERSION=${PROJECT_MAJOR_VERSION} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_MINOR_VERSION=${PROJECT_MINOR_VERSION} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_NAME=${PROJECT_NAME} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_RELEASE_ITER=${PROJECT_RELEASE_ITER} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_RELEASE_NUM=${PROJECT_RELEASE_NUM} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_REQUIRE_ALPINE=${PROJECT_REQUIRE_ALPINE} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_REVISION_VERSION=${PROJECT_REVISION_VERSION} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_STATIC_LINK=${PROJECT_STATIC_LINK} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_SUPPORT_DIR=${PROJECT_SUPPORT_DIR} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_TOOLCHAIN_FILE_CMAKE=${PROJECT_TOOLCHAIN_FILE_CMAKE} ${PROJECT_CMAKE_OPTS}"
|
||||
PROJECT_CMAKE_OPTS="-DPROJECT_TOOLCHAIN_FILE_MESON=${PROJECT_TOOLCHAIN_FILE_MESON} ${PROJECT_CMAKE_OPTS}"
|
||||
|
||||
for PROJECT_LIBRARY in "${PROJECT_LIBRARIES[@]}"; do
|
||||
ENABLE_NAME=PROJECT_ENABLE_${PROJECT_LIBRARY}
|
||||
PROJECT_CMAKE_OPTS="${PROJECT_CMAKE_OPTS} -D${ENABLE_NAME}=${!ENABLE_NAME}"
|
||||
done
|
||||
|
||||
PKG_CONFIG_PATH="${PROJECT_EXTERNAL_BUILD_ROOT}/lib/pkgconfig:${PROJECT_EXTERNAL_BUILD_ROOT}/lib64/pkgconfig:${PROJECT_EXTERNAL_BUILD_ROOT}/shared/pkgconfig:${PKG_CONFIG_PATH}"
|
||||
|
||||
if [ "${DISABLE_CREATE_DIRS}" != "1" ]; then
|
||||
mkdir -p "${PROJECT_BUILD_DIR}"
|
||||
mkdir -p "${PROJECT_DIST_DIR}"
|
||||
fi
|
||||
|
||||
PATH="${PROJECT_EXTERNAL_BUILD_ROOT}/bin:${PATH}"
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
PROJECT_OS=windows
|
||||
else
|
||||
PROJECT_OS=linux
|
||||
fi
|
||||
|
||||
PROJECT_FILE_PART=${PROJECT_NAME}_${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_REVISION_VERSION}-${PROJECT_RELEASE_ITER}_${PROJECT_GIT_REV}_${PROJECT_OS}_${PROJECT_BUILD_ARCH2}
|
||||
PROJECT_OUT_FILE=${PROJECT_FILE_PART}.tar.gz
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
PROJECT_APP_BINARY_EXT=.exe
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_IS_MINGW_UNIX}" != "1" ]; then
|
||||
MSYS=winsymlinks:nativestrict
|
||||
fi
|
||||
|
||||
export MSYS
|
||||
export NUM_JOBS
|
||||
export OPENSSL_ROOT_DIR
|
||||
export PATH
|
||||
export PKG_CONFIG_PATH
|
||||
export PROJECT_3RD_PARTY_DIR
|
||||
export PROJECT_APP_BINARY_EXT
|
||||
export PROJECT_APP_LIST
|
||||
export PROJECT_BUILD_ARCH
|
||||
export PROJECT_BUILD_ARCH2
|
||||
export PROJECT_BUILD_CLEAN
|
||||
export PROJECT_BUILD_DIR
|
||||
export PROJECT_BUILD_SHARED_LIBS
|
||||
export PROJECT_CMAKE_BUILD_TYPE
|
||||
export PROJECT_CMAKE_BUILD_TYPE_LOWER
|
||||
export PROJECT_CMAKE_OPTS
|
||||
export PROJECT_COMPANY_NAME
|
||||
export PROJECT_COPYRIGHT
|
||||
export PROJECT_DESC
|
||||
export PROJECT_DIST_DIR
|
||||
export PROJECT_ENABLE_WIN32_LONG_PATH_NAMES
|
||||
export PROJECT_FILE_PART
|
||||
export PROJECT_GIT_REV
|
||||
export PROJECT_IS_ALPINE
|
||||
export PROJECT_IS_ARM64
|
||||
export PROJECT_IS_MINGW
|
||||
export PROJECT_IS_MINGW_UNIX
|
||||
export PROJECT_LINK_TYPE
|
||||
export PROJECT_MAJOR_VERSION
|
||||
export PROJECT_MINGW64_COPY_DEPENDENCIES
|
||||
export PROJECT_MINGW64_DOCKER_BUILD_ARGS
|
||||
export PROJECT_MINOR_VERSION
|
||||
export PROJECT_MSYS2_PACKAGE_LIST
|
||||
export PROJECT_NAME
|
||||
export PROJECT_OS
|
||||
export PROJECT_OUT_FILE
|
||||
export PROJECT_PRIVATE_KEY
|
||||
export PROJECT_PUBLIC_KEY
|
||||
export PROJECT_RELEASE_ITER
|
||||
export PROJECT_RELEASE_NUM
|
||||
export PROJECT_REQUIRE_ALPINE
|
||||
export PROJECT_REVISION_VERSION
|
||||
export PROJECT_SOURCE_DIR
|
||||
export PROJECT_STATIC_LINK
|
||||
export PROJECT_SUPPORT_DIR
|
||||
export PROJECT_TOOLCHAIN_FILE_CMAKE
|
||||
export PROJECT_TOOLCHAIN_FILE_MESON
|
||||
export PROJECT_URL
|
||||
|
||||
for PROJECT_LIBRARY in "${PROJECT_LIBRARIES[@]}"; do
|
||||
ENABLE_NAME=PROJECT_ENABLE_${PROJECT_LIBRARY}
|
||||
KEEP_NAME=PROJECT_KEEP_${PROJECT_LIBRARY}
|
||||
export ${ENABLE_NAME}
|
||||
export ${KEEP_NAME}
|
||||
done
|
||||
|
||||
echo "-=[Settings]=-"
|
||||
echo " App binary extension: ${PROJECT_APP_BINARY_EXT}"
|
||||
echo " App list: ${PROJECT_APP_LIST[*]}"
|
||||
echo " Build arch: ${PROJECT_BUILD_ARCH}"
|
||||
echo " Build arch2: ${PROJECT_BUILD_ARCH2}"
|
||||
echo " Build clean: ${PROJECT_BUILD_CLEAN}"
|
||||
echo " Build dir: ${PROJECT_BUILD_DIR}"
|
||||
echo " Build shared libraries: ${PROJECT_BUILD_SHARED_LIBS}"
|
||||
echo " CMake options: -G\"Unix Makefiles\" -DPROJECT_COMPANY_NAME=\"${PROJECT_COMPANY_NAME}\" -DPROJECT_COPYRIGHT=\"${PROJECT_COPYRIGHT}\" -DPROJECT_DESC=\"${PROJECT_DESC}\" -DPROJECT_URL=\"${PROJECT_URL}\" ${PROJECT_CMAKE_OPTS} "
|
||||
echo " CMake toolchain file: ${PROJECT_TOOLCHAIN_FILE_CMAKE}"
|
||||
echo " Cmake Build type: ${PROJECT_CMAKE_BUILD_TYPE}"
|
||||
echo " Company name: ${PROJECT_COMPANY_NAME}"
|
||||
echo " Copyright: ${PROJECT_COPYRIGHT}"
|
||||
echo " Description: ${PROJECT_DESC}"
|
||||
echo " Dist dir: ${PROJECT_DIST_DIR}"
|
||||
echo " External build root: ${PROJECT_EXTERNAL_BUILD_ROOT}"
|
||||
echo " File part: ${PROJECT_FILE_PART}"
|
||||
echo " Is ARM64: ${PROJECT_IS_ARM64}"
|
||||
echo " Is Alpine: ${PROJECT_IS_ALPINE}"
|
||||
echo " Is MINGW on Unix: ${PROJECT_IS_MINGW_UNIX}"
|
||||
echo " Is MINGW: ${PROJECT_IS_MINGW}"
|
||||
echo " Job count: ${NUM_JOBS}"
|
||||
echo " Link type: ${PROJECT_LINK_TYPE}"
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
echo " Long path names: ${PROJECT_ENABLE_WIN32_LONG_PATH_NAMES}"
|
||||
fi
|
||||
echo " Meson toolchain file: ${PROJECT_TOOLCHAIN_FILE_MESON}"
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ] && [ "${PROJECT_IS_MINGW_UNIX}" == "1" ]; then
|
||||
echo " MinGW docker build args: ${PROJECT_MINGW64_DOCKER_BUILD_ARGS}"
|
||||
fi
|
||||
echo " OPENSSL_ROOT_DIR: ${OPENSSL_ROOT_DIR}"
|
||||
echo " Out file: ${PROJECT_OUT_FILE}"
|
||||
echo " PATH: ${PATH}"
|
||||
echo " PKG_CONFIG_PATH: ${PKG_CONFIG_PATH}"
|
||||
echo " Require Alpine: ${PROJECT_REQUIRE_ALPINE}"
|
||||
echo " Static link: ${PROJECT_STATIC_LINK}"
|
||||
echo " Support dir: ${PROJECT_SUPPORT_DIR}"
|
||||
echo " Third-party dir: ${PROJECT_3RD_PARTY_DIR}"
|
||||
echo " Unit testing enabled: ${PROJECT_ENABLE_TESTING}"
|
||||
echo " URL: ${PROJECT_URL}"
|
||||
echo "-=[Libraries]=-"
|
||||
for PROJECT_LIBRARY in "${PROJECT_LIBRARIES[@]}"; do
|
||||
ENABLE_NAME=PROJECT_ENABLE_${PROJECT_LIBRARY}
|
||||
KEEP_NAME=PROJECT_KEEP_${PROJECT_LIBRARY}
|
||||
if [ "${!ENABLE_NAME}" == "ON" ] || [ "${!KEEP_NAME}" == "1" ]; then
|
||||
echo " ${ENABLE_NAME}: Enable[${!ENABLE_NAME}] Keep[${!KEEP_NAME}]"
|
||||
fi
|
||||
done
|
||||
popd
|
12
scripts/info.cmd
Normal file
12
scripts/info.cmd
Normal file
@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ARG1=%~1
|
||||
set ARG2=%~2
|
||||
set ARG3=%~3
|
||||
|
||||
pushd "%~dp0%"
|
||||
call mingw64 -no-start ./info.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0
|
||||
popd
|
||||
|
5
scripts/info.sh
Executable file
5
scripts/info.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 1
|
49
scripts/libraries.sh
Executable file
49
scripts/libraries.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_LIBRARIES=(
|
||||
BACKWARD_CPP
|
||||
CPP_HTTPLIB
|
||||
CURL
|
||||
JSON
|
||||
OPENSSL
|
||||
ROCKSDB
|
||||
SPDLOG
|
||||
TESTING
|
||||
)
|
||||
|
||||
declare -A PROJECT_CLEANUP
|
||||
PROJECT_CLEANUP[BACKWARD_CPP]="include/backward.hpp:src/backward.cpp"
|
||||
PROJECT_CLEANUP[BINUTILS]="3rd_party/mingw64/binutils-*"
|
||||
PROJECT_CLEANUP[CPP_HTTPLIB]="3rd_party/cpp-httplib-*"
|
||||
PROJECT_CLEANUP[CURL]="3rd_party/curl-*"
|
||||
PROJECT_CLEANUP[EXPAT]="3rd_party/mingw64/expat-*"
|
||||
PROJECT_CLEANUP[GCC]="3rd_party/mingw64/gcc-*"
|
||||
PROJECT_CLEANUP[ICU]="3rd_party/mingw64/icu-release-*"
|
||||
PROJECT_CLEANUP[JSON]="3rd_party/json-*"
|
||||
PROJECT_CLEANUP[LIBBITCOIN_SYSTEM_ON]="3rd_party/boost_${PROJECT_VERSIONS[BOOST_MAJOR]}_${PROJECT_VERSIONS[BOOST_MINOR]}_*"
|
||||
PROJECT_CLEANUP[MINGW]="3rd_party/mingw64/mingw-w64-*"
|
||||
PROJECT_CLEANUP[OPENSSL]="3rd_party/openssl-*"
|
||||
PROJECT_CLEANUP[PKG_CONFIG]="3rd_party/mingw64/pkg-config-*"
|
||||
PROJECT_CLEANUP[ROCKSDB]="3rd_party/rocksdb-*"
|
||||
PROJECT_CLEANUP[SPDLOG]="3rd_party/spdlog-*"
|
||||
PROJECT_CLEANUP[TESTING]="3rd_party/googletest-*"
|
||||
PROJECT_CLEANUP[ZLIB]="3rd_party/mingw64/zlib-*"
|
||||
export PROJECT_CLEANUP
|
||||
|
||||
declare -A PROJECT_DOWNLOADS
|
||||
PROJECT_DOWNLOADS[BINUTILS]="https://ftp.gnu.org/gnu/binutils/binutils-${PROJECT_VERSIONS[BINUTILS]}.tar.xz;binutils-${PROJECT_VERSIONS[BINUTILS]}.tar.xz;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[BOOST2]="https://archives.boost.io/release/${PROJECT_VERSIONS[BOOST2_MAJOR]}.${PROJECT_VERSIONS[BOOST2_MINOR]}.${PROJECT_VERSIONS[BOOST2_PATCH]}/source/boost_${PROJECT_VERSIONS[BOOST2_MAJOR]}_${PROJECT_VERSIONS[BOOST2_MINOR]}_${PROJECT_VERSIONS[BOOST2_PATCH]}.tar.gz;boost_${PROJECT_VERSIONS[BOOST2_MAJOR]}_${PROJECT_VERSIONS[BOOST2_MINOR]}_${PROJECT_VERSIONS[BOOST2_PATCH]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[CPP_HTTPLIB]="https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${PROJECT_VERSIONS[CPP_HTTPLIB]}.tar.gz;cpp-httplib-${PROJECT_VERSIONS[CPP_HTTPLIB]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[CURL]="https://github.com/curl/curl/archive/refs/tags/curl-${PROJECT_VERSIONS[CURL2]}.tar.gz;curl-${PROJECT_VERSIONS[CURL]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[EXPAT]="https://github.com/libexpat/libexpat/archive/refs/tags/R_${PROJECT_VERSIONS[EXPAT2]}.tar.gz;expat-${PROJECT_VERSIONS[EXPAT]}.tar.gz;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[GCC]="https://ftp.gnu.org/gnu/gcc/gcc-${PROJECT_VERSIONS[GCC]}/gcc-${PROJECT_VERSIONS[GCC]}.tar.gz;gcc-${PROJECT_VERSIONS[GCC]}.tar.gz;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[GTEST]="https://github.com/google/googletest/archive/refs/tags/v${PROJECT_VERSIONS[GTEST]}.tar.gz;googletest-${PROJECT_VERSIONS[GTEST]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[ICU]="https://github.com/unicode-org/icu/archive/refs/tags/release-${PROJECT_VERSIONS[ICU]}.tar.gz;icu-release-${PROJECT_VERSIONS[ICU]}.tar.gz;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[JSON]="https://github.com/nlohmann/json/archive/refs/tags/v${PROJECT_VERSIONS[JSON]}.tar.gz;json-${PROJECT_VERSIONS[JSON]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[MINGW]="https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v${PROJECT_VERSIONS[MINGW]}.tar.bz2;;mingw-w64-v${PROJECT_VERSIONS[MINGW]}.tar.bz2;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[OPENSSL]="https://github.com/openssl/openssl/releases/download/openssl-${PROJECT_VERSIONS[OPENSSL]}/openssl-${PROJECT_VERSIONS[OPENSSL]}.tar.gz;openssl-${PROJECT_VERSIONS[OPENSSL]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[PKG_CONFIG]="https://pkgconfig.freedesktop.org/releases/pkg-config-${PROJECT_VERSIONS[PKG_CONFIG]}.tar.gz;pkg-config-${PROJECT_VERSIONS[PKG_CONFIG]}.tar.gz;3rd_party/mingw64"
|
||||
PROJECT_DOWNLOADS[ROCKSDB]="https://github.com/facebook/rocksdb/archive/refs/tags/v${PROJECT_VERSIONS[ROCKSDB]}.tar.gz;rocksdb-${PROJECT_VERSIONS[ROCKSDB]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[SPDLOG]="https://github.com/gabime/spdlog/archive/refs/tags/v${PROJECT_VERSIONS[SPDLOG]}.tar.gz;spdlog-${PROJECT_VERSIONS[SPDLOG]}.tar.gz;3rd_party"
|
||||
PROJECT_DOWNLOADS[ZLIB]="https://github.com/madler/zlib/archive/refs/tags/v${PROJECT_VERSIONS[ZLIB]}.tar.gz;zlib-${PROJECT_VERSIONS[ZLIB]}.tar.gz;3rd_party/mingw64"
|
||||
export PROJECT_DOWNLOADS
|
90
scripts/make_common.sh
Executable file
90
scripts/make_common.sh
Executable file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5"
|
||||
|
||||
mkdir -p "${PROJECT_BUILD_DIR}/build"
|
||||
|
||||
if [ -d "${PROJECT_DIST_DIR}" ]; then
|
||||
rm -rf "${PROJECT_DIST_DIR}"
|
||||
mkdir -p "${PROJECT_DIST_DIR}"
|
||||
fi
|
||||
|
||||
if [ -f "${PROJECT_SOURCE_DIR}/pre_build.sh" ]; then
|
||||
"${PROJECT_SOURCE_DIR}/pre_build.sh"
|
||||
fi
|
||||
|
||||
ln -sf "${PROJECT_BUILD_DIR}/build/compile_commands.json" "${PROJECT_SOURCE_DIR}/compile_commands.json"
|
||||
|
||||
pushd "${PROJECT_BUILD_DIR}"
|
||||
cmake "${PROJECT_SOURCE_DIR}" \
|
||||
-G"Unix Makefiles" \
|
||||
-DPROJECT_COMPANY_NAME="${PROJECT_COMPANY_NAME}" \
|
||||
-DPROJECT_COPYRIGHT="${PROJECT_COPYRIGHT}" \
|
||||
-DPROJECT_DESC="${PROJECT_DESC}" \
|
||||
-DPROJECT_INTERFACE=1 \
|
||||
-DPROJECT_URL="${PROJECT_URL}" \
|
||||
${PROJECT_CMAKE_OPTS} || exit 1
|
||||
|
||||
if [ "${PROJECT_BUILD_CLEAN}" == "clean" ]; then
|
||||
make clean
|
||||
pushd build
|
||||
make clean
|
||||
popd
|
||||
fi
|
||||
|
||||
make -j${NUM_JOBS} || exit 1
|
||||
|
||||
pushd build
|
||||
make -j${NUM_JOBS} || exit 1
|
||||
popd
|
||||
popd
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" != "1" ] && [ "${PROJECT_REQUIRE_ALPINE}" == "ON" ]; then
|
||||
rsync -av --progress /usr/share/icu/74.2/ "${PROJECT_DIST_DIR}/icu/"
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_BUILD_SHARED_LIBS}" == "ON" ] && [ "${PROJECT_IS_MINGW}" != "1" ]; then
|
||||
rsync -av --progress ${PROJECT_EXTERNAL_BUILD_ROOT}/ "${PROJECT_DIST_DIR}/"
|
||||
pushd "${PROJECT_DIST_DIR}"
|
||||
rm lib64
|
||||
ln -sf lib lib64
|
||||
popd
|
||||
fi
|
||||
|
||||
for APP in ${PROJECT_APP_LIST[@]}; do
|
||||
if [ "${PROJECT_BUILD_SHARED_LIBS}" == "ON" ]; then
|
||||
if [ "${PROJECT_IS_MINGW}" != "1" ]; then
|
||||
rm "${PROJECT_DIST_DIR}/${APP}${PROJECT_APP_BINARY_EXT}"
|
||||
if [ "${PROJECT_ENABLE_CURL}" == "ON" ]; then
|
||||
mv "${PROJECT_DIST_DIR}/cacert.pem" "${PROJECT_DIST_DIR}/bin/cacert.pem"
|
||||
fi
|
||||
rsync -av --progress "${PROJECT_BUILD_DIR}/build/${APP}${PROJECT_APP_BINARY_EXT}" "${PROJECT_DIST_DIR}/bin/"
|
||||
cat <<EOF >>"${PROJECT_DIST_DIR}/${APP}${PROJECT_APP_BINARY_EXT}"
|
||||
#!/bin/sh
|
||||
PROJECT_SCRIPTS_DIR=\$(realpath "\$0")
|
||||
PROJECT_SCRIPTS_DIR=\$(dirname "\${PROJECT_SCRIPTS_DIR}")
|
||||
|
||||
export LD_LIBRARY_PATH="\${PROJECT_SCRIPTS_DIR}/lib:\${PROJECT_SCRIPTS_DIR}/lib64:\${LD_LIBRARY_PATH}"
|
||||
|
||||
\${PROJECT_SCRIPTS_DIR}/bin/${APP}${PROJECT_APP_BINARY_EXT} \$*
|
||||
EOF
|
||||
chmod +x "${PROJECT_DIST_DIR}/${APP}${PROJECT_APP_BINARY_EXT}"
|
||||
else
|
||||
rsync -av --progress "${PROJECT_BUILD_DIR}/build/${APP}${PROJECT_APP_BINARY_EXT}" "${PROJECT_DIST_DIR}/"
|
||||
fi
|
||||
else
|
||||
rsync -av --progress "${PROJECT_BUILD_DIR}/build/${APP}${PROJECT_APP_BINARY_EXT}" "${PROJECT_DIST_DIR}/"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${PROJECT_IS_MINGW}" == "1" ]; then
|
||||
. "${PROJECT_SCRIPTS_DIR}/copy_mingw64_deps.sh" "$1" "$2" "$3" "$4" "$5"
|
||||
fi
|
||||
|
||||
if [ -f "${PROJECT_SOURCE_DIR}/post_build.sh" ]; then
|
||||
"${PROJECT_SOURCE_DIR}/post_build.sh"
|
||||
fi
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/make_package.sh" "$1" "$2" "$3" "$4" "$5"
|
11
scripts/make_package.cmd
Normal file
11
scripts/make_package.cmd
Normal file
@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ARG1=%~1
|
||||
set ARG2=%~2
|
||||
set ARG3=%~3
|
||||
|
||||
pushd "%~dp0%"
|
||||
call mingw64 -no-start ./make_package.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0 || exit 1
|
||||
popd
|
66
scripts/make_package.sh
Executable file
66
scripts/make_package.sh
Executable file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5"
|
||||
|
||||
function error_exit() {
|
||||
echo $1
|
||||
rm -rf ${TEMP_DIR}
|
||||
exit $2
|
||||
}
|
||||
|
||||
function create_file_validations() {
|
||||
local SOURCE_FILE=$1
|
||||
sha256sum ${SOURCE_FILE} >${SOURCE_FILE}.sha256 || error_exit "failed to create sha256 for file: ${SOURCE_FILE}" 1
|
||||
if [ "${PROJECT_PRIVATE_KEY}" != "" ]; then
|
||||
openssl dgst -sha256 -sign "${PROJECT_PRIVATE_KEY}" -out "${SOURCE_FILE}.sig" "${SOURCE_FILE}" || error_exit "failed to create signature for file: ${SOURCE_FILE}" 1
|
||||
openssl dgst -sha256 -verify "${PROJECT_PUBLIC_KEY}" -signature "${SOURCE_FILE}.sig" "${SOURCE_FILE}" || error_exit "failed to validate signature for file: ${SOURCE_FILE}" 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -d "${PROJECT_DIST_DIR}" ]; then
|
||||
error_exit "dist directory not found: ${PROJECT_DIST_DIR}" 2
|
||||
fi
|
||||
|
||||
pushd "${PROJECT_DIST_DIR}"
|
||||
if [ -f "${PROJECT_OUT_FILE}" ]; then
|
||||
rm -f "${PROJECT_OUT_FILE}" || error_exit "failed to delete file: ${PROJECT_OUT_FILE}" 1
|
||||
fi
|
||||
if [ -f "${PROJECT_OUT_FILE}.sha256" ]; then
|
||||
rm -f "${PROJECT_OUT_FILE}.sha256" || error_exit "failed to delete file: ${PROJECT_OUT_FILE}.sha256" 1
|
||||
fi
|
||||
if [ -f "${PROJECT_OUT_FILE}.sig" ]; then
|
||||
rm -f "${PROJECT_OUT_FILE}.sig" || error_exit "failed to delete file: ${PROJECT_OUT_FILE}.sig" 1
|
||||
fi
|
||||
popd
|
||||
|
||||
rsync -av --progress ${PROJECT_DIST_DIR}/ ${TEMP_DIR}/${PROJECT_NAME}/ || error_exit "failed to rsync" 1
|
||||
|
||||
for APP in ${PROJECT_APP_LIST[@]}; do
|
||||
if [ "${PROJECT_BUILD_SHARED_LIBS}" == "ON" ] && [ "${PROJECT_IS_MINGW}" != "1" ]; then
|
||||
strip ${TEMP_DIR}/${PROJECT_NAME}/bin/${APP}${PROJECT_APP_BINARY_EXT}
|
||||
else
|
||||
strip ${TEMP_DIR}/${PROJECT_NAME}/${APP}${PROJECT_APP_BINARY_EXT}
|
||||
fi
|
||||
done
|
||||
|
||||
pushd "${TEMP_DIR}/${PROJECT_NAME}/"
|
||||
IFS=$'\n'
|
||||
set -f
|
||||
FILE_LIST=$(find . -type f)
|
||||
for FILE in ${FILE_LIST}; do
|
||||
create_file_validations "${FILE}"
|
||||
done
|
||||
unset IFS
|
||||
set +f
|
||||
popd
|
||||
|
||||
pushd "${PROJECT_DIST_DIR}"
|
||||
tar cvzf "${PROJECT_OUT_FILE}" -C ${TEMP_DIR} . || error_exit "failed to create archive: ${PROJECT_OUT_FILE}" 1
|
||||
create_file_validations "${PROJECT_OUT_FILE}"
|
||||
popd
|
||||
|
||||
error_exit "created package ${PROJECT_FILE_PART}" 0
|
20
scripts/make_unix.sh
Executable file
20
scripts/make_unix.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" 0 0
|
||||
|
||||
if [ -f "${PROJECT_SCRIPTS_DIR}/cleanup.sh" ]; then
|
||||
. "${PROJECT_SCRIPTS_DIR}/cleanup.sh" "$1" "$2" "$3" 0 0
|
||||
rm ${PROJECT_SCRIPTS_DIR}/cleanup.*
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_REQUIRE_ALPINE}" == "ON" ] || [ "${PROJECT_IS_ARM64}" == "1" ]; then
|
||||
DOCKER_NAME=alpine
|
||||
DOCKER_CONTAINER=${PROJECT_NAME}_${DOCKER_NAME}_${PROJECT_BUILD_ARCH}
|
||||
DOCKER_TAG=${PROJECT_NAME}:${DOCKER_NAME}
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/docker_common.sh" || exit 1
|
||||
else
|
||||
"${PROJECT_SOURCE_DIR}/scripts/make_common.sh" "${PROJECT_BUILD_ARCH}" "${PROJECT_CMAKE_BUILD_TYPE}" "${PROJECT_BUILD_CLEAN}" 0 0 || exit 1
|
||||
fi
|
16
scripts/make_win32.cmd
Normal file
16
scripts/make_win32.cmd
Normal file
@ -0,0 +1,16 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ARG1=%~1
|
||||
set ARG2=%~2
|
||||
set ARG3=%~3
|
||||
|
||||
pushd "%~dp0%"
|
||||
call setup_msys2.cmd "%ARG1%" "%ARG2%" "%ARG3%"
|
||||
if exist "cleanup.cmd" (
|
||||
call cleanup.cmd "%ARG1%" "%ARG2%" "%ARG3%" 1 0
|
||||
del cleanup.*
|
||||
)
|
||||
call mingw64 -no-start ./make_common.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0 || exit 1
|
||||
popd
|
16
scripts/make_win32.sh
Executable file
16
scripts/make_win32.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" 1 1
|
||||
|
||||
if [ -f "${PROJECT_SCRIPTS_DIR}/cleanup.sh" ]; then
|
||||
. "${PROJECT_SCRIPTS_DIR}/cleanup.sh" "$1" "$2" "$3" 1 1
|
||||
rm ${PROJECT_SCRIPTS_DIR}/cleanup.*
|
||||
fi
|
||||
|
||||
DOCKER_NAME=mingw64
|
||||
DOCKER_CONTAINER=${PROJECT_NAME}_${DOCKER_NAME}
|
||||
DOCKER_TAG=${PROJECT_NAME}:${DOCKER_NAME}
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/docker_common.sh" || exit 1
|
18
scripts/run_docker_shell.sh
Executable file
18
scripts/run_docker_shell.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOCKER_NAME=$1
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$2" "$3" "$4" "$5" "$6" 1 1>/dev/null 2>&1
|
||||
|
||||
if [ -f "${PROJECT_SCRIPTS_DIR}/cleanup.sh" ]; then
|
||||
. "${PROJECT_SCRIPTS_DIR}/cleanup.sh" "$2" "$3" "$4" "$5" "$6"
|
||||
rm ${PROJECT_SCRIPTS_DIR}/cleanup.*
|
||||
fi
|
||||
|
||||
DOCKER_CONTAINER=${PROJECT_NAME}_${DOCKER_NAME}_${PROJECT_BUILD_ARCH}_shell
|
||||
DOCKER_TAG=${PROJECT_NAME}:${DOCKER_NAME}
|
||||
DOCKER_SHELL=1
|
||||
|
||||
. "${PROJECT_SCRIPTS_DIR}/docker_common.sh" || exit 1
|
12
scripts/run_tests.cmd
Normal file
12
scripts/run_tests.cmd
Normal file
@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ARG1=%~1
|
||||
set ARG2=%~2
|
||||
set ARG3=%~3
|
||||
|
||||
pushd "%~dp0%"
|
||||
call mingw64 -no-start ./run_tests.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0
|
||||
popd
|
||||
|
19
scripts/run_tests.sh
Executable file
19
scripts/run_tests.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 0
|
||||
|
||||
pushd "${PROJECT_DIST_DIR}"
|
||||
if [ -e "./${PROJECT_NAME}_test${PROJECT_APP_BINARY_EXT}" ]; then
|
||||
for APP in ${PROJECT_APP_LIST[@]}; do
|
||||
if [[ "$APP" == *_test ]]; then
|
||||
if [ "${PROJECT_IS_MINGW_UNIX}" == "1" ]; then
|
||||
wine64 "${PROJECT_DIST_DIR}/${PROJECT_NAME}_test${PROJECT_APP_BINARY_EXT}" || exit 1
|
||||
else
|
||||
"./${PROJECT_NAME}_test${PROJECT_APP_BINARY_EXT}" || exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
popd
|
12
scripts/setup_msys2.cmd
Normal file
12
scripts/setup_msys2.cmd
Normal file
@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
|
||||
set ARG1=%~1
|
||||
set ARG2=%~2
|
||||
set ARG3=%~3
|
||||
|
||||
pushd "%~dp0%"
|
||||
call mingw64 -no-start ./setup_msys2.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0
|
||||
call mingw64 -no-start ./setup_msys2.sh "%ARG1%" "%ARG2%" "%ARG3%" 1 0
|
||||
popd
|
187
scripts/setup_msys2.sh
Executable file
187
scripts/setup_msys2.sh
Executable file
@ -0,0 +1,187 @@
|
||||
#!/bin/bash
|
||||
|
||||
PROJECT_MSYS2_PACKAGE_LIST=()
|
||||
|
||||
PROJECT_SCRIPTS_DIR=$(realpath "$0")
|
||||
PROJECT_SCRIPTS_DIR=$(dirname "${PROJECT_SCRIPTS_DIR}")
|
||||
. "${PROJECT_SCRIPTS_DIR}/env.sh" "$1" "$2" "$3" "$4" "$5" 1 1>/dev/null 2>&1
|
||||
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-autotools
|
||||
mingw64/mingw-w64-x86_64-clang-tools-extra
|
||||
mingw64/mingw-w64-x86_64-cmake
|
||||
mingw64/mingw-w64-x86_64-curl
|
||||
mingw64/mingw-w64-x86_64-diffutils
|
||||
mingw64/mingw-w64-x86_64-gcc
|
||||
mingw64/mingw-w64-x86_64-gdb
|
||||
mingw64/mingw-w64-x86_64-icu
|
||||
mingw64/mingw-w64-x86_64-make
|
||||
mingw64/mingw-w64-x86_64-mesa
|
||||
mingw64/mingw-w64-x86_64-meson
|
||||
mingw64/mingw-w64-x86_64-meson-python
|
||||
mingw64/mingw-w64-x86_64-ninja
|
||||
mingw64/mingw-w64-x86_64-python
|
||||
mingw64/mingw-w64-x86_64-python-mako
|
||||
mingw64/mingw-w64-x86_64-toolchain
|
||||
mingw64/mingw-w64-x86_64-wget
|
||||
mingw64/mingw-w64-x86_64-zlib
|
||||
msys/bison
|
||||
msys/flex
|
||||
msys/git
|
||||
msys/patch
|
||||
msys/rsync
|
||||
make
|
||||
)
|
||||
|
||||
if [ "${PROJECT_ENABLE_BOOST}" == "ON" ]; then
|
||||
if [ "${PROJECT_ENABLE_LIBBITCOIN_SYSTEM}" == "ON" ]; then
|
||||
yes | pacman -Ry mingw64/mingw-w64-x86_64-boost
|
||||
else
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-boost
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_CLI11}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-cli11
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FLAC}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-flac
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FONTCONFIG}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-fontconfig
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_FREETYPE2}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-freetype
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBDSM}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libdsm
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBEVENT}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libevent
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBICONV}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libiconv
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBJPEG_TURBO}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libjpeg-turbo
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBPNG}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libpng
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBSODIUM}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libsodium
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_LIBTASN}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libtasn1
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_NANA}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-nana
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_NUSPELL}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-nuspell
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OGG}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libogg
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OPENAL}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-openal
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_OPENSSL}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-openssl
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_PUGIXML}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-pugixml
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SDL}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-SDL2
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SFML}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-sfml
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_SQLITE}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-sqlite3
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_TESTING}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-gtest
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_VORBIS}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-libvorbis
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "${PROJECT_ENABLE_WXWIDGETS}" == "ON" ]; then
|
||||
PROJECT_MSYS2_PACKAGE_LIST+=(
|
||||
mingw64/mingw-w64-x86_64-wxwidgets3.2-msw
|
||||
)
|
||||
fi
|
||||
|
||||
pacman -Sqyuu --noconfirm &&
|
||||
pacman -S --noconfirm --needed --disable-download-timeout msys2-keyring &&
|
||||
pacman -S --noconfirm --needed --disable-download-timeout \
|
||||
${PROJECT_MSYS2_PACKAGE_LIST[@]}
|
27
scripts/versions.sh
Executable file
27
scripts/versions.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -A PROJECT_VERSIONS
|
||||
PROJECT_VERSIONS[BINUTILS]="2.43"
|
||||
PROJECT_VERSIONS[BOOST2_MAJOR]="1"
|
||||
PROJECT_VERSIONS[BOOST2_MINOR]="76"
|
||||
PROJECT_VERSIONS[BOOST2_PATCH]="0"
|
||||
PROJECT_VERSIONS[BOOST_MAJOR]="1"
|
||||
PROJECT_VERSIONS[BOOST_MINOR]="87"
|
||||
PROJECT_VERSIONS[BOOST_PATCH]="0"
|
||||
PROJECT_VERSIONS[CPP_HTTPLIB]="0.18.1"
|
||||
PROJECT_VERSIONS[CURL]="8.11.0"
|
||||
PROJECT_VERSIONS[CURL2]="8_11_0"
|
||||
PROJECT_VERSIONS[EXPAT]="2.6.4"
|
||||
PROJECT_VERSIONS[EXPAT2]="2_6_4"
|
||||
PROJECT_VERSIONS[GCC]="14.2.0"
|
||||
PROJECT_VERSIONS[GTEST]="1.15.2"
|
||||
PROJECT_VERSIONS[ICU]="76-1"
|
||||
PROJECT_VERSIONS[JSON]="3.11.3"
|
||||
PROJECT_VERSIONS[MESA]="23.3.3"
|
||||
PROJECT_VERSIONS[MINGW]="12.0.0"
|
||||
PROJECT_VERSIONS[OPENSSL]="3.4.0"
|
||||
PROJECT_VERSIONS[PKG_CONFIG]="0.29.2"
|
||||
PROJECT_VERSIONS[ROCKSDB]="9.7.4"
|
||||
PROJECT_VERSIONS[SPDLOG]="1.15.0"
|
||||
PROJECT_VERSIONS[ZLIB]="1.3.1"
|
||||
export PROJECT_VERSIONS
|
BIN
support/3rd_party/cpp-httplib-0.18.1.tar.gz
vendored
Normal file
BIN
support/3rd_party/cpp-httplib-0.18.1.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/cpp-httplib-0.18.1.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/cpp-httplib-0.18.1.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
405abd8170f2a446fc8612ac635d0db5947c0d2e156e32603403a4496255ff00 *cpp-httplib-0.18.1.tar.gz
|
BIN
support/3rd_party/curl-8.11.0.tar.gz
vendored
Normal file
BIN
support/3rd_party/curl-8.11.0.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/curl-8.11.0.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/curl-8.11.0.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
5a231145114589491fc52da118f9c7ef8abee885d1cb1ced99c7290e9a352f07 *curl-8.11.0.tar.gz
|
BIN
support/3rd_party/googletest-1.15.2.tar.gz
vendored
Normal file
BIN
support/3rd_party/googletest-1.15.2.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/googletest-1.15.2.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/googletest-1.15.2.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926 googletest-1.15.2.tar.gz
|
BIN
support/3rd_party/json-3.11.3.tar.gz
vendored
Normal file
BIN
support/3rd_party/json-3.11.3.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/json-3.11.3.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/json-3.11.3.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
0d8ef5af7f9794e3263480193c491549b2ba6cc74bb018906202ada498a79406 json-3.11.3.tar.gz
|
BIN
support/3rd_party/mingw64/binutils-2.43.tar.xz
vendored
Normal file
BIN
support/3rd_party/mingw64/binutils-2.43.tar.xz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/binutils-2.43.tar.xz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/binutils-2.43.tar.xz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
b53606f443ac8f01d1d5fc9c39497f2af322d99e14cea5c0b4b124d630379365 binutils-2.43.tar.xz
|
BIN
support/3rd_party/mingw64/expat-2.6.4.tar.gz
vendored
Normal file
BIN
support/3rd_party/mingw64/expat-2.6.4.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/expat-2.6.4.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/expat-2.6.4.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
372b18f6527d162fa9658f1c74d22a37429b82d822f5a1e1fc7e00f6045a06a2 *expat-2.6.4.tar.gz
|
BIN
support/3rd_party/mingw64/gcc-14.2.0.tar.gz
vendored
Normal file
BIN
support/3rd_party/mingw64/gcc-14.2.0.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/gcc-14.2.0.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/gcc-14.2.0.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
7d376d445f93126dc545e2c0086d0f647c3094aae081cdb78f42ce2bc25e7293 gcc-14.2.0.tar.gz
|
BIN
support/3rd_party/mingw64/icu-release-76-1.tar.gz
vendored
Normal file
BIN
support/3rd_party/mingw64/icu-release-76-1.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/icu-release-76-1.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/icu-release-76-1.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
a2c443404f00098e9e90acf29dc318e049d2dc78d9ae5f46efb261934a730ce2 icu-release-76-1.tar.gz
|
BIN
support/3rd_party/mingw64/mingw-w64-v12.0.0.tar.bz2
vendored
Normal file
BIN
support/3rd_party/mingw64/mingw-w64-v12.0.0.tar.bz2
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/mingw-w64-v12.0.0.tar.bz2.sha256
vendored
Normal file
1
support/3rd_party/mingw64/mingw-w64-v12.0.0.tar.bz2.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
cc41898aac4b6e8dd5cffd7331b9d9515b912df4420a3a612b5ea2955bbeed2f mingw-w64-v12.0.0.tar.bz2
|
BIN
support/3rd_party/mingw64/pkg-config-0.29.2.tar.gz
vendored
Normal file
BIN
support/3rd_party/mingw64/pkg-config-0.29.2.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/pkg-config-0.29.2.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/pkg-config-0.29.2.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591 pkg-config-0.29.2.tar.gz
|
BIN
support/3rd_party/mingw64/zlib-1.3.1.tar.gz
vendored
Normal file
BIN
support/3rd_party/mingw64/zlib-1.3.1.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/mingw64/zlib-1.3.1.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/mingw64/zlib-1.3.1.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
17e88863f3600672ab49182f217281b6fc4d3c762bde361935e436a95214d05c zlib-1.3.1.tar.gz
|
BIN
support/3rd_party/openssl-3.4.0.tar.gz
vendored
Normal file
BIN
support/3rd_party/openssl-3.4.0.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/openssl-3.4.0.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/openssl-3.4.0.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
e15dda82fe2fe8139dc2ac21a36d4ca01d5313c75f99f46c4e8a27709b7294bf *openssl-3.4.0.tar.gz
|
BIN
support/3rd_party/rocksdb-9.7.4.tar.gz
vendored
Normal file
BIN
support/3rd_party/rocksdb-9.7.4.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/rocksdb-9.7.4.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/rocksdb-9.7.4.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
9b810c81731835fda0d4bbdb51d3199d901fa4395733ab63752d297da84c5a47 *rocksdb-9.7.4.tar.gz
|
BIN
support/3rd_party/spdlog-1.15.0.tar.gz
vendored
Normal file
BIN
support/3rd_party/spdlog-1.15.0.tar.gz
vendored
Normal file
Binary file not shown.
1
support/3rd_party/spdlog-1.15.0.tar.gz.sha256
vendored
Normal file
1
support/3rd_party/spdlog-1.15.0.tar.gz.sha256
vendored
Normal file
@ -0,0 +1 @@
|
||||
9962648c9b4f1a7bbc76fd8d9172555bad1871fdb14ff4f842ef87949682caa5 *spdlog-1.15.0.tar.gz
|
4509
support/include/backward.hpp
Normal file
4509
support/include/backward.hpp
Normal file
File diff suppressed because it is too large
Load Diff
59
support/include/utils/all.hpp
Normal file
59
support/include/utils/all.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_ALL_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_ALL_HPP_
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
#include "utils/base64.hpp"
|
||||
#include "utils/collection.hpp"
|
||||
#if defined(_WIN32)
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
#endif // defined(_WIN32)
|
||||
#include "utils/common.hpp"
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
#include "utils/db/sqlite/db_delete.hpp"
|
||||
#include "utils/db/sqlite/db_insert.hpp"
|
||||
#include "utils/db/sqlite/db_select.hpp"
|
||||
#include "utils/db/sqlite/db_update.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "utils/encrypting_reader.hpp"
|
||||
#include "utils/encryption.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "utils/hash.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "utils/path.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "utils/time.hpp"
|
||||
#if !defined(_WIN32)
|
||||
#include "utils/unix.hpp"
|
||||
#endif // !defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
#include "utils/windows.hpp"
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#endif // MONITARR_INCLUDE_UTILS_ALL_HPP_
|
174
support/include/utils/base64.hpp
Normal file
174
support/include/utils/base64.hpp
Normal file
@ -0,0 +1,174 @@
|
||||
// NOLINTBEGIN
|
||||
#ifndef _MACARON_BASE64_H_
|
||||
#define _MACARON_BASE64_H_
|
||||
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2016 tomykaira
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#pragma GCC diagnostic ignored "-Wuseless-cast"
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace macaron::Base64 {
|
||||
static std::string Encode(const unsigned char *data, std::size_t len) {
|
||||
static constexpr std::array<unsigned char, 64U> sEncodingTable{
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/',
|
||||
};
|
||||
|
||||
auto in_len{len};
|
||||
std::string ret;
|
||||
if (in_len > 0) {
|
||||
std::size_t out_len{4U * ((in_len + 2U) / 3U)};
|
||||
ret = std::string(out_len, '\0');
|
||||
std::size_t i;
|
||||
auto *p = reinterpret_cast<unsigned char *>(ret.data());
|
||||
|
||||
for (i = 0U; i < in_len - 2U; i += 3U) {
|
||||
*p++ = sEncodingTable[(data[i] >> 2U) & 0x3F];
|
||||
*p++ = sEncodingTable[((data[i] & 0x3) << 4U) |
|
||||
((int)(data[i + 1U] & 0xF0) >> 4U)];
|
||||
*p++ = sEncodingTable[((data[i + 1] & 0xF) << 2) |
|
||||
((int)(data[i + 2U] & 0xC0) >> 6U)];
|
||||
*p++ = sEncodingTable[data[i + 2U] & 0x3F];
|
||||
}
|
||||
if (i < in_len) {
|
||||
*p++ = sEncodingTable[(data[i] >> 2U) & 0x3F];
|
||||
if (i == (in_len - 1U)) {
|
||||
*p++ = sEncodingTable[((data[i] & 0x3) << 4U)];
|
||||
*p++ = '=';
|
||||
} else {
|
||||
*p++ = sEncodingTable[((data[i] & 0x3) << 4U) |
|
||||
((int)(data[i + 1U] & 0xF0) >> 4U)];
|
||||
*p++ = sEncodingTable[((data[i + 1U] & 0xF) << 2U)];
|
||||
}
|
||||
*p++ = '=';
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[[maybe_unused]] static std::string Encode(std::string_view data) {
|
||||
return Encode(reinterpret_cast<const unsigned char *>(data.data()),
|
||||
data.size());
|
||||
}
|
||||
|
||||
[[maybe_unused]] static std::vector<unsigned char>
|
||||
Decode(std::string_view input) {
|
||||
static constexpr std::array<unsigned char, 256> kDecodingTable{
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, 52, 53, 54, 55, 56, 57,
|
||||
58, 59, 60, 61, 64, 64, 64, 64, 64, 64, 64, 0, 1, 2, 3, 4, 5, 6,
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 64, 64, 64, 64, 64, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
|
||||
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64,
|
||||
};
|
||||
|
||||
std::vector<unsigned char> out;
|
||||
if (not input.empty()) {
|
||||
auto in_len{input.size()};
|
||||
if (in_len % 4U != 0U) {
|
||||
throw std::runtime_error("Input data size is not a multiple of 4");
|
||||
}
|
||||
|
||||
std::size_t out_len{in_len / 4U * 3U};
|
||||
if (input[in_len - 1U] == '=') {
|
||||
out_len--;
|
||||
}
|
||||
if (input[in_len - 2U] == '=') {
|
||||
out_len--;
|
||||
}
|
||||
|
||||
out.resize(out_len);
|
||||
|
||||
for (std::size_t i = 0U, j = 0U; i < in_len;) {
|
||||
std::uint32_t a =
|
||||
input.at(i) == '='
|
||||
? 0U & i++
|
||||
: kDecodingTable[static_cast<unsigned char>(input.at(i++))];
|
||||
std::uint32_t b =
|
||||
input.at(i) == '='
|
||||
? 0U & i++
|
||||
: kDecodingTable[static_cast<unsigned char>(input.at(i++))];
|
||||
std::uint32_t c =
|
||||
input.at(i) == '='
|
||||
? 0U & i++
|
||||
: kDecodingTable[static_cast<unsigned char>(input.at(i++))];
|
||||
std::uint32_t d =
|
||||
input.at(i) == '='
|
||||
? 0U & i++
|
||||
: kDecodingTable[static_cast<unsigned char>(input.at(i++))];
|
||||
|
||||
std::uint32_t triple =
|
||||
(a << 3U * 6U) + (b << 2U * 6U) + (c << 1U * 6U) + (d << 0U * 6U);
|
||||
|
||||
if (j < out_len)
|
||||
out[j++] = (triple >> 2U * 8U) & 0xFF;
|
||||
if (j < out_len)
|
||||
out[j++] = (triple >> 1U * 8U) & 0xFF;
|
||||
if (j < out_len)
|
||||
out[j++] = (triple >> 0U * 8U) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
} // namespace macaron::Base64
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif /* _MACARON_BASE64_H_ */
|
||||
|
||||
// NOLINTEND
|
178
support/include/utils/collection.hpp
Normal file
178
support/include/utils/collection.hpp
Normal file
@ -0,0 +1,178 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_COLLECTION_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_COLLECTION_HPP_
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace monitarr::utils::collection {
|
||||
template <typename col_t>
|
||||
[[nodiscard]] inline auto excludes(const col_t &collection,
|
||||
const typename col_t::value_type &val)
|
||||
-> bool;
|
||||
|
||||
template <typename col_t>
|
||||
[[nodiscard]] inline auto includes(const col_t &collection,
|
||||
const typename col_t::value_type &val)
|
||||
-> bool;
|
||||
|
||||
template <typename val_t>
|
||||
[[nodiscard]] inline auto from_hex_string(std::string_view str, val_t &val)
|
||||
-> bool;
|
||||
|
||||
template <typename val_t>
|
||||
[[nodiscard]] inline auto from_hex_string(std::wstring_view str, val_t &val)
|
||||
-> bool;
|
||||
template <typename col_t>
|
||||
inline auto remove_element(col_t &collection,
|
||||
const typename col_t::value_type &value) -> col_t &;
|
||||
|
||||
template <typename col_t>
|
||||
[[nodiscard]] inline auto to_hex_string(const col_t &collection) -> std::string;
|
||||
|
||||
template <typename col_t>
|
||||
[[nodiscard]] inline auto to_hex_wstring(const col_t &collection)
|
||||
-> std::wstring;
|
||||
|
||||
template <typename col_t>
|
||||
inline auto excludes(const col_t &collection,
|
||||
const typename col_t::value_type &val) -> bool {
|
||||
return std::find(collection.begin(), collection.end(), val) ==
|
||||
collection.end();
|
||||
}
|
||||
|
||||
template <typename col_t>
|
||||
inline auto includes(const col_t &collection,
|
||||
const typename col_t::value_type &val) -> bool {
|
||||
return std::find(collection.begin(), collection.end(), val) !=
|
||||
collection.end();
|
||||
}
|
||||
|
||||
template <typename val_t>
|
||||
[[nodiscard]] inline auto from_hex_string_t(std::string_view str, val_t &val)
|
||||
-> bool {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
static constexpr const auto base16{16};
|
||||
|
||||
try {
|
||||
val.clear();
|
||||
|
||||
std::string fmt_val{str};
|
||||
utils::string::trim(fmt_val);
|
||||
if (fmt_val.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
fmt_val = utils::string::to_lower(fmt_val);
|
||||
if (utils::string::begins_with(fmt_val, "0x")) {
|
||||
fmt_val = fmt_val.substr(2U);
|
||||
}
|
||||
|
||||
if (fmt_val.empty()) {
|
||||
throw utils::error::create_exception(function_name,
|
||||
{
|
||||
"hex string is invalid",
|
||||
str,
|
||||
});
|
||||
}
|
||||
|
||||
if (fmt_val.length() % 2U) {
|
||||
fmt_val = '0' + fmt_val;
|
||||
}
|
||||
|
||||
auto iter = std::find_if_not(
|
||||
fmt_val.begin(), fmt_val.end(), [](auto cur_char) -> bool {
|
||||
auto check = static_cast<std::uint32_t>(cur_char);
|
||||
return ((check >= 48U && check <= 57U) ||
|
||||
(check >= 97U && check <= 102U));
|
||||
});
|
||||
if (iter != fmt_val.end()) {
|
||||
auto invalid_idx{std::distance(fmt_val.begin(), iter)};
|
||||
throw std::range_error(utils::error::create_error_message({
|
||||
function_name,
|
||||
"invalid character in hex string",
|
||||
std::to_string(invalid_idx),
|
||||
std::string(1U, str.at(invalid_idx)),
|
||||
str,
|
||||
}));
|
||||
}
|
||||
|
||||
val.resize(fmt_val.length() / 2U);
|
||||
for (std::size_t idx = 0U; idx < fmt_val.length(); idx += 2U) {
|
||||
val.at(idx / 2U) = static_cast<typename val_t::value_type>(
|
||||
std::strtoul(fmt_val.substr(idx, 2U).c_str(), nullptr, base16));
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
}
|
||||
|
||||
val.clear();
|
||||
return false;
|
||||
}
|
||||
template <typename val_t>
|
||||
inline auto from_hex_string(std::string_view str, val_t &val) -> bool {
|
||||
return from_hex_string_t<val_t>(str, val);
|
||||
}
|
||||
|
||||
template <typename val_t>
|
||||
inline auto from_hex_string(std::wstring_view str, val_t &val) -> bool {
|
||||
return from_hex_string_t<val_t>(utils::string::to_utf8(str), val);
|
||||
}
|
||||
|
||||
template <typename col_t>
|
||||
inline auto remove_element(col_t &collection,
|
||||
const typename col_t::value_type &value) -> col_t & {
|
||||
collection.erase(std::remove(collection.begin(), collection.end(), value),
|
||||
collection.end());
|
||||
return collection;
|
||||
}
|
||||
|
||||
template <typename col_t>
|
||||
inline auto to_hex_string(const col_t &collection) -> std::string {
|
||||
static_assert(sizeof(typename col_t::value_type) == 1U,
|
||||
"value_type must be 1 byte in size");
|
||||
static constexpr const auto mask = 0xFF;
|
||||
|
||||
std::stringstream stream{};
|
||||
for (auto &&val : collection) {
|
||||
stream << std::setfill('0') << std::setw(2) << std::hex
|
||||
<< (static_cast<std::uint32_t>(val) & mask);
|
||||
}
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template <typename col_t>
|
||||
inline auto to_hex_wstring(const col_t &collection) -> std::wstring {
|
||||
return utils::string::from_utf8(to_hex_string<col_t>(collection));
|
||||
}
|
||||
} // namespace monitarr::utils::collection
|
||||
|
||||
#endif // MONITARR_INCLUDE_UTILS_COLLECTION_HPP_
|
54
support/include/utils/com_init_wrapper.hpp
Normal file
54
support/include/utils/com_init_wrapper.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_
|
||||
#if defined(_WIN32)
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace monitarr::utils {
|
||||
struct com_init_wrapper final {
|
||||
com_init_wrapper()
|
||||
: initialized_(
|
||||
SUCCEEDED(::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) {}
|
||||
|
||||
com_init_wrapper(const com_init_wrapper &) = delete;
|
||||
com_init_wrapper(com_init_wrapper &&) = delete;
|
||||
|
||||
~com_init_wrapper() {
|
||||
if (initialized_) {
|
||||
::CoUninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
auto operator=(const com_init_wrapper &) -> com_init_wrapper & = delete;
|
||||
auto operator=(com_init_wrapper &&) -> com_init_wrapper & = delete;
|
||||
|
||||
[[nodiscard]] auto is_initialized() const -> bool { return initialized_; }
|
||||
|
||||
private:
|
||||
BOOL initialized_;
|
||||
};
|
||||
} // namespace monitarr::utils
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
#endif // MONITARR_INCLUDE_UTILS_COM_INIT_WRAPPER_HPP_
|
145
support/include/utils/common.hpp
Normal file
145
support/include/utils/common.hpp
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_COMMON_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_COMMON_HPP_
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
namespace monitarr::utils {
|
||||
struct result final {
|
||||
std::string function_name;
|
||||
bool ok{true};
|
||||
std::string reason{"success"};
|
||||
|
||||
[[nodiscard]] operator bool() const { return ok; }
|
||||
};
|
||||
|
||||
using retryable_action_t = std::function<bool()>;
|
||||
|
||||
[[nodiscard]] inline constexpr auto
|
||||
calculate_read_size(std::uint64_t total_size, std::size_t read_size,
|
||||
std::uint64_t offset) -> std::size_t {
|
||||
return static_cast<std::size_t>(
|
||||
((offset + read_size) > total_size)
|
||||
? ((offset < total_size) ? total_size - offset : 0U)
|
||||
: read_size);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto compare_version_strings(std::string version1,
|
||||
std::string version2)
|
||||
-> std::int32_t;
|
||||
|
||||
[[nodiscard]] auto compare_version_strings(std::wstring_view version1,
|
||||
std::wstring_view version2)
|
||||
-> std::int32_t;
|
||||
|
||||
#if defined(PROJECT_ENABLE_STDUUID)
|
||||
[[nodiscard]] auto create_uuid_string() -> std::string;
|
||||
|
||||
[[nodiscard]] auto create_uuid_wstring() -> std::wstring;
|
||||
#endif // defined(PROJECT_ENABLE_STDUUID)
|
||||
|
||||
template <typename result_t, typename data_t>
|
||||
[[nodiscard]] inline constexpr auto divide_with_ceiling(result_t numerator,
|
||||
data_t denominator)
|
||||
-> result_t;
|
||||
|
||||
template <typename data_t>
|
||||
[[nodiscard]] inline auto generate_random_between(data_t begin, data_t end)
|
||||
-> data_t;
|
||||
|
||||
[[nodiscard]] auto generate_random_string(std::size_t length) -> std::string;
|
||||
|
||||
[[nodiscard]] auto generate_random_wstring(std::size_t length) -> std::wstring;
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
template <typename data_t>
|
||||
[[nodiscard]] inline auto generate_secure_random() -> data_t;
|
||||
|
||||
template <typename data_t>
|
||||
[[nodiscard]] inline auto generate_secure_random(std::size_t size) -> data_t;
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
[[nodiscard]] auto get_environment_variable(std::string_view variable)
|
||||
-> std::string;
|
||||
|
||||
[[nodiscard]] auto get_environment_variable(std::wstring_view variable)
|
||||
-> std::wstring;
|
||||
|
||||
#if defined(PROJECT_ENABLE_BOOST)
|
||||
[[nodiscard]] auto get_next_available_port(std::uint16_t first_port,
|
||||
std::uint16_t &available_port)
|
||||
-> bool;
|
||||
#endif // defined(PROJECT_ENABLE_BOOST)
|
||||
|
||||
[[nodiscard]] auto retry_action(
|
||||
retryable_action_t action, std::size_t retry_count = 200U,
|
||||
std::chrono::milliseconds retry_wait = std::chrono::milliseconds(10))
|
||||
-> bool;
|
||||
|
||||
template <typename result_t, typename data_t>
|
||||
inline constexpr auto divide_with_ceiling(result_t numerator,
|
||||
data_t denominator) -> result_t {
|
||||
static_assert(std::is_integral_v<std::remove_cv_t<data_t>>,
|
||||
"denominator must be an integral type");
|
||||
|
||||
return denominator == 0
|
||||
? 0
|
||||
: (numerator / denominator) + (numerator % denominator != 0);
|
||||
}
|
||||
|
||||
template <typename data_t>
|
||||
inline auto generate_random_between(data_t begin, data_t end) -> data_t {
|
||||
static_assert(std::is_integral_v<std::remove_cv_t<data_t>>,
|
||||
"data_t must be an integral type");
|
||||
if (end <= begin) {
|
||||
throw std::range_error("end must be greater than begin");
|
||||
}
|
||||
|
||||
thread_local std::mt19937 gen(
|
||||
static_cast<unsigned long>(std::time(nullptr) ^ std::random_device{}()));
|
||||
std::uniform_int_distribution<data_t> dis(begin, end);
|
||||
return dis(gen);
|
||||
}
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
template <typename data_t> inline auto generate_secure_random() -> data_t {
|
||||
static_assert(!is_collection<std::decay_t<data_t>>::value,
|
||||
"data_t is a vector or collection");
|
||||
data_t ret{};
|
||||
randombytes_buf(&ret, sizeof(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename data_t>
|
||||
inline auto generate_secure_random(std::size_t size) -> data_t {
|
||||
static_assert(is_collection<std::decay_t<data_t>>::value,
|
||||
"data_t is not a vector or collection");
|
||||
data_t ret;
|
||||
ret.resize(size);
|
||||
randombytes_buf(ret.data(), ret.size() * sizeof(typename data_t::value_type));
|
||||
return ret;
|
||||
}
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
} // namespace monitarr::utils
|
||||
|
||||
#endif // MONITARR_INCLUDE_UTILS_COMMON_HPP_
|
482
support/include/utils/config.hpp
Normal file
482
support/include/utils/config.hpp
Normal file
@ -0,0 +1,482 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_CONFIG_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_CONFIG_HPP_
|
||||
|
||||
#define NOMINMAX
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define WINVER 0x0602
|
||||
#define _WIN32_WINNT WINVER
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#include <windows.h>
|
||||
#if defined(PROJECT_ENABLE_WINFSP)
|
||||
#include <sddl.h>
|
||||
#endif // defined(PROJECT_ENABLE_WINFSP)
|
||||
|
||||
#include <direct.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <errno.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <objbase.h>
|
||||
#include <psapi.h>
|
||||
#include <rpc.h>
|
||||
#include <share.h>
|
||||
#include <shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <stdio.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(__cplusplus)
|
||||
#include <time.h>
|
||||
#endif // !defined(__cplusplus)
|
||||
#else // !defined(_WIN32)
|
||||
#include <arpa/inet.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <libgen.h>
|
||||
#include <netinet/in.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#if defined(__LFS64__)
|
||||
#include <sys/stat64.h>
|
||||
#else // !defined(__LFS64__)
|
||||
#include <sys/stat.h>
|
||||
#endif // defined(__LFS64__)
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/statfs.h>
|
||||
#endif // defined(HAS_SETXATTR)
|
||||
|
||||
#if defined(HAS_SETXATTR)
|
||||
#include <sys/types.h>
|
||||
#include <sys/xattr.h>
|
||||
#endif // defined(HAS_SETXATTR)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <libproc.h>
|
||||
#include <sys/attr.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/vnode.h>
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
#include <unistd.h>
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
#if defined(HAS_WORDEXP_H)
|
||||
#include <wordexp.h>
|
||||
#endif // defined(HAS_WORDEXP_H)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <bit>
|
||||
#include <cerrno>
|
||||
#include <chrono>
|
||||
#include <ciso646>
|
||||
#include <climits>
|
||||
#include <codecvt>
|
||||
#include <condition_variable>
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <deque>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <future>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <locale>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <ranges>
|
||||
#include <regex>
|
||||
#include <span>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#endif // defined(__cplusplus)
|
||||
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
#include "curl/curl.h"
|
||||
#include "curl/multi.h"
|
||||
#endif // defined(PROJECT_ENABLE_CURL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_FUSE)
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
#include <fuse.h>
|
||||
#include <fuse_lowlevel.h>
|
||||
#else
|
||||
#include <fuse/fuse.h>
|
||||
#endif
|
||||
#endif // defined(PROJECT_ENABLE_FUSE)
|
||||
|
||||
#if defined(PROJECT_ENABLE_FZF)
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // defined(__cplusplus)
|
||||
#include "fzf.h"
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif // defined(__cplusplus)
|
||||
#endif // defined(PROJECT_ENABLE_FZF)
|
||||
|
||||
#if defined(PROJECT_ENABLE_OPENSSL)
|
||||
#include "openssl/ssl.h"
|
||||
#endif // defined(PROJECT_ENABLE_OPENSSL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBDSM)
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // defined(__cplusplus)
|
||||
#include "bdsm/bdsm.h"
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
struct netbios_ns_deleter final {
|
||||
void operator()(netbios_ns *ns) const {
|
||||
if (ns != nullptr) {
|
||||
netbios_ns_destroy(ns);
|
||||
}
|
||||
}
|
||||
};
|
||||
using netbios_ns_t = std::unique_ptr<netbios_ns, netbios_ns_deleter>;
|
||||
|
||||
inline const auto smb_session_deleter = [](smb_session *session) {
|
||||
if (session != nullptr) {
|
||||
smb_session_destroy(session);
|
||||
}
|
||||
};
|
||||
using smb_session_t = std::shared_ptr<smb_session>;
|
||||
|
||||
struct smb_stat_deleter final {
|
||||
void operator()(smb_stat st) const {
|
||||
if (st != nullptr) {
|
||||
smb_stat_destroy(st);
|
||||
}
|
||||
}
|
||||
};
|
||||
using smb_stat_t = std::unique_ptr<smb_file, smb_stat_deleter>;
|
||||
|
||||
struct smb_stat_list_deleter final {
|
||||
void operator()(smb_file *list) const {
|
||||
if (list != nullptr) {
|
||||
smb_stat_list_destroy(list);
|
||||
}
|
||||
}
|
||||
};
|
||||
using smb_stat_list_t = std::unique_ptr<smb_file, smb_stat_list_deleter>;
|
||||
#endif // defined(__cplusplus)
|
||||
#endif // defined(PROJECT_ENABLE_LIBDSM)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBEVENT)
|
||||
#include "event2/buffer.h"
|
||||
#include "event2/bufferevent.h"
|
||||
#include "event2/listener.h"
|
||||
#include "event2/thread.h"
|
||||
#include "event2/util.h"
|
||||
#endif // defined(PROJECT_ENABLE_LIBEVENT)
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
#include "sodium.h"
|
||||
#endif // defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SDL)
|
||||
#include "SDL.h"
|
||||
#include "SDL_gamecontroller.h"
|
||||
#include "SDL_joystick.h"
|
||||
#endif // defined(PROJECT_ENABLE_SDL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
#include "sqlite3.h"
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#if defined(PROJECT_ENABLE_VLC)
|
||||
#include <vlc/vlc.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
[[nodiscard]] inline auto get_libvlc_error_msg() -> std::string {
|
||||
const auto *msg = libvlc_errmsg();
|
||||
return msg == nullptr ? "none" : msg;
|
||||
}
|
||||
|
||||
struct vlc_deleter final {
|
||||
void operator()(libvlc_instance_t *inst) const {
|
||||
if (inst != nullptr) {
|
||||
libvlc_release(inst);
|
||||
}
|
||||
}
|
||||
};
|
||||
using vlc_t = std::unique_ptr<libvlc_instance_t, vlc_deleter>;
|
||||
|
||||
struct vlc_media_deleter final {
|
||||
void operator()(libvlc_media_t *media) const {
|
||||
if (media != nullptr) {
|
||||
libvlc_media_release(media);
|
||||
}
|
||||
}
|
||||
};
|
||||
using vlc_media_t = std::unique_ptr<libvlc_media_t, vlc_media_deleter>;
|
||||
|
||||
struct vlc_media_list_deleter final {
|
||||
void operator()(libvlc_media_list_t *media_list) const {
|
||||
if (media_list != nullptr) {
|
||||
libvlc_media_list_release(media_list);
|
||||
}
|
||||
}
|
||||
};
|
||||
using vlc_media_list_t =
|
||||
std::unique_ptr<libvlc_media_list_t, vlc_media_list_deleter>;
|
||||
|
||||
struct vlc_string_deleter final {
|
||||
void operator()(char *str) const {
|
||||
if (str != nullptr) {
|
||||
libvlc_free(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
using vlc_string_t = std::unique_ptr<char, vlc_string_deleter>;
|
||||
#endif // defined(__cplusplus)
|
||||
#endif // defined(PROJECT_ENABLE_VLC)
|
||||
|
||||
#if !defined(fstat64)
|
||||
#define fstat64 fstat
|
||||
#endif // !defined(fstat64)
|
||||
|
||||
#if !defined(pread64)
|
||||
#define pread64 pread
|
||||
#endif // !defined(pread64)
|
||||
|
||||
#if !defined(pwrite64)
|
||||
#define pwrite64 pwrite
|
||||
#endif // !defined(pwrite64)
|
||||
|
||||
#if !defined(stat64)
|
||||
#define stat64 stat
|
||||
#endif // !defined(stat64)
|
||||
|
||||
#if !defined(statfs64)
|
||||
#define statfs64 statfs
|
||||
#endif // !defined(statfs64)
|
||||
|
||||
#if !defined(off64_t)
|
||||
#define off64_t std::size_t
|
||||
#endif // !defined(off64_t)
|
||||
|
||||
#if !defined(__off64_t)
|
||||
#define __off64_t off64_t
|
||||
#endif // !defined(__off64_t)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if defined(PROJECT_ENABLE_BOOST)
|
||||
#include "boost/archive/text_iarchive.hpp"
|
||||
#include "boost/archive/text_oarchive.hpp"
|
||||
#include "boost/asio.hpp"
|
||||
#include "boost/asio/io_context.hpp"
|
||||
#include "boost/bind/bind.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include "boost/dynamic_bitset/serialization.hpp"
|
||||
#include "boost/endian/conversion.hpp"
|
||||
#include "boost/integer.hpp"
|
||||
#include "boost/interprocess/sync/named_mutex.hpp"
|
||||
#include "boost/interprocess/sync/scoped_lock.hpp"
|
||||
#include "boost/multiprecision/cpp_dec_float.hpp"
|
||||
#include "boost/multiprecision/cpp_int.hpp"
|
||||
#include "boost/serialization/vector.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_BOOST)
|
||||
|
||||
#if defined(PROJECT_ENABLE_CLI11)
|
||||
#if defined(PROJECT_IS_MINGW) && !defined(PROJECT_IS_MINGW_UNIX)
|
||||
#include "CLI/CLI.hpp"
|
||||
#else // !defined(PROJECT_IS_MINGW) || defined(PROJECT_IS_MINGW_UNIX)
|
||||
#include "CLI11.hpp"
|
||||
#endif // defined(PROJECT_IS_MINGW) && !defined(PROJECT_IS_MINGW_UNIX)
|
||||
#endif // defined(PROJECT_ENABLE_CLI11)
|
||||
|
||||
#if defined(PROJECT_ENABLE_CPP_HTTPLIB)
|
||||
#include "httplib.h"
|
||||
#endif // defined(PROJECT_ENABLE_JSON)
|
||||
|
||||
#if defined(PROJECT_ENABLE_DTL)
|
||||
#include "dtl/dtl.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_DTL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_JSON)
|
||||
#include "json.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_JSON)
|
||||
|
||||
#if defined(PROJECT_ENABLE_NANA)
|
||||
#include "nana/gui.hpp"
|
||||
#include "nana/gui/timer.hpp"
|
||||
#include "nana/gui/widgets/button.hpp"
|
||||
#include "nana/gui/widgets/combox.hpp"
|
||||
#include "nana/gui/widgets/group.hpp"
|
||||
#include "nana/gui/widgets/label.hpp"
|
||||
#include "nana/gui/widgets/panel.hpp"
|
||||
#include "nana/gui/widgets/picture.hpp"
|
||||
#include "nana/gui/widgets/tabbar.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_NANA)
|
||||
|
||||
#if defined(PROJECT_ENABLE_PUGIXML)
|
||||
#include "pugixml.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_PUGIXML)
|
||||
|
||||
#if defined(PROJECT_ENABLE_ROCKSDB)
|
||||
#include "rocksdb/db.h"
|
||||
#include "rocksdb/utilities/transaction_db.h"
|
||||
#endif // defined(PROJECT_ENABLE_ROCKSDB)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SFML)
|
||||
#include "RoundedRectangleShape.hpp"
|
||||
#include "SFML/Graphics.hpp"
|
||||
#include "Text2.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_SFML)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SAGO_PLATFORM_FOLDERS)
|
||||
#include "platform_folders.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_SAGO_PLATFORM_FOLDERS)
|
||||
|
||||
#if defined(PROJECT_ENABLE_SPDLOG)
|
||||
#include "spdlog/async.h"
|
||||
#include "spdlog/fmt/bundled/core.h"
|
||||
#include "spdlog/fmt/bundled/format.h"
|
||||
#include "spdlog/fmt/bundled/ranges.h"
|
||||
#include "spdlog/fmt/chrono.h"
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#endif // defined(PROJECT_ENABLE_SPDLOG)
|
||||
|
||||
#if defined(PROJECT_ENABLE_STDUUID)
|
||||
#include "uuid.h"
|
||||
#endif // defined(PROJECT_ENABLE_STDUUID)
|
||||
|
||||
#if defined(PROJECT_ENABLE_TPL)
|
||||
#include "process.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_TPL)
|
||||
|
||||
#if defined(PROJECT_ENABLE_WINFSP)
|
||||
#include "winfsp/winfsp.hpp"
|
||||
#endif // defined(PROJECT_ENABLE_WINFSP)
|
||||
|
||||
namespace monitarr {
|
||||
using data_buffer = std::vector<unsigned char>;
|
||||
using mutex_lock = std::lock_guard<std::mutex>;
|
||||
using recur_mutex_lock = std::lock_guard<std::recursive_mutex>;
|
||||
using stop_type = std::atomic_bool;
|
||||
using stop_type_callback = std::function<std::atomic_bool()>;
|
||||
using unique_mutex_lock = std::unique_lock<std::mutex>;
|
||||
using unique_recur_mutex_lock = std::unique_lock<std::recursive_mutex>;
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
|
||||
inline constexpr const auto max_path_length = std::size_t{32767U};
|
||||
#else // !defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
|
||||
inline constexpr const auto max_path_length = std::size_t{MAX_PATH};
|
||||
#endif // defined(PROJECT_ENABLE_WIN32_LONG_PATH_NAMES)
|
||||
|
||||
using native_handle = HANDLE;
|
||||
#else // !defined(_WIN32)
|
||||
inline constexpr const auto max_path_length = std::size_t{PATH_MAX};
|
||||
using native_handle = int;
|
||||
#if !defined(INVALID_HANDLE_VALUE)
|
||||
#define INVALID_HANDLE_VALUE (-1)
|
||||
#endif // !defined(INVALID_HANDLE_VALUE)
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
template <class... Ts> struct overloaded : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
template <typename T> struct is_collection {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <typename T, typename A>
|
||||
struct is_collection<std::vector<T, A>> : std::true_type {};
|
||||
|
||||
template <typename T> struct is_collection<std::deque<T>> : std::true_type {};
|
||||
|
||||
template <> struct is_collection<std::string> : std::true_type {};
|
||||
|
||||
template <> struct is_collection<std::wstring> : std::true_type {};
|
||||
|
||||
struct file_deleter final {
|
||||
void operator()(FILE *file) {
|
||||
if (file != nullptr) {
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
using file_t = std::unique_ptr<FILE, file_deleter>;
|
||||
|
||||
struct http_range final {
|
||||
std::uint64_t begin{};
|
||||
std::uint64_t end{};
|
||||
};
|
||||
|
||||
using http_headers = std::map<std::string, std::string>;
|
||||
using http_query_parameters = std::map<std::string, std::string>;
|
||||
using http_ranges = std::vector<http_range>;
|
||||
} // namespace monitarr
|
||||
#endif // defined(__cplusplus)
|
||||
|
||||
#define MONITARR_USES_FUNCTION_NAME() \
|
||||
static constexpr const std::string_view function_name { \
|
||||
static_cast<const char *>(__FUNCTION__), \
|
||||
}
|
||||
|
||||
#endif // MONITARR_INCLUDE_UTILS_CONFIG_HPP_
|
170
support/include/utils/db/sqlite/db_common.hpp
Normal file
170
support/include/utils/db/sqlite/db_common.hpp
Normal file
@ -0,0 +1,170 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#include "utils/config.hpp"
|
||||
|
||||
#include "utils/error.hpp"
|
||||
|
||||
namespace monitarr::utils::db::sqlite {
|
||||
using db_types_t = std::variant<std::int64_t, std::string>;
|
||||
|
||||
struct sqlite3_deleter final {
|
||||
void operator()(sqlite3 *db3) const;
|
||||
};
|
||||
|
||||
using db3_t = std::unique_ptr<sqlite3, sqlite3_deleter>;
|
||||
|
||||
struct sqlite3_statement_deleter final {
|
||||
void operator()(sqlite3_stmt *stmt) const {
|
||||
if (stmt != nullptr) {
|
||||
sqlite3_finalize(stmt);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using db3_stmt_t = std::unique_ptr<sqlite3_stmt, sqlite3_statement_deleter>;
|
||||
|
||||
[[nodiscard]] auto
|
||||
create_db(std::string db_path,
|
||||
const std::map<std::string, std::string> &sql_create_tables) -> db3_t;
|
||||
|
||||
[[nodiscard]] auto execute_sql(sqlite3 &db3, const std::string &sql,
|
||||
std::string &err) -> bool;
|
||||
|
||||
void set_journal_mode(sqlite3 &db3);
|
||||
|
||||
struct db_comp_data_t final {
|
||||
std::string column_name;
|
||||
std::string op_type;
|
||||
};
|
||||
|
||||
struct db_context_t {
|
||||
db_context_t(sqlite3 *db3_, std::string table_name_)
|
||||
: db3(db3_), table_name(std::move(table_name_)) {}
|
||||
|
||||
sqlite3 *db3{};
|
||||
std::string table_name;
|
||||
};
|
||||
|
||||
struct db_result final {
|
||||
struct context final {
|
||||
db3_stmt_t stmt;
|
||||
};
|
||||
|
||||
class db_column final {
|
||||
public:
|
||||
db_column(std::int32_t index, std::string name, db_types_t value) noexcept;
|
||||
|
||||
db_column() noexcept = default;
|
||||
db_column(const db_column &) = default;
|
||||
db_column(db_column &&column) noexcept = default;
|
||||
|
||||
~db_column() = default;
|
||||
|
||||
auto operator=(const db_column &) -> db_column & = default;
|
||||
auto operator=(db_column &&) -> db_column & = default;
|
||||
|
||||
private:
|
||||
std::int32_t index_{};
|
||||
std::string name_;
|
||||
db_types_t value_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_index() const -> std::int32_t { return index_; }
|
||||
|
||||
[[nodiscard]] auto get_name() const -> std::string { return name_; }
|
||||
|
||||
template <typename data_type>
|
||||
[[nodiscard]] auto get_value() const -> data_type {
|
||||
MONITARR_USES_FUNCTION_NAME();
|
||||
|
||||
return std::visit(
|
||||
overloaded{
|
||||
[](const data_type &value) -> data_type { return value; },
|
||||
[](auto &&) -> data_type {
|
||||
throw utils::error::create_exception(
|
||||
function_name, {
|
||||
"data type not supported",
|
||||
});
|
||||
},
|
||||
},
|
||||
value_);
|
||||
}
|
||||
|
||||
#if defined(PROJECT_ENABLE_JSON)
|
||||
[[nodiscard]] auto get_value_as_json() const -> nlohmann::json;
|
||||
#endif // defined(PROJECT_ENABLE_JSON)
|
||||
};
|
||||
|
||||
class db_row final {
|
||||
public:
|
||||
db_row(std::shared_ptr<context> ctx);
|
||||
|
||||
private:
|
||||
std::map<std::string, db_column> columns_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_columns() const -> std::vector<db_column>;
|
||||
|
||||
[[nodiscard]] auto get_column(std::int32_t index) const -> db_column;
|
||||
|
||||
[[nodiscard]] auto get_column(std::string name) const -> db_column;
|
||||
};
|
||||
|
||||
db_result(db3_stmt_t stmt, std::int32_t res);
|
||||
|
||||
db_result() = default;
|
||||
db_result(const db_result &) = default;
|
||||
db_result(db_result &&) noexcept = default;
|
||||
|
||||
auto operator=(const db_result &) -> db_result & = default;
|
||||
auto operator=(db_result &&) -> db_result & = default;
|
||||
|
||||
using row = db_row;
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
mutable std::int32_t res_{};
|
||||
|
||||
private:
|
||||
void set_res(std::int32_t res) const { res_ = res; }
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto get_error() const -> std::int32_t { return res_; }
|
||||
|
||||
[[nodiscard]] auto get_error_str() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto get_row(std::optional<row> &opt_row) const -> bool;
|
||||
|
||||
[[nodiscard]] auto has_row() const -> bool;
|
||||
|
||||
void next_row() const;
|
||||
|
||||
[[nodiscard]] auto ok() const -> bool;
|
||||
};
|
||||
} // namespace monitarr::utils::db::sqlite
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_COMMON_HPP_
|
73
support/include/utils/db/sqlite/db_delete.hpp
Normal file
73
support/include/utils/db/sqlite/db_delete.hpp
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
|
||||
#include "utils/db/sqlite/db_where_t.hpp"
|
||||
|
||||
namespace monitarr::utils::db::sqlite {
|
||||
class db_delete final {
|
||||
public:
|
||||
struct context final : db_context_t {
|
||||
struct db_delete_op_t final {
|
||||
std::shared_ptr<context> ctx;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
};
|
||||
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
using w_t = db_where_t<context, db_delete_op_t>;
|
||||
using wd_t = where_data_t<w_t>;
|
||||
|
||||
std::unique_ptr<wd_t> where_data;
|
||||
};
|
||||
|
||||
public:
|
||||
db_delete(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
|
||||
db_delete(std::shared_ptr<context> ctx) : ctx_(std::move(ctx)) {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
|
||||
[[nodiscard]] auto
|
||||
group(context::w_t::group_func_t func) -> context::w_t::wn_t;
|
||||
|
||||
[[nodiscard]] auto where(std::string column_name) const -> context::w_t::cn_t;
|
||||
};
|
||||
} // namespace monitarr::utils::db::sqlite
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_DELETE_HPP_
|
64
support/include/utils/db/sqlite/db_insert.hpp
Normal file
64
support/include/utils/db/sqlite/db_insert.hpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright <2018-2025> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#ifndef MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
||||
#define MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#include "utils/db/sqlite/db_common.hpp"
|
||||
|
||||
namespace monitarr::utils::db::sqlite {
|
||||
class db_insert final {
|
||||
public:
|
||||
struct context final : db_context_t {
|
||||
context(sqlite3 *db3_, std::string table_name_)
|
||||
: db_context_t(db3_, table_name_) {}
|
||||
|
||||
bool or_replace{false};
|
||||
std::map<std::string, db_types_t> values;
|
||||
};
|
||||
|
||||
public:
|
||||
db_insert(sqlite3 &db3, std::string table_name)
|
||||
: ctx_(std::make_shared<context>(&db3, table_name)) {}
|
||||
|
||||
db_insert(std::shared_ptr<context> ctx) : ctx_(std::move(ctx)) {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<context> ctx_;
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto or_replace() -> db_insert {
|
||||
ctx_->or_replace = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto column_value(std::string column_name, db_types_t value)
|
||||
-> db_insert;
|
||||
|
||||
[[nodiscard]] auto dump() const -> std::string;
|
||||
|
||||
[[nodiscard]] auto go() const -> db_result;
|
||||
};
|
||||
} // namespace monitarr::utils::db::sqlite
|
||||
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
#endif // MONITARR_INCLUDE_UTILS_DB_SQLITE_DB_INSERT_HPP_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user