This commit is contained in:
DS 2024-05-17 13:37:06 +00:00 committed by GitHub
commit ad05e66eb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 157 additions and 8 deletions

View File

@ -277,6 +277,7 @@ find_package(Lua REQUIRED)
if(NOT USE_LUAJIT)
add_subdirectory(lib/bitop)
endif()
add_subdirectory(lib/sha256)
if(BUILD_BENCHMARKS)
add_subdirectory(lib/catch2)

View File

@ -20,6 +20,8 @@ General options and their default values:
SemiDebug - Partially optimized debug build
RelWithDebInfo - Release build with debug information
MinSizeRel - Release build with -Os passed to compiler to make executable as small as possible
PRECOMPILE_HEADERS=FALSE - Precompile some headers (experimental; requires CMake 3.16 or later)
PRECOMPILED_HEADERS_PATH= - Path to a file listing all headers to precompile (default points to src/precompiled_headers.txt)
ENABLE_CURL=ON - Build with cURL; Enables use of online mod repo, public serverlist and remote media fetching via http
ENABLE_CURSES=ON - Build with (n)curses; Enables a server side terminal (command line option: --terminal)
ENABLE_GETTEXT=ON - Build with Gettext; Allows using translations

14
lib/sha256/CMakeLists.txt Normal file
View File

@ -0,0 +1,14 @@
project(sha256 C)
add_library(sha256 STATIC sha256.c)
target_include_directories(sha256 INTERFACE .)
INCLUDE(CheckIncludeFiles)
check_include_files(endian.h HAVE_ENDIAN_H)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
"${PROJECT_BINARY_DIR}/cmake_config.h"
)
target_include_directories(sha256 PRIVATE "${PROJECT_BINARY_DIR}")

View File

@ -0,0 +1,5 @@
// Filled in by the build system
#pragma once
#cmakedefine HAVE_ENDIAN_H

View File

@ -56,17 +56,13 @@
#include <stdlib.h>
#include <string.h>
#include "util/sha256.h"
#include "sha256/sha256.h"
#if defined(_MSC_VER) && !defined(__clang__) && !defined(__attribute__)
#define __attribute__(a)
#endif
/* pull HAVE_ENDIAN_H from Minetest */
#include "config.h"
#if !HAVE_ENDIAN_H
#undef HAVE_ENDIAN_H
#endif
#include "cmake_config.h" /* HAVE_ENDIAN_H */
/** endian.h **/
/*

View File

@ -48,6 +48,25 @@ if(NOT (BUILD_CLIENT OR BUILD_SERVER))
endif()
option(PRECOMPILE_HEADERS "Precompile some headers (experimental; requires CMake 3.16 or later)" FALSE)
set(PRECOMPILED_HEADERS_PATH "" CACHE FILEPATH "Path to a file listing all headers to precompile")
if(PRECOMPILE_HEADERS)
if(${CMAKE_VERSION} VERSION_LESS 3.16)
message(FATAL_ERROR "PRECOMPILE_HEADERS is on, but precompiled headers require at least CMake 3.16.")
endif()
if(PRECOMPILED_HEADERS_PATH)
set(PRECOMPILED_HEADERS ${PRECOMPILED_HEADERS_PATH})
else()
set(PRECOMPILED_HEADERS "${CMAKE_SOURCE_DIR}/src/precompiled_headers.txt")
endif()
message(STATUS "Reading headers to precompile from: ${PRECOMPILED_HEADERS}")
# ignore lines that begin with # and empty lines
file(STRINGS ${PRECOMPILED_HEADERS} PRECOMPILED_HEADERS_LIST REGEX "^[^#].*$")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${PRECOMPILED_HEADERS})
endif()
option(ENABLE_CURL "Enable cURL support for fetching media" TRUE)
set(USE_CURL FALSE)
@ -565,6 +584,7 @@ if(BUILD_CLIENT)
${GMP_LIBRARY}
${JSON_LIBRARY}
${LUA_BIT_LIBRARY}
sha256
${FREETYPE_LIBRARY}
${PLATFORM_LIBS}
# on Android, Minetest depends on SDL2 directly
@ -618,6 +638,10 @@ if(BUILD_CLIENT)
if(BUILD_BENCHMARKS)
target_link_libraries(${PROJECT_NAME} catch2)
endif()
if(PRECOMPILE_HEADERS)
target_precompile_headers(${PROJECT_NAME} PRIVATE ${PRECOMPILED_HEADERS_LIST})
endif()
endif(BUILD_CLIENT)
@ -637,6 +661,7 @@ if(BUILD_SERVER)
${JSON_LIBRARY}
${LUA_LIBRARY}
${LUA_BIT_LIBRARY}
sha256
${GMP_LIBRARY}
${PLATFORM_LIBS}
)
@ -680,6 +705,10 @@ if(BUILD_SERVER)
if(BUILD_BENCHMARKS)
target_link_libraries(${PROJECT_NAME}server catch2)
endif()
if(PRECOMPILE_HEADERS)
target_precompile_headers(${PROJECT_NAME}server PRIVATE ${PRECOMPILED_HEADERS_LIST})
endif()
endif(BUILD_SERVER)
# See issue #4638

103
src/precompiled_headers.txt Normal file
View File

@ -0,0 +1,103 @@
# stdlib
# ------
# C stuff:
<cassert>
<cctype>
<cerrno>
<cfenv>
<cfloat>
<cinttypes>
<ciso646>
<climits>
<clocale>
<cmath>
<csetjmp>
<csignal>
<cstdarg>
<cstdbool>
<cstddef>
<cstdint>
<cstdio>
<cstdlib>
<cstring>
<ctgmath>
<ctime>
<cuchar>
<cwchar>
<cwctype>
# Containers:
<array>
<deque>
<forward_list>
<list>
<map>
<queue>
<set>
<stack>
<unordered_map>
<unordered_set>
<vector>
# Input/Output:
<fstream>
<iomanip>
<ios>
<iosfwd>
<iostream>
<istream>
<ostream>
<sstream>
<streambuf>
# Multi-threading:
<atomic>
<condition_variable>
<future>
<mutex>
<shared_mutex>
<thread>
# Other:
<algorithm>
<any>
<bitset>
<charconv>
<chrono>
<codecvt>
<complex>
<exception>
<execution>
<functional>
<initializer_list>
<iterator>
<limits>
<locale>
<memory>
<memory_resource>
<new>
<numeric>
<optional>
<random>
<ratio>
<regex>
<stdexcept>
<string>
<string_view>
<system_error>
<tuple>
<typeindex>
<typeinfo>
<type_traits>
<utility>
<valarray>
<variant>
# libs
# ----
# jsoncpp
<json/json.h>

View File

@ -13,7 +13,6 @@ set(UTIL_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/quicktune.cpp
${CMAKE_CURRENT_SOURCE_DIR}/serialize.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sha1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sha256.c
${CMAKE_CURRENT_SOURCE_DIR}/string.cpp
${CMAKE_CURRENT_SOURCE_DIR}/srp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/timetaker.cpp

View File

@ -50,7 +50,7 @@
#include <mini-gmp.h>
#endif
#include "util/sha256.h"
#include <sha256/sha256.h>
#include "srp.h"
//#define CSRP_USE_SHA1