Most of FDB compiling on Windows with cmake

This commit is contained in:
mpilman 2019-02-04 21:25:10 -08:00 committed by Alex Miller
parent 192a48105c
commit 7a858b902d
13 changed files with 155 additions and 123 deletions

View File

@ -23,6 +23,12 @@ project(fdb
HOMEPAGE_URL "http://www.foundationdb.org/" HOMEPAGE_URL "http://www.foundationdb.org/"
LANGUAGES C CXX ASM Java) LANGUAGES C CXX ASM Java)
if(WIN32)
# C# is currently only supported on Windows.
# On other platforms we find mono manually
enable_language(CSharp)
endif()
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")
message (STATUS "${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}") message (STATUS "${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}")
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")

View File

@ -23,11 +23,8 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fdb_c.g.S
add_custom_target(fdb_c_generated DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fdb_c.g.S add_custom_target(fdb_c_generated DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fdb_c.g.S
${CMAKE_CURRENT_BINARY_DIR}/fdb_c_function_pointers.g.h) ${CMAKE_CURRENT_BINARY_DIR}/fdb_c_function_pointers.g.h)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h vexillographer_compile(TARGET fdb_c_options LANG c OUT ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h
COMMAND ${MONO_EXECUTABLE} ${VEXILLOGRAPHER_EXE} ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options c ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h)
DEPENDS ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options vexillographer
COMMENT "Generate C options")
add_custom_target(fdb_c_options DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h)
include(GenerateExportHeader) include(GenerateExportHeader)

View File

@ -109,11 +109,8 @@ set(GENERATED_JAVA_FILES
${GENERATED_JAVA_DIR}/TransactionOptions.java ${GENERATED_JAVA_DIR}/TransactionOptions.java
${GENERATED_JAVA_DIR}/FDBException.java) ${GENERATED_JAVA_DIR}/FDBException.java)
add_custom_command(OUTPUT ${GENERATED_JAVA_FILES} vexillographer_compile(TARGET fdb_java_options LANG java OUT ${GENERATED_JAVA_DIR}
COMMAND ${MONO_EXECUTABLE} ${VEXILLOGRAPHER_EXE} ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options java ${GENERATED_JAVA_DIR} OUTPUT ${GENERATED_JAVA_FILES})
DEPENDS ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options vexillographer
COMMENT "Generate Java options")
add_custom_target(fdb_java_options DEPENDS ${GENERATED_JAVA_DIR}/StreamingMode.java)
set(SYSTEM_NAME "linux") set(SYSTEM_NAME "linux")
if (APPLE) if (APPLE)

View File

@ -29,14 +29,8 @@ add_custom_target(python_binding ALL DEPENDS ${out_files})
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/bindings/python/fdb) file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/bindings/python/fdb)
set(options_file ${PROJECT_BINARY_DIR}/bindings/python/fdb/fdboptions.py) set(options_file ${PROJECT_BINARY_DIR}/bindings/python/fdb/fdboptions.py)
add_custom_command(OUTPUT ${options_file} vexillographer_compile(TARGET fdb_python_options LANG python OUT ${options_file}
COMMAND ${MONO_EXECUTABLE} ${VEXILLOGRAPHER_EXE} ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options python ${options_file} OUTPUT ${options_file})
DEPENDS ${PROJECT_SOURCE_DIR}/fdbclient/vexillographer/fdb.options vexillographer
COMMENT "Generate Python options")
add_custom_target(fdb_python_options DEPENDS
${options_file}
${PROJECT_SOURCE_DIR}/fdbclient/vexillographer/fdb.options
vexillographer)
add_dependencies(python_binding fdb_python_options) add_dependencies(python_binding fdb_python_options)

View File

@ -1,3 +1,21 @@
set(ACTORCOMPILER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorCompiler.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorParser.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ParseTree.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Program.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Properties/AssemblyInfo.cs)
if(WIN32)
add_executable(actorcompiler ${ACTORCOMPILER_SRCS})
target_compile_options(actorcompiler PRIVATE "/langversion:6")
set_property(TARGET actorcompiler PROPERTY VS_DOTNET_REFERENCES
"System"
"System.Core"
"System.Xml.Linq"
"System.Data.DataSetExtensions"
"Microsoft.CSharp"
"System.Data"
"System.Xml")
else()
find_program(MONO_EXECUTABLE mono) find_program(MONO_EXECUTABLE mono)
find_program(MCS_EXECUTABLE dmcs) find_program(MCS_EXECUTABLE dmcs)
@ -19,12 +37,6 @@ if (NOT MONO_FOUND)
message(FATAL_ERROR "Could not find mono") message(FATAL_ERROR "Could not find mono")
endif() endif()
set(ACTORCOMPILER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorCompiler.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ActorParser.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/ParseTree.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Program.cs
${CMAKE_CURRENT_SOURCE_DIR}/flow/actorcompiler/Properties/AssemblyInfo.cs)
set(ACTOR_COMPILER_REFERENCES set(ACTOR_COMPILER_REFERENCES
"-r:System,System.Core,System.Xml.Linq,System.Data.DataSetExtensions,Microsoft.CSharp,System.Data,System.Xml") "-r:System,System.Core,System.Xml.Linq,System.Data.DataSetExtensions,Microsoft.CSharp,System.Data,System.Xml")
@ -34,3 +46,4 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe
COMMENT "Compile actor compiler" VERBATIM) COMMENT "Compile actor compiler" VERBATIM)
add_custom_target(actorcompiler DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe) add_custom_target(actorcompiler DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe)
set(actor_exe "${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe") set(actor_exe "${CMAKE_CURRENT_BINARY_DIR}/actorcompiler.exe")
endif()

View File

@ -6,6 +6,16 @@ set(VEXILLOGRAPHER_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/ruby.cs ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/ruby.cs
${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/vexillographer.cs) ${CMAKE_CURRENT_SOURCE_DIR}/fdbclient/vexillographer/vexillographer.cs)
if(WIN32)
add_executable(vexillographer ${VEXILLOGRAPHER_SRCS})
target_compile_options(vexillographer PRIVATE "/langversion:6")
set_property(TARGET vexillographer PROPERTY VS_DOTNET_REFERENCES
"System"
"System.Core"
"System.Data"
"System.Xml"
"System.Xml.Linq")
else()
set(VEXILLOGRAPHER_REFERENCES "-r:System,System.Core,System.Data,System.Xml,System.Xml.Linq") set(VEXILLOGRAPHER_REFERENCES "-r:System,System.Core,System.Data,System.Xml,System.Xml.Linq")
set(VEXILLOGRAPHER_EXE "${CMAKE_CURRENT_BINARY_DIR}/vexillographer.exe") set(VEXILLOGRAPHER_EXE "${CMAKE_CURRENT_BINARY_DIR}/vexillographer.exe")
add_custom_command(OUTPUT ${VEXILLOGRAPHER_EXE} add_custom_command(OUTPUT ${VEXILLOGRAPHER_EXE}
@ -13,13 +23,24 @@ add_custom_command(OUTPUT ${VEXILLOGRAPHER_EXE}
DEPENDS ${VEXILLOGRAPHER_SRCS} DEPENDS ${VEXILLOGRAPHER_SRCS}
COMMENT "Compile Vexillographer") COMMENT "Compile Vexillographer")
add_custom_target(vexillographer DEPENDS ${VEXILLOGRAPHER_EXE}) add_custom_target(vexillographer DEPENDS ${VEXILLOGRAPHER_EXE})
endif()
set(ERROR_GEN_SRCS macro(vexillographer_compile)
${CMAKE_CURRENT_SOURCE_DIR}/flow/error_gen.cs) set(CX_ONE_VALUE_ARGS TARGET LANG OUT)
set(ERROR_GEN_REFERENCES "-r:System,System.Core,System.Data,System.Xml,System.Xml.Linq") set(CX_MULTI_VALUE_ARGS OUTPUT)
set(ERROR_GEN_EXE "${CMAKE_CURRENT_BINARY_DIR}/error_gen.exe") cmake_parse_arguments(VX "" "${CX_ONE_VALUE_ARGS}" "${CX_MULTI_VALUE_ARGS}" "${ARGN}")
add_custom_command (OUTPUT ${ERROR_GEN_EXE} if(WIN32)
COMMAND ${MCS_EXECUTABLE} ARGS ${ERROR_GEN_REFERENCES} ${ERROR_GEN_SRCS} -target:exe -out:${ERROR_GEN_EXE} add_custom_command(
DEPENDS ${ERROR_GEN_SRCS} OUTPUT ${VX_OUTPUT}
COMMENT "Compile error_gen") COMMAND $<TARGET_FILE:vexillographer> ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options ${VX_LANG} ${VX_OUT}
add_custom_target(error_gen DEPENDS ${ERROR_GEN_EXE}) DEPENDS ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options vexillographer
COMMENT "Generate FDBOptions ${VX_LANG} files")
else()
add_custom_command(
OUTPUT ${VX_OUTPUT}
COMMAND ${MONO_EXECUTABLE} ${VEXILLOGRAPHER_EXE} ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options ${VX_LANG} ${VX_OUT}
DEPENDS ${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options vexillographer
COMMENT "Generate FDBOptions ${VX_LANG} files")
endif()
add_custom_target(${VX_TARGET} DEPENDS ${VX_OUTPUT})
endmacro()

View File

@ -40,7 +40,7 @@ set(CMAKE_REQUIRED_LIBRARIES c)
if(WIN32) if(WIN32)
add_compile_options(/W3 /EHsc) add_compile_options(/W3 /EHsc /std:c++11)
else() else()
if(USE_GOLD_LINKER) if(USE_GOLD_LINKER)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")

View File

@ -31,10 +31,17 @@ macro(actor_compile target srcs)
set(actor_compiler_flags "--disable-actor-without-wait-error") set(actor_compiler_flags "--disable-actor-without-wait-error")
endif() endif()
if(tmp) if(tmp)
if(WIN32)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${tmp}"
COMMAND $<TARGET_FILE:actorcompiler> "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" ${actor_compiler_flags}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler ${actor_exe}
COMMENT "Compile actor: ${src}")
else()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${tmp}"
COMMAND ${MONO_EXECUTABLE} ${actor_exe} "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" ${actor_compiler_flags} > /dev/null COMMAND ${MONO_EXECUTABLE} ${actor_exe} "${CMAKE_CURRENT_SOURCE_DIR}/${src}" "${CMAKE_CURRENT_BINARY_DIR}/${tmp}" ${actor_compiler_flags} > /dev/null
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler ${actor_exe} DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler ${actor_exe}
COMMENT "Compile actor: ${src}") COMMENT "Compile actor: ${src}")
endif()
set(_tmp_out "${_tmp_out};${CMAKE_CURRENT_BINARY_DIR}/${tmp}") set(_tmp_out "${_tmp_out};${CMAKE_CURRENT_BINARY_DIR}/${tmp}")
endif() endif()
endforeach() endforeach()

View File

@ -9,7 +9,6 @@ if(DIR_LAYOUT MATCHES "TARGZ")
set(DIR_LAYOUT "STANDALONE") set(DIR_LAYOUT "STANDALONE")
endif() endif()
if(UNIX)
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
set(FDB_CONFIG_DIR "etc/foundationdb") set(FDB_CONFIG_DIR "etc/foundationdb")
if("${LIB64}" STREQUAL "TRUE") if("${LIB64}" STREQUAL "TRUE")
@ -58,7 +57,6 @@ if(UNIX)
set(FDB_PYTHON_INSTALL_DIR "${FDB_LIB_DIR}/python2.7/site-packages/fdb") set(FDB_PYTHON_INSTALL_DIR "${FDB_LIB_DIR}/python2.7/site-packages/fdb")
set(FDB_SHARE_DIR "usr/share") set(FDB_SHARE_DIR "usr/share")
endif() endif()
endif()
################################################################################ ################################################################################
# Version information # Version information

View File

@ -84,11 +84,8 @@ set(FDBCLIENT_SRCS
${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.cpp) ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.cpp)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.h ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.cpp vexillographer_compile(TARGET fdboptions LANG cpp OUT ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g
COMMAND ${MONO_EXECUTABLE} ${VEXILLOGRAPHER_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/vexillographer/fdb.options cpp ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.h ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.cpp)
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vexillographer/fdb.options vexillographer
COMMENT "Generate FDBOptions c++ files")
add_custom_target(fdboptions DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.h ${CMAKE_CURRENT_BINARY_DIR}/FDBOptions.g.cpp)
actor_set(FDBCLIENT_BUILD "${FDBCLIENT_SRCS}") actor_set(FDBCLIENT_BUILD "${FDBCLIENT_SRCS}")
add_library(fdbclient STATIC ${FDBCLIENT_BUILD}) add_library(fdbclient STATIC ${FDBCLIENT_BUILD})

View File

@ -20,7 +20,9 @@
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#ifndef _WIN32
#include <unistd.h> #include <unistd.h>
#endif
#include <random> #include <random>
#ifdef __linux__ #ifdef __linux__

View File

@ -29,6 +29,7 @@
#else #else
#include <unordered_map> #include <unordered_map>
#endif #endif
#include <functional>
class UID { class UID {
uint64_t part[2]; uint64_t part[2];
@ -60,7 +61,7 @@ template <class Ar> void save( Ar& ar, UID const& uid ) { const_cast<UID&>(uid).
namespace std { namespace std {
template <> template <>
class hash<UID> : public unary_function<UID,size_t> { class hash<UID> {
public: public:
size_t operator()(UID const& u) const { return u.hash(); } size_t operator()(UID const& u) const { return u.hash(); }
}; };

View File

@ -47,9 +47,8 @@
#include "flow/FaultInjection.h" #include "flow/FaultInjection.h"
#ifdef _WIN32 #ifdef _WIN32
#define NOMINMAX
#include <windows.h> #include <windows.h>
#undef max
#undef min
#include <io.h> #include <io.h>
#include <psapi.h> #include <psapi.h>
#include <stdio.h> #include <stdio.h>