Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
83b8dccf
Commit
83b8dccf
authored
Apr 18, 2017
by
Kenton Varda
Committed by
GitHub
Apr 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #414 from harrishancock/msvc-samples
Build samples with MSVC
parents
244c2c1b
d3095dd6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
5 deletions
+62
-5
CapnProtoConfig.cmake.in
c++/cmake/CapnProtoConfig.cmake.in
+4
-2
CMakeLists.txt
c++/samples/CMakeLists.txt
+53
-0
calculator-server.c++
c++/samples/calculator-server.c++
+3
-3
test-helpers.c++
c++/src/kj/test-helpers.c++
+2
-0
No files found.
c++/cmake/CapnProtoConfig.cmake.in
View file @
83b8dccf
...
...
@@ -12,8 +12,10 @@
set(CapnProto_VERSION @VERSION@)
set(CAPNP_EXECUTABLE $<TARGET_FILE:CapnProto::capnp_tool>)
set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:CapnProto::capnpc_cpp>)
if(@CAPNP_BUILD_TOOLS@)
set(CAPNP_EXECUTABLE $<TARGET_FILE:CapnProto::capnp_tool>)
set(CAPNPC_CXX_EXECUTABLE $<TARGET_FILE:CapnProto::capnpc_cpp>)
endif()
set(CAPNP_INCLUDE_DIRECTORY "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
# work around http://public.kitware.com/Bug/view.php?id=15258
...
...
c++/samples/CMakeLists.txt
0 → 100644
View file @
83b8dccf
# A Cap'n Proto sample project.
#
# To build (non-MSVC):
# 1. Install Cap'n Proto somewhere ($PREFIX below):
#
# mkdir capnproto/build
# cd capnproto/build
# cmake ../c++ -DCMAKE_INSTALL_PREFIX=$PREFIX
# cmake --build . --target install
# export PATH=$PREFIX/bin:$PATH
#
# 2. Ensure Cap'n Proto's executables are on the PATH, then build the sample project:
#
# export PATH=$PREFIX/bin:$PATH
# mkdir ../build-samples
# cd ../build-samples
# cmake ../c++/samples
# cmake --build .
#
# Caveat for MSVC:
#
# MSVC cannot yet build the Cap'n Proto executables, so there won't be any `$PREFIX/bin` directory
# to put on the PATH. To work around this, you can use CMAKE_PREFIX_PATH or CMAKE_MODULE_PATH to
# find the installed MSVC-built Cap'n Proto package, and set CAPNP_EXECUTABLE and
# CAPNPC_CXX_EXECUTABLE to the MinGW-built executables manually.
#
# Here's an example step 2, assuming a MinGW-built Cap'n Proto is installed at $PREFIX_MINGW and
# an MSVC-built Cap'n Proto is installed at $PREFIX_MSVC:
#
# mkdir ../build-samples
# cd ../build-samples
# cmake ../c++/samples -DCMAKE_PREFIX_PATH=$PREFIX_MSVC \
# -DCAPNP_EXECUTABLE=$PREFIX_MINGW/bin/capnp.exe \
# -DCAPNPC_CXX_EXECUTABLE=$PREFIX_MINGW/bin/capnpc-c++.exe
# cmake --build .
project
(
"Cap'n Proto Samples"
CXX
)
cmake_minimum_required
(
VERSION 3.0
)
find_package
(
CapnProto CONFIG REQUIRED
)
capnp_generate_cpp
(
addressbookSources addressbookHeaders addressbook.capnp
)
add_executable
(
addressbook addressbook.c++
${
addressbookSources
}
)
target_link_libraries
(
addressbook CapnProto::capnp
)
target_include_directories
(
addressbook PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
)
capnp_generate_cpp
(
calculatorSources calculatorHeaders calculator.capnp
)
add_executable
(
calculator-client calculator-client.c++
${
calculatorSources
}
)
add_executable
(
calculator-server calculator-server.c++
${
calculatorSources
}
)
target_link_libraries
(
calculator-client CapnProto::capnp-rpc
)
target_link_libraries
(
calculator-server CapnProto::capnp-rpc
)
target_include_directories
(
calculator-client PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
)
target_include_directories
(
calculator-server PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
)
c++/samples/calculator-server.c++
View file @
83b8dccf
...
...
@@ -74,7 +74,7 @@ kj::Promise<double> evaluateImpl(
kj
::
joinPromises
(
kj
::
mv
(
paramPromises
));
// When the parameters are complete, call the function.
return
joinedParams
.
then
([
func
](
kj
::
Array
<
double
>&&
paramValues
)
mutable
{
return
joinedParams
.
then
([
KJ_CPCAP
(
func
)
](
kj
::
Array
<
double
>&&
paramValues
)
mutable
{
auto
request
=
func
.
callRequest
();
request
.
setParams
(
paramValues
);
return
request
.
send
().
then
(
...
...
@@ -120,7 +120,7 @@ public:
KJ_REQUIRE
(
params
.
size
()
==
paramCount
,
"Wrong number of parameters."
);
return
evaluateImpl
(
body
.
getRoot
<
Calculator
::
Expression
>
(),
params
)
.
then
([
context
](
double
value
)
mutable
{
.
then
([
KJ_CPCAP
(
context
)
](
double
value
)
mutable
{
context
.
getResults
().
setValue
(
value
);
});
}
...
...
@@ -168,7 +168,7 @@ class CalculatorImpl final: public Calculator::Server {
public
:
kj
::
Promise
<
void
>
evaluate
(
EvaluateContext
context
)
override
{
return
evaluateImpl
(
context
.
getParams
().
getExpression
())
.
then
([
context
](
double
value
)
mutable
{
.
then
([
KJ_CPCAP
(
context
)
](
double
value
)
mutable
{
context
.
getResults
().
setValue
(
kj
::
heap
<
ValueImpl
>
(
value
));
});
}
...
...
c++/src/kj/test-helpers.c++
View file @
83b8dccf
...
...
@@ -24,6 +24,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#else
#include <process.h>
#endif
namespace
kj
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment