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)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
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)
message(SEND_ERROR "Requires a C++11 compiler and standard library.")
endif()
......
......@@ -22,13 +22,21 @@ if(CAPNP_LITE AND BUILD_TOOLS)
message(WARNING "Command-line tools will not be built with CAPNP_LITE.")
endif()
if(MSVC AND NOT CAPNP_LITE)
message(SEND_ERROR "Building with MSVC is only supported with CAPNP_LITE.")
endif()
if(CAPNP_LITE)
set(CAPNP_LITE_FLAG "-DCAPNP_LITE")
else()
set(CAPNP_LITE_FLAG)
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 =======================================================================
......@@ -36,25 +44,27 @@ add_subdirectory(src)
# Install ======================================================================
# Variables for pkg-config files
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${EXEC_INSTALL_PREFIX}")
set(libdir "${LIB_INSTALL_DIR}")
set(includedir "${INCLUDE_INSTALL_DIR}")
set(PTHREAD_CFLAGS "-pthread")
set(STDLIB_FLAG) # TODO: Unsupported
if(NOT MSVC) # Don't install pkg-config files when building with MSVC
# Variables for pkg-config files
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${EXEC_INSTALL_PREFIX}")
set(libdir "${LIB_INSTALL_DIR}")
set(includedir "${INCLUDE_INSTALL_DIR}")
set(PTHREAD_CFLAGS "-pthread")
set(STDLIB_FLAG) # TODO: Unsupported
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")
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")
if(NOT CAPNP_LITE)
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")
endif()
if(NOT CAPNP_LITE)
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")
endif()
unset(STDLIB_FLAG)
unset(PTHREAD_CFLAGS)
unset(includedir)
unset(libdir)
unset(exec_prefix)
unset(prefix)
unset(STDLIB_FLAG)
unset(PTHREAD_CFLAGS)
unset(includedir)
unset(libdir)
unset(exec_prefix)
unset(prefix)
endif()
......@@ -15,22 +15,38 @@ if(BUILD_TESTING)
ExternalProject_Add(gtest_build
URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
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
)
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)
set_property(TARGET gtest
PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a"
)
if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
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_library(gtest_main UNKNOWN IMPORTED)
set_property(TARGET gtest_main
PROPERTY IMPORTED_LOCATION "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a"
)
if(CMAKE_GENERATOR MATCHES "Visual Studio.*" OR CMAKE_GENERATOR STREQUAL Xcode)
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)
ExternalProject_Get_Property(gtest_build source_dir)
......
......@@ -1069,7 +1069,7 @@ struct WireHelpers {
}
// 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*
// a non-struct list, only *from* them.
......
......@@ -1061,7 +1061,7 @@ struct Exception {
# - Bugs.
# - Invalid input.
# - Configuration errors.
# - Network probles.
# - Network problems.
# - Insufficient resources.
# - Version skew (unimplemented functionality).
# - Other logistical problems.
......
......@@ -65,7 +65,7 @@ struct Node {
struct NestedNode {
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.)
......@@ -361,7 +361,7 @@ struct Brand {
# List of parameter bindings.
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.
}
}
......
# kj ===========================================================================
set(kj_sources
common.c++
units.c++
memory.c++
refcount.c++
set(kj_sources_lite
array.c++
string.c++
string-tree.c++
exception.c++
common.c++
debug.c++
arena.c++
exception.c++
io.c++
memory.c++
mutex.c++
string.c++
thread.c++
)
set(kj_sources_heavy
units.c++
refcount.c++
string-tree.c++
arena.c++
main.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
common.h
units.h
......@@ -81,21 +89,14 @@ if(BUILD_TESTING)
add_executable(kj-tests
common-test.c++
memory-test.c++
refcount-test.c++
array-test.c++
string-test.c++
string-tree-test.c++
exception-test.c++
debug-test.c++
arena-test.c++
units-test.c++
tuple-test.c++
one-of-test.c++
function-test.c++
io-test.c++
mutex-test.c++
threadlocal-test.c++
threadlocal-pthread-test.c++
std/iostream-test.c++
)
# TODO: Link with librt on Solaris for sched_yield
target_link_libraries(kj-tests kj gtest gtest_main)
......@@ -107,9 +108,16 @@ if(BUILD_TESTING)
async-test.c++
async-unix-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/char-test.c++
std/iostream-test.c++
)
target_link_libraries(kj-heavy-tests kj kj-async gtest gtest_main)
add_dependencies(check kj-heavy-tests)
......
......@@ -191,7 +191,7 @@ public:
if (pollResult == 0) {
// Not ready yet. We can safely use the edge-triggered observer.
return observer.whenBecomesReadable();
return observer.whenBecomesWritable();
} else {
// Ready now.
return kj::READY_NOW;
......
......@@ -1088,7 +1088,7 @@ public:
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* 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()) {}
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