mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 09:33:45 +01:00
Move sha256.c to lib/
Precompiled headers don't work if we're not a pure C++ project.
This commit is contained in:
parent
3120558dd1
commit
cdbbac5b6d
@ -277,6 +277,7 @@ find_package(Lua REQUIRED)
|
||||
if(NOT USE_LUAJIT)
|
||||
add_subdirectory(lib/bitop)
|
||||
endif()
|
||||
add_subdirectory(lib/sha256)
|
||||
|
||||
if(BUILD_UNITTESTS OR BUILD_BENCHMARKS)
|
||||
add_subdirectory(lib/catch2)
|
||||
|
14
lib/sha256/CMakeLists.txt
Normal file
14
lib/sha256/CMakeLists.txt
Normal 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}")
|
5
lib/sha256/cmake_config.h.in
Normal file
5
lib/sha256/cmake_config.h.in
Normal file
@ -0,0 +1,5 @@
|
||||
// Filled in by the build system
|
||||
|
||||
#pragma once
|
||||
|
||||
#cmakedefine HAVE_ENDIAN_H
|
@ -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 **/
|
||||
/*
|
@ -565,6 +565,7 @@ if(BUILD_CLIENT)
|
||||
${GMP_LIBRARY}
|
||||
${JSON_LIBRARY}
|
||||
${LUA_BIT_LIBRARY}
|
||||
sha256
|
||||
${FREETYPE_LIBRARY}
|
||||
${PLATFORM_LIBS}
|
||||
# on Android, Minetest depends on SDL2 directly
|
||||
@ -637,6 +638,7 @@ if(BUILD_SERVER)
|
||||
${JSON_LIBRARY}
|
||||
${LUA_LIBRARY}
|
||||
${LUA_BIT_LIBRARY}
|
||||
sha256
|
||||
${GMP_LIBRARY}
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
|
@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "version.h"
|
||||
#include "util/hex.h"
|
||||
#include "util/sha1.h"
|
||||
#include "util/sha256.h"
|
||||
#include <sha256/sha256.h>
|
||||
#include "util/png.h"
|
||||
#include <cstdio>
|
||||
|
||||
@ -573,7 +573,7 @@ int ModApiUtil::l_sha256(lua_State *L)
|
||||
|
||||
auto data = readParam<std::string_view>(L, 1);
|
||||
bool hex = !lua_isboolean(L, 2) || !readParam<bool>(L, 2);
|
||||
|
||||
|
||||
std::string data_sha256;
|
||||
data_sha256.resize(SHA256_DIGEST_LENGTH);
|
||||
SHA256(reinterpret_cast<const unsigned char*>(data.data()), data.size(),
|
||||
|
@ -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
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include <mini-gmp.h>
|
||||
#endif
|
||||
|
||||
#include "util/sha256.h"
|
||||
#include <sha256/sha256.h>
|
||||
|
||||
#include "srp.h"
|
||||
//#define CSRP_USE_SHA1
|
||||
|
Loading…
Reference in New Issue
Block a user