Skip to content

Commit a9285ee

Browse files
committed
chore: relocate sources and add build presets
- move implementation sources under src/corosio/src and adjust build files - add CMakePresets.json default Ninja configure to out/build - note portable capy::cond comparisons in docs and public API comments - refresh ignore rules to keep build scripts while ignoring outputs
1 parent f32951c commit a9285ee

32 files changed

Lines changed: 49 additions & 29 deletions

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/build-*/
2-
/bin64/
3-
.cache/
4-
/output/
5-
/.temp
1+
/.vscode/
2+
/build/
3+
!/build/Jamfile
4+
!/build/wolfssl.jam
5+
/out/
6+
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,19 @@ file(GLOB_RECURSE BOOST_COROSIO_HEADERS CONFIGURE_DEPENDS
130130
"${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio/*.hpp"
131131
"${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio.hpp")
132132
file(GLOB_RECURSE BOOST_COROSIO_SOURCES CONFIGURE_DEPENDS
133-
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp"
134-
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
135-
# Exclude wolfssl files from main library (they are added separately when WolfSSL is found)
136-
list(FILTER BOOST_COROSIO_HEADERS EXCLUDE REGEX ".*/wolfssl/.*")
137-
list(FILTER BOOST_COROSIO_SOURCES EXCLUDE REGEX ".*/wolfssl/.*")
133+
"${CMAKE_CURRENT_SOURCE_DIR}/src/corosio/src/*.hpp"
134+
"${CMAKE_CURRENT_SOURCE_DIR}/src/corosio/src/*.cpp")
138135

139136
source_group("" FILES "include/boost/corosio.hpp")
140137
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/corosio" PREFIX "include" FILES ${BOOST_COROSIO_HEADERS})
141-
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src" PREFIX "src" FILES ${BOOST_COROSIO_SOURCES})
138+
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src/corosio/src" PREFIX "src" FILES ${BOOST_COROSIO_SOURCES})
142139

143140
function(boost_corosio_setup_properties target)
144141
target_compile_features(${target} PUBLIC cxx_std_20)
145142
target_include_directories(${target} PUBLIC "${PROJECT_SOURCE_DIR}/include")
146-
target_include_directories(${target} PRIVATE "${PROJECT_SOURCE_DIR}/src")
143+
target_include_directories(${target} PRIVATE
144+
"${PROJECT_SOURCE_DIR}/src/corosio"
145+
"${PROJECT_SOURCE_DIR}/src/corosio/src")
147146
target_link_libraries(${target}
148147
PUBLIC
149148
${BOOST_COROSIO_DEPENDENCIES}

CMakePresets.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "Custom configure preset",
6+
"displayName": "Custom configure preset",
7+
"description": "Sets Ninja generator, build and install directory",
8+
"generator": "Ninja",
9+
"binaryDir": "${sourceDir}/out/build/${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug",
12+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
13+
}
14+
}
15+
]
16+
}

build/Jamfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,11 @@ project boost/corosio
3131
: source-location $(COROSIO_ROOT)
3232
;
3333

34-
local COROSIO_SRC =
35-
[ glob $(COROSIO_ROOT)/src/*.cpp ]
36-
[ glob $(COROSIO_ROOT)/src/detail/*.cpp ]
37-
;
38-
39-
alias corosio_sources : $(COROSIO_SRC) ;
40-
4134
# System libraries
4235
lib ws2_32 ;
4336

37+
alias corosio_sources : [ glob-tree-ex $(COROSIO_ROOT)/src/corosio/src : *.cpp ] ;
38+
4439
lib boost_corosio
4540
: corosio_sources
4641
: requirements
@@ -50,7 +45,8 @@ lib boost_corosio
5045
<target-os>windows:<library>ws2_32
5146
<target-os>windows:<define>_WIN32_WINNT=0x0602
5247
<include>$(COROSIO_ROOT)/include
53-
<include>$(COROSIO_ROOT)/src
48+
<include>$(COROSIO_ROOT)/src/corosio
49+
<include>$(COROSIO_ROOT)/src/corosio/src
5450
: usage-requirements
5551
<library>/boost/capy//boost_capy
5652
<library>/boost/url//boost_url

doc/modules/ROOT/pages/io/acceptor.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ capy::task<void> accept_loop(corosio::io_context& ioc)
115115
116116
if (ec)
117117
{
118-
if (ec == boost::system::errc::operation_canceled)
118+
if (ec == capy::cond::canceled)
119119
break; // Acceptor was closed
120120
std::cerr << "Accept error: " << ec.message() << "\n";
121121
continue;

doc/modules/ROOT/pages/io/sockets.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ auto [ec, n] = co_await s.read_some(
9494
9595
if (ec)
9696
{
97-
if (ec == capy::error::eof)
97+
if (ec == capy::cond::eof)
9898
std::cout << "Peer closed connection\n";
9999
else
100100
std::cerr << "Read error: " << ec.message() << "\n";
@@ -213,11 +213,11 @@ auto [ec, n] = co_await s.read_some(buf);
213213
214214
if (ec)
215215
{
216-
if (ec == capy::error::eof)
216+
if (ec == capy::cond::eof)
217217
{
218218
// Normal disconnect (end of stream)
219219
}
220-
else if (ec == boost::system::errc::operation_canceled)
220+
else if (ec == capy::cond::canceled)
221221
{
222222
// We called cancel()
223223
}

include/boost/corosio/acceptor.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ class BOOST_COROSIO_DECL acceptor : public io_object
235235
@return An awaitable that completes with `io_result<>`.
236236
Returns success on successful accept, or an error code on
237237
failure including:
238-
- operation_canceled: Cancelled via stop_token or cancel()
238+
- operation_canceled: Cancelled via stop_token or cancel().
239+
Check `ec == cond::canceled` for portable comparison.
239240
240241
@par Preconditions
241242
The acceptor must be listening (`is_open() == true`).
@@ -259,6 +260,7 @@ class BOOST_COROSIO_DECL acceptor : public io_object
259260
/** Cancel any pending asynchronous operations.
260261
261262
All outstanding operations complete with `errc::operation_canceled`.
263+
Check `ec == cond::canceled` for portable comparison.
262264
*/
263265
void cancel();
264266

include/boost/corosio/io_stream.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ class BOOST_COROSIO_DECL io_stream : public io_object
4343
@return An awaitable that completes with a pair of
4444
`{error_code, bytes_transferred}`. Returns success with the
4545
number of bytes read, or an error code on failure including:
46-
- capy::error::eof: End of stream reached
47-
- operation_canceled: Cancelled via stop_token or cancel()
46+
- capy::error::eof: End of stream reached.
47+
Check `ec == cond::eof` for portable comparison.
48+
- operation_canceled: Cancelled via stop_token or cancel().
49+
Check `ec == cond::canceled` for portable comparison.
4850
4951
@par Preconditions
5052
The socket must be open and connected.
@@ -75,7 +77,8 @@ class BOOST_COROSIO_DECL io_stream : public io_object
7577
`{error_code, bytes_transferred}`. Returns success with the
7678
number of bytes written, or an error code on failure including:
7779
- broken_pipe: Connection closed by peer
78-
- operation_canceled: Cancelled via stop_token or cancel()
80+
- operation_canceled: Cancelled via stop_token or cancel().
81+
Check `ec == cond::canceled` for portable comparison.
7982
8083
@par Preconditions
8184
The socket must be open and connected.

include/boost/corosio/resolver.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ class BOOST_COROSIO_DECL resolver : public io_object
310310
/** Cancel any pending asynchronous operations.
311311
312312
All outstanding operations complete with `errc::operation_canceled`.
313+
Check `ec == cond::canceled` for portable comparison.
313314
*/
314315
void cancel();
315316

include/boost/corosio/socket.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ class BOOST_COROSIO_DECL socket : public io_stream
241241
- connection_refused: No server listening at endpoint
242242
- timed_out: Connection attempt timed out
243243
- network_unreachable: No route to host
244-
- operation_canceled: Cancelled via stop_token or cancel()
244+
- operation_canceled: Cancelled via stop_token or cancel().
245+
Check `ec == cond::canceled` for portable comparison.
245246
246247
@par Preconditions
247248
The socket must be open (`is_open() == true`).
@@ -265,6 +266,7 @@ class BOOST_COROSIO_DECL socket : public io_stream
265266
/** Cancel any pending asynchronous operations.
266267
267268
All outstanding operations complete with `errc::operation_canceled`.
269+
Check `ec == cond::canceled` for portable comparison.
268270
*/
269271
void cancel();
270272

0 commit comments

Comments
 (0)