travis: add Windows cross-compilation

Summary:
- downcase includes for case-sensitive filesystems
- give targets the same name (librocksdb) on all platforms

With this patch it is possible to cross-compile RocksDB for Windows
from a Linux host using mingw.

cc yuslepukhin orgads
Closes https://github.com/facebook/rocksdb/pull/2107

Differential Revision: D4849784

Pulled By: siying

fbshipit-source-id: ad26ed6b4d393851aa6551e6aa4201faba82ef60
main
Tamir Duberstein 8 years ago committed by Facebook Github Bot
parent a30a696034
commit fdaefa0309
  1. 9
      .travis.yml
  2. 8
      CMakeLists.txt
  3. 2
      db/c_test.c
  4. 4
      port/win/env_win.cc
  5. 2
      port/win/env_win.h
  6. 8
      port/win/io_win.h
  7. 2
      port/win/win_logger.h
  8. 2
      port/win/win_thread.cc
  9. 2
      port/win/xpress_win.cc
  10. 3
      util/log_buffer.cc

@ -16,7 +16,7 @@ cache:
addons: addons:
apt: apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['clang-3.6' , 'g++-6', 'zlib1g-dev', 'libbz2-dev', 'libsnappy-dev', 'curl', 'libgflags-dev'] packages: ['clang-3.6' , 'g++-6', 'zlib1g-dev', 'libbz2-dev', 'libsnappy-dev', 'curl', 'libgflags-dev', 'mingw-w64']
env: env:
- TEST_GROUP=platform_dependent1 - TEST_GROUP=platform_dependent1
- TEST_GROUP=platform_dependent2 - TEST_GROUP=platform_dependent2
@ -30,6 +30,7 @@ env:
# Build examples # Build examples
- JOB_NAME=examples - JOB_NAME=examples
- JOB_NAME=cmake - JOB_NAME=cmake
- JOB_NAME=cmake-mingw
matrix: matrix:
exclude: exclude:
@ -39,6 +40,11 @@ matrix:
env: TEST_GROUP=1 env: TEST_GROUP=1
- os: osx - os: osx
env: TEST_GROUP=2 env: TEST_GROUP=2
- os : osx
env: JOB_NAME=cmake-mingw
- os: linux
env: JOB_NAME=cmake-mingw
compiler: clang
before_script: before_script:
- if [[ "${TRAVIS_OS_NAME}" == 'linux' && "${CXX}" == 'clang++' ]]; then CXX=clang++-3.6; fi - if [[ "${TRAVIS_OS_NAME}" == 'linux' && "${CXX}" == 'clang++' ]]; then CXX=clang++-3.6; fi
@ -58,6 +64,7 @@ script:
- if [[ "${JOB_NAME}" == 'lite_build' ]]; then OPT="-DTRAVIS -DROCKSDB_LITE" V=1 make -j4 static_lib; fi - if [[ "${JOB_NAME}" == 'lite_build' ]]; then OPT="-DTRAVIS -DROCKSDB_LITE" V=1 make -j4 static_lib; fi
- if [[ "${JOB_NAME}" == 'examples' ]]; then OPT=-DTRAVIS V=1 make -j4 static_lib; cd examples; make -j4; fi - if [[ "${JOB_NAME}" == 'examples' ]]; then OPT=-DTRAVIS V=1 make -j4 static_lib; cd examples; make -j4; fi
- if [[ "${JOB_NAME}" == 'cmake' ]]; then mkdir build && cd build && cmake .. && make -j4 rocksdb; fi - if [[ "${JOB_NAME}" == 'cmake' ]]; then mkdir build && cd build && cmake .. && make -j4 rocksdb; fi
- if [[ "${JOB_NAME}" == 'cmake-mingw' ]]; then mkdir build && cd build && cmake .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb; fi
notifications: notifications:
email: email:
- leveldb@fb.com - leveldb@fb.com

@ -506,16 +506,14 @@ else()
env/io_posix.cc) env/io_posix.cc)
endif() endif()
set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX})
set(ROCKSDB_SHARED_LIB rocksdb-shared${ARTIFACT_SUFFIX})
set(ROCKSDB_IMPORT_LIB ${ROCKSDB_SHARED_LIB})
if(WIN32) if(WIN32)
set(SYSTEM_LIBS ${SYSTEM_LIBS} Shlwapi.lib Rpcrt4.lib) set(SYSTEM_LIBS ${SYSTEM_LIBS} Shlwapi.lib Rpcrt4.lib)
set(ROCKSDB_STATIC_LIB rocksdblib${ARTIFACT_SUFFIX})
set(ROCKSDB_IMPORT_LIB rocksdb${ARTIFACT_SUFFIX})
set(LIBS ${ROCKSDB_STATIC_LIB} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) set(LIBS ${ROCKSDB_STATIC_LIB} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
else() else()
set(SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT} rt) set(SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT} rt)
set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX})
set(ROCKSDB_SHARED_LIB rocksdb-shared)
set(ROCKSDB_IMPORT_LIB ${ROCKSDB_SHARED_LIB})
set(LIBS ${ROCKSDB_SHARED_LIB} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) set(LIBS ${ROCKSDB_SHARED_LIB} ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES}) add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES})

@ -20,7 +20,7 @@
// Can not use port/port.h macros as this is a c file // Can not use port/port.h macros as this is a c file
#ifdef OS_WIN #ifdef OS_WIN
#include <Windows.h> #include <windows.h>
#define snprintf _snprintf #define snprintf _snprintf

@ -35,8 +35,8 @@
#include "monitoring/thread_status_updater.h" #include "monitoring/thread_status_updater.h"
#include "monitoring/thread_status_util.h" #include "monitoring/thread_status_util.h"
#include <Rpc.h> // For UUID generation #include <rpc.h> // for uuid generation
#include <Windows.h> #include <windows.h>
namespace rocksdb { namespace rocksdb {

@ -21,7 +21,7 @@
#include "util/threadpool_imp.h" #include "util/threadpool_imp.h"
#include <stdint.h> #include <stdint.h>
#include <Windows.h> #include <windows.h>
#include <mutex> #include <mutex>
#include <vector> #include <vector>

@ -14,11 +14,11 @@
#include <mutex> #include <mutex>
#include <string> #include <string>
#include "rocksdb/Status.h" #include "rocksdb/status.h"
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include "util/aligned_buffer.h" #include "util/aligned_buffer.h"
#include <Windows.h> #include <windows.h>
namespace rocksdb { namespace rocksdb {
@ -77,8 +77,8 @@ class WinFileData {
public: public:
// We want this class be usable both for inheritance (prive // We want this class be usable both for inheritance (prive
// or protected) and for containment so __ctor and __dtor public // or protected) and for containment so __ctor and __dtor public
WinFileData(const std::string& filename, HANDLE hFile, bool use_direct_io) WinFileData(const std::string& filename, HANDLE hFile, bool direct_io)
: filename_(filename), hFile_(hFile), use_direct_io_(use_direct_io) {} : filename_(filename), hFile_(hFile), use_direct_io_(direct_io) {}
virtual ~WinFileData() { this->CloseFile(); } virtual ~WinFileData() { this->CloseFile(); }

@ -19,7 +19,7 @@
#include "rocksdb/env.h" #include "rocksdb/env.h"
#include <stdint.h> #include <stdint.h>
#include <Windows.h> #include <windows.h>
namespace rocksdb { namespace rocksdb {

@ -13,7 +13,7 @@
#include <assert.h> #include <assert.h>
#include <process.h> // __beginthreadex #include <process.h> // __beginthreadex
#include <Windows.h> #include <windows.h>
#include <stdexcept> #include <stdexcept>
#include <system_error> #include <system_error>

@ -10,7 +10,7 @@
// found in the LICENSE file. See the AUTHORS file for names of contributors. // found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "port/win/xpress_win.h" #include "port/win/xpress_win.h"
#include <Windows.h> #include <windows.h>
#include <cassert> #include <cassert>
#include <memory> #include <memory>

@ -62,12 +62,13 @@ void LogBuffer::FlushBufferToLog() {
for (BufferedLog* log : logs_) { for (BufferedLog* log : logs_) {
const time_t seconds = log->now_tv.tv_sec; const time_t seconds = log->now_tv.tv_sec;
struct tm t; struct tm t;
localtime_r(&seconds, &t); if (localtime_r(&seconds, &t) != nullptr) {
Log(log_level_, info_log_, Log(log_level_, info_log_,
"(Original Log Time %04d/%02d/%02d-%02d:%02d:%02d.%06d) %s", "(Original Log Time %04d/%02d/%02d-%02d:%02d:%02d.%06d) %s",
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
t.tm_sec, static_cast<int>(log->now_tv.tv_usec), log->message); t.tm_sec, static_cast<int>(log->now_tv.tv_usec), log->message);
} }
}
logs_.clear(); logs_.clear();
} }

Loading…
Cancel
Save