1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
#
# Copyright (c) 2019-2025 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
#
# 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 sequence ;
path-constant this_dir : . ;
# The hostname to use for examples
local hostname = [ os.environ BOOST_MYSQL_SERVER_HOST ] ;
if $(hostname) = ""
{
hostname = "127.0.0.1" ;
}
# Builds and run an example
rule run_example (
example_name :
sources * :
args * :
python_runner ? :
requirements *
)
{
# If we're using a Python runner, don't use Valgrind
local valgrind_target = /boost/mysql/test//launch_with_valgrind ;
local launcher = ;
if python_runner {
valgrind_target = ;
launcher = <testing.launcher>"python $(this_dir)/private/$(python_runner)" ;
}
# Join the supplied command-line arguments
local arg_str = [ sequence.join $(args) : " " ] ;
run
/boost/mysql/test//boost_mysql_compiled
$(valgrind_target)
$(sources)
: requirements
<testing.arg>$(arg_str)
$(launcher)
$(requirements)
: target-name $(example_name)
;
}
local regular_args = example_user example_password $(hostname) ;
# Tutorials
run_example tutorial_sync : 1_tutorial/1_sync.cpp : $(regular_args) ;
run_example tutorial_async : 1_tutorial/2_async.cpp : $(regular_args) ;
run_example tutorial_with_params : 1_tutorial/3_with_params.cpp : $(regular_args) 1 ;
run_example tutorial_static_interface : 1_tutorial/4_static_interface.cpp : $(regular_args) 1 ;
run_example tutorial_updates_transactions : 1_tutorial/5_updates_transactions.cpp : $(regular_args) 1 "John" ;
run_example tutorial_connection_pool : 1_tutorial/6_connection_pool.cpp : $(hostname)
: run_tutorial_connection_pool.py ;
run_example tutorial_error_handling : 1_tutorial/7_error_handling.cpp : $(hostname) --test-errors
: run_tutorial_connection_pool.py : ;
# Simple examples
run_example inserts : 2_simple/inserts.cpp
: $(regular_args) "John" "Doe" "HGS" 50000 ;
run_example deletes : 2_simple/deletes.cpp
: $(regular_args) 20 ;
run_example callbacks : 2_simple/callbacks.cpp
: $(regular_args) ;
run_example coroutines_cpp11 : 2_simple/coroutines_cpp11.cpp /boost/mysql/test//boost_context_lib
: $(regular_args) : :
# TODO: remove when https://github.com/boostorg/context/issues/284 is fixed
<warnings-as-errors>off
;
run_example batch_inserts : 2_simple/batch_inserts.cpp /boost/mysql/test//boost_json_lib
: $(hostname) : run_batch_inserts.py ;
run_example batch_inserts_generic : 2_simple/batch_inserts_generic.cpp /boost/mysql/test//boost_json_lib
: $(hostname) : run_batch_inserts.py ;
run_example patch_updates : 2_simple/patch_updates.cpp
: $(hostname) : run_patch_updates.py ;
run_example dynamic_filters : 2_simple/dynamic_filters.cpp
: $(hostname) : run_dynamic_filters.py ;
run_example disable_tls : 2_simple/disable_tls.cpp
: $(regular_args) ;
run_example tls_certificate_verification : 2_simple/tls_certificate_verification.cpp
: $(regular_args) ;
run_example metadata : 2_simple/metadata.cpp
: $(regular_args) ;
run_example prepared_statements : 2_simple/prepared_statements.cpp
: $(regular_args) "HGS" ;
run_example multi_function : 2_simple/multi_function.cpp
: $(regular_args) ;
run_example pipeline : 2_simple/pipeline.cpp
: $(regular_args) "HGS" ;
run_example source_script : 2_simple/source_script.cpp
: $(regular_args) $(this_dir)/private/test_script.sql ;
run_example unix_socket : 2_simple/unix_socket.cpp
: example_user example_password
:
:
<target-os>windows:<build>no
;
# Advanced
run_example http_server_cpp14_coroutines :
3_advanced/http_server_cpp14_coroutines/main.cpp
3_advanced/http_server_cpp14_coroutines/repository.cpp
3_advanced/http_server_cpp14_coroutines/handle_request.cpp
3_advanced/http_server_cpp14_coroutines/server.cpp
/boost/mysql/test//boost_context_lib
/boost/mysql/test//boost_json_lib
/boost/url//boost_url
/boost/mysql/test//boost_beast_lib
: $(hostname)
: run_notes.py
:
# MSVC 14.1 fails with an internal compiler error while building server.cpp for this config
<toolset>msvc-14.1,<address-model>32,<cxxstd>17,<variant>release:<build>no
# Uses heavily Boost.Context coroutines, which aren't fully supported by asan
<address-sanitizer>norecover:<build>no
<address-sanitizer>enable:<build>no
# TODO: remove when https://github.com/boostorg/context/issues/284 is fixed
<warnings-as-errors>off
;
run_example http_server_cpp20 :
3_advanced/http_server_cpp20/main.cpp
3_advanced/http_server_cpp20/repository.cpp
3_advanced/http_server_cpp20/handle_request.cpp
3_advanced/http_server_cpp20/server.cpp
3_advanced/http_server_cpp20/error.cpp
/boost/mysql/test//boost_json_lib
/boost/url//boost_url
/boost/mysql/test//boost_beast_lib
: $(hostname)
: run_orders.py
;
|