Compare commits

...

15 Commits

Author SHA1 Message Date
bff5cb65a5 Boost super-project tests target
fix #53
2024-02-20 13:53:27 -03:00
42bb99ed25 support platforms without wchar_t
closes #51
2023-10-24 14:22:30 -04:00
175f467a03 select hash implementation with macros based on word size
fixes #46
2023-05-29 11:30:18 -04:00
6275cd7fe3 disable string_view overloads when type is convertible to basic_static_string
fixes #47
2023-05-29 10:51:06 -04:00
ac84c4f40e string_view interoperability
fix #26
2023-01-19 19:57:32 -03:00
269987446e check for char8_t directly
fix #40
2023-01-18 22:10:36 -03:00
82ff4e0679 static_string<0> does not memcpy
fix #41
2023-01-18 22:09:45 -03:00
9c3d5febe7 tests include main header 2023-01-18 22:09:31 -03:00
0c914ff05b fix noexcept-type warning 2022-11-04 10:34:09 -07:00
bfce6eea90 fix unused-function warning 2022-11-03 22:48:35 -07:00
ffce33d483 fix array-bounds warning 2022-11-03 14:12:02 -07:00
c4f6491537 fix restrict warning 2022-11-02 15:46:33 -07:00
25579e482f update jamfile
fix #24
2022-11-01 14:11:31 -07:00
3e9489a7af update CMakeLists.txt
fix #4
2022-11-01 13:39:05 -07:00
7822f1b991 update CI
fix #31, fix #20
2022-10-31 16:09:33 -07:00
16 changed files with 2084 additions and 929 deletions

View File

@ -1,5 +1,6 @@
# Copyright 2016, 2017 Peter Dimov # Copyright 2016, 2017 Peter Dimov
# Copyright (C) 2017 - 2019 James E. King III # Copyright 2017 - 2019 James E. King III
# Copyright 2019 - 2021 Alexander Grund
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -21,7 +22,7 @@
version: 1.0.{build}-{branch} version: 1.0.{build}-{branch}
shallow_clone: true shallow_clone: false
branches: branches:
only: only:
@ -33,115 +34,101 @@ branches:
- /pr\/.*/ - /pr\/.*/
matrix: matrix:
fast_finish: false
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green: # Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures: allow_failures:
- MAYFAIL: true - MAYFAIL: true
environment: environment:
global: global:
B2_CI_VERSION: 1
GIT_FETCH_JOBS: 4
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties # see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however: # to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most # on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles... # libraries that care about this exercise it in their Jamfiles...
# B2_ADDRESS_MODEL: address-model=64,32 B2_ADDRESS_MODEL: 32,64
# B2_LINK: link=shared,static B2_LINK: shared,static
# B2_THREADING: threading=multi,single # B2_THREADING: threading=multi,single
B2_VARIANT: variant=release B2_VARIANT: release
matrix: matrix:
- FLAVOR: Visual Studio 2022
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
B2_CXXFLAGS: -permissive-
B2_CXXSTD: 14,17,20
B2_TOOLSET: msvc-14.3
- FLAVOR: Visual Studio 2019 - FLAVOR: Visual Studio 2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64 B2_CXXFLAGS: -permissive-
B2_CXXFLAGS: cxxflags=-permissive- B2_CXXSTD: 14,17,2a
B2_CXXSTD: 17 # 2a
B2_TOOLSET: msvc-14.2 B2_TOOLSET: msvc-14.2
- FLAVOR: Visual Studio 2017 C++2a Strict - FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64 B2_CXXFLAGS: -permissive-
B2_CXXFLAGS: cxxflags=-permissive- B2_CXXSTD: 2a
B2_CXXSTD: 17 # 2a
B2_TOOLSET: msvc-14.1 B2_TOOLSET: msvc-14.1
- FLAVOR: Visual Studio 2017 C++17 - FLAVOR: Visual Studio 2017 C++14/17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64 B2_CXXSTD: 14,17
B2_CXXSTD: 17
B2_TOOLSET: msvc-14.1
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2017 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: address-model=64,32
B2_TOOLSET: msvc-14.1 B2_TOOLSET: msvc-14.1
- FLAVOR: clang-cl - FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
B2_ADDRESS_MODEL: address-model=64 ADDCOMMANDS: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"'
B2_CXXSTD: 11 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,14,17
B2_TOOLSET: clang-win B2_TOOLSET: clang-win
- FLAVOR: Visual Studio 2015 C++14 (Default) # not supported
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 # - FLAVOR: Visual Studio 2015, 2013
B2_ADDRESS_MODEL: address-model=64,32 # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-14.0 # B2_TOOLSET: msvc-12.0,msvc-14.0
B2_VARIANT: variant=debug
- FLAVOR: Visual Studio 2010, 2012, 2013 # - FLAVOR: Visual Studio 2008, 2010, 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 # APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0 # B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
# B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: cygwin (32-bit) - FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin; ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32 B2_ADDRESS_MODEL: 32
B2_CXXSTD: 03,11 B2_CXXSTD: 11,14,1z
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: cygwin (64-bit) - FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin; ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,17 B2_CXXSTD: 11,14,1z
# https://github.com/boostorg/test/issues/144
B2_DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc B2_TOOLSET: gcc
- FLAVOR: mingw32 - FLAVOR: mingw32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ARCH: i686 B2_ADDRESS_MODEL: 32
B2_ADDRESS_MODEL: address-model=32 ADDPATH: C:\mingw\bin;
B2_CXXSTD: 03,11 B2_CXXSTD: 11,14,17,2a
SCRIPT: ci\appveyor\mingw.bat B2_TOOLSET: gcc
B2_VARIANT: variant=debug
- FLAVOR: mingw64 - FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ARCH: x86_64 ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
B2_ADDRESS_MODEL: address-model=64 B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,17 B2_CXXSTD: 11,14,17,2a
B2_DEFINES: define=__USE_ISOC99 B2_TOOLSET: gcc
SCRIPT: ci\appveyor\mingw.bat
install: install:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_% - '%ADDCOMMANDS%'
- git clone https://github.com/boostorg/boost-ci.git C:\boost-ci - git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned
- xcopy /s /e /q /i C:\boost-ci\ci .\ci # Copy ci folder if not testing Boost.CI
- if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci
- rmdir /s /q C:\boost-ci-cloned
- ci\appveyor\install.bat - ci\appveyor\install.bat
build: off build: off
test_script: test_script: ci\build.bat
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH%
# The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
- IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
# Echo the complete build command to the build log
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
# Now go build...
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)

View File

@ -1,276 +0,0 @@
# Copyright 2015-2019 Rene Rivera.
# Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Azure Pipelines build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
trigger:
branches:
include:
- develop
- master
- bugfix/*
- feature/*
- fix/*
- pr/*
pr:
branches:
include:
- develop
variables:
- name: B2_VARIANT
value: variant=release,debug
stages:
- stage: Test
jobs:
- job: 'Linux'
pool:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
GCC 8:
B2_TOOLSET: gcc
B2_CXXSTD: 14,17
CXX: g++-8
PACKAGES: g++-8
GCC 7:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14,17
CXX: g++-7
PACKAGES: g++-7
GCC 6:
B2_TOOLSET: gcc
B2_CXXSTD: 11,14
CXX: g++-6
PACKAGES: g++-6
GCC 5:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-5
PACKAGES: g++-5
GCC 4.9:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.9
PACKAGES: g++-4.9
GCC 4.8:
B2_TOOLSET: gcc
B2_CXXSTD: 11
CXX: g++-4.8
PACKAGES: g++-4.8
Clang 8:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-8
PACKAGES: clang-8
LLVM_REPO: llvm-toolchain-xenial-8
Clang 7:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-7
PACKAGES: clang-7
LLVM_REPO: llvm-toolchain-xenial-7
Clang 6:
B2_TOOLSET: clang
B2_CXXSTD: 14,17
CXX: clang++-6.0
PACKAGES: clang-6.0
LLVM_REPO: llvm-toolchain-xenial-6.0
Clang 5:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
PACKAGES: clang-5.0
CXX: clang++-5.0
LLVM_REPO: llvm-toolchain-xenial-5.0
Clang 4:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17
CXX: clang++-4.0
PACKAGES: clang-4.0
LLVM_REPO: llvm-toolchain-xenial-4.0
Clang 3.9:
B2_TOOLSET: clang
B2_CXXSTD: 11,14
CXX: clang++-3.9
PACKAGES: clang-3.9
Clang 3.8:
B2_TOOLSET: clang
CXX: clang++-3.8
B2_CXXSTD: 11,14
PACKAGES: clang-3.8
Clang 3.7:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.7
PACKAGES: clang-3.7
Clang 3.6:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.6
PACKAGES: clang-3.6
Clang 3.5:
B2_TOOLSET: clang
B2_CXXSTD: 11
CXX: clang++-3.5
PACKAGES: clang-3.5
steps:
- bash: |
set -e
uname -a
sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
if test -n "${LLVM_REPO}" ; then
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo -E apt-add-repository "deb http://apt.llvm.org/xenial/ ${LLVM_REPO} main"
fi
sudo -E apt-get update
sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ${PACKAGES}
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
cp -pr boost-ci/ci boost-ci/.codecov.yml .
rm -rf boost-ci
source ci/azure-pipelines/install.sh
# AzP requires to run special task in order to export
# SELF and BOOST_ROOT as job-scoped variable from a script.
# NOTE: Disable set -x is necessary, see the troubleshooting guide
# on "Variables having ' (single quote) appended":
# https://docs.microsoft.com/en-us/azure/devops/pipelines/troubleshooting
set +x
echo "##vso[task.setvariable variable=SELF]"$SELF
echo "##vso[task.setvariable variable=BOOST_ROOT]"$BOOST_ROOT
set -x
displayName: 'Install'
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh --debug-configuration
displayName: 'Build'
- job: 'Windows'
strategy:
matrix:
VS 2019 C++17 Strict:
B2_TOOLSET: msvc-14.2
B2_CXXSTD: 17
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'windows-2019'
VS 2017 C++17 Strict:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: 17
B2_CXXFLAGS: cxxflags=-permissive-
B2_ADDRESS_MODEL: address-model=64
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++17:
B2_TOOLSET: msvc-14.1
B2_CXXSTD: 17
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
VS 2017 C++14:
B2_TOOLSET: msvc-14.1
#B2_CXXSTD: 14 # default
B2_ADDRESS_MODEL: address-model=64,32
VM_IMAGE: 'vs2017-win2016'
pool:
vmImage: $(VM_IMAGE)
steps:
- script: |
set SELF=%BUILD_REPOSITORY_NAME:-=_%
for /f "tokens=2 delims=/" %%a in ("%SELF%") do set SELF=%%a
set BOOST_ROOT=%BUILD_SOURCESDIRECTORY%\boost-root
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci
xcopy /s /e /q /i boost-ci\ci .\ci
cmd /k ci\azure-pipelines\install.bat
echo ##vso[task.setvariable variable=SELF]%SELF%
echo ##vso[task.setvariable variable=BOOST_ROOT]%BOOST_ROOT%
displayName: 'Install'
- script: |
PATH=%ADDPATH%%PATH%
REM The definition of B2_TOOLCXX omits B2_CXXSTD= if it was not defined above
IF NOT DEFINED B2_CXXSTD (SET B2_TOOLCXX=toolset=%B2_TOOLSET%) ELSE (SET B2_TOOLCXX=toolset=%B2_TOOLSET% cxxstd=%B2_CXXSTD%)
cd %BOOST_ROOT%
ECHO b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
b2 libs/%SELF:\=/% %B2_TOOLCXX% %B2_CXXFLAGS% %B2_DEFINES% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3
displayName: 'Build'
- job: 'macOS'
pool:
vmImage: 'macOS-10.14'
strategy:
matrix:
Xcode_11_3_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.3.1.app
Xcode_11_2_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.2.1.app
Xcode_11_2:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.2.app
Xcode_11_1:
B2_TOOLSET: clang
B2_CXXSTD: 14,17,2a
XCODE_APP: /Applications/Xcode_11.1.app
Xcode_10_3:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.3.app
Xcode_10_2_1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.2.1.app
Xcode_10_2:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.2.app
Xcode_10_1:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.1.app
Xcode_10_0:
B2_TOOLSET: clang
B2_CXXSTD: 11,14,17,2a
XCODE_APP: /Applications/Xcode_10.app
steps:
- bash: |
set -e
git clone --branch master https://github.com/boostorg/boost-ci.git boost-ci-cloned
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
source ci/azure-pipelines/install.sh
displayName: Install
- bash: |
set -e
echo "SELF=$SELF"
echo "BOOST_ROOT=$BOOST_ROOT"
cd $BOOST_ROOT/libs/$SELF
ci/azure-pipelines/build.sh
displayName: 'Build'

25
.codecov.yml Normal file
View File

@ -0,0 +1,25 @@
# Copyright 2019 - 2021 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Sample codecov configuration file. Edit as required
codecov:
max_report_age: off
require_ci_to_pass: yes
notify:
# Increase this if you have multiple coverage collection jobs
after_n_builds: 1
wait_for_ci: yes
# Change how pull request comments look
comment:
layout: "reach,diff,flags,files,footer"
# Ignore specific files or folders. Glob patterns are supported.
# See https://docs.codecov.com/docs/ignoring-paths
ignore:
- extra/*
- extra/**/*
- test/*
- test/**/*

117
.drone.star Normal file
View File

@ -0,0 +1,117 @@
# Use, modification, and distribution are
# subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE.txt)
#
# Copyright Rene Rivera 2020.
# Copyright Alan de Freitas 2022.
# For Drone CI we use the Starlark scripting language to reduce duplication.
# As the yaml syntax for Drone CI is rather limited.
#
#
globalenv={'B2_CI_VERSION': '1', 'B2_VARIANT': 'release'}
linuxglobalimage="cppalliance/droneubuntu1804:1"
windowsglobalimage="cppalliance/dronevs2019"
def main(ctx):
return [
# Priorities: (no 2a, no betas)
#
# coverage
# latest gcc: 17,20
# latest clang: 17,20
# oldest gcc: 11
# oldest clang: 11
# asan
# tsan
# ubsan
# valgrind
# arm64
# s390x
# docs
# cmake superproject
# cmake install
# (...the rest)
# Coverage
linux_cxx("Coverage", "g++-8", packages="g++-8", buildscript="drone", buildtype="codecov", image=linuxglobalimage, environment={'COMMENT': 'codecov.io', 'LCOV_BRANCH_COVERAGE': '0', 'B2_CXXSTD': '11', 'B2_TOOLSET': 'gcc-8', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', "CODECOV_TOKEN": {"from_secret": "codecov_token"}, "COVERALLS_REPO_TOKEN": {"from_secret": "coveralls_repo_token"}}, globalenv=globalenv),
# Latest gcc
linux_cxx("GCC 12: C++17,20", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'gcc-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("GCC 12: C++17,20 Standalone", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'gcc-12', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Latest clang
linux_cxx("Clang 15: C++17,20", "clang++-15", packages="clang-15 libstdc++-10-dev", llvm_os="jammy", llvm_ver="15", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-15', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 15: C++17,20 Standalone", "clang++-15", packages="clang-15 libstdc++-10-dev", llvm_os="jammy", llvm_ver="15", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-15', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Oldest compilers
linux_cxx("GCC 4.8: C++11", "g++-4.8", packages="g++-4.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 4.8: C++11 Standalone", "g++-4.8", packages="g++-4.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.8', 'B2_CXXFLAGS': '-Werror', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("Clang 3.8: C++11", "clang++-3.8", packages="clang-3.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_VARIANT': 'debug', 'B2_CXXFLAGS': '-Werror', 'B2_TOOLSET': 'clang-3.8', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("Clang 3.8: C++11 Standalone", "clang++-3.8", packages="clang-3.8", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_VARIANT': 'debug', 'B2_CXXFLAGS': '-Werror', 'B2_TOOLSET': 'clang-3.8', 'B2_DEFINES': 'define=BOOST_STATIC_STRING_STANDALONE', 'B2_CXXSTD': '11'}, globalenv=globalenv),
# Sanitizers + Valgrind
linux_cxx("ASan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'asan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_ASAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True'}, globalenv=globalenv, privileged=True),
linux_cxx("TSan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'tsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_TSAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1'}, globalenv=globalenv),
linux_cxx("UBSan", "g++-12", packages="g++-12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-12', 'B2_CXXSTD': '11,14,17', 'B2_UBSAN': '1', 'B2_DEFINES': 'define=BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': '-fuse-ld=gold'}, globalenv=globalenv),
linux_cxx("Valgrind", "clang++-14", packages="clang-14 libc6-dbg libc++-dev libstdc++-9-dev", llvm_os="jammy", llvm_ver="14", buildscript="drone", buildtype="valgrind", image="cppalliance/droneubuntu2204:1", environment={'COMMENT': 'valgrind', 'B2_TOOLSET': 'clang-14', 'B2_CXXSTD': '11,14,17', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'B2_VARIANT': 'debug', 'B2_TESTFLAGS': 'testing.launcher=valgrind', 'VALGRIND_OPTS': '--error-exitcode=1'}, globalenv=globalenv),
# arm64 (unsigned char)
linux_cxx("ARM64: GCC 11", "g++-11", packages="g++-11", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, arch="arm64", globalenv=globalenv),
# s390x
linux_cxx("S390x: Clang 12", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, arch="s390x", globalenv=globalenv),
# Documentation
# linux_cxx("Docs", "g++", packages="docbook docbook-xml docbook-xsl xsltproc libsaxonhe-java default-jre-headless flex libfl-dev bison unzip rsync", buildtype="docs", buildscript="drone", image="cppalliance/droneubuntu1804:1", environment={'COMMENT': 'docs'}, globalenv=globalenv),
# CMake tests (https://github.com/boostorg/boost-ci)
## Compiling as part of the boost superproject
linux_cxx("CMake Superproject", "g++", packages="", buildscript="drone", buildtype="cmake-superproject", image="cppalliance/droneubuntu1804:1", globalenv=globalenv),
## Installing
# linux_cxx("CMake Install", "g++", packages="", buildscript="drone", buildtype="cmake1", image="cppalliance/droneubuntu1804:1", environment={'CMAKE_INSTALL_TEST': '1'}, globalenv=globalenv),
# ------------------------------------------------------------------
# OSX
osx_cxx("OSX: Clang", "g++", packages="", buildscript="drone", buildtype="boost", xcode_version="13.4.1", environment={'B2_TOOLSET': 'clang', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,17'}, globalenv=globalenv),
# GCC (All other versions)
linux_cxx("GCC 4.9: C++11", "g++-4.9", packages="g++-4.9", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'gcc-4.9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 5: C++11", "g++-5", packages="g++-5", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-5', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11'}, globalenv=globalenv),
linux_cxx("GCC 6: C++11,14", "g++-6", packages="g++-6", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-6', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("GCC 7: C++14,17", "g++-7", packages="g++-7", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-7', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("GCC 8: C++17", "g++-8", packages="g++-8", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 9: C++17", "g++-9", packages="g++-9", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 10: C++17", "g++-10", packages="g++-10", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-10', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("GCC 11: C++17,20", "g++-11", packages="g++-11", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# Clang (All other versions)
linux_cxx("Clang 4.0: C++11,14", "clang++-4.0", packages="clang-4.0 libstdc++-6-dev", llvm_os="xenial", llvm_ver="4.0", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'B2_TOOLSET': 'clang-4.0', 'B2_CXXFLAGS': '', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("Clang 5.0: C++11,14", "clang++-5.0", packages="clang-5.0 libstdc++-7-dev", llvm_os="bionic", llvm_ver="5.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-5.0', 'B2_CXXFLAGS': '', 'B2_CXXSTD': '11,14'}, globalenv=globalenv),
linux_cxx("Clang 6.0: C++11,14", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libc++abi-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="6.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14', 'B2_STDLIB': 'libc++'}, globalenv=globalenv),
linux_cxx("Clang 6.0: C++14,17", "clang++-6.0", packages="clang-6.0 libc6-dbg libc++-dev libc++abi-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="6.0", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-6.0', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 7: C++17", "clang++-7", packages="clang-7 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="7", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-7', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("Clang 8: C++17", "clang++-8", packages="clang-8 libc6-dbg libc++-dev libstdc++-8-dev", llvm_os="bionic", llvm_ver="8", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-8', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, globalenv=globalenv),
linux_cxx("Clang 9: C++14,17", "clang++-9", packages="clang-9 libstdc++-9-dev", llvm_os="bionic", llvm_ver="9", buildscript="drone", buildtype="boost", image=linuxglobalimage, environment={'B2_TOOLSET': 'clang-9', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 10: C++14,17", "clang++-10", packages="clang-10 libstdc++-9-dev", llvm_os="focal", llvm_ver="10", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-10', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 11: C++14,17", "clang++-11", packages="clang-11 libstdc++-9-dev", llvm_os="focal", llvm_ver="11", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '14,17'}, globalenv=globalenv),
linux_cxx("Clang 12: C++17,20", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:1", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 13: C++17,20", "clang++-13", packages="clang-13 libstdc++-10-dev", llvm_os="jammy", llvm_ver="13", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-13', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
linux_cxx("Clang 14: C++17,20", "clang++-14", packages="clang-14 libstdc++-10-dev", llvm_os="jammy", llvm_ver="14", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2204:1", environment={'B2_TOOLSET': 'clang-14', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
# arm64 (unsigned char)
linux_cxx("ARM64: Clang 12", "clang++-12", packages="clang-12 libstdc++-9-dev", llvm_os="focal", llvm_ver="12", buildscript="drone", buildtype="boost", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'clang-12', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '11,14,17,20'}, arch="arm64", globalenv=globalenv),
# s390x
linux_cxx("S390x: GCC 11", "g++-11", packages="g++-11", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2004:multiarch", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXFLAGS': '-Werror', 'B2_CXXSTD': '17'}, arch="s390x", globalenv=globalenv),
# MSVC
windows_cxx("MSVC 14.1", "", image="cppalliance/dronevs2017", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.1", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "11,14,17"},globalenv=globalenv),
windows_cxx("MSVC 14.2: C++14,17,latest", "", image="cppalliance/dronevs2019", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.2", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "14,17,latest"},globalenv=globalenv),
windows_cxx("MSVC 14.3: C++17,20", "", image="cppalliance/dronevs2022", buildtype="boost", buildscript="drone", environment={"B2_TOOLSET": "msvc-14.3", 'B2_CXXFLAGS': '/WX', "B2_CXXSTD": "17,20"},globalenv=globalenv),
]
# from https://github.com/boostorg/boost-ci
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")

31
.drone/drone.bat Normal file
View File

@ -0,0 +1,31 @@
@ECHO ON
setlocal enabledelayedexpansion
if "%DRONE_JOB_BUILDTYPE%" == "boost" (
echo '==================================> INSTALL'
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
REM source ci/travis/install.sh
REM The contents of install.sh below:
for /F %%i in ("%DRONE_REPO%") do @set SELF=%%~nxi
SET BOOST_CI_TARGET_BRANCH=%DRONE_COMMIT_BRANCH%
SET BOOST_CI_SRC_FOLDER=%cd%
call ci\common_install.bat
echo '==================================> COMPILE'
REM set B2_TARGETS=libs/!SELF!/test libs/!SELF!/example
set B2_TARGETS=libs/!SELF!/test
call !BOOST_ROOT!\libs\!SELF!\ci\build.bat
) else if "%DRONE_JOB_BUILDTYPE%" == "standalone-windows" (
REM not used
)

236
.drone/drone.sh Executable file
View File

@ -0,0 +1,236 @@
#!/bin/bash
# Copyright 2020 Rene Rivera, Sam Darwin
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
set -xe
export TRAVIS_BUILD_DIR=$(pwd)
export DRONE_BUILD_DIR=$(pwd)
export TRAVIS_BRANCH=$DRONE_BRANCH
export TRAVIS_EVENT_TYPE=$DRONE_BUILD_EVENT
export VCS_COMMIT_ID=$DRONE_COMMIT
export GIT_COMMIT=$DRONE_COMMIT
export REPO_NAME=$DRONE_REPO
export USER=$(whoami)
export CC=${CC:-gcc}
export PATH=~/.local/bin:/usr/local/bin:$PATH
common_install() {
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
cp -prf boost-ci-cloned/ci .
rm -rf boost-ci-cloned
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
unset -f cd
fi
export SELF=$(basename $REPO_NAME)
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
export BOOST_CI_SRC_FOLDER=$(pwd)
. ./ci/common_install.sh
}
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
export B2_TARGETS=${B2_TARGETS:-"libs/$SELF/test"}
$BOOST_ROOT/libs/$SELF/ci/travis/build.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "docs" ]; then
echo '==================================> INSTALL'
export SELF=$(basename $REPO_NAME)
pwd
cd ..
mkdir -p $HOME/cache && cd $HOME/cache
if [ ! -d doxygen ]; then git clone -b 'Release_1_8_15' --depth 1 https://github.com/doxygen/doxygen.git && echo "not-cached"; else echo "cached"; fi
cd doxygen
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
cd build
sudo make install
cd ../..
if [ ! -f saxonhe.zip ]; then wget -O saxonhe.zip https://sourceforge.net/projects/saxon/files/Saxon-HE/9.9/SaxonHE9-9-1-4J.zip/download && echo "not-cached"; else echo "cached"; fi
unzip -o saxonhe.zip
sudo rm /usr/share/java/Saxon-HE.jar
sudo cp saxon9he.jar /usr/share/java/Saxon-HE.jar
cd ..
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root --depth 1
cd boost-root
export BOOST_ROOT=$(pwd)
git submodule update --init libs/context
git submodule update --init tools/boostbook
git submodule update --init tools/boostdep
git submodule update --init tools/docca
git submodule update --init tools/quickbook
rsync -av $TRAVIS_BUILD_DIR/ libs/$SELF
python tools/boostdep/depinst/depinst.py ../tools/quickbook
./bootstrap.sh
./b2 headers
echo '==================================> SCRIPT'
echo "using doxygen ; using boostbook ; using saxonhe ;" >tools/build/src/user-config.jam
./b2 -j3 libs/$SELF/doc//boostrelease
elif [ "$DRONE_JOB_BUILDTYPE" == "codecov" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
set +e
cd $BOOST_ROOT/libs/$SELF
ci/travis/codecov.sh
# coveralls
# uses multiple lcov steps from boost-ci codecov.sh script
if [ -n "${COVERALLS_REPO_TOKEN}" ]; then
echo "processing coveralls"
pip3 install --user cpp-coveralls
cd $BOOST_CI_SRC_FOLDER
export PATH=/tmp/lcov/bin:$PATH
command -v lcov
lcov --version
lcov --remove coverage.info -o coverage_filtered.info '*/test/*' '*/extra/*'
cpp-coveralls --verbose -l coverage_filtered.info
fi
elif [ "$DRONE_JOB_BUILDTYPE" == "valgrind" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
cd $BOOST_ROOT/libs/$SELF
ci/travis/valgrind.sh
elif [ "$DRONE_JOB_BUILDTYPE" == "standalone" ]; then
echo '==================================> INSTALL'
# Installing cmake with apt-get, so not required here:
# pip install --user cmake
echo '==================================> SCRIPT'
export CXXFLAGS="-Wall -Wextra -Werror -std=c++17"
mkdir __build_17
cd __build_17
cmake -DBOOST_JSON_STANDALONE=1 ..
cmake --build .
ctest -V .
export CXXFLAGS="-Wall -Wextra -Werror -std=c++2a"
mkdir ../__build_2a
cd ../__build_2a
cmake -DBOOST_JSON_STANDALONE=1 ..
cmake --build .
ctest -V .
elif [ "$DRONE_JOB_BUILDTYPE" == "coverity" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> SCRIPT'
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$TRAVIS_BRANCH" = "develop" -o "$TRAVIS_BRANCH" = "master" \) -a \( "$DRONE_BUILD_EVENT" = "push" -o "$DRONE_BUILD_EVENT" = "cron" \) ]; then
cd $BOOST_ROOT/libs/$SELF
ci/travis/coverity.sh
fi
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake-superproject" ]; then
echo '==================================> INSTALL'
common_install
echo '==================================> COMPILE'
# May want to re-enable -Werror
# export CXXFLAGS="-Wall -Wextra -Werror"
export CXXFLAGS="-Wall -Wextra"
mkdir __build_static
cd __build_static
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
-DBOOST_INCLUDE_LIBRARIES=$SELF ..
cmake --build .
ctest --output-on-failure -R boost_$SELF
cd ..
mkdir __build_shared
cd __build_shared
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
-DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON ..
cmake --build .
ctest --output-on-failure -R boost_$SELF
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake1" ]; then
echo '==================================> INSTALL'
# https://github.com/opencv/opencv-python#frequently-asked-questions
pip install --upgrade pip
pip install --user cmake
echo '==================================> SCRIPT'
export SELF=$(basename $REPO_NAME)
BOOST_BRANCH=develop && [ "$DRONE_BRANCH" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
# mkdir -p libs/$SELF
# cp -r $DRONE_BUILD_DIR/* libs/$SELF
# git submodule update --init tools/boostdep
git submodule update --init --recursive
mkdir -p libs/$SELF
cp -r $DRONE_BUILD_DIR/* libs/$SELF
# CMake tests
cd libs/$SELF
mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build . --target install
ctest --output-on-failure
# CMake subdir tests
cd ../test/cmake_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
cmake --build . --target check
ctest --output-on-failure
# Install Library
cd ../../../../.. && mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DBOOST_INCLUDE_LIBRARIES=$SELF -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
cmake --build . --target install
# CMake install tests
cd ../libs/$SELF/test/cmake_test && mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
cmake -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_PREFIX_PATH=~/.local ..
cmake --build .
ctest --output-on-failure
fi

522
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,522 @@
# Copyright 2020-2021 Peter Dimov
# Copyright 2021 Andrey Semashev
# Copyright 2022 Alan de Freitas
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
concurrency:
group: ${{format('{0}:{1}', github.repository, github.ref)}}
cancel-in-progress: true
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
DEFAULT_BUILD_VARIANT: debug,release
jobs:
posix:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
# Linux, gcc
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-4.8
- toolset: gcc-4.9
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- g++-4.9
- toolset: gcc-5
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- g++-5
- toolset: gcc-6
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-6
- toolset: gcc-7
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-7
- toolset: gcc-8
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- g++-8
- toolset: gcc-9
cxxstd: "17"
os: ubuntu-22.04
install:
- g++-9
- toolset: gcc-10
cxxstd: "17"
os: ubuntu-22.04
install:
- g++-10
- toolset: gcc-11
cxxstd: "17,20"
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
- name: UBSAN
toolset: gcc-11
cxxstd: "17,20"
ubsan: 1
os: ubuntu-22.04
install:
- g++-11
sources:
- "ppa:ubuntu-toolchain-r/test"
# Linux, clang
- toolset: clang
compiler: clang++-3.8
cxxstd: "11"
os: ubuntu-22.04
container: ubuntu:16.04
install:
- clang-3.8
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-8
- g++-7
gcc_toolchain: 7
- toolset: clang
compiler: clang++-9
cxxstd: "14,17"
os: ubuntu-22.04
container: ubuntu:18.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "14,17"
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "14,17"
os: ubuntu-20.04
install:
- clang-11
# clang 12 tested on drone
# - toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# os: ubuntu-22.04
# install:
# - clang-12
# - toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# cxxflags: -stdlib=libc++
# linkflags: -stdlib=libc++
# os: ubuntu-20.04
# install:
# - clang-12
# - libc++-12-dev
# - libc++abi-12-dev
# - name: UBSAN
# toolset: clang
# compiler: clang++-12
# cxxstd: "17,20"
# cxxflags: -stdlib=libc++
# linkflags: -stdlib=libc++
# ubsan: 1
# os: ubuntu-20.04
# install:
# - clang-12
# - libc++-12-dev
# - libc++abi-12-dev
- toolset: clang
cxxstd: "11,14,17"
os: macos-11
- name: CMake tests
cmake_tests: 1
os: ubuntu-22.04
timeout-minutes: 120
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
steps:
- name: Setup environment
run: |
if [ -f "/etc/debian_version" ]
then
echo "DEBIAN_FRONTEND=noninteractive" >> $GITHUB_ENV
export DEBIAN_FRONTEND=noninteractive
fi
if [ -n "${{matrix.container}}" ]
then
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
if [ -f "/etc/debian_version" ]
then
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y sudo software-properties-common tzdata wget curl apt-transport-https make apt-file unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev
# install pip:
python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))')
if [[ ${python_version} =~ ^3\.[0-5]$ ]]; then
true
else
apt-get install -y python3-distutils
fi
wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py
python3 get-pip.py
# install git:
# apt-get install -y git
apt-add-repository ppa:git-core/ppa
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update && apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y git
# install cmake:
# apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y cmake
sudo pip3 install cmake
fi
fi
git config --global pack.threads 0
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
SOURCE_KEYS=(${{join(matrix.source_keys, ' ')}})
SOURCES=(${{join(matrix.sources, ' ')}})
for key in "${SOURCE_KEYS[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
wget -O - "$key" | sudo apt-key add - && break || sleep 2
done
done
if [ ${#SOURCES[@]} -gt 0 ]
then
APT_ADD_REPO_COMMON_ARGS=("-y")
APT_ADD_REPO_HAS_SOURCE_ARGS=0
SOFTWARE_PROPERTIES_VERSION="$(dpkg-query --showformat='${Version}' --show software-properties-common)"
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.96.24.20"
then
APT_ADD_REPO_COMMON_ARGS+=("-n")
fi
if dpkg --compare-versions "$SOFTWARE_PROPERTIES_VERSION" ge "0.98.10"
then
APT_ADD_REPO_HAS_SOURCE_ARGS=1
fi
for source in "${SOURCES[@]}"
do
for i in {1..$NET_RETRY_COUNT}
do
APT_ADD_REPO_ARGS=("${APT_ADD_REPO_COMMON_ARGS[@]}")
if [ $APT_ADD_REPO_HAS_SOURCE_ARGS -ne 0 ]
then
case "$source" in
"ppa:"*)
APT_ADD_REPO_ARGS+=("-P")
;;
"deb "*)
APT_ADD_REPO_ARGS+=("-S")
;;
*)
APT_ADD_REPO_ARGS+=("-U")
;;
esac
fi
APT_ADD_REPO_ARGS+=("$source")
sudo -E apt-add-repository "${APT_ADD_REPO_ARGS[@]}" && break || sleep 2
done
done
fi
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y ${{join(matrix.install, ' ')}}
- name: Setup GCC Toolchain
if: matrix.gcc_toolchain
run: |
GCC_TOOLCHAIN_ROOT="$HOME/gcc-toolchain"
echo "GCC_TOOLCHAIN_ROOT=\"$GCC_TOOLCHAIN_ROOT\"" >> $GITHUB_ENV
MULTIARCH_TRIPLET="$(dpkg-architecture -qDEB_HOST_MULTIARCH)"
mkdir -p "$GCC_TOOLCHAIN_ROOT"
ln -s /usr/include "$GCC_TOOLCHAIN_ROOT/include"
ln -s /usr/bin "$GCC_TOOLCHAIN_ROOT/bin"
mkdir -p "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET"
ln -s "/usr/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}" "$GCC_TOOLCHAIN_ROOT/lib/gcc/$MULTIARCH_TRIPLET/${{matrix.gcc_toolchain}}"
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
BUILD_JOBS=$((nproc || sysctl -n hw.ncpu) 2> /dev/null)
echo "BUILD_JOBS=$BUILD_JOBS" >> $GITHUB_ENV
echo "CMAKE_BUILD_PARALLEL_LEVEL=$BUILD_JOBS" >> $GITHUB_ENV
DEPINST_ARGS=()
GIT_VERSION="$(git --version | sed -e 's/git version //')"
if $(dpkg --compare-versions "$GIT_VERSION" ge 2.8.0)
then
DEPINST_ARGS+=("--git_args" "--jobs $GIT_FETCH_JOBS")
fi
cd ..
git clone -b "$BOOST_BRANCH" --depth 1 "https://github.com/boostorg/boost.git" "boost-root"
cd boost-root
# mkdir -p libs/$LIBRARY
# cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
# git submodule update --init tools/boostdep
git submodule update --init --recursive
mkdir -p libs/$SELF
cp -r $GITHUB_WORKSPACE/* libs/$SELF
DEPINST_ARGS+=("$LIBRARY")
python tools/boostdep/depinst/depinst.py "${DEPINST_ARGS[@]}"
if [ -z "${{matrix.cmake_tests}}" ]
then
./bootstrap.sh
./b2 headers
if [ -n "${{matrix.compiler}}" -o -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n "using ${{matrix.toolset}} : : ${{matrix.compiler}}" > ~/user-config.jam
if [ -n "$GCC_TOOLCHAIN_ROOT" ]
then
echo -n " : <compileflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\" <linkflags>\"--gcc-toolchain=$GCC_TOOLCHAIN_ROOT\"" >> ~/user-config.jam
fi
echo " ;" >> ~/user-config.jam
fi
fi
- name: Run tests
if: matrix.cmake_tests == ''
run: |
cd ../boost-root
B2_ARGS=("-j" "$BUILD_JOBS" "toolset=${{matrix.toolset}}" "cxxstd=${{matrix.cxxstd}}")
if [ -n "${{matrix.build_variant}}" ]
then
B2_ARGS+=("variant=${{matrix.build_variant}}")
else
B2_ARGS+=("variant=$DEFAULT_BUILD_VARIANT")
fi
if [ -n "${{matrix.threading}}" ]
then
B2_ARGS+=("threading=${{matrix.threading}}")
fi
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
fi
B2_ARGS+=("libs/$LIBRARY/test")
./b2 "${B2_ARGS[@]}"
# - name: Run CMake tests
# if: matrix.cmake_tests != ''
# run: |
# cd ../boost-root
# git submodule update --init --recursive
# cd libs/$LIBRARY
# mkdir __build__ && cd __build__
# cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
# cmake --build . --target install
windows:
strategy:
fail-fast: false
matrix:
include:
#- toolset: msvc-14.1
# cxxstd: "14,17,latest"
# addrmd: 32,64
# os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "17,20"
addrmd: 32,64
os: windows-2022
# - toolset: gcc
# cxxstd: "11,14,17"
# addrmd: 64
# os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j %NUMBER_OF_PROCESSORS% libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
CMake:
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-22.04, build_shared: ON, build_type: Debug, generator: 'Unix Makefiles' }
- { os: ubuntu-22.04, build_shared: OFF, build_type: Debug, generator: 'Unix Makefiles' }
- { os: windows-2019, build_shared: ON, build_type: Debug, generator: 'Visual Studio 16 2019' }
- { os: windows-2019, build_shared: OFF, build_type: Debug, generator: 'Visual Studio 16 2019' }
timeout-minutes: 120
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Fetch Boost.CI
uses: actions/checkout@v2
with:
repository: boostorg/boost-ci
ref: master
path: boost-ci-cloned
- name: Get CI scripts folder
run: |
# Copy ci folder if not testing Boost.CI
[[ "$GITHUB_REPOSITORY" =~ "boost-ci" ]] || cp -r boost-ci-cloned/ci .
rm -rf boost-ci-cloned
- name: Setup Boost
env: {B2_DONT_BOOTSTRAP: 1}
run: source ci/github/install.sh
# - name: Run CMake tests
# run: |
# cd "$BOOST_ROOT"
# mkdir __build_cmake_test__ && cd __build_cmake_test__
# cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ..
# cmake --build . --target tests boost_url_tests boost_url_limits boost_url_extra --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}
# - name: Run CMake subdir tests
# run: |
# cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
# [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_subdir_test"
# cd "$cmake_test_folder"
# mkdir __build_cmake_subdir_test__ && cd __build_cmake_subdir_test__
# cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=OFF -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} ..
# cmake --build . --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}
# - name: Install Library
# run: |
# cd "$BOOST_ROOT"
# mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
# cmake -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_INSTALL_PREFIX=~/.local -DBoost_VERBOSE=ON -DBoost_DEBUG=ON ..
# cmake --build . --target install --config ${{matrix.build_type}}
# - name: Run CMake install tests
# run: |
# cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_test" # New unified folder
# [ -d "$cmake_test_folder" ] || cmake_test_folder="$BOOST_ROOT/libs/$SELF/test/cmake_install_test"
# cd "$cmake_test_folder"
# mkdir __build_cmake_install_test__ && cd __build_cmake_install_test__
# cmake -G "${{matrix.generator}}" -DBOOST_CI_INSTALL_TEST=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.build_shared}} -DCMAKE_PREFIX_PATH=~/.local ..
# cmake --build . --config ${{matrix.build_type}}
# ctest --output-on-failure --build-config ${{matrix.build_type}}

View File

@ -1,275 +0,0 @@
# Copyright 2016 Peter Dimov
# Copyright 2017 - 2019 James E. King III
# Copyright 2020 Krystian Stasiowski
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Travis CI build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want in the 'jobs'.
# 2. If you have more than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. If you want to enable a big-endian build, you need to uncomment the
# big-endian build job.
# 5. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the scripts will do everything else for you.
dist: xenial
language: cpp
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release
install:
- git clone https://github.com/boostorg/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
- qemu-user-static
services:
- docker
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh
#
# Default toolsets in Ubuntu
#
# trusty xenial bionic
# 14.04 16.04 18.04
# ------ ------ ------
# clang 3.4 3.8 6.0
# gcc 4.8.2 5.3.1 7.3.0
#
anchors:
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-3.8",
"ubuntu-toolchain-r-test" ] } }
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-xenial-4.0",
"ubuntu-toolchain-r-test" ] } }
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-xenial-5.0",
"ubuntu-toolchain-r-test" ] } }
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-6.0",
"ubuntu-toolchain-r-test" ] } }
clang-7: &clang-7 { apt: { packages: [ "clang-7",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-7",
"ubuntu-toolchain-r-test" ] } }
clang-8: &clang-8 { apt: { packages: [ "clang-8",
"libc6-dbg",
"libc++-dev",
"libstdc++-8-dev" ], sources: [ "llvm-toolchain-xenial-8",
"ubuntu-toolchain-r-test" ] } }
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ] } }
gcc-49: &gcc-49 { apt: { packages: [ "g++-4.9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ] } }
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-9: &gcc-9 { apt: { packages: [ "g++-9" ], sources: [ "ubuntu-toolchain-r-test" ] } }
jobs:
allow_failures:
- env:
- COPY="all the environment settings from your job"
include:
# coverage
- os: linux
env:
- COMMENT=codecov.io
- B2_CXXSTD=11
- B2_TOOLSET=gcc-8
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
script:
- cd $BOOST_ROOT/libs/$SELF
- tools/codecov.sh
- os: linux
env:
- COMMENT=asan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="address-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=tsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="thread-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-8
- os: linux
env:
- COMMENT=ubsan
- B2_VARIANT=variant=debug
- B2_TOOLSET=gcc-8
- B2_CXXSTD=11,14
- B2_CXXFLAGS="undefined-sanitizer=norecover"
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_LINKFLAGS="linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: *gcc-8
- os: linux
env:
- COMMENT=valgrind
- B2_TOOLSET=clang-6.0
- B2_CXXSTD=11,14
- B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_VARIANT=variant=debug
- B2_TESTFLAGS=testing.launcher=valgrind
- VALGRIND_OPTS=--error-exitcode=1
addons: *clang-6
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/valgrind.sh
# libstdc++
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.8", "B2_CXXSTD=11" ], addons: *gcc-48 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=gcc-4.9", "B2_CXXSTD=11" ], addons: *gcc-49 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-5", "B2_CXXSTD=11,14" ], addons: *gcc-5 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-6", "B2_CXXSTD=11,14" ], addons: *gcc-6 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-7", "B2_CXXSTD=14,17" ], addons: *gcc-7 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-8", "B2_CXXSTD=17" ], addons: *gcc-8 }
- { os: "linux", env: [ "B2_TOOLSET=gcc-9", "B2_CXXSTD=17" ], addons: *gcc-9 }
- { os: "linux", dist: "trusty", # xenial has libstdc++ from gcc 5.4.0 with newer ABI
env: [ "B2_TOOLSET=clang-3.8", "B2_CXXSTD=11" ], addons: *clang-38 }
- { os: "linux", env: [ "B2_TOOLSET=clang-4.0", "B2_CXXSTD=11,14" ], addons: *clang-4 }
- { os: "linux", env: [ "B2_TOOLSET=clang-5.0", "B2_CXXSTD=11,14" ], addons: *clang-5 }
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=14,17" ], addons: *clang-6 }
- { os: "linux", env: [ "B2_TOOLSET=clang-7", "B2_CXXSTD=17" ], addons: *clang-7 }
- { os: "linux", env: [ "B2_TOOLSET=clang-8", "B2_CXXSTD=17" ], addons: *clang-8 }
- os: "linux"
env: ["B2_TOOLSET=clang-9", "B2_CXXSTD=11,14,17"]
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- clang-9
- libc6-dbg
- libc++-dev
- libstdc++-8-dev
# libc++
- { os: "linux", env: [ "B2_TOOLSET=clang-6.0", "B2_CXXSTD=11,14",
"B2_CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
- { os: "osx" , env: [ "B2_TOOLSET=clang", "B2_CXXSTD=11,17" ] }
# to enable Intel ICC define INTEL_ICC_SERIAL_NUMBER and the following (under development):
# - { os: "linux", env: [ "B2_TOOLSET=intel-linux", "B2_CXXSTD=11,14,17" ], addons: *gcc-7,
# script: cd $BOOST_ROOT/libs/$SELF && ci/travis/intelicc.sh }
# uncomment to enable a big-endian build job, just note that it is 5-10 times slower
# than a regular build and travis has a 50 minute time limit per job
# - os: linux
# env:
# - COMMENT=big-endian
# - B2_CXXSTD=03
# - B2_TOOLSET=gcc
# - B2_DEFINES="define=BOOST_NO_STRESS_TEST=1"
# - BDDE_OS=red
# - BDDE_ARCH=ppc64
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/bdde.sh
# - os: linux
# env:
# - COMMENT=cppcheck
# script:
# - cd $BOOST_ROOT/libs/$SELF
# - ci/travis/cppcheck.sh
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
env:
- COMMENT="Coverity Scan"
- B2_TOOLSET=clang
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/coverity.sh
# Standalone tests for StaticString
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-7", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-7 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-8", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-8 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=gcc-9", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *gcc-9 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-6.0", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-6 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-7", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-7 }
- { os: "linux", env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang-8", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ], addons: *clang-8 }
- os: "linux"
env: ["COMMENT=STANDALONE", "B2_TOOLSET=clang-9", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17"]
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages:
- clang-9
- libc6-dbg
- libc++-dev
- libstdc++-8-dev
- { os: "osx" , env: [ "COMMENT=STANDALONE", "B2_TOOLSET=clang", "B2_DEFINES=define=BOOST_STATIC_STRING_STANDALONE", "B2_CXXSTD=17" ] }
notifications:
email:
false

View File

@ -1,32 +1,5 @@
# Generated by `boostdep --cmake static_string`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_library(boost_static_string INTERFACE)
add_library(Boost::static_string ALIAS boost_static_string)
target_include_directories(boost_static_string INTERFACE include)
target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::static_assert
Boost::throw_exception
Boost::utility
)
else()
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -34,140 +7,112 @@ else()
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
#------------------------------------------------------------------------------- cmake_minimum_required(VERSION 3.5...3.16)
function (DoGroupSources curdir rootdir folder) project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach (child ${children})
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
elseif (${child} STREQUAL "CMakeLists.txt")
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
else()
string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
string (REPLACE "/" "\\" groupname ${groupname})
source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endfunction()
function (GroupSources curdir folder) set(BOOST_STATIC_STRING_IS_ROOT OFF)
DoGroupSources (${curdir} ${curdir} ${folder}) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endfunction() set(BOOST_STATIC_STRING_IS_ROOT ON)
endif ()
#------------------------------------------------------------------------------- if (BOOST_STATIC_STRING_IS_ROOT)
# include(CTest)
# StaticString endif ()
#
#-------------------------------------------------------------------------------
set_property (GLOBAL PROPERTY USE_FOLDERS ON) # Options
if (NOT BOOST_SUPERPROJECT_VERSION)
option(BOOST_STATIC_STRING_INSTALL "Install boost::static_string files" ${BOOST_STATIC_STRING_IS_ROOT})
option(BOOST_STATIC_STRING_BUILD_TESTS "Build boost::static_string tests" OFF)
else ()
set(BOOST_STATIC_STRING_BUILD_TESTS ${BUILD_TESTING})
endif ()
if (MSVC) # Find boost
set (CMAKE_VERBOSE_MAKEFILE FALSE) if (BOOST_SUPERPROJECT_VERSION)
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Jamroot" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../boost-build.jam" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../bootstrap.sh" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../libs")
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
else ()
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST ON)
endif ()
add_definitions ( if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
-D_WIN32_WINNT=0x0601 find_package(Boost 1.78.0 REQUIRED COMPONENTS container)
) elseif (BOOST_STATIC_STRING_IS_ROOT)
set(BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES core)
set(BOOST_INCLUDE_LIBRARIES static_string assert container_hash static_assert throw_exception utility ${BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES})
set(BOOST_EXCLUDE_LIBRARIES static_string)
set(CMAKE_FOLDER Dependencies)
add_subdirectory(../.. Dependencies/boost EXCLUDE_FROM_ALL)
unset(CMAKE_FOLDER)
endif ()
add_compile_options( # Sources
/permissive- # strict C++ include(GNUInstallDirs)
/W4 # enable all warnings file(GLOB_RECURSE BOOST_STATIC_STRING_HEADERS CONFIGURE_DEPENDS
/MP # Multi-processor compilation include/boost/*.hpp
include/boost/*.ipp
include/boost/*.natvis
) )
set (Boost_USE_STATIC_LIBS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set (Boost_USE_STATIC_RUNTIME ON) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_STATIC_STRING_HEADERS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "" FILES ${BOOST_STATIC_STRING_SOURCES})
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") # Target
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT") add_library(boost_static_string INTERFACE)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT") add_library(Boost::static_string ALIAS boost_static_string)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") target_compile_features(boost_static_string INTERFACE cxx_constexpr)
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") if (BOOST_SUPERPROJECT_VERSION)
target_include_directories(boost_static_string INTERFACE "${PROJECT_SOURCE_DIR}/include")
else ()
target_include_directories(boost_static_string
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
endif ()
# for RelWithDebInfo builds, disable incremental linking if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
# since CMake sets it ON by default for that build type and it target_link_libraries(boost_static_string
# causes warnings INTERFACE
# Boost::headers
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags )
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}) else ()
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags}) target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::core
Boost::static_assert
Boost::throw_exception
Boost::utility
)
endif ()
else() if (BOOST_STATIC_STRING_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
set (THREADS_PREFER_PTHREAD_FLAG ON) install(TARGETS boost_static_string
find_package (Threads) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
set( CMAKE_CXX_FLAGS install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/boost
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter") DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp"
)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
endif ()
endif()
# Must come before Boost includes, otherwise the if (BUILD_TESTING OR BOOST_STATIC_STRING_BUILD_TESTS)
# IDE sees the wrong file due to boost/ symlinks. add_subdirectory(test)
include_directories (include) endif ()
#-------------------------------------------------------------------------------
#
# Boost
#
#-------------------------------------------------------------------------------
get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
include_directories (${BOOST_ROOT})
link_directories(${BOOST_ROOT}/stage/lib)
#-------------------------------------------------------------------------------
if ("${VARIANT}" STREQUAL "coverage")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE DEBUG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
elseif ("${VARIANT}" STREQUAL "ubasan")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
endif()
elseif ("${VARIANT}" STREQUAL "debug")
set (CMAKE_BUILD_TYPE DEBUG)
elseif ("${VARIANT}" STREQUAL "release")
set (CMAKE_BUILD_TYPE RELEASE)
endif()
#-------------------------------------------------------------------------------
#GroupSources (test "/")
#-------------------------------------------------------------------------------
#
# Tests and examples
#
#include_directories (.)
file (GLOB_RECURSE PROJECT_FILES
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.ipp
)
add_subdirectory (test)
endif()

View File

@ -1,6 +1,7 @@
# #
# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
# Copyright (c) 2020 Krystian Stasiowski (sdkrystian at gmail dot com) # Copyright (c) 2020 Krystian Stasiowski (sdkrystian at gmail dot com)
# Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -9,16 +10,17 @@
project static_string/doc ; project static_string/doc ;
import boostbook ; import boostbook ;
import type ;
import os ;
import ../../../tools/docca/docca.jam ; import ../../../tools/docca/docca.jam ;
docca.reference reference.qbk docca.reference reference.qbk
: :
xsl/custom-overrides.xsl xsl/custom-overrides.xsl
[ glob-tree-ex ../include/boost/static_string : *.hpp *.ipp : detail impl ] [ glob-tree-ex ../include/boost/static_string : *.hpp *.ipp : detail impl ]
: :
<doxygen:param>PROJECT_NAME=StaticString <doxygen:param>PROJECT_NAME=StaticString
<doxygen:param>PROJECT_BRIEF="String Library" <doxygen:param>PROJECT_BRIEF="Static String Library"
<doxygen:param>ALIASES="esafe=\"@par Exception Safety\"" <doxygen:param>ALIASES="esafe=\"@par Exception Safety\""
<doxygen:param>FILE_PATTERNS= <doxygen:param>FILE_PATTERNS=
<doxygen:param>EXAMPLE_PATTERNS= <doxygen:param>EXAMPLE_PATTERNS=
@ -90,7 +92,7 @@ boostbook static_string
<xsl:param>chapter.autolabel=0 <xsl:param>chapter.autolabel=0
<xsl:param>chunk.section.depth=8 # Depth to which sections should be chunked <xsl:param>chunk.section.depth=8 # Depth to which sections should be chunked
<xsl:param>chunk.first.sections=1 # Chunk the first top-level section? <xsl:param>chunk.first.sections=1 # Chunk the first top-level section?
<xsl:param>generate.toc="" <xsl:param>generate.toc="chapter toc,title section nop reference nop"
<include>../../../tools/boostbook/dtd <include>../../../tools/boostbook/dtd
: :
<dependency>images <dependency>images

View File

@ -14,6 +14,17 @@
// Are we dependent on Boost? // Are we dependent on Boost?
// #define BOOST_STATIC_STRING_STANDALONE // #define BOOST_STATIC_STRING_STANDALONE
#include <cstdint>
// detect 32/64 bit
#if UINTPTR_MAX == UINT64_MAX
#define BOOST_STATIC_STRING_ARCH 64
#elif UINTPTR_MAX == UINT32_MAX
#define BOOST_STATIC_STRING_ARCH 32
#else
#error Unknown or unsupported architecture, please open an issue
#endif
// Can we have deduction guides? // Can we have deduction guides?
#if __cpp_deduction_guides >= 201703L #if __cpp_deduction_guides >= 201703L
#define BOOST_STATIC_STRING_USE_DEDUCT #define BOOST_STATIC_STRING_USE_DEDUCT
@ -147,15 +158,51 @@
#endif #endif
#ifndef BOOST_STATIC_STRING_STANDALONE #ifndef BOOST_STATIC_STRING_STANDALONE
#include <boost/config.hpp>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/container_hash/hash.hpp> #include <boost/container_hash/hash.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/utility/string_view.hpp> #include <boost/utility/string_view.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) || \
defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
#include <string_view>
#define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
#endif
#else #else
#include <cassert> #include <cassert>
#include <stdexcept> #include <stdexcept>
/*
* Replicate the logic from Boost.Config
*/
// GNU libstdc++3:
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
#if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
// libc++:
#elif defined(_LIBCPP_VERSION)
#if (_LIBCPP_VERSION < 4000) || (__cplusplus <= 201402L)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
// MSVC uses logic from catch all for BOOST_NO_CXX17_HDR_STRING_VIEW
// catch all:
#elif !defined(_YVALS) && !defined(_CPPLIB_VER)
#if (!defined(__has_include) || (__cplusplus < 201700))
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#elif !__has_include(<string_view>)
# define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
#endif
#endif
#if !defined(BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW) || \
defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
#include <string_view> #include <string_view>
#define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
#endif
#endif #endif
// Compiler bug prevents constexpr from working with clang 4.x and 5.x // Compiler bug prevents constexpr from working with clang 4.x and 5.x
@ -192,6 +239,30 @@ defined(BOOST_STATIC_STRING_CPP14)
#define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR #define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
#endif #endif
#ifndef BOOST_STATIC_STRING_STANDALONE
#if ! defined(BOOST_NO_CWCHAR) && ! defined(BOOST_NO_SWPRINTF)
#define BOOST_STATIC_STRING_HAS_WCHAR
#endif
#else
#ifndef __has_include
// If we don't have __has_include in standalone,
// we will assume that <cwchar> exists.
#define BOOST_STATIC_STRING_HAS_WCHAR
#elif __has_include(<cwchar>)
#define BOOST_STATIC_STRING_HAS_WCHAR
#endif
#endif
#ifdef BOOST_STATIC_STRING_HAS_WCHAR
#include <cwchar>
#endif
// Define the basic string_view type used by the library
// Conversions to and from other available string_view types
// are still defined.
#if !defined(BOOST_STATIC_STRING_STANDALONE) || \
defined(BOOST_STATIC_STRING_HAS_STD_STRING_VIEW)
#define BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
namespace boost { namespace boost {
namespace static_strings { namespace static_strings {
@ -205,4 +276,6 @@ using basic_string_view =
#endif #endif
} // static_strings } // static_strings
} // boost } // boost
#endif
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@
], ],
"maintainers": [ "maintainers": [
"Krystian Stasiowski <sdkrystian@gmail.com>", "Krystian Stasiowski <sdkrystian@gmail.com>",
"Alan de Freitas <alandefreitas@gmail.com>",
"Vinnie Falco <vinnie.falco@gmail.com>" "Vinnie Falco <vinnie.falco@gmail.com>"
], ],
"cxxstd": "11" "cxxstd": "11"

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,16 +7,26 @@
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
GroupSources (include/boost/static_string static_string) # Custom target used by the boost super-project
GroupSources (test "/") if(NOT TARGET tests)
add_custom_target(tests)
set_property(TARGET tests PROPERTY FOLDER _deps)
endif()
add_executable (tests set(BOOST_STATIC_STRING_TESTS_FILES
${PROJECT_FILES} CMakeLists.txt
Jamfile Jamfile
static_string.cpp constexpr_tests.hpp
) compile_fail.hpp
static_string.cpp
)
target_link_libraries(tests source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${BOOST_STATIC_STRING_TESTS_FILES})
) add_executable(boost_static_string_tests ${BOOST_STATIC_STRING_TESTS_FILES})
set_property(TARGET tests PROPERTY FOLDER "tests") # The include dependencies are found in the CMakeLists.txt
# of the root project directory.
# See: BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES
target_link_libraries(boost_static_string_tests PRIVATE Boost::static_string)
add_test(NAME boost_static_string_tests COMMAND boost_static_string_tests)
add_dependencies(tests boost_static_string_tests)

View File

@ -357,8 +357,10 @@ testConstantEvaluation()
a.substr(0); a.substr(0);
#endif #endif
#ifdef BOOST_STATIC_STRING_HAS_STRING_VIEW
// subview // subview
a.subview(0); a.subview(0);
#endif
// copy // copy
char k[20]{}; char k[20]{};

View File

@ -9,11 +9,12 @@
// //
// Test that header file is self-contained. // Test that header file is self-contained.
#include <boost/static_string/static_string.hpp> #include <boost/static_string.hpp>
#include "constexpr_tests.hpp" #include "constexpr_tests.hpp"
#include "compile_fail.hpp" #include "compile_fail.hpp"
#include <boost/core/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/core/ignore_unused.hpp>
#include <cstdlib> #include <cstdlib>
#include <cwchar> #include <cwchar>
#include <cctype> #include <cctype>
@ -25,7 +26,15 @@ namespace static_strings {
template class basic_static_string<420, char>; template class basic_static_string<420, char>;
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
using string_view = basic_string_view<char, std::char_traits<char>>; using string_view = basic_string_view<char, std::char_traits<char>>;
#endif
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
using string_like = basic_string_view<char, std::char_traits<char>>;
#else
using string_like = std::string;
#endif
template <class S> template <class S>
bool bool
@ -50,13 +59,21 @@ testSV(const S& s, typename S::size_type pos, typename S::size_type n)
{ {
if (pos <= s.size()) if (pos <= s.size())
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
typename S::string_view_type str = s.subview(pos, n); typename S::string_view_type str = s.subview(pos, n);
#else
auto str = s.substr(pos, n);
#endif
typename S::size_type rlen = (std::min)(n, s.size() - pos); typename S::size_type rlen = (std::min)(n, s.size() - pos);
return (S::traits_type::compare(s.data() + pos, str.data(), rlen) == 0); return (S::traits_type::compare(s.data() + pos, str.data(), rlen) == 0);
} }
else else
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST_THROWS((s.subview(pos, n)), std::out_of_range); BOOST_TEST_THROWS((s.subview(pos, n)), std::out_of_range);
#else
BOOST_TEST_THROWS((s.substr(pos, n)), std::out_of_range);
#endif
return true; return true;
} }
} }
@ -228,29 +245,52 @@ testR(S s, typename S::size_type pos, typename S::size_type n1, const typename S
template<typename Arithmetic> template<typename Arithmetic>
bool bool
testTS(Arithmetic value, const char* str_expected = "", const wchar_t* wstr_expected = L"", bool test_expected = false) testTS(Arithmetic value, const char* str_expected = "", bool test_expected = false)
{ {
const auto str = to_static_string(value); const auto str = to_static_string(value);
const auto wstr = to_static_wstring(value);
if (std::is_floating_point<Arithmetic>::value) if (std::is_floating_point<Arithmetic>::value)
{ {
const auto std_res = std::to_string(value); const auto std_res = std::to_string(value);
const auto wstd_res = std::to_wstring(value); return str == std_res.data();
return str == std_res.data() && wstr == wstd_res.data();
} }
else else
{ {
if (std::is_signed<Arithmetic>::value) if (std::is_signed<Arithmetic>::value)
{ {
return Arithmetic(std::strtoll(str.begin(), nullptr, 10)) == value && return
Arithmetic(std::wcstoll(wstr.begin(), nullptr, 10)) == value && Arithmetic(std::strtoll(str.begin(), nullptr, 10)) == value &&
(test_expected ? str == str_expected && wstr == wstr_expected : true); (! test_expected || str == str_expected);
} }
else else
{ {
return Arithmetic(std::strtoull(str.begin(), nullptr, 10)) == value && return Arithmetic(std::strtoull(str.begin(), nullptr, 10)) == value &&
Arithmetic(std::wcstoull(wstr.begin(), nullptr, 10)) == value && (! test_expected || str == str_expected);
(test_expected ? str == str_expected && wstr == wstr_expected : true); }
}
}
template<typename Arithmetic>
bool
testTWS(Arithmetic value, const wchar_t* wstr_expected = L"", bool test_expected = false)
{
const auto wstr = to_static_wstring(value);
if (std::is_floating_point<Arithmetic>::value)
{
const auto wstd_res = std::to_wstring(value);
return wstr == wstd_res.data();
}
else
{
if (std::is_signed<Arithmetic>::value)
{
return
Arithmetic(std::wcstoll(wstr.begin(), nullptr, 10)) == value &&
(! test_expected || wstr == wstr_expected);
}
else
{
return Arithmetic(std::wcstoull(wstr.begin(), nullptr, 10)) == value &&
(! test_expected || wstr == wstr_expected);
} }
} }
} }
@ -341,11 +381,11 @@ testConstruct()
} }
{ {
static_string<3> s1( static_string<3> s1(
string_view("123")); string_like("123"));
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(static_string<2>(string_view("123"))), (static_string<2>(string_like("123"))),
std::length_error); std::length_error);
} }
{ {
@ -412,6 +452,7 @@ testAssignment()
BOOST_TEST(static_string<4>{}.assign(cs.begin(), cs.end()) == "abcd"); BOOST_TEST(static_string<4>{}.assign(cs.begin(), cs.end()) == "abcd");
BOOST_TEST(static_string<4>{"*"}.assign(cs.begin(), cs.end()) == "abcd"); BOOST_TEST(static_string<4>{"*"}.assign(cs.begin(), cs.end()) == "abcd");
BOOST_TEST_THROWS(static_string<2>{"*"}.assign(cs.begin(), cs.end()), std::length_error); BOOST_TEST_THROWS(static_string<2>{"*"}.assign(cs.begin(), cs.end()), std::length_error);
ignore_unused(s);
} }
// assign(std::initializer_list<CharT> ilist) // assign(std::initializer_list<CharT> ilist)
@ -422,6 +463,7 @@ testAssignment()
// assign(T const& t) // assign(T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -429,6 +471,21 @@ testAssignment()
return "abc"; return "abc";
} }
}; };
#else
struct T
{
char const* data() const noexcept
{
static char p[] = "abc";
return p;
}
std::size_t size() const noexcept
{
return 3;
}
};
#endif
BOOST_TEST(static_string<3>{}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{}.assign(T{}) == "abc");
BOOST_TEST(static_string<3>{"*"}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{"*"}.assign(T{}) == "abc");
BOOST_TEST(static_string<3>{"***"}.assign(T{}) == "abc"); BOOST_TEST(static_string<3>{"***"}.assign(T{}) == "abc");
@ -437,6 +494,7 @@ testAssignment()
// assign(T const& t, size_type pos, size_type count = npos) // assign(T const& t, size_type pos, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -444,6 +502,23 @@ testAssignment()
return "abcde"; return "abcde";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "abcde";
return p;
}
std::size_t
size() const
{
return 5;
}
};
#endif
BOOST_TEST(static_string<5>{}.assign(T{}, 0) == "abcde"); BOOST_TEST(static_string<5>{}.assign(T{}, 0) == "abcde");
BOOST_TEST(static_string<5>{}.assign(T{}, 0, 5) == "abcde"); BOOST_TEST(static_string<5>{}.assign(T{}, 0, 5) == "abcde");
BOOST_TEST(static_string<5>{}.assign(T{}, 1, 3) == "bcd"); BOOST_TEST(static_string<5>{}.assign(T{}, 1, 3) == "bcd");
@ -505,15 +580,14 @@ testAssignment()
} }
{ {
static_string<3> s1; static_string<3> s1;
s1 = string_view("123"); s1 = string_like("123");
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
static_string<1> s2; static_string<1> s2;
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
s2 = string_view("123"), s2 = string_like("123"),
std::length_error); std::length_error);
} }
{ {
static_string<4> s1; static_string<4> s1;
s1.assign(3, 'x'); s1.assign(3, 'x');
@ -601,14 +675,14 @@ testAssignment()
} }
{ {
static_string<5> s1; static_string<5> s1;
s1.assign(string_view("123")); s1.assign(string_like("123"));
BOOST_TEST(s1 == "123"); BOOST_TEST(s1 == "123");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
s1.assign(string_view("12345")); s1.assign(string_like("12345"));
BOOST_TEST(s1 == "12345"); BOOST_TEST(s1 == "12345");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
s1.assign(string_view("1234567")), s1.assign(string_like("1234567")),
std::length_error); std::length_error);
} }
{ {
@ -672,6 +746,13 @@ testAssignment()
s_long.assign(s_long.data() + 2, 8); s_long.assign(s_long.data() + 2, 8);
BOOST_TEST(s_long == "rem ipsu"); BOOST_TEST(s_long == "rem ipsu");
// issue #41
{
boost::static_strings::static_string<0> a;
auto b = a;
BOOST_TEST(b == "");
}
} }
// done // done
@ -786,11 +867,20 @@ testElements()
BOOST_TEST(std::memcmp( BOOST_TEST(std::memcmp(
s.c_str(), "123\0", 4) == 0); s.c_str(), "123\0", 4) == 0);
} }
#ifdef BOOST_STATIC_ASSERT_HAS_STRING_VIEW
{ {
static_string<3> s("123"); static_string<3> s("123");
string_view sv = s; string_view sv = s;
BOOST_TEST(static_string<5>(sv) == "123"); BOOST_TEST(static_string<5>(sv) == "123");
} }
#endif
#ifdef BOOST_STATIC_ASSERT_HAS_STD_STRING_VIEW
{
static_string<3> s("123");
std::string_view sv = s;
BOOST_TEST(static_string<5>(sv) == "123");
}
#endif
} }
// done // done
@ -897,12 +987,17 @@ testClear()
BOOST_TEST(*s.end() == 0); BOOST_TEST(*s.end() == 0);
} }
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic push // false positives
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
// done // done
static static
void void
testInsert() testInsert()
{ {
using sv = string_view; using sv = string_like;
using S = static_string<100>; using S = static_string<100>;
// insert(size_type index, size_type count, CharT ch) // insert(size_type index, size_type count, CharT ch)
@ -983,6 +1078,7 @@ testInsert()
// insert(size_type index, T const& t) // insert(size_type index, T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -990,6 +1086,23 @@ testInsert()
return "b"; return "b";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "b";
return p;
}
std::size_t
size() const
{
return 1;
}
};
#endif
BOOST_TEST(static_string<3>{"ac"}.insert(1, T{}) == "abc"); BOOST_TEST(static_string<3>{"ac"}.insert(1, T{}) == "abc");
BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, T{}), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, T{}), std::out_of_range);
BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, T{}), std::length_error); BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, T{}), std::length_error);
@ -997,6 +1110,7 @@ testInsert()
// insert(size_type index, T const& t, size_type index_str, size_type count = npos) // insert(size_type index, T const& t, size_type index_str, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -1004,6 +1118,23 @@ testInsert()
return "abcd"; return "abcd";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
static char p[] = "abcd";
return p;
}
std::size_t
size() const noexcept
{
return 4;
}
};
#endif
BOOST_TEST(static_string<6>{"ae"}.insert(1, T{}, 1) == "abcde"); BOOST_TEST(static_string<6>{"ae"}.insert(1, T{}, 1) == "abcde");
BOOST_TEST(static_string<6>{"abe"}.insert(2, T{}, 2) == "abcde"); BOOST_TEST(static_string<6>{"abe"}.insert(2, T{}, 2) == "abcde");
BOOST_TEST(static_string<4>{"ac"}.insert(1, T{}, 1, 1) == "abc"); BOOST_TEST(static_string<4>{"ac"}.insert(1, T{}, 1, 1) == "abc");
@ -1050,6 +1181,7 @@ testInsert()
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s2.insert(6, "__")), (s2.insert(6, "__")),
std::out_of_range); std::out_of_range);
ignore_unused(s3);
} }
{ {
static_string<7> s1("12345"); static_string<7> s1("12345");
@ -1130,16 +1262,16 @@ testInsert()
} }
{ {
static_string<5> s1("123"); static_string<5> s1("123");
s1.insert(1, string_view("UV")); s1.insert(1, string_like("UV"));
BOOST_TEST(s1 == "1UV23"); BOOST_TEST(s1 == "1UV23");
BOOST_TEST(*s1.end() == 0); BOOST_TEST(*s1.end() == 0);
static_string<4> s2("123"); static_string<4> s2("123");
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s2.insert(1, string_view("UV"))), (s2.insert(1, string_like("UV"))),
std::length_error); std::length_error);
static_string<5> s3("123"); static_string<5> s3("123");
BOOST_TEST_THROWS( BOOST_TEST_THROWS(
(s3.insert(5, string_view("UV"))), (s3.insert(5, string_like("UV"))),
std::out_of_range); std::out_of_range);
} }
{ {
@ -1639,6 +1771,10 @@ testInsert()
BOOST_TEST(testI(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen"))); BOOST_TEST(testI(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen")));
} }
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
// done // done
static static
void void
@ -1967,7 +2103,7 @@ void
testAppend() testAppend()
{ {
using S = static_string<400>; using S = static_string<400>;
using sv = string_view; using sv = string_like;
// append(size_type count, CharT ch) // append(size_type count, CharT ch)
BOOST_TEST(static_string<1>{}.append(1, 'a') == "a"); BOOST_TEST(static_string<1>{}.append(1, 'a') == "a");
@ -2003,6 +2139,7 @@ testAppend()
cs.begin() + 2, cs.begin() + 4) == "abcd"); cs.begin() + 2, cs.begin() + 4) == "abcd");
BOOST_TEST_THROWS(static_string<2>{"ab"}.append( BOOST_TEST_THROWS(static_string<2>{"ab"}.append(
cs.begin() + 2, cs.begin() + 4), std::length_error); cs.begin() + 2, cs.begin() + 4), std::length_error);
ignore_unused(s);
} }
// append(std::initializer_list<CharT> ilist) // append(std::initializer_list<CharT> ilist)
@ -2011,6 +2148,7 @@ testAppend()
// append(T const& t) // append(T const& t)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -2018,12 +2156,29 @@ testAppend()
return "c"; return "c";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
return "c";
}
std::size_t
size() const noexcept
{
return 1;
}
};
#endif
BOOST_TEST(static_string<3>{"ab"}.append(T{}) == "abc"); BOOST_TEST(static_string<3>{"ab"}.append(T{}) == "abc");
BOOST_TEST_THROWS(static_string<3>{"abc"}.append(T{}), std::length_error); BOOST_TEST_THROWS(static_string<3>{"abc"}.append(T{}), std::length_error);
} }
// append(T const& t, size_type pos, size_type count = npos) // append(T const& t, size_type pos, size_type count = npos)
{ {
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
struct T struct T
{ {
operator string_view() const noexcept operator string_view() const noexcept
@ -2031,6 +2186,22 @@ testAppend()
return "abcd"; return "abcd";
} }
}; };
#else
struct T
{
char const*
data() const noexcept
{
return "abcd";
}
std::size_t
size() const noexcept
{
return 4;
}
};
#endif
BOOST_TEST(static_string<4>{"ab"}.append(T{}, 2) == "abcd"); BOOST_TEST(static_string<4>{"ab"}.append(T{}, 2) == "abcd");
BOOST_TEST(static_string<3>{"a"}.append(T{}, 1, 2) == "abc"); BOOST_TEST(static_string<3>{"a"}.append(T{}, 1, 2) == "abc");
BOOST_TEST_THROWS(static_string<4>{"abc"}.append(T{}, 5), std::out_of_range); BOOST_TEST_THROWS(static_string<4>{"abc"}.append(T{}, 5), std::out_of_range);
@ -2121,7 +2292,7 @@ testAppend()
std::length_error); std::length_error);
} }
{ {
string_view s1("XYZ"); string_like s1("XYZ");
static_string<5> s2("12"); static_string<5> s2("12");
s2.append(s1); s2.append(s1);
BOOST_TEST(s2 == "12XYZ"); BOOST_TEST(s2 == "12XYZ");
@ -2176,7 +2347,7 @@ static
void void
testPlusEquals() testPlusEquals()
{ {
using sv = string_view; using sv = string_like;
// operator+=(CharT ch) // operator+=(CharT ch)
BOOST_TEST((static_string<3>{"ab"} += 'c') == "abc"); BOOST_TEST((static_string<3>{"ab"} += 'c') == "abc");
@ -2232,7 +2403,7 @@ testPlusEquals()
std::length_error); std::length_error);
} }
{ {
string_view s1("34"); string_like s1("34");
static_string<4> s2("12"); static_string<4> s2("12");
s2 += s1; s2 += s1;
BOOST_TEST(s2 == "1234"); BOOST_TEST(s2 == "1234");
@ -2268,6 +2439,7 @@ testCompare()
BOOST_TEST(s1.compare(0, 2, s2.data()) < 0); BOOST_TEST(s1.compare(0, 2, s2.data()) < 0);
BOOST_TEST(s2.compare(0, 1, s1.data()) > 0); BOOST_TEST(s2.compare(0, 1, s1.data()) > 0);
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST(s1.compare(s2.subview()) < 0); BOOST_TEST(s1.compare(s2.subview()) < 0);
BOOST_TEST(s2.compare(s1.subview()) > 0); BOOST_TEST(s2.compare(s1.subview()) > 0);
@ -2276,6 +2448,7 @@ testCompare()
BOOST_TEST(s1.compare(0, 2, s2.subview(), 0, 1) < 0); BOOST_TEST(s1.compare(0, 2, s2.subview(), 0, 1) < 0);
BOOST_TEST(s2.compare(0, 1, s1.subview(), 0, 2) > 0); BOOST_TEST(s2.compare(0, 1, s1.subview(), 0, 2) > 0);
#endif
BOOST_TEST(s1 < "10"); BOOST_TEST(s1 < "10");
BOOST_TEST(s2 > "1"); BOOST_TEST(s2 > "1");
@ -2284,6 +2457,14 @@ testCompare()
BOOST_TEST(s1 < "20"); BOOST_TEST(s1 < "20");
BOOST_TEST(s2 > "1"); BOOST_TEST(s2 > "1");
BOOST_TEST(s2 > "2"); BOOST_TEST(s2 > "2");
BOOST_TEST(s1 < string_like("10"));
BOOST_TEST(s2 > string_like("1"));
BOOST_TEST(string_like("10") > s1);
BOOST_TEST(string_like("1") < s2);
BOOST_TEST(s1 < string_like("20"));
BOOST_TEST(s2 > string_like("1"));
BOOST_TEST(s2 > string_like("2"));
} }
{ {
str2 s1("x"); str2 s1("x");
@ -2319,6 +2500,19 @@ testCompare()
BOOST_TEST(! ("x" < s)); BOOST_TEST(! ("x" < s));
BOOST_TEST(! ("x" > s)); BOOST_TEST(! ("x" > s));
BOOST_TEST(! ("x" != s)); BOOST_TEST(! ("x" != s));
BOOST_TEST(s == string_like("x"));
BOOST_TEST(s <= string_like("x"));
BOOST_TEST(s >= string_like("x"));
BOOST_TEST(! (s < string_like("x")));
BOOST_TEST(! (s > string_like("x")));
BOOST_TEST(! (s != string_like("x")));
BOOST_TEST(string_like("x") == s);
BOOST_TEST(string_like("x") <= s);
BOOST_TEST(string_like("x") >= s);
BOOST_TEST(! (string_like("x") < s));
BOOST_TEST(! (string_like("x") > s));
BOOST_TEST(! (string_like("x") != s));
} }
{ {
str2 s("x"); str2 s("x");
@ -2334,6 +2528,19 @@ testCompare()
BOOST_TEST(! ("y" == s)); BOOST_TEST(! ("y" == s));
BOOST_TEST(! ("y" <= s)); BOOST_TEST(! ("y" <= s));
BOOST_TEST(! ("y" < s)); BOOST_TEST(! ("y" < s));
BOOST_TEST(s <= string_like("y"));
BOOST_TEST(s < string_like("y"));
BOOST_TEST(s != string_like("y"));
BOOST_TEST(! (s == string_like("y")));
BOOST_TEST(! (s >= string_like("y")));
BOOST_TEST(! (s > "x"));
BOOST_TEST(string_like("y") >= s);
BOOST_TEST(string_like("y") > s);
BOOST_TEST(string_like("y") != s);
BOOST_TEST(! (string_like("y") == s));
BOOST_TEST(! (string_like("y") <= s));
BOOST_TEST(! (string_like("y") < s));
} }
{ {
str1 s1("x"); str1 s1("x");
@ -3729,16 +3936,16 @@ testGeneral()
void void
testToStaticString() testToStaticString()
{ {
BOOST_TEST(testTS(0, "0", L"0", true)); BOOST_TEST(testTS(0, "0", true));
BOOST_TEST(testTS(0u, "0", L"0", true)); BOOST_TEST(testTS(0u, "0", true));
BOOST_TEST(testTS(0xffff, "65535", L"65535", true)); BOOST_TEST(testTS(0xffff, "65535", true));
BOOST_TEST(testTS(0x10000, "65536", L"65536", true)); BOOST_TEST(testTS(0x10000, "65536", true));
BOOST_TEST(testTS(0xffffffff, "4294967295", L"4294967295", true)); BOOST_TEST(testTS(0xffffffff, "4294967295", true));
BOOST_TEST(testTS(-65535, "-65535", L"-65535", true)); BOOST_TEST(testTS(-65535, "-65535", true));
BOOST_TEST(testTS(-65536, "-65536", L"-65536", true)); BOOST_TEST(testTS(-65536, "-65536", true));
BOOST_TEST(testTS(-4294967295ll, "-4294967295", L"-4294967295", true)); BOOST_TEST(testTS(-4294967295ll, "-4294967295", true));
BOOST_TEST(testTS(1, "1", L"1", true)); BOOST_TEST(testTS(1, "1", true));
BOOST_TEST(testTS(-1, "-1", L"-1", true)); BOOST_TEST(testTS(-1, "-1", true));
BOOST_TEST(testTS(0.1)); BOOST_TEST(testTS(0.1));
BOOST_TEST(testTS(0.0000001)); BOOST_TEST(testTS(0.0000001));
BOOST_TEST(testTS(-0.0000001)); BOOST_TEST(testTS(-0.0000001));
@ -3772,6 +3979,35 @@ testToStaticString()
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == "infinity" || str == "inf"); static_string<0>::npos || str == "infinity" || str == "inf");
} }
#ifdef BOOST_STATIC_STRING_HAS_WCHAR
BOOST_TEST(testTWS(0, L"0", true));
BOOST_TEST(testTWS(0u, L"0", true));
BOOST_TEST(testTWS(0xffff, L"65535", true));
BOOST_TEST(testTWS(0x10000, L"65536", true));
BOOST_TEST(testTWS(0xffffffff, L"4294967295", true));
BOOST_TEST(testTWS(-65535, L"-65535", true));
BOOST_TEST(testTWS(-65536, L"-65536", true));
BOOST_TEST(testTWS(-4294967295ll, L"-4294967295", true));
BOOST_TEST(testTWS(1, L"1", true));
BOOST_TEST(testTWS(-1, L"-1", true));
BOOST_TEST(testTWS(0.1));
BOOST_TEST(testTWS(0.0000001));
BOOST_TEST(testTWS(-0.0000001));
BOOST_TEST(testTWS(-0.1));
BOOST_TEST(testTWS(1234567890.0001));
BOOST_TEST(testTWS(1.123456789012345));
BOOST_TEST(testTWS(-1234567890.1234));
BOOST_TEST(testTWS(-1.123456789012345));
BOOST_TEST(testTWS(std::numeric_limits<long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<long long>::min()));
BOOST_TEST(testTWS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<unsigned long long>::max()));
BOOST_TEST(testTWS(std::numeric_limits<long double>::min()));
BOOST_TEST(testTWS(std::numeric_limits<float>::min()));
{ {
auto str = to_static_wstring(std::numeric_limits<float>::max()); auto str = to_static_wstring(std::numeric_limits<float>::max());
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
@ -3787,6 +4023,7 @@ testToStaticString()
BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') != BOOST_TEST(str.find('e') != static_string<0>::npos || str.find('.') !=
static_string<0>::npos || str == L"infinity" || str == L"inf"); static_string<0>::npos || str == L"infinity" || str == L"inf");
} }
#endif
} }
// done // done
@ -3795,8 +4032,8 @@ testFind()
{ {
const char* cs1 = "12345"; const char* cs1 = "12345";
const char* cs2 = "2345"; const char* cs2 = "2345";
string_view v1 = cs1; string_like v1 = cs1;
string_view v2 = cs2; string_like v2 = cs2;
static_string<5> fs1 = cs1; static_string<5> fs1 = cs1;
static_string<4> fs2 = cs2; static_string<4> fs2 = cs2;
using S = static_string<400>; using S = static_string<400>;
@ -5119,8 +5356,8 @@ testFind()
const char* cs3 = "12456"; const char* cs3 = "12456";
const char* cs4 = "2356"; const char* cs4 = "2356";
string_view v3 = cs3; string_like v3 = cs3;
string_view v4 = cs4; string_like v4 = cs4;
static_string<5> fs3 = cs3; static_string<5> fs3 = cs3;
static_string<4> fs4 = cs4; static_string<4> fs4 = cs4;
@ -5814,11 +6051,16 @@ testFind()
#include <iostream> #include <iostream>
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic push // false positives
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
// done // done
void void
testReplace() testReplace()
{ {
// replace(size_type pos1, size_type n1, const charT* s, size_type n2); // replace(size_type pos1, size_type n1, const charT* s, size_type n2);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(5, 2, fs1.data() + 1, 8) == "helloelloworlrld"); BOOST_TEST(fs1.replace(5, 2, fs1.data() + 1, 8) == "helloelloworlrld");
@ -5900,12 +6142,12 @@ testReplace()
// replace(size_type pos1, size_type n1, const T& t); // replace(size_type pos1, size_type n1, const T& t);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(0, fs1.size(), string_view(fs1)) == "helloworld"); BOOST_TEST(fs1.replace(0, fs1.size(), string_like(fs1.data(), fs1.size())) == "helloworld");
} }
// replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos); // replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(0, fs1.size(), string_view(fs1), 0, fs1.size()) == "helloworld"); BOOST_TEST(fs1.replace(0, fs1.size(), string_like(fs1.data(), fs1.size()), 0, fs1.size()) == "helloworld");
} }
// replace(size_type pos, size_type n, const charT * s); // replace(size_type pos, size_type n, const charT * s);
{ {
@ -5931,7 +6173,7 @@ testReplace()
// replace(const_iterator i1, const_iterator i2, const T& t); // replace(const_iterator i1, const_iterator i2, const T& t);
{ {
static_string<20> fs1 = "helloworld"; static_string<20> fs1 = "helloworld";
BOOST_TEST(fs1.replace(fs1.begin(), fs1.end(), string_view(fs1)) == "helloworld"); BOOST_TEST(fs1.replace(fs1.begin(), fs1.end(), string_like(fs1.data(), fs1.size())) == "helloworld");
} }
// replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); // replace(const_iterator i1, const_iterator i2, const charT* s, size_type n);
{ {
@ -6818,6 +7060,10 @@ testReplace()
BOOST_TEST_THROWS(T("aaaaa").replace(0, 1, S("bbbbbbbbbbbbb")), std::length_error); BOOST_TEST_THROWS(T("aaaaa").replace(0, 1, S("bbbbbbbbbbbbb")), std::length_error);
} }
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
// done // done
void void
testSubstr() testSubstr()
@ -7074,21 +7320,21 @@ testStartsEnds()
BOOST_TEST(S("1234567890").starts_with("1234567890")); BOOST_TEST(S("1234567890").starts_with("1234567890"));
BOOST_TEST(!S("1234567890").starts_with("234")); BOOST_TEST(!S("1234567890").starts_with("234"));
BOOST_TEST(!S("1234567890").starts_with("12345678900")); BOOST_TEST(!S("1234567890").starts_with("12345678900"));
BOOST_TEST(S("1234567890").starts_with(string_view("1234567890"))); BOOST_TEST(S("1234567890").starts_with(string_like("1234567890")));
BOOST_TEST(S("1234567890").ends_with('0')); BOOST_TEST(S("1234567890").ends_with('0'));
BOOST_TEST(S("1234567890").ends_with("890")); BOOST_TEST(S("1234567890").ends_with("890"));
BOOST_TEST(S("1234567890").ends_with("1234567890")); BOOST_TEST(S("1234567890").ends_with("1234567890"));
BOOST_TEST(!S("1234567890").ends_with("234")); BOOST_TEST(!S("1234567890").ends_with("234"));
BOOST_TEST(!S("1234567890").ends_with("12345678900")); BOOST_TEST(!S("1234567890").ends_with("12345678900"));
BOOST_TEST(S("1234567890").ends_with(string_view("1234567890"))); BOOST_TEST(S("1234567890").ends_with(string_like("1234567890")));
BOOST_TEST(!S().starts_with('0')); BOOST_TEST(!S().starts_with('0'));
BOOST_TEST(!S().starts_with("0")); BOOST_TEST(!S().starts_with("0"));
BOOST_TEST(!S().starts_with(string_view("0"))); BOOST_TEST(!S().starts_with(string_like("0")));
BOOST_TEST(!S().ends_with('0')); BOOST_TEST(!S().ends_with('0'));
BOOST_TEST(!S().ends_with("0")); BOOST_TEST(!S().ends_with("0"));
BOOST_TEST(!S().ends_with(string_view("0"))); BOOST_TEST(!S().ends_with(string_like("0")));
} }
void void
@ -7129,7 +7375,9 @@ testStream()
static_string<10> b = "abcdefghij"; static_string<10> b = "abcdefghij";
a << b; a << b;
static_string<10> c(std::istream_iterator<char>{a}, std::istream_iterator<char>{}); static_string<10> c(std::istream_iterator<char>{a}, std::istream_iterator<char>{});
#ifdef BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
BOOST_TEST(a.str() == b.subview()); BOOST_TEST(a.str() == b.subview());
#endif
BOOST_TEST(b == c); BOOST_TEST(b == c);
} }
@ -7198,6 +7446,15 @@ testOperatorPlus()
} }
} }
// issue 47
struct issue_47 : static_string<32>
{
bool compare(const issue_47& other) const
{
return *this < other;
}
};
int int
runTests() runTests()
{ {
@ -7249,4 +7506,5 @@ int
main() main()
{ {
return boost::static_strings::runTests(); return boost::static_strings::runTests();
} }