Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for CMake toolchain independent build framework #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,18 @@ Debug
Benchmark
vs2010.*
leveldbutil

# Auto-generated by CMake
ALL_BUILD.vcxproj
ALL_BUILD.vcxproj.filters
CMakeCache.txt
CMakeFiles/
ZERO_CHECK.vcxproj
ZERO_CHECK.vcxproj.filters
cmake_install.cmake
leveldb.opensdf
leveldb.sdf
leveldb.sln
leveldb.v12.suo
leveldb.vcxproj
leveldb.vcxproj.filters
76 changes: 76 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Set CMake minimum version
cmake_minimum_required(VERSION 2.8)

#
# Name the project
project(leveldb)

add_definitions(
# Required for Windows port
-DLEVELDB_PLATFORM_WINDOWS
# Required for Windows port
-DOS_WIN
# Disable secure CRT warnings
-D_CRT_SECURE_NO_WARNINGS
# Disable "signed/unsigned mismatch" warning
-wd4018
# Disable "conversion from 'uint64_t' to 'size_t'" warning
-wd4244
# Disable "forcing value to bool 'true' or 'false'" warning
-wd4800
# Disable "POSIX name for this item is deprecated" warning
-wd4996
)

#
# Add include directories
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/port/win
)

#
# Add static library
add_library(
leveldb
db/builder.cc
db/c.cc
db/dbformat.cc
db/db_impl.cc
db/db_iter.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_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_win.cc
util/filter_policy.cc
util/hash.cc
util/logging.cc
util/options.cc
util/status.cc
)
9 changes: 0 additions & 9 deletions port/port_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@ AtomicPointer::AtomicPointer(void* v) {
Release_Store(v);
}

BOOL CALLBACK InitHandleFunction (PINIT_ONCE InitOnce, PVOID func, PVOID *lpContext) {
((void (*)())func)();
return true;
}

void InitOnce(OnceType* once, void (*initializer)()) {
InitOnceExecuteOnce((PINIT_ONCE)once, InitHandleFunction, initializer, NULL);
}

void* AtomicPointer::Acquire_Load() const {
void * p = nullptr;
InterlockedExchangePointer(&p, rep_);
Expand Down
4 changes: 0 additions & 4 deletions port/port_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ class CondVar {

};

typedef void* OnceType;
#define LEVELDB_ONCE_INIT 0
extern void InitOnce(port::OnceType*, void (*initializer)());

// Storage for a lock-free pointer
class AtomicPointer {
private:
Expand Down
8 changes: 8 additions & 0 deletions port/win/stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;

#if defined(_WIN32)
typedef int32_t ssize_t;
#elif defined(_WIN64)
typedef int64_t ssize_t;
#else
#error "Unknown architecture"
#endif

#endif // STORAGE_LEVELDB_PORT_WIN_STDINT_H_
12 changes: 6 additions & 6 deletions util/comparator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ class BytewiseComparatorImpl : public Comparator {
};
} // namespace

static port::OnceType once = LEVELDB_ONCE_INIT;
static const Comparator* bytewise;

static void InitModule() {
bytewise = new BytewiseComparatorImpl;
Comparator* GetSingleModule()
{
static Comparator* bytewise = new BytewiseComparatorImpl();
return bytewise;
}

static const Comparator* bytewise = GetSingleModule();

const Comparator* BytewiseComparator() {
port::InitOnce(&once, InitModule);
return bytewise;
}

Expand Down
11 changes: 7 additions & 4 deletions util/env_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,15 @@ Win32Env::~Win32Env()

} // Win32 namespace

static port::OnceType once = LEVELDB_ONCE_INIT;
static Env* default_env;
static void InitDefaultEnv() { default_env = new Win32::Win32Env(); }
Env* GetSingleModule()
{
static Env* default_env = new Win32::Win32Env();
return default_env;
}

static Env* default_env = GetSingleModule();

Env* Env::Default() {
port::InitOnce(&once, InitDefaultEnv);
return default_env;
}

Expand Down
160 changes: 0 additions & 160 deletions vs2010.vcxproj

This file was deleted.