mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-24 14:11:49 +08:00
Port for leveldb
This commit is contained in:
parent
2b41ebc759
commit
75746d0b1f
75
ports/leveldb/CMakeLists.txt
Normal file
75
ports/leveldb/CMakeLists.txt
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(leveldb C CXX)
|
||||||
|
|
||||||
|
option(INSTALL_HEADERS "Install header files" ON)
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
-DWIN32
|
||||||
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
-D_SCL_SECURE_NO_WARNINGS
|
||||||
|
-D_CRT_SECURE_NO_WARNINGS
|
||||||
|
-DNOMINMAX
|
||||||
|
-DLEVELDB_ATOMIC_PRESENT
|
||||||
|
-DLEVELDB_PLATFORM_WINDOWS
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(libleveldb
|
||||||
|
db/builder.cc
|
||||||
|
db/c.cc
|
||||||
|
db/dbformat.cc
|
||||||
|
db/db_impl.cc
|
||||||
|
db/db_iter.cc
|
||||||
|
db/dumpfile.cc
|
||||||
|
db/filename.cc
|
||||||
|
db/log_reader.cc
|
||||||
|
db/log_writer.cc
|
||||||
|
db/memtable.cc
|
||||||
|
db/repair.cc
|
||||||
|
db/table_cache.cc
|
||||||
|
db/version_edit.cc
|
||||||
|
db/version_set.cc
|
||||||
|
db/write_batch.cc
|
||||||
|
helpers/memenv/memenv.cc
|
||||||
|
port/port_posix_sse.cc
|
||||||
|
port/port_win.cc
|
||||||
|
table/block.cc
|
||||||
|
table/block_builder.cc
|
||||||
|
table/filter_block.cc
|
||||||
|
table/format.cc
|
||||||
|
table/iterator.cc
|
||||||
|
table/merger.cc
|
||||||
|
table/table.cc
|
||||||
|
table/table_builder.cc
|
||||||
|
table/two_level_iterator.cc
|
||||||
|
util/arena.cc
|
||||||
|
util/bloom.cc
|
||||||
|
util/cache.cc
|
||||||
|
util/coding.cc
|
||||||
|
util/comparator.cc
|
||||||
|
util/crc32c.cc
|
||||||
|
util/env.cc
|
||||||
|
util/env_posix.cc
|
||||||
|
util/env_win.cc
|
||||||
|
util/filter_policy.cc
|
||||||
|
util/hash.cc
|
||||||
|
util/histogram.cc
|
||||||
|
util/logging.cc
|
||||||
|
util/options.cc
|
||||||
|
util/status.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} include)
|
||||||
|
|
||||||
|
target_link_libraries(libleveldb PUBLIC Iphlpapi.lib Shlwapi.lib)
|
||||||
|
|
||||||
|
install(TARGETS libleveldb
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(INSTALL_HEADERS)
|
||||||
|
file(GLOB HEADERS include/leveldb/*.h)
|
||||||
|
install(FILES ${HEADERS} DESTINATION include/leveldb)
|
||||||
|
install(FILES helpers/memenv/memenv.h DESTINATION include)
|
||||||
|
endif()
|
3
ports/leveldb/CONTROL
Normal file
3
ports/leveldb/CONTROL
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Source: leveldb
|
||||||
|
Version: 2017-10-25-8b1cd3753b184341e837b30383832645135d3d73
|
||||||
|
Description: LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
|
63
ports/leveldb/msvc_code_fix.diff
Normal file
63
ports/leveldb/msvc_code_fix.diff
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
db/c.cc | 2 ++
|
||||||
|
port/port_win.h | 7 +++++++
|
||||||
|
util/env_win.cc | 6 ++++--
|
||||||
|
3 files changed, 13 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/db/c.cc b/db/c.cc
|
||||||
|
index 08ff0ad..b23e3dc 100644
|
||||||
|
--- a/db/c.cc
|
||||||
|
+++ b/db/c.cc
|
||||||
|
@@ -5,7 +5,9 @@
|
||||||
|
#include "leveldb/c.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
+#ifndef WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
+#endif
|
||||||
|
#include "leveldb/cache.h"
|
||||||
|
#include "leveldb/comparator.h"
|
||||||
|
#include "leveldb/db.h"
|
||||||
|
diff --git a/port/port_win.h b/port/port_win.h
|
||||||
|
index e8bf46e..989c15c 100644
|
||||||
|
--- a/port/port_win.h
|
||||||
|
+++ b/port/port_win.h
|
||||||
|
@@ -32,9 +32,16 @@
|
||||||
|
#define STORAGE_LEVELDB_PORT_PORT_WIN_H_
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
+#if !(_MSC_VER >= 1900)
|
||||||
|
#define snprintf _snprintf
|
||||||
|
+#endif
|
||||||
|
#define close _close
|
||||||
|
#define fread_unlocked _fread_nolock
|
||||||
|
+#ifdef _WIN64
|
||||||
|
+#define ssize_t int64_t
|
||||||
|
+#else
|
||||||
|
+#define ssize_t int32_t
|
||||||
|
+#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
diff --git a/util/env_win.cc b/util/env_win.cc
|
||||||
|
index d32c4e6..3b4c92b 100644
|
||||||
|
--- a/util/env_win.cc
|
||||||
|
+++ b/util/env_win.cc
|
||||||
|
@@ -761,14 +761,16 @@ uint64_t Win32Env::NowMicros()
|
||||||
|
static Status CreateDirInner( const std::string& dirname )
|
||||||
|
{
|
||||||
|
Status sRet;
|
||||||
|
- DWORD attr = ::GetFileAttributes(dirname.c_str());
|
||||||
|
+ std::wstring dirnameW;
|
||||||
|
+ ToWidePath(dirname, dirnameW);
|
||||||
|
+ DWORD attr = ::GetFileAttributesW(dirnameW.c_str());
|
||||||
|
if (attr == INVALID_FILE_ATTRIBUTES) { // doesn't exist:
|
||||||
|
std::size_t slash = dirname.find_last_of("\\");
|
||||||
|
if (slash != std::string::npos){
|
||||||
|
sRet = CreateDirInner(dirname.substr(0, slash));
|
||||||
|
if (!sRet.ok()) return sRet;
|
||||||
|
}
|
||||||
|
- BOOL result = ::CreateDirectory(dirname.c_str(), NULL);
|
||||||
|
+ BOOL result = ::CreateDirectoryW(dirnameW.c_str(), NULL);
|
||||||
|
if (result == FALSE) {
|
||||||
|
sRet = Status::IOError(dirname, "Could not create directory.");
|
||||||
|
return sRet;
|
35
ports/leveldb/portfile.cmake
Normal file
35
ports/leveldb/portfile.cmake
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
include(vcpkg_common_functions)
|
||||||
|
|
||||||
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||||
|
message(FATAL_ERROR "leveldb doesn't currently support dynamic buildsas there are no export symbols defined.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/leveldb-8b1cd3753b184341e837b30383832645135d3d73)
|
||||||
|
|
||||||
|
vcpkg_from_github(
|
||||||
|
OUT_SOURCE_PATH "leveldb"
|
||||||
|
BRANCH "bitcoin-fork"
|
||||||
|
REPO "bitcoin-core/leveldb"
|
||||||
|
REF "8b1cd3753b184341e837b30383832645135d3d73"
|
||||||
|
SHA512 f5ad5fd21fb28ee052a4f3873abd58dab508c71621bcd482ab9e6ef4b57eca182c81502ddfe59736f5b2a54f2d05b397dd15982b3bd5d9039cd481eae3c7b958
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "Patching")
|
||||||
|
|
||||||
|
vcpkg_apply_patches(SOURCE_PATH ${SOURCE_PATH}
|
||||||
|
PATCHES ${CMAKE_CURRENT_LIST_DIR}/msvc_code_fix.diff)
|
||||||
|
|
||||||
|
message(STATUS "Building")
|
||||||
|
|
||||||
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||||
|
|
||||||
|
vcpkg_configure_cmake(
|
||||||
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
|
PREFER_NINJA # Disable this option if project cannot be built with Ninja
|
||||||
|
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_install_cmake()
|
||||||
|
|
||||||
|
# Handle copyright
|
||||||
|
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/leveldb RENAME copyright)
|
Loading…
Reference in New Issue
Block a user