Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

master update for release. #379

Merged
merged 18 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@ cmake_minimum_required(VERSION 3.5...3.16)

project(boost_process VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

add_library(boost_process INTERFACE)
add_library(boost_process
src/detail/environment_posix.cpp
src/detail/environment_win.cpp
src/detail/last_error.cpp
src/detail/process_handle_windows.cpp
src/detail/throw_error.cpp
src/detail/utf8.cpp
src/ext/cmd.cpp
src/ext/cwd.cpp
src/ext/env.cpp
src/ext/exe.cpp
src/ext/proc_info.cpp
src/posix/close_handles.cpp
src/windows/default_launcher.cpp
src/environment.cpp
src/error.cpp
src/pid.cpp
src/shell.cpp)

add_library(Boost::process ALIAS boost_process)

target_include_directories(boost_process INTERFACE include)
target_include_directories(boost_process PUBLIC include)
target_link_libraries(boost_process
INTERFACE
PUBLIC
Boost::algorithm
Boost::asio
Boost::config
Expand All @@ -28,6 +46,16 @@ target_link_libraries(boost_process
Boost::winapi
)

target_compile_definitions(boost_process
PRIVATE BOOST_PROCESS_SOURCE=1
)

if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_DYN_LINK)
else()
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_STATIC_LINK)
endif()

if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")

add_subdirectory(test)
Expand Down
49 changes: 49 additions & 0 deletions build/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2024 Klemens D. Morgenstern
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

import os ;
import feature ;
import ../../config/checks/config : requires ;

project : requirements
<define>BOOST_ASIO_NO_DEPRECATED
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
<toolset>msvc:<cxxflags>/bigobj
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
<target-os>linux:<linkflags>-lpthread
: source-location ../src
;

alias process_sources
: detail/environment_posix.cpp
detail/environment_win.cpp
detail/last_error.cpp
detail/process_handle_windows.cpp
detail/throw_error.cpp
detail/utf8.cpp
ext/cmd.cpp
ext/cwd.cpp
ext/env.cpp
ext/exe.cpp
ext/proc_info.cpp
posix/close_handles.cpp
windows/default_launcher.cpp
environment.cpp
error.cpp
pid.cpp
shell.cpp
;

lib boost_process
: process_sources
: requirements <define>BOOST_PROCESS_SOURCE=1
<link>shared:<define>BOOST_PROCESS_DYN_LINK=1
: usage-requirements
<link>shared:<define>BOOST_PROCESS_DYN_LINK=1

;

boost-install boost_process ;
20 changes: 12 additions & 8 deletions doc/Jamfile.jam
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ using doxygen ;

local images = [ glob images/*.svg ] ;
install images : $(images) : <location>html/boost_process ;
install images_glob : $(images) : <location>$(BOOST_ROOT)/doc/html/boost_process ;
install images_glob : $(images) : <location>$(BOOST_ROOT)/doc/html/boost_process ;

import type ;
type.register XMLPROCESSWORKAROUND : : XML ;
import generators ;
generators.register-standard common.copy : XML : XMLPROCESSWORKAROUND ;

xmlprocessworkaround posix_pseudocode : posix_pseudocode.xml ;
xmlprocessworkaround windows_pseudocode : windows_pseudocode.xml ;
xmlprocessworkaround posix_pseudocode : v1/posix_pseudocode.xml ;
xmlprocessworkaround windows_pseudocode : v1/windows_pseudocode.xml ;

path-constant INCLUDES : ../../.. ;

doxygen autodoc
doxygen reference_v1
:
$(INCLUDES)/boost/process.hpp
[ glob $(INCLUDES)/boost/process/*.hpp ]
$(INCLUDES)/boost/process/v1.hpp
[ glob $(INCLUDES)/boost/process/v1/*.hpp ]
:
<doxygen:param>EXCLUDE_SYMBOLS=BOOST_ASIO_INITFN_RESULT_TYPE
<doxygen:param>PREDEFINED=BOOST_PROCESS_DOXYGEN
<doxygen:param>"PREDEFINED=\\
BOOST_PROCESS_DOXYGEN=1 \\
BOOST_PROCESS_V1_INLINE=
"
<doxygen:param>HIDE_UNDOC_CLASSES=YES
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
<doxygen:param>EXAMPLE_PATH=.
Expand Down Expand Up @@ -67,6 +70,7 @@ doxygen reference_v2
BOOST_ASIO_DEFAULT_COMPLETION_TOKEN=DEFAULT \\
BOOST_CONSTEXPR=constexpr \\
BOOST_CXX14_CONSTEXPR=constexpr \\
BOOST_PROCESS_V2_INLINE= \\
BOOST_ATTRIBUTE_NODISCARD=[[nodiscard]]
"
<doxygen.doxproc.id>reference_v2
Expand All @@ -84,7 +88,7 @@ boostbook standalone
:
process.qbk
:
<dependency>autodoc
<dependency>reference_v1
<dependency>reference_v2
<dependency>images
<dependency>images_glob
Expand Down
60 changes: 0 additions & 60 deletions doc/posix_pseudocode.xml

This file was deleted.

12 changes: 3 additions & 9 deletions doc/process.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
]
]

[note [link process.v2 Process V2] is available as experimental]
[note Process v1 will be deprecated in the future. Use v2 for new projects.]

[include introduction.qbk]
[include concepts.qbk]
[include tutorial.qbk]
[include design.qbk]
[include extend.qbk]
[include faq.qbk]
[xinclude autodoc.xml]
[include v1.qbk]
[include v2.qbk]
[include acknowledgements.qbk]
[include v2.qbk]
11 changes: 11 additions & 0 deletions doc/v1.qbk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[section:v1 Process V1]

[include v1/introduction.qbk]
[include v1/concepts.qbk]
[include v1/tutorial.qbk]
[include v1/design.qbk]
[include v1/extend.qbk]
[include v1/faq.qbk]
[xinclude reference_v2.xml]

[endsect]
File renamed without changes.
6 changes: 3 additions & 3 deletions doc/design.qbk → doc/v1/design.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ but the one of the launching process, not the one passed to the child process.]
The simplest form to extend functionality is to provide another handler, which
will be called on the respective events on process launching. The names are:

*`boost::process::on_setup`
*`boost::process::on_error`
*`boost::process::on_success`
*`boost::process::v1::on_setup`
*`boost::process::v1::on_error`
*`boost::process::v1::on_success`


As an example:
Expand Down
52 changes: 26 additions & 26 deletions doc/extend.qbk → doc/v1/extend.qbk
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
[def __on_exit__ [globalref boost::process::on_exit on_exit]]
[def __on_success__ [globalref boost::process::extend::on_success ex::on_success]]
[def __child__ [classref boost::process::child child]]
[def __handler__ [classref boost::process::extend::handler handler]]
[def __on_success__ [memberref boost::process::extend::handler::on_success on_success]]
[def __posix_executor__ [classref boost::process::extend::posix_executor ex::posix_executor]]
[def __windows_executor__ [classref boost::process::extend::windows_executor ex::windows_executor]]
[def __on_exit__ [globalref boost::process::v1::on_exit on_exit]]
[def __on_success__ [globalref boost::process::v1::extend::on_success ex::on_success]]
[def __child__ [classref boost::process::v1::child child]]
[def __handler__ [classref boost::process::v1::extend::handler handler]]
[def __on_success__ [memberref boost::process::v1::extend::handler::on_success on_success]]
[def __posix_executor__ [classref boost::process::v1::extend::posix_executor ex::posix_executor]]
[def __windows_executor__ [classref boost::process::v1::extend::windows_executor ex::windows_executor]]
[def __io_context__ [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_context.html boost::asio::io_context]]
[def __require_io_context__ [classref boost::process::extend::require_io_context ex::require_io_context]]
[def __async_handler__ [classref boost::process::extend::async_handler ex::async_handler]]
[def __get_io_context__ [funcref boost::process::extend::get_io_context ex::get_io_context]]
[def __require_io_context__ [classref boost::process::v1::extend::require_io_context ex::require_io_context]]
[def __async_handler__ [classref boost::process::v1::extend::async_handler ex::async_handler]]
[def __get_io_context__ [funcref boost::process::v1::extend::get_io_context ex::get_io_context]]

[section:extend Extensions]
To extend the library, the header [headerref boost/process/extend.hpp extend] is provided.

It only provides the explicit style for custom properties, but no implicit style.

What this means is, that a custom initializer can be implemented, a reference which can be passed to one of the launching functions.
If a class inherits [classref boost::process::extend::handler] it will be regarded as an initializer and thus directly put into the sequence
If a class inherits [classref boost::process::v1::extend::handler] it will be regarded as an initializer and thus directly put into the sequence
the executor gets passed.

[section:structure Structure]

The executor calls different handlers of the initializers during the process launch.
The basic structure consists of three functions, as given below:

* [globalref boost::process::extend::on_setup on_setup]
* [globalref boost::process::extend::on_error on_error]
* [globalref boost::process::extend::on_success on_success]
* [globalref boost::process::v1::extend::on_setup on_setup]
* [globalref boost::process::v1::extend::on_error on_error]
* [globalref boost::process::v1::extend::on_success on_success]

'''
<imagedata fileref="boost_process/windows_exec.svg"/>
'''

Additionally posix provides three more handlers, listed below:

* [globalref boost::process::extend::on_fork_error on_fork_error]
* [globalref boost::process::extend::on_exec_setup on_exec_setup]
* [globalref boost::process::extend::on_exec_error on_exec_error]
* [globalref boost::process::v1::extend::on_fork_error on_fork_error]
* [globalref boost::process::v1::extend::on_exec_setup on_exec_setup]
* [globalref boost::process::v1::extend::on_exec_error on_exec_error]

For more information see the reference of [classref boost::process::extend::posix_executor posix_executor].
For more information see the reference of [classref boost::process::v1::extend::posix_executor posix_executor].

[endsect]
[section:simple Simple extensions]
Expand All @@ -55,8 +55,8 @@ __child__ c("foo", __on_success__=[](auto & exec) {std::cout << "hello world" <<

Considering that lambdas can also capture values, data can easily be shared between handlers.

To see which members the executor has, refer to [classref boost::process::extend::windows_executor windows_executor]
and [classref boost::process::extend::posix_executor posix_executor].
To see which members the executor has, refer to [classref boost::process::v1::extend::windows_executor windows_executor]
and [classref boost::process::v1::extend::posix_executor posix_executor].

[note Combined with __on_exit__ this can also handle the process exit.]

Expand All @@ -67,7 +67,7 @@ and [classref boost::process::extend::posix_executor posix_executor].
[section:handler Handler Types]

Since the previous example is in a functional style, it is not very reusable.
To solve that problem, the [classref boost::process::extend::handler handler] has an alias in the `boost::process::extend` namespace, to be inherited.
To solve that problem, the [classref boost::process::v1::extend::handler handler] has an alias in the `boost::process::v1::extend` namespace, to be inherited.
So let's implement the hello world example in a class.

```
Expand All @@ -86,7 +86,7 @@ __child__ c("foo", hello_world());

[note The implementation is done via overloading, not overriding.]

Every handler not implemented defaults to [classref boost::process::extend::handler handler], where an empty handler is defined for each event.
Every handler not implemented defaults to [classref boost::process::v1::extend::handler handler], where an empty handler is defined for each event.

[endsect]

Expand All @@ -108,11 +108,11 @@ struct async_foo : __handler__, __require_io_context__
}
};
```
[note Inheriting [globalref boost::process::extend::require_io_context require_io_context] is necessary, so [funcref boost::process::system system] provides one.]
[note Inheriting [globalref boost::process::v1::extend::require_io_context require_io_context] is necessary, so [funcref boost::process::v1::system system] provides one.]

Additionally the handler can provide a function that is invoked when the child process exits. This is done through __async_handler__.

[note [globalref boost::process::extend::async_handler async_handler] implies [globalref boost::process::extend::require_io_context require_io_context] .]
[note [globalref boost::process::v1::extend::async_handler async_handler] implies [globalref boost::process::v1::extend::require_io_context require_io_context] .]

```
struct async_bar : __handler, __async_handler__
Expand All @@ -131,7 +131,7 @@ struct async_bar : __handler, __async_handler__
```


[caution `on_exit_handler` does not default and is always required when [classref boost::process::extend::async_handler async_handler] is inherited. ]
[caution `on_exit_handler` does not default and is always required when [classref boost::process::v1::extend::async_handler async_handler] is inherited. ]

[caution `on_exit_handler` uses `boost::asio::signal_set` to listen for SIGCHLD on posix. The application must not also register a signal handler for SIGCHLD using functions such as `signal()` or `sigaction()` (but using `boost::asio::signal_set` is fine). ]

Expand All @@ -156,7 +156,7 @@ auto set_error = [](auto & exec)
__child__ c("foo", on_setup=set_error);
```

Since we do not specify the error-handling mode in this example, this will throw [classref boost::process::process_error process_error].
Since we do not specify the error-handling mode in this example, this will throw [classref boost::process::v1::process_error process_error].

[endsect]

Expand Down
File renamed without changes.
Loading
Loading