Commit 4b31d5a2 authored by Kenton Varda's avatar Kenton Varda

Merge branch 'master' of github.com:kentonv/capnproto

parents 36df9e4c f86de2e8
...@@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 2.8) ...@@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CheckIncludeFileCXX) include(CheckIncludeFileCXX)
check_include_file_cxx(initializer_list HAS_CXX11 "-std=c++11") if(MSVC)
check_include_file_cxx(initializer_list HAS_CXX11)
else()
check_include_file_cxx(initializer_list HAS_CXX11 "-std=c++11")
endif()
if(NOT HAS_CXX11) if(NOT HAS_CXX11)
message(SEND_ERROR "Requires a C++11 compiler and standard library.") message(SEND_ERROR "Requires a C++11 compiler and standard library.")
endif() endif()
......
...@@ -22,13 +22,21 @@ if(CAPNP_LITE AND BUILD_TOOLS) ...@@ -22,13 +22,21 @@ if(CAPNP_LITE AND BUILD_TOOLS)
message(WARNING "Command-line tools will not be built with CAPNP_LITE.") message(WARNING "Command-line tools will not be built with CAPNP_LITE.")
endif() endif()
if(MSVC AND NOT CAPNP_LITE)
message(SEND_ERROR "Building with MSVC is only supported with CAPNP_LITE.")
endif()
if(CAPNP_LITE) if(CAPNP_LITE)
set(CAPNP_LITE_FLAG "-DCAPNP_LITE") set(CAPNP_LITE_FLAG "-DCAPNP_LITE")
else() else()
set(CAPNP_LITE_FLAG) set(CAPNP_LITE_FLAG)
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c++11 -pthread ${CAPNP_LITE_FLAG}") if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 ${CAPNP_LITE_FLAG}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c++11 -pthread ${CAPNP_LITE_FLAG}")
endif()
# Source ======================================================================= # Source =======================================================================
...@@ -36,25 +44,27 @@ add_subdirectory(src) ...@@ -36,25 +44,27 @@ add_subdirectory(src)
# Install ====================================================================== # Install ======================================================================
# Variables for pkg-config files if(NOT MSVC) # Don't install pkg-config files when building with MSVC
set(prefix "${CMAKE_INSTALL_PREFIX}") # Variables for pkg-config files
set(exec_prefix "${EXEC_INSTALL_PREFIX}") set(prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${LIB_INSTALL_DIR}") set(exec_prefix "${EXEC_INSTALL_PREFIX}")
set(includedir "${INCLUDE_INSTALL_DIR}") set(libdir "${LIB_INSTALL_DIR}")
set(PTHREAD_CFLAGS "-pthread") set(includedir "${INCLUDE_INSTALL_DIR}")
set(STDLIB_FLAG) # TODO: Unsupported set(PTHREAD_CFLAGS "-pthread")
set(STDLIB_FLAG) # TODO: Unsupported
configure_file(capnp.pc.in "${CMAKE_CURRENT_BINARY_DIR}/capnp.pc" @ONLY) configure_file(capnp.pc.in "${CMAKE_CURRENT_BINARY_DIR}/capnp.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capnp.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capnp.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
if(NOT CAPNP_LITE) if(NOT CAPNP_LITE)
configure_file(capnp-rpc.pc.in "${CMAKE_CURRENT_BINARY_DIR}/capnp-rpc.pc" @ONLY) configure_file(capnp-rpc.pc.in "${CMAKE_CURRENT_BINARY_DIR}/capnp-rpc.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capnp-rpc.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/capnp-rpc.pc" DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
endif() endif()
unset(STDLIB_FLAG) unset(STDLIB_FLAG)
unset(PTHREAD_CFLAGS) unset(PTHREAD_CFLAGS)
unset(includedir) unset(includedir)
unset(libdir) unset(libdir)
unset(exec_prefix) unset(exec_prefix)
unset(prefix) unset(prefix)
endif()
...@@ -15,22 +15,38 @@ if(BUILD_TESTING) ...@@ -15,22 +15,38 @@ if(BUILD_TESTING)
ExternalProject_Add(gtest_build ExternalProject_Add(gtest_build
URL http://googletest.googlecode.com/files/gtest-1.7.0.zip URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
URL_MD5 2d6ec8ccdf5c46b05ba54a9fd1d130d7 URL_MD5 2d6ec8ccdf5c46b05ba54a9fd1d130d7
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dgtest_force_shared_crt=1
INSTALL_COMMAND "" # Disable install INSTALL_COMMAND "" # Disable install
) )
ExternalProject_Get_Property(gtest_build binary_dir) ExternalProject_Get_Property(gtest_build binary_dir)
# Set platform-specific library prefix/extensions.
if(MSVC)
set(gtest_prefix)
set(gtest_suffix ".lib")
else()
set(gtest_prefix "lib")
set(gtest_suffix ".a")
endif()
add_library(gtest UNKNOWN IMPORTED) add_library(gtest UNKNOWN IMPORTED)
set_property(TARGET gtest if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a" set_target_properties(gtest PROPERTIES IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${gtest_prefix}gtest${gtest_suffix}")
) set_target_properties(gtest PROPERTIES IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${gtest_prefix}gtest${gtest_suffix}")
else()
set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${binary_dir}/${gtest_prefix}gtest${gtest_suffix}")
endif()
add_dependencies(gtest gtest_build) add_dependencies(gtest gtest_build)
add_library(gtest_main UNKNOWN IMPORTED) add_library(gtest_main UNKNOWN IMPORTED)
set_property(TARGET gtest_main if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a" set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${gtest_prefix}gtest_main${gtest_suffix}")
) set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${gtest_prefix}gtest_main${gtest_suffix}")
else()
set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION "${binary_dir}/${gtest_prefix}gtest_main${gtest_suffix}")
endif()
add_dependencies(gtest_main gtest) add_dependencies(gtest_main gtest)
ExternalProject_Get_Property(gtest_build source_dir) ExternalProject_Get_Property(gtest_build source_dir)
......
...@@ -1069,7 +1069,7 @@ struct WireHelpers { ...@@ -1069,7 +1069,7 @@ struct WireHelpers {
} }
// We must verify that the pointer has the right size. Unlike in // We must verify that the pointer has the right size. Unlike in
// getWritableStructListReference(), we never need to "upgrade" the data, because this // getWritableStructListPointer(), we never need to "upgrade" the data, because this
// method is called only for non-struct lists, and there is no allowed upgrade path *to* // method is called only for non-struct lists, and there is no allowed upgrade path *to*
// a non-struct list, only *from* them. // a non-struct list, only *from* them.
......
...@@ -1061,7 +1061,7 @@ struct Exception { ...@@ -1061,7 +1061,7 @@ struct Exception {
# - Bugs. # - Bugs.
# - Invalid input. # - Invalid input.
# - Configuration errors. # - Configuration errors.
# - Network probles. # - Network problems.
# - Insufficient resources. # - Insufficient resources.
# - Version skew (unimplemented functionality). # - Version skew (unimplemented functionality).
# - Other logistical problems. # - Other logistical problems.
......
...@@ -65,7 +65,7 @@ struct Node { ...@@ -65,7 +65,7 @@ struct Node {
struct NestedNode { struct NestedNode {
name @0 :Text; name @0 :Text;
# Unqualified symbol name. Unlike Node.name, this *can* be used programmatically. # Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically.
# #
# (On Zooko's triangle, this is the node's petname according to its parent scope.) # (On Zooko's triangle, this is the node's petname according to its parent scope.)
...@@ -361,7 +361,7 @@ struct Brand { ...@@ -361,7 +361,7 @@ struct Brand {
# List of parameter bindings. # List of parameter bindings.
inherit @2 :Void; inherit @2 :Void;
# The place where this TypeEnivornment appears is actually within this scope or a sub-scope, # The place where this Brand appears is actually within this scope or a sub-scope,
# and the bindings for this scope should be inherited from the reference point. # and the bindings for this scope should be inherited from the reference point.
} }
} }
......
# kj =========================================================================== # kj ===========================================================================
set(kj_sources set(kj_sources_lite
common.c++
units.c++
memory.c++
refcount.c++
array.c++ array.c++
string.c++ common.c++
string-tree.c++
exception.c++
debug.c++ debug.c++
arena.c++ exception.c++
io.c++ io.c++
memory.c++
mutex.c++ mutex.c++
string.c++
thread.c++ thread.c++
)
set(kj_sources_heavy
units.c++
refcount.c++
string-tree.c++
arena.c++
main.c++ main.c++
parse/char.c++ parse/char.c++
) )
if(NOT CAPNP_LITE)
set(kj_sources ${kj_sources_lite} ${kj_sources_heavy})
else()
set(kj_sources ${kj_sources_lite})
endif()
set(kj_headers set(kj_headers
common.h common.h
units.h units.h
...@@ -81,21 +89,14 @@ if(BUILD_TESTING) ...@@ -81,21 +89,14 @@ if(BUILD_TESTING)
add_executable(kj-tests add_executable(kj-tests
common-test.c++ common-test.c++
memory-test.c++ memory-test.c++
refcount-test.c++
array-test.c++ array-test.c++
string-test.c++ string-test.c++
string-tree-test.c++
exception-test.c++ exception-test.c++
debug-test.c++ debug-test.c++
arena-test.c++
units-test.c++
tuple-test.c++
one-of-test.c++
function-test.c++
io-test.c++ io-test.c++
mutex-test.c++ mutex-test.c++
threadlocal-test.c++ threadlocal-test.c++
threadlocal-pthread-test.c++ std/iostream-test.c++
) )
# TODO: Link with librt on Solaris for sched_yield # TODO: Link with librt on Solaris for sched_yield
target_link_libraries(kj-tests kj gtest gtest_main) target_link_libraries(kj-tests kj gtest gtest_main)
...@@ -107,9 +108,16 @@ if(BUILD_TESTING) ...@@ -107,9 +108,16 @@ if(BUILD_TESTING)
async-test.c++ async-test.c++
async-unix-test.c++ async-unix-test.c++
async-io-test.c++ async-io-test.c++
refcount-test.c++
string-tree-test.c++
arena-test.c++
units-test.c++
tuple-test.c++
one-of-test.c++
function-test.c++
threadlocal-pthread-test.c++
parse/common-test.c++ parse/common-test.c++
parse/char-test.c++ parse/char-test.c++
std/iostream-test.c++
) )
target_link_libraries(kj-heavy-tests kj kj-async gtest gtest_main) target_link_libraries(kj-heavy-tests kj kj-async gtest gtest_main)
add_dependencies(check kj-heavy-tests) add_dependencies(check kj-heavy-tests)
......
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
if (pollResult == 0) { if (pollResult == 0) {
// Not ready yet. We can safely use the edge-triggered observer. // Not ready yet. We can safely use the edge-triggered observer.
return observer.whenBecomesReadable(); return observer.whenBecomesWritable();
} else { } else {
// Ready now. // Ready now.
return kj::READY_NOW; return kj::READY_NOW;
......
...@@ -1088,7 +1088,7 @@ public: ...@@ -1088,7 +1088,7 @@ public:
inline constexpr ArrayPtr(decltype(nullptr)): ptr(nullptr), size_(0) {} inline constexpr ArrayPtr(decltype(nullptr)): ptr(nullptr), size_(0) {}
inline constexpr ArrayPtr(T* ptr, size_t size): ptr(ptr), size_(size) {} inline constexpr ArrayPtr(T* ptr, size_t size): ptr(ptr), size_(size) {}
inline constexpr ArrayPtr(T* begin, T* end): ptr(begin), size_(end - begin) {} inline constexpr ArrayPtr(T* begin, T* end): ptr(begin), size_(end - begin) {}
inline KJ_CONSTEXPR() ArrayPtr(std::initializer_list<RemoveConstOrDisable<T>> init) inline KJ_CONSTEXPR() ArrayPtr(::std::initializer_list<RemoveConstOrDisable<T>> init)
: ptr(init.begin()), size_(init.size()) {} : ptr(init.begin()), size_(init.size()) {}
template <size_t size> template <size_t size>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment