diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000000..76a6cb5064 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,238 @@ +name: Continuous Integration + +on: + push: + branches: + - master + - develop + - feature/* + + pull_request: + branches: + - develop + +jobs: + lint: + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install codespell + run: pip3 install codespell + + # - name: Lint + # if: always() + # working-directory: asio + # run: cmake -D FORMAT_COMMAND=clang-format-18 -P cmake/lint.cmake || echo ignored + + - name: Spell check + if: always() + working-directory: asio + run: cmake -P cmake/spell.cmake || echo ignored + + coverage: + needs: [lint] + + runs-on: ubuntu-24.04 + + # To enable coverage, delete the last line from the conditional below and + # edit the "" placeholder to your GitHub name. + # If you do not wish to use codecov, then simply delete this job from the + # workflow. + if: github.repository_owner == '' + + steps: + - uses: actions/checkout@v4 + + - name: Install LCov + run: sudo apt-get update -q + && sudo apt-get install ninja-build lcov -q -y + + - name: Configure + working-directory: asio + run: cmake --preset=ci-coverage + + - name: Build + working-directory: asio + run: cmake --build build/coverage -j 4 + + - name: Test + working-directory: asio/build/coverage + run: ctest --output-on-failure --no-tests=error -j 4 + + - name: Process coverage info + working-directory: asio + run: cmake --build build/coverage -t coverage + + - name: Submit to codecov.io + uses: codecov/codecov-action@v4 + with: + file: build/coverage/coverage.info + + sanitize: + needs: [lint] + + runs-on: ubuntu-24.04 + + env: {CXX: clang++-18} + + steps: + - uses: actions/checkout@v4 + + - name: Setup ninja build toolchain + uses: aminya/setup-cpp@v1 + with: + ninja: true + + - name: Configure + working-directory: asio + run: cmake --preset=ci-sanitize + + - name: Build + working-directory: asio + run: cmake --build build/sanitize -j 4 + + - name: Test + working-directory: asio/build/sanitize + env: + ASAN_OPTIONS: "strict_string_checks=1:\ + detect_stack_use_after_return=1:\ + check_initialization_order=1:\ + strict_init_order=1:\ + detect_leaks=1" + UBSAN_OPTIONS: print_stacktrace=1 + run: ctest --output-on-failure --no-tests=error -j 4 + + test: + needs: [lint] + + strategy: + fail-fast: false + matrix: + os: [macos-15, ubuntu-24.04, windows-2022] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup ninja build toolchain + uses: aminya/setup-cpp@v1 + with: + ninja: true + + - name: Install static analyzers + if: matrix.os == 'ubuntu-24.04' + run: | + # Not used! sudo apt-get install cppcheck -y -q + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 19 all + sudo update-alternatives --install \ + /usr/bin/clang-tidy clang-tidy \ + /usr/bin/clang-tidy-19 150 + + - name: Install llvm-19 + if: startsWith(matrix.os, 'macos') + run: | + brew install llvm@19 + echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.envrc + echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> /Users/runner/.envrc + echo 'export CPPFLAGS="-L/opt/homebrew/opt/llvm/include"' >> /Users/runner/.envrc + + # see https://github.com/mathstuf/cxx-modules-sandbox/blob/master/.github/workflows/cmake.yml + - name: Visual Studio toolchain environment + uses: TheMrMilchmann/setup-msvc-dev@v1 + with: + arch: x64 + + # # see https://github.com/marketplace/actions/enable-developer-command-prompt + # - uses: ilammy/msvc-dev-cmd@v1 + # if: matrix.os == 'windows-2022' + # with: + # vsversion: 2022 + + - name: Configure windows + if: matrix.os == 'windows-2022' + working-directory: asio + run: | + Add-Content "$env:GITHUB_ENV" 'UseMultiToolTask=true' + Add-Content "$env:GITHUB_ENV" 'EnforceProcessCountAcrossBuilds=true' + cmake --preset=ci-windows + + - name: Configure macos + if: matrix.os == 'macos-15' + working-directory: asio + shell: bash + run: | + source /Users/runner/.envrc + which clang++ && clang++ --version + CXX=$(brew --prefix llvm@19)/bin/clang++ cmake --preset=ci-macos + + - name: Configure ubuntu + if: matrix.os == 'ubuntu-24.04' + working-directory: asio + env: + CXX: clang++-19 + run: cmake --preset=ci-ubuntu + + - name: Build + working-directory: asio + run: cmake --build build --config Debug -j 4 + + - name: Install + working-directory: asio + run: cmake --install build --config Debug # see CMakePresets.json! --prefix stagedir + + - name: Test + working-directory: asio/build + run: ctest --output-on-failure --no-tests=error -C Debug -j 4 + + docs: + # Deploy docs only when builds succeed + needs: [sanitize, test] + + runs-on: ubuntu-24.04 + + # To enable, first you have to create an orphaned gh-pages branch: + # + # git switch --orphan gh-pages + # git commit --allow-empty -m "Initial commit" + # git push -u origin gh-pages + # + # Edit the placeholder below to your GitHub name, so this action + # runs only in your repository and no one else's fork. After these, delete + # this comment and the last line in the conditional below. + # If you do not wish to use GitHub Pages for deploying documentation, then + # simply delete this job similarly to the coverage one. + if: github.ref == 'refs/heads/master' + && github.event_name == 'push' + && github.repository_owner == '' + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: {python-version: "3.12"} + + - name: Install m.css dependencies + run: pip3 install ninja jinja2 Pygments + + - name: Install Doxygen + run: sudo apt-get update -q + && sudo apt-get install doxygen -q -y + + - name: Build docs + working-directory: asio + run: cmake "-DPROJECT_SOURCE_DIR=$PWD" "-DPROJECT_BINARY_DIR=$PWD/build" + -P cmake/docs-ci.cmake + + - name: Deploy docs + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: build/docs/html diff --git a/asio/.CMakeUserPresets.json b/asio/.CMakeUserPresets.json new file mode 100644 index 0000000000..4b6bac162f --- /dev/null +++ b/asio/.CMakeUserPresets.json @@ -0,0 +1,136 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "configurePresets": [ + { + "name": "dev-common", + "hidden": true, + "generator": "Ninja", + "inherits": [ + "dev-mode" + ] + }, + { + "name": "dev-Linux", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-Linux" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "dev-Darwin", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-Darwin" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "dev-Windows", + "binaryDir": "${sourceDir}/build/${presetName}", + "inherits": [ + "dev-common", + "ci-windows" + ], + "environment": { + "UseMultiToolTask": "true", + "EnforceProcessCountAcrossBuilds": "true" + } + }, + { + "name": "dev", + "binaryDir": "${sourceDir}/build/dev", + "inherits": "dev-" + }, + { + "name": "dev-coverage", + "binaryDir": "${sourceDir}/build/coverage", + "inherits": [ + "dev-mode", + "coverage-Linux" + ] + } + ], + "buildPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "jobs": 12, + "targets": [ + "install" + ] + }, + { + "name": "verify", + "configurePreset": "dev", + "jobs": 12, + "targets": [ + "all_verify_interface_header_sets" + ] + } + ], + "testPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "output": { + "outputOnFailure": true + }, + "execution": { + "jobs": 12, + "noTestsAction": "error" + } + } + ], + "packagePresets": [ + { + "name": "dev", + "configurePreset": "dev", + "generators": [ + "TGZ" + ] + } + ], + "workflowPresets": [ + { + "name": "dev", + "steps": [ + { + "type": "configure", + "name": "dev" + }, + { + "type": "build", + "name": "dev" + }, + { + "type": "build", + "name": "verify" + }, + { + "type": "test", + "name": "dev" + }, + { + "type": "package", + "name": "dev" + } + ] + } + ] +} diff --git a/asio/.TODO.txt b/asio/.TODO.txt new file mode 100644 index 0000000000..6819e6b0b4 --- /dev/null +++ b/asio/.TODO.txt @@ -0,0 +1,99 @@ +#!/bin/sh +set -x +set -e + +make +git ls-files '::*CMakeLists.txt' | xargs cmake-lint +ninja -C build/dev spell-check 2>&1 | tee .TODO.txt +# +ninja: Entering directory `build/dev' +[1/1] Checking spelling +FAILED: CMakeFiles/spell-check /Users/clausklein/Workspace/cpp/asio/asio/build/dev/CMakeFiles/spell-check +cd /Users/clausklein/Workspace/cpp/asio/asio && /usr/local/bin/cmake -D SPELL_COMMAND=codespell -P /Users/clausklein/Workspace/cpp/asio/asio/cmake/spell.cmake +Used config files: + 1: .codespellrc +./include/asio/basic_datagram_socket.hpp:348: ore ==> or +./include/asio/basic_datagram_socket.hpp:380: ore ==> or +./include/asio/basic_raw_socket.hpp:342: ore ==> or +./include/asio/basic_raw_socket.hpp:373: ore ==> or +./include/asio/disposition.hpp:29: arbtirary ==> arbitrary +./include/asio/io_context.hpp:301: reponsibility ==> responsibility +./include/asio/io_context.hpp:350: reponsibility ==> responsibility +./include/asio/use_future.hpp:93: retuned ==> returned +./include/asio/impl/use_future.hpp:105: exeption ==> exception, exemption +./include/asio/experimental/impl/parallel_group.hpp:81: operatations ==> operations +./include/asio/experimental/impl/parallel_group.hpp:396: operatations ==> operations +./include/asio/detail/executor_function.hpp:119: copyable ==> copiable +./include/asio/detail/service_registry.hpp:79: Initalise ==> Initialise +./include/asio/detail/service_registry.hpp:84: Initalise ==> Initialise +./include/asio/detail/timer_queue_ptime.hpp:34: instantation ==> instantiation +./include/asio/detail/win_iocp_io_context.hpp:260: resouce ==> resource +./include/asio/detail/impl/socket_ops.ipp:3330: servent ==> servant, serpent, fervent +./include/asio/detail/impl/socket_ops.ipp:3341: servent ==> servant, serpent, fervent +./include/asio/detail/impl/socket_ops.ipp:3715: servent ==> servant, serpent, fervent +./include/asio/execution/any_executor.hpp:112: requre ==> require +./include/asio/execution/impl/bad_executor.ipp:2: exection ==> execution, ejection, election, exertion +./include/asio/ip/detail/endpoint.hpp:31: implementating ==> implementing +./src/examples/cpp20/operations/composed_6.cpp:116: asychronous ==> asynchronous +./src/examples/cpp20/operations/composed_7.cpp:74: asychronous ==> asynchronous +./src/examples/cpp20/operations/composed_7.cpp:120: asychronous ==> asynchronous +./src/examples/cpp11/timers/time_t_timer.cpp:66: absoluate ==> absolute +./src/examples/cpp11/porthopper/client.cpp:96: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:120: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:149: renegotation ==> renegotiation +./src/examples/cpp11/porthopper/client.cpp:162: renegotation ==> renegotiation +./src/examples/cpp11/operations/composed_6.cpp:93: asychronous ==> asynchronous +./src/examples/cpp11/operations/composed_7.cpp:60: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_6.cpp:111: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_7.cpp:73: asychronous ==> asynchronous +./src/examples/cpp14/operations/composed_7.cpp:119: asychronous ==> asynchronous +./src/doc/history.qbk:327: potental ==> potential +./src/doc/history.qbk:451: immmediate ==> immediate +./src/doc/history.qbk:1149: occured ==> occurred +./src/doc/history.qbk:1996: compatiblity ==> compatibility +./src/doc/history.qbk:2113: Lightening ==> Lightning, Lighting +./src/doc/history.qbk:2189: copyable ==> copiable +./src/doc/history.qbk:2232: discconected ==> disconnected +./src/doc/history.qbk:2394: compatability ==> compatibility +./src/doc/history.qbk:2819: copyable ==> copiable +./src/doc/history.qbk:2854: accomodate ==> accommodate +./src/doc/history.qbk:3074: tranferred ==> transferred +./src/doc/history.qbk:3193: re-use ==> reuse +./src/doc/quickref.xml:17: thead ==> thread +./src/doc/quickref.xml:26: thead ==> thread +./src/doc/quickref.xml:133: thead ==> thread +./src/doc/quickref.xml:139: thead ==> thread +./src/doc/quickref.xml:350: thead ==> thread +./src/doc/quickref.xml:356: thead ==> thread +./src/doc/quickref.xml:454: thead ==> thread +./src/doc/quickref.xml:460: thead ==> thread +./src/doc/quickref.xml:604: thead ==> thread +./src/doc/quickref.xml:619: thead ==> thread +./src/doc/quickref.xml:719: thead ==> thread +./src/doc/quickref.xml:731: thead ==> thread +./src/doc/reference.qbk:1705: requre ==> require +./src/doc/reference.qbk:3974: requre ==> require +./src/doc/reference.qbk:18087: ore ==> or +./src/doc/reference.qbk:18149: ore ==> or +./src/doc/reference.qbk:32346: ore ==> or +./src/doc/reference.qbk:32408: ore ==> or +./src/doc/reference.qbk:91119: requre ==> require +./src/doc/reference.qbk:112306: reponsibility ==> responsibility +./src/doc/reference.qbk:112349: reponsibility ==> responsibility +./src/doc/reference.qbk:112433: reponsibility ==> responsibility +./src/doc/reference.qbk:112467: reponsibility ==> responsibility +./src/doc/reference.qbk:167559: retuned ==> returned +./src/doc/using.qbk:232: Explictly ==> Explicitly +./src/doc/requirements/asynchronous_operations.qbk:332: asynchonous ==> asynchronous +./src/doc/overview/coro.qbk:15: transfomers ==> transformers +./src/doc/overview/coro.qbk:136: dermined ==> determined +./src/doc/overview/coro.qbk:137: follwing ==> following +./src/doc/overview/coro.qbk:194: direclty ==> directly +./src/doc/overview/cpp20_coroutines.qbk:223: Asynchonous ==> Asynchronous +./src/doc/overview/immediate_completion.qbk:16: immmediate ==> immediate +./src/doc/overview/implementation.qbk:63: asynchonous ==> asynchronous +CMake Error at cmake/spell.cmake:27 (message): + Run again with FIX=YES to fix these errors. + + +ninja: build stopped: subcommand failed. diff --git a/asio/.clang-format b/asio/.clang-format new file mode 100644 index 0000000000..d3bbf30c17 --- /dev/null +++ b/asio/.clang-format @@ -0,0 +1,178 @@ +--- +#XXX Language: Cpp +# BasedOnStyle: Chromium +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: false +AlignConsecutiveAssignments: false +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortEnumsOnASingleLine: false +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: MultiLine + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: true + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +# BreakBeforeInheritanceComma: true +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: true +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Regroup +IncludeCategories: + # Standard library headers come before anything else + - Regex: '^<[a-z_]+>' + Priority: -1 + - Regex: '^<.+\.h(pp)?>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: true +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: AfterHash +IndentExternBlock: NoIndent +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: Wrapped +JavaScriptQuotes: Double +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + - ParseTestProto + - ParsePartialTestProto + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptForEachMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE +... diff --git a/asio/.clang-tidy b/asio/.clang-tidy new file mode 100644 index 0000000000..702655a364 --- /dev/null +++ b/asio/.clang-tidy @@ -0,0 +1,166 @@ +--- +# Enable ALL the things! Except not really +# misc-non-private-member-variables-in-classes: the options don't do anything +Checks: "*,\ + -google-readability-todo,\ + -google-build-using-namespace,\ + -altera-unroll-loops,\ + -fuchsia-*,\ + fuchsia-multiple-inheritance,\ + -llvm-header-guard,\ + -llvm-include-order,\ + -llvmlibc-*,\ + -cppcoreguidelines-pro-bounds-pointer-arithmetic,\ + -cppcoreguidelines-avoid-do-while,\ + -*-magic-numbers,\ + -performance-avoid-endl, + -misc-include-cleaner,\ + misc-header-include-cycle,\ + -misc-non-private-member-variables-in-classes" +WarningsAsErrors: '' +CheckOptions: + - key: 'bugprone-argument-comment.StrictMode' + value: 'true' +# Prefer using enum classes with 2 values for parameters instead of bools + - key: 'bugprone-argument-comment.CommentBoolLiterals' + value: 'true' + - key: 'bugprone-misplaced-widening-cast.CheckImplicitCasts' + value: 'true' + - key: 'bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression' + value: 'true' + - key: 'bugprone-suspicious-string-compare.WarnOnLogicalNotComparison' + value: 'true' + - key: readability-identifier-length.MinimumParameterNameLength + value: '2' + - key: readability-identifier-length.MinimumVariableNameLength + value: '1' + - key: 'readability-simplify-boolean-expr.ChainedConditionalReturn' + value: 'true' + - key: 'readability-simplify-boolean-expr.ChainedConditionalAssignment' + value: 'true' + - key: 'readability-uniqueptr-delete-release.PreferResetCall' + value: 'true' + - key: 'cppcoreguidelines-init-variables.MathHeader' + value: '' + - key: 'cppcoreguidelines-narrowing-conversions.PedanticMode' + value: 'true' + - key: 'readability-else-after-return.WarnOnUnfixable' + value: 'true' + - key: 'readability-else-after-return.WarnOnConditionVariables' + value: 'true' + - key: 'readability-inconsistent-declaration-parameter-name.Strict' + value: 'true' + - key: 'readability-qualified-auto.AddConstToQualified' + value: 'true' + - key: 'readability-redundant-access-specifiers.CheckFirstDeclaration' + value: 'true' +# These seem to be the most common identifier styles + - key: 'readability-identifier-naming.AbstractClassCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ClassMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstantPointerParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprFunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ConstexprVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.EnumCase' + value: 'lower_case' + - key: 'readability-identifier-naming.EnumConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.FunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalConstantPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalFunctionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.GlobalVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.InlineNamespaceCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalConstantPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalPointerCase' + value: 'lower_case' + - key: 'readability-identifier-naming.LocalVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.MacroDefinitionCase' + value: 'UPPER_CASE' + - key: 'readability-identifier-naming.MemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.MethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.NamespaceCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ParameterPackCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PointerParameterCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PrivateMemberCase' + value: 'lower_case' + # - key: 'readability-identifier-naming.PrivateMemberPrefix' + # value: 'm_' + - key: 'readability-identifier-naming.PrivateMemberSuffix' + value: '_' + - key: 'readability-identifier-naming.PrivateMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ProtectedMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ProtectedMemberPrefix' + value: 'm_' + - key: 'readability-identifier-naming.ProtectedMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PublicMemberCase' + value: 'lower_case' + - key: 'readability-identifier-naming.PublicMethodCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ScopedEnumConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StaticConstantCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StaticVariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.StructCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.TemplateTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.TypeAliasCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TypedefCase' + value: 'lower_case' + - key: 'readability-identifier-naming.TypeTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.UnionCase' + value: 'lower_case' + - key: 'readability-identifier-naming.ValueTemplateParameterCase' + value: 'CamelCase' + - key: 'readability-identifier-naming.VariableCase' + value: 'lower_case' + - key: 'readability-identifier-naming.VirtualMethodCase' + value: 'lower_case' +... diff --git a/asio/.cmake-format b/asio/.cmake-format new file mode 100644 index 0000000000..244841805d --- /dev/null +++ b/asio/.cmake-format @@ -0,0 +1,30 @@ +parse: + additional_commands: + foo: + flags: + - BAR + - BAZ + kwargs: + NAME: '1' + DEPENDS: '*' + HEADERS: '*' + SOURCES: '*' + +format: + dangle_parens: true + keyword_case: upper + line_ending: unix + line_width: 120 + max_lines_hwrap: 3 + max_pargs_hwrap: 8 + max_rows_cmdline: 3 + max_subgroups_hwrap: 4 + min_prefix_chars: 8 + separate_ctrl_name_with_space: false + separate_fn_name_with_space: false + tab_size: 2 + +markup: + bullet_char: '*' + enum_char: . + enable_markup: false diff --git a/asio/.cmakefiles.txt b/asio/.cmakefiles.txt new file mode 100644 index 0000000000..e5c79f937e --- /dev/null +++ b/asio/.cmakefiles.txt @@ -0,0 +1,48 @@ +#!/bin/sh +# +# git ls-files '::*.md' '::*.cmake' '::*CMakeLists.txt' '::*.json' '::*.cmake.in' +# +files=' +../.github/workflows/cmake.yml +.CMakeUserPresets.json +.TODO.txt +.clang-format +.clang-tidy +.cmake-format +.cmakefiles.txt +.codespellrc +.gitignore +GNUmakefile +docs +requirements.txt +BUILDING.md +CMakeLists.txt +CMakePresets.json +CODE_OF_CONDUCT.md +CONTRIBUTING.md +HACKING.md +README.md +asio.pc.cmake +cmake/AddUninstallTarget.cmake +cmake/coverage.cmake +cmake/dev-mode.cmake +cmake/docs-ci.cmake +cmake/docs.cmake +cmake/folders.cmake +cmake/install-config.cmake +cmake/install-rules.cmake +cmake/lint-targets.cmake +cmake/lint.cmake +cmake/prelude.cmake +cmake/spell-targets.cmake +cmake/spell.cmake +cmake/variables.cmake +cmake/windows-set-path.cmake +module/asio.cppm +module/tests/main.hpp +module/tests/main.cpp +module/tests/CMakeLists.txt +src/tests/CMakeLists.txt +' + +tar czvf .cmakefiles.tgz ${files} diff --git a/asio/.codespellrc b/asio/.codespellrc new file mode 100644 index 0000000000..5c562c4cf2 --- /dev/null +++ b/asio/.codespellrc @@ -0,0 +1,7 @@ +[codespell] +builtin = clear,rare,names,informal,code +check-filenames = +check-hidden = +skip = */.git,*/build,*/prefix,*/stage,.TODO.txt +quiet-level = 2 +ignore-words-list = tim,deque,endcode,keep-alives,nmake diff --git a/asio/.gitignore b/asio/.gitignore index 39252178ea..1843c2c225 100644 --- a/asio/.gitignore +++ b/asio/.gitignore @@ -22,3 +22,19 @@ test-driver *.zip /*.cpp /*.hpp +### cmake-init generated: +.git +.github/ +.idea/ +.vs/ +.vscode/ +.init +build/ +cmake-build-*/ +stagedir/ +prefix/ +CMakeLists.txt.user +CMakeUserPresets.json +tags +*.swp +*.bak diff --git a/asio/BUILDING.md b/asio/BUILDING.md new file mode 100644 index 0000000000..c93a304070 --- /dev/null +++ b/asio/BUILDING.md @@ -0,0 +1,89 @@ +# Building with CMake + +## Build + +This project doesn't require any special command-line flags to build to keep +things simple. + +Here are the steps for building in release mode with a single-configuration +generator, like the Unix Makefiles one: + +```sh +cmake -S . -B build -D CMAKE_BUILD_TYPE=Release +cmake --build build +``` + +Here are the steps for building in release mode with a multi-configuration +generator, like the Visual Studio ones: + +```sh +cmake -S . -B build +cmake --build build --config Release +``` + +### Building with MSVC + +Note that MSVC by default is not standards compliant and you need to pass some +flags to make it behave properly. See the `flags-windows` preset in the +[CMakePresets.json](CMakePresets.json) file for the flags and with what +variable to provide them to CMake during configuration. + +### Building on Apple Silicon + +CMake supports building on Apple Silicon properly since 3.20.1. Make sure you +have the [latest version][1] installed. + +## Install + +This project doesn't require any special command-line flags to install to keep +things simple. As a prerequisite, the project has to be built with the above +commands already. + +The below commands require at least CMake 3.15 to run, because that is the +version in which [Install a Project][2] was added. + +Here is the command for installing the release mode artifacts with a +single-configuration generator, like the Unix Makefiles one: + +```sh +cmake --install build +``` + +Here is the command for installing the release mode artifacts with a +multi-configuration generator, like the Visual Studio ones: + +```sh +cmake --install build --config Release +``` + +### CMake package + +This project exports a CMake package to be used with the [`find_package`][3] +command of CMake: + +* Package name: `asio` +* Target name: `asio::asio` + +Example usage: + +```cmake +find_package(asio REQUIRED) +# Declare the imported target as a build requirement using PRIVATE, where +# project_target is a target created in the consuming project +target_link_libraries( + project_target PRIVATE + asio::asio +) +``` + +### Note to packagers + +The `CMAKE_INSTALL_INCLUDEDIR` is set to a path other than just `include` if +the project is configured as a top level project to avoid indirectly including +other libraries when installed to a common prefix. Please review the +[install-rules.cmake](cmake/install-rules.cmake) file for the full set of +install rules. + +[1]: https://cmake.org/download/ +[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#install-a-project +[3]: https://cmake.org/cmake/help/latest/command/find_package.html diff --git a/asio/CMakeLists.txt b/asio/CMakeLists.txt new file mode 100644 index 0000000000..93c2faa65e --- /dev/null +++ b/asio/CMakeLists.txt @@ -0,0 +1,113 @@ +cmake_minimum_required(VERSION 3.25...3.31) + +include(cmake/prelude.cmake) + +project(asio + VERSION 1.32.0.1 + DESCRIPTION "Asio C++ Library" + HOMEPAGE_URL "http://think-async.com/Asio/" + LANGUAGES CXX +) + +include(cmake/variables.cmake) + +if(PROJECT_IS_TOP_LEVEL) + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(snprintf cstdio ASIO_HAS_SNPRINTF) + check_cxx_symbol_exists(sprintf_s cstdio ASIO_HAS_SECURE_RTL) +endif() + +set(CPPdefinitions ASIO_NO_DEPRECATED ASIO_DISABLE_BOOST_CONTEXT_FIBER) +if(ASIO_HAS_SECURE_RTL) + list(APPEND CPPdefinitions ASIO_HAS_SECURE_RTL) +elseif(ASIO_HAS_SNPRINTF) + list(APPEND CPPdefinitions ASIO_HAS_SNPRINTF) +endif() + +option(ASIO_SEPARATE_COMPILATION "build asio lib too" ${PROJECT_IS_TOP_LEVEL}) +set(CMAKE_DEBUG_POSTFIX D) + +# ---- add dependency libraries ---- + +find_package(Threads REQUIRED) +find_package(OpenSSL REQUIRED) + +# ---- Declare library ---- + +file(GLOB_RECURSE _asio_implementation "include/asio/*/*.hpp" "include/asio/*.ipp") +list(FILTER _asio_implementation EXCLUDE REGEX [=[.*/experimental/.*]=]) + +# asio interface library +add_library(asio_header INTERFACE) +add_library(asio::asio_header ALIAS asio_header) +target_sources(asio_header INTERFACE FILE_SET HEADERS BASE_DIRS include FILES ${_asio_implementation}) +target_link_libraries(asio_header INTERFACE OpenSSL::SSL OpenSSL::Crypto) + +target_compile_definitions(asio_header INTERFACE ${CPPdefinitions}) +target_compile_features( + asio_header INTERFACE "$<$:cxx_std_23>" + "$<$>:cxx_std_20>" +) +target_link_libraries(asio_header INTERFACE Threads::Threads) + +if(ASIO_SEPARATE_COMPILATION) + set(_libasio_SOURCES src/asio.cpp) + + if(OpenSSL_FOUND) + list(APPEND _libasio_SOURCES src/asio_ssl.cpp) + endif() + + set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL}) + + file(GLOB_RECURSE _asio_headers "include/asio/*.hpp") + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/experimental/.*\.hpp]=]) + list(FILTER _asio_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + + # FIXME: some header in include/asio/detail fails CMAKE_VERIFY_INTERFACE_HEADER_SETS! + # NOTE: we need them installed, but we used them install with asio_header INTERFACE! CK + set(_public_headers include/asio.hpp ${_asio_headers}) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/detail/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/impl/.*\.hpp]=]) + list(FILTER _public_headers EXCLUDE REGEX [=[.*/spawn.*\.hpp]=]) + # foreach(header in LISTS ${_public_headers}) + # message(INFO "${header}") + # endforeach() + + add_library(asio ${_libasio_SOURCES}) + add_library(asio::asio ALIAS asio) + target_sources(asio PUBLIC FILE_SET public_headers TYPE HEADERS BASE_DIRS include FILES ${_public_headers}) + + target_compile_definitions(asio PUBLIC ASIO_SEPARATE_COMPILATION ${CPPdefinitions}) + target_link_libraries(asio PUBLIC Threads::Threads) + target_compile_features( + asio INTERFACE "$<$:cxx_std_23>" "$<$>:cxx_std_20>" + ) + + if(ASIO_WARNINGS_AS_ERRORS AND ASIO_DEVELOPER_MODE AND UNIX) + target_compile_options(asio PUBLIC -Werror) + endif() + + if(OpenSSL_FOUND) + target_link_libraries(asio PUBLIC OpenSSL::SSL OpenSSL::Crypto) + endif() +endif() + +# ---- Install rules ---- + +if(NOT CMAKE_SKIP_INSTALL_RULES) + include(cmake/AddUninstallTarget.cmake) + include(cmake/install-rules.cmake) + configure_file(asio.pc.cmake asio.pc) + install(FILES ${PROJECT_BINARY_DIR}/asio.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(FILES module/asio.cppm DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/asio/module) +endif() + +# ---- Developer mode ---- + +if(NOT ASIO_DEVELOPER_MODE) + return() +elseif(NOT PROJECT_IS_TOP_LEVEL) + message(AUTHOR_WARNING "Developer mode is intended for developers of asio") +endif() + +include(cmake/dev-mode.cmake) diff --git a/asio/CMakePresets.json b/asio/CMakePresets.json new file mode 100644 index 0000000000..f7eee70b6a --- /dev/null +++ b/asio/CMakePresets.json @@ -0,0 +1,223 @@ +{ + "version": 4, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "cmake-pedantic", + "hidden": true, + "warnings": { + "dev": true, + "deprecated": true, + "uninitialized": true, + "unusedCli": true, + "systemVars": false + }, + "errors": { + "dev": true, + "deprecated": true + } + }, + { + "name": "dev-mode", + "hidden": true, + "inherits": "cmake-pedantic", + "cacheVariables": { + "ASIO_DEVELOPER_MODE": "ON" + } + }, + { + "name": "cppcheck", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_CPPCHECK": "cppcheck;--inline-suppr" + } + }, + { + "name": "clang-tidy", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_CLANG_TIDY": "clang-tidy-18;--header-filter=^${sourceDir}/" + } + }, + { + "name": "ci-std", + "description": + "This preset makes sure the project actually builds with at least the specified standard", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_EXTENSIONS": "OFF", + "CMAKE_CXX_STANDARD": "20", + "CMAKE_CXX_STANDARD_REQUIRED": "ON" + } + }, + { + "name": "flags-Linux", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": + "-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast", + "CMAKE_EXE_LINKER_FLAGS": + "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now", + "CMAKE_SHARED_LINKER_FLAGS": + "-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + } + }, + { + "name": "flags-Darwin", + "hidden": true, + "cacheVariables": { + "CMAKE_CXX_FLAGS": + "-fstack-protector-strong -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "flags-Windows", + "description": + "Note that all the flags after /W3 are required for MSVC to conform to the language standard", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_CXX_COMPILER": "cl", + "CMAKE_CXX_FLAGS_PEDANTIC": + "/sdl /guard:cf /utf-8 /diagnostics:caret /w14165 /w44242 /w44254 /w44263 /w34265 /w34287 /w44296 /w44365 /w44388 /w44464 /w14545 /w14546 /w14547 /w14549 /w14555 /w34619 /w34640 /w24826 /w14905 /w14906 /w14928 /w45038 /W3 /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /EHsc", + "CMAKE_EXE_LINKER_FLAGS_PEDANTIC": "/machine:x64 /guard:cf" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } + }, + { + "name": "gen-Linux", + "generator": "Ninja", + "hidden": true, + "inherits": [ + "flags-Linux", + "ci-std" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "gen-Darwin", + "generator": "Ninja", + "hidden": true, + "inherits": [ + "flags-Darwin", + "ci-std" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "gen-win64", + "inherits": [ + "flags-Windows", + "ci-std" + ], + "generator": "Ninja", + "hidden": true + }, + { + "name": "coverage-Linux", + "binaryDir": "${sourceDir}/build/coverage", + "inherits": "gen-Linux", + "hidden": true, + "cacheVariables": { + "ASIO_ENABLE_COVERAGE": "ON", + "CMAKE_BUILD_TYPE": "Coverage", + "CMAKE_CONFIGURATION_TYPES": "Coverage", + "CMAKE_CXX_FLAGS_COVERAGE": + "-Og -g --coverage -fkeep-inline-functions -fkeep-static-functions", + "CMAKE_EXE_LINKER_FLAGS_COVERAGE": "--coverage", + "CMAKE_SHARED_LINKER_FLAGS_COVERAGE": "--coverage" + } + }, + { + "name": "ci-coverage", + "inherits": [ + "coverage-Linux", + "dev-mode" + ], + "cacheVariables": { + "COVERAGE_HTML_COMMAND": "" + } + }, + { + "name": "ci-sanitize", + "binaryDir": "${sourceDir}/build/sanitize", + "inherits": [ + "gen-Linux", + "clang-tidy", + "dev-mode" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Sanitize", + "CMAKE_CONFIGURATION_TYPES": "Sanitize", + "CMAKE_CXX_FLAGS_SANITIZE": + "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common" + } + }, + { + "name": "ci-build", + "binaryDir": "${sourceDir}/build", + "installDir": "${sourceDir}/stagedir", + "cacheVariables": { + "CMAKE_PREFIX_PATH": { + "type": "path", + "value": "${sourceDir}/stagedir" + } + }, + "hidden": true + }, + { + "name": "ci-Darwin", + "inherits": [ + "ci-build", + "gen-Darwin", + "dev-mode" + ] + }, + { + "name": "ci-macos", + "inherits": "ci-Darwin" + }, + { + "name": "ci-Linux", + "inherits": [ + "ci-build", + "gen-Linux", + "dev-mode" + ] + }, + { + "name": "ci-ubuntu", + "inherits": "ci-Linux" + }, + { + "name": "ci-windows", + "inherits": [ + "ci-build", + "gen-win64", + "dev-mode" + ] + } + ] +} diff --git a/asio/CODE_OF_CONDUCT.md b/asio/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..d1202311b8 --- /dev/null +++ b/asio/CODE_OF_CONDUCT.md @@ -0,0 +1,5 @@ +# Code of Conduct + +* You will be judged by your contributions first, and your sense of humor + second. +* Nobody owes you anything. diff --git a/asio/CONTRIBUTING.md b/asio/CONTRIBUTING.md new file mode 100644 index 0000000000..10cccf381c --- /dev/null +++ b/asio/CONTRIBUTING.md @@ -0,0 +1,19 @@ +# Contributing + + + +## Code of Conduct + +Please see the [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md) document. + +## Getting started + +Helpful notes for developers can be found in the [`HACKING.md`](HACKING.md) +document. + +In addition to he above, if you use the presets file as instructed, then you +should NOT check it into source control, just as the CMake documentation +suggests. diff --git a/asio/GNUmakefile b/asio/GNUmakefile new file mode 100644 index 0000000000..261d188c7d --- /dev/null +++ b/asio/GNUmakefile @@ -0,0 +1,50 @@ +# Standard stuff + +.SUFFIXES: +$(VERBOSE).SILENT: + +MAKEFLAGS+= --no-builtin-rules +MAKEFLAGS+= --warn-undefined-variables + +export hostSystemName=$(shell uname) + +.PHONY: all check test clean distclean +all: .init + cmake --workflow --preset dev --fresh + +check: + -iwyu_tool -p build/dev \ + build/dev/asio_verify_interface_header_sets/asio/basic_readable_pipe.hpp.cxx \ + build/dev/asio_verify_interface_header_sets/asio/detail/reactive_socket_send_op.hpp.cxx \ + -- -Xiwyu --cxx17ns #XXX -Xiwyu --transitive_includes_only + run-clang-tidy -p build/dev -checks='-*,misc-header-*,misc-include-*' src/tests + # ninja -C build/dev spell-check + # ninja -C build/dev format-check + +test: + cmake --preset ci-${hostSystemName} + cmake --build build + cmake --install build --prefix $(CURDIR)/stagedir + cmake -G Ninja -B build/tests -S src/tests -D CMAKE_PREFIX_PATH=$(CURDIR)/stagedir/usr/local + cmake --build build/tests + ctest --test-dir build/tests + +.init: requirements.txt .CMakeUserPresets.json + perl -p -e 's//${hostSystemName}/;' .CMakeUserPresets.json > CMakeUserPresets.json + -pip3 install --user --upgrade -r requirements.txt + touch .init + +clean: + rm -rf build + +distclean: clean + rm -rf stagedir .init tags *.bak + +GNUmakefile :: ; +*.txt :: ; +*.json :: ; + +# Anything we don't know how to build will use this rule. +# The command is a do-nothing command. +# +% :: ; diff --git a/asio/HACKING.md b/asio/HACKING.md new file mode 100644 index 0000000000..731de4d571 --- /dev/null +++ b/asio/HACKING.md @@ -0,0 +1,149 @@ +# Hacking + +Here is some wisdom to help you build and test this project as a developer and +potential contributor. + +If you plan to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) +guide. + +## Developer mode + +Build system targets that are only useful for developers of this project are +hidden if the `ASIO_DEVELOPER_MODE` option is disabled. Enabling this +option makes tests and other developer targets and options available. Not +enabling this option means that you are a consumer of this project and thus you +have no need for these targets and options. + +Developer mode is always set to on in CI workflows. + +### Presets + +This project makes use of [presets][1] to simplify the process of configuring +the project. As a developer, you are recommended to always have the [latest +CMake version][2] installed to make use of the latest Quality-of-Life +additions. + +You have a few options to pass `ASIO_DEVELOPER_MODE` to the configure +command, but this project prefers to use presets. + +As a developer, you should create a `CMakeUserPresets.json` file at the root of +the project: + +```json +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 14, + "patch": 0 + }, + "configurePresets": [ + { + "name": "dev", + "binaryDir": "${sourceDir}/build/dev", + "inherits": ["dev-mode", "ci-"], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ], + "buildPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug" + } + ], + "testPresets": [ + { + "name": "dev", + "configurePreset": "dev", + "configuration": "Debug", + "output": { + "outputOnFailure": true + } + } + ] +} +``` + +You should replace `` in your newly created presets file with the name of +the operating system you have, which may be `win64`, `linux` or `darwin`. You +can see what these correspond to in the +[`CMakePresets.json`](CMakePresets.json) file. + +`CMakeUserPresets.json` is also the perfect place in which you can put all +sorts of things that you would otherwise want to pass to the configure command +in the terminal. + +> **Note** +> Some editors are pretty greedy with how they open projects with presets. +> Some just randomly pick a preset and start configuring without your consent, +> which can be confusing. Make sure that your editor configures when you +> actually want it to, for example in CLion you have to make sure only the +> `dev-dev preset` has `Enable profile` ticked in +> `File > Settings... > Build, Execution, Deployment > CMake` and in Visual +> Studio you have to set the option `Never run configure step automatically` +> in `Tools > Options > CMake` **prior to opening the project**, after which +> you can manually configure using `Project > Configure Cache`. + +### Configure, build and test + +If you followed the above instructions, then you can configure, build and test +the project respectively with the following commands from the project root on +any operating system with any build system: + +```sh +cmake --preset=dev +cmake --build --preset=dev +ctest --preset=dev +``` + +If you are using a compatible editor (e.g. VSCode) or IDE (e.g. CLion, VS), you +will also be able to select the above created user presets for automatic +integration. + +Please note that both the build and test commands accept a `-j` flag to specify +the number of jobs to use, which should ideally be specified to the number of +threads your CPU has. You may also want to add that to your preset using the +`jobs` property, see the [presets documentation][1] for more details. + +### Developer mode targets + +These are targets you may invoke using the build command from above, with an +additional `-t ` flag: + +#### `coverage` + +Available if `ENABLE_COVERAGE` is enabled. This target processes the output of +the previously run tests when built with coverage configuration. The commands +this target runs can be found in the `COVERAGE_TRACE_COMMAND` and +`COVERAGE_HTML_COMMAND` cache variables. The trace command produces an info +file by default, which can be submitted to services with CI integration. The +HTML command uses the trace command's output to generate an HTML document to +`/coverage_html` by default. + +#### `docs` + +Available if `BUILD_MCSS_DOCS` is enabled. Builds to documentation using +Doxygen and m.css. The output will go to `/docs` by default +(customizable using `DOXYGEN_OUTPUT_DIRECTORY`). + +#### `format-check` and `format-fix` + +These targets run the clang-format tool on the codebase to check errors and to +fix them respectively. Customization available using the `FORMAT_PATTERNS` and +`FORMAT_COMMAND` cache variables. + +#### `run-examples` + +Runs all the examples created by the `add_example` command. + +#### `spell-check` and `spell-fix` + +These targets run the codespell tool on the codebase to check errors and to fix +them respectively. Customization available using the `SPELL_COMMAND` cache +variable. + +[1]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html +[2]: https://cmake.org/download/ diff --git a/asio/README.md b/asio/README.md new file mode 100644 index 0000000000..3e38f02fd0 --- /dev/null +++ b/asio/README.md @@ -0,0 +1,19 @@ +# asio + +This is the asio project. + +# Building and installing + +See the [BUILDING](BUILDING.md) document. + +# Contributing + +See the [CONTRIBUTING](CONTRIBUTING.md) document. + +# Licensing + + diff --git a/asio/asio.pc.cmake b/asio/asio.pc.cmake new file mode 100644 index 0000000000..31df77d380 --- /dev/null +++ b/asio/asio.pc.cmake @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@/bin +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: A cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach. +Version: @PROJECT_VERSION@ +Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} -DASIO_NO_DEPRECATED +Lflags: +Requires: +Requires.private: diff --git a/asio/cmake/AddUninstallTarget.cmake b/asio/cmake/AddUninstallTarget.cmake new file mode 100644 index 0000000000..e9bbcec327 --- /dev/null +++ b/asio/cmake/AddUninstallTarget.cmake @@ -0,0 +1,93 @@ +# SPDX-FileCopyrightText: 2012-2021 Istituto Italiano di Tecnologia (IIT) +# SPDX-FileCopyrightText: 2008-2013 Kitware Inc. +# SPDX-License-Identifier: BSD-3-Clause + +#[=======================================================================[.rst: +AddUninstallTarget +------------------ + +Add the "uninstall" target for your project:: + + include(AddUninstallTarget) + + +will create a file ``cmake_uninstall.cmake`` in the build directory and add a +custom target ``uninstall`` (or ``UNINSTALL`` on Visual Studio and Xcode) that +will remove the files installed by your package (using +``install_manifest.txt``). +See also +https://gitlab.kitware.com/cmake/community/wikis/FAQ#can-i-do-make-uninstall-with-cmake + +The :module:`AddUninstallTarget` module must be included in your main +``CMakeLists.txt``. If included in a subdirectory it does nothing. +This allows you to use it safely in your main ``CMakeLists.txt`` and include +your project using ``add_subdirectory`` (for example when using it with +:cmake:module:`FetchContent`). + +If the ``uninstall`` target already exists, the module does nothing. +#]=======================================================================] + +# AddUninstallTarget works only when included in the main CMakeLists.txt +if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") + return() +endif() + +# The name of the target is uppercase in MSVC and Xcode (for coherence with the +# other standard targets) +if("${CMAKE_GENERATOR}" MATCHES "^(Visual Studio|Xcode)") + set(_uninstall "UNINSTALL") +else() + set(_uninstall "uninstall") +endif() + +# If target is already defined don't do anything +if(TARGET ${_uninstall}) + return() +endif() + +set(_filename cmake_uninstall.cmake) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_filename}" + "if(NOT EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\") + message(WARNING \"Cannot find install manifest: \\\"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\\\"\") + return() +endif() + +file(READ \"${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt\" files) +string(STRIP \"\${files}\" files) +string(REGEX REPLACE \"\\n\" \";\" files \"\${files}\") +list(REVERSE files) +foreach(file \${files}) + if(IS_SYMLINK \"\$ENV{DESTDIR}\${file}\" OR EXISTS \"\$ENV{DESTDIR}\${file}\") + message(STATUS \"Uninstalling: \$ENV{DESTDIR}\${file}\") + execute_process( + COMMAND \${CMAKE_COMMAND} -E remove \"\$ENV{DESTDIR}\${file}\" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval) + if(NOT \"\${rm_retval}\" EQUAL 0) + message(FATAL_ERROR \"Problem when removing \\\"\$ENV{DESTDIR}\${file}\\\"\") + endif() + else() + message(STATUS \"Not-found: \$ENV{DESTDIR}\${file}\") + endif() +endforeach(file) +" +) + +set(_desc "Uninstall the project...") +if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + set(_comment COMMAND \$\(CMAKE_COMMAND\) -E cmake_echo_color --switch=$\(COLOR\) --cyan "${_desc}") +else() + set(_comment COMMENT "${_desc}") +endif() +add_custom_target( + ${_uninstall} + ${_comment} + COMMAND ${CMAKE_COMMAND} -P ${_filename} + USES_TERMINAL + BYPRODUCTS uninstall_byproduct + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" +) +set_property(SOURCE uninstall_byproduct PROPERTY SYMBOLIC 1) + +set_property(TARGET ${_uninstall} PROPERTY FOLDER "CMakePredefinedTargets") diff --git a/asio/cmake/coverage.cmake b/asio/cmake/coverage.cmake new file mode 100644 index 0000000000..5f3a32d833 --- /dev/null +++ b/asio/cmake/coverage.cmake @@ -0,0 +1,23 @@ +# ---- Variables ---- + +# We use variables separate from what CTest uses, because those have +# customization issues +set(COVERAGE_TRACE_COMMAND lcov -c -q -o "${PROJECT_BINARY_DIR}/coverage.info" -d "${PROJECT_BINARY_DIR}" --include + "${PROJECT_SOURCE_DIR}/*" + CACHE STRING "; separated command to generate a trace for the 'coverage' target" +) + +set(COVERAGE_HTML_COMMAND genhtml --legend -f -q "${PROJECT_BINARY_DIR}/coverage.info" -p "${PROJECT_SOURCE_DIR}" -o + "${PROJECT_BINARY_DIR}/coverage_html" + CACHE STRING "; separated command to generate an HTML report for the 'coverage' target" +) + +# ---- Coverage target ---- + +add_custom_target( + coverage + COMMAND ${COVERAGE_TRACE_COMMAND} + COMMAND ${COVERAGE_HTML_COMMAND} + COMMENT "Generating coverage report" + VERBATIM +) diff --git a/asio/cmake/dev-mode.cmake b/asio/cmake/dev-mode.cmake new file mode 100644 index 0000000000..39fed3560d --- /dev/null +++ b/asio/cmake/dev-mode.cmake @@ -0,0 +1,24 @@ +include(cmake/folders.cmake) + +option(ASIO_BUILD_TESTING "Use ctest" ON) +if(ASIO_BUILD_TESTING) + enable_testing() + + add_subdirectory(src/tests) + add_subdirectory(module/tests) +endif() + +option(ASIO_BUILD_MCSS_DOCS "Build documentation using Doxygen and m.css" OFF) +if(ASIO_BUILD_MCSS_DOCS) + include(cmake/docs.cmake) +endif() + +option(ASIO_ENABLE_COVERAGE "Enable coverage support separate from CTest's" OFF) +if(ASIO_ENABLE_COVERAGE) + include(cmake/coverage.cmake) +endif() + +include(cmake/lint-targets.cmake) +include(cmake/spell-targets.cmake) + +add_folders(Project) diff --git a/asio/cmake/docs-ci.cmake b/asio/cmake/docs-ci.cmake new file mode 100644 index 0000000000..1a4727bd2b --- /dev/null +++ b/asio/cmake/docs-ci.cmake @@ -0,0 +1,104 @@ +cmake_minimum_required(VERSION 3.14) + +foreach(var IN ITEMS PROJECT_BINARY_DIR PROJECT_SOURCE_DIR) + if(NOT DEFINED "${var}") + message(FATAL_ERROR "${var} must be defined") + endif() +endforeach() +set(bin "${PROJECT_BINARY_DIR}") +set(src "${PROJECT_SOURCE_DIR}") + +# ---- Dependencies ---- + +set(mcss_SOURCE_DIR "${bin}/docs/.ci") +if(NOT IS_DIRECTORY "${mcss_SOURCE_DIR}") + file(MAKE_DIRECTORY "${mcss_SOURCE_DIR}") + file(DOWNLOAD https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip "${mcss_SOURCE_DIR}/mcss.zip" + STATUS status EXPECTED_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + ) + if(NOT status MATCHES "^0;") + message(FATAL_ERROR "Download failed with ${status}") + endif() + execute_process( + COMMAND "${CMAKE_COMMAND}" -E tar xf mcss.zip WORKING_DIRECTORY "${mcss_SOURCE_DIR}" RESULT_VARIABLE result + ) + if(NOT result EQUAL "0") + message(FATAL_ERROR "Extraction failed with ${result}") + endif() + file(REMOVE "${mcss_SOURCE_DIR}/mcss.zip") +endif() + +find_program(Python3_EXECUTABLE NAMES python3 python) +if(NOT Python3_EXECUTABLE) + message(FATAL_ERROR "Python executable was not found") +endif() + +# ---- Process project() call in CMakeLists.txt ---- + +file(READ "${src}/CMakeLists.txt" content) + +string(FIND "${content}" "project(" index) +if(index EQUAL "-1") + message(FATAL_ERROR "Could not find \"project(\"") +endif() +string(SUBSTRING "${content}" "${index}" -1 content) + +string(FIND "${content}" "\n)\n" index) +if(index EQUAL "-1") + message(FATAL_ERROR "Could not find \"\\n)\\n\"") +endif() +string(SUBSTRING "${content}" 0 "${index}" content) + +file(WRITE "${bin}/docs-ci.project.cmake" "docs_${content}\n)\n") + +macro(list_pop_front list out) + list(GET "${list}" 0 "${out}") + list(REMOVE_AT "${list}" 0) +endmacro() + +function(docs_project name) + cmake_parse_arguments(PARSE_ARGV 1 "" "" "VERSION;DESCRIPTION;HOMEPAGE_URL" LANGUAGES) + set(PROJECT_NAME "${name}" PARENT_SCOPE) + if(DEFINED _VERSION) + set(PROJECT_VERSION "${_VERSION}" PARENT_SCOPE) + string(REGEX MATCH "^[0-9]+(\\.[0-9]+)*" versions "${_VERSION}") + string(REPLACE . ";" versions "${versions}") + set(suffixes MAJOR MINOR PATCH TWEAK) + while(NOT versions STREQUAL "" AND NOT suffixes STREQUAL "") + list_pop_front(versions version) + list_pop_front(suffixes suffix) + set("PROJECT_VERSION_${suffix}" "${version}" PARENT_SCOPE) + endwhile() + endif() + if(DEFINED _DESCRIPTION) + set(PROJECT_DESCRIPTION "${_DESCRIPTION}" PARENT_SCOPE) + endif() + if(DEFINED _HOMEPAGE_URL) + set(PROJECT_HOMEPAGE_URL "${_HOMEPAGE_URL}" PARENT_SCOPE) + endif() +endfunction() + +include("${bin}/docs-ci.project.cmake") + +# ---- Generate docs ---- + +if(NOT DEFINED DOXYGEN_OUTPUT_DIRECTORY) + set(DOXYGEN_OUTPUT_DIRECTORY "${bin}/docs") +endif() +set(out "${DOXYGEN_OUTPUT_DIRECTORY}") + +foreach(file IN ITEMS Doxyfile conf.py) + configure_file("${src}/docs/${file}.in" "${bin}/docs/${file}" @ONLY) +endforeach() + +set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") +set(config "${bin}/docs/conf.py") + +file(REMOVE_RECURSE "${out}/html" "${out}/xml") + +execute_process( + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" WORKING_DIRECTORY "${bin}/docs" RESULT_VARIABLE result +) +if(NOT result EQUAL "0") + message(FATAL_ERROR "m.css returned with ${result}") +endif() diff --git a/asio/cmake/docs.cmake b/asio/cmake/docs.cmake new file mode 100644 index 0000000000..5f41772f87 --- /dev/null +++ b/asio/cmake/docs.cmake @@ -0,0 +1,41 @@ +# ---- Dependencies ---- + +set(extract_timestamps "") +if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") + set(extract_timestamps DOWNLOAD_EXTRACT_TIMESTAMP YES) +endif() + +include(FetchContent) +FetchContent_Declare( + mcss + URL https://github.com/friendlyanon/m.css/releases/download/release-1/mcss.zip + URL_MD5 00cd2757ebafb9bcba7f5d399b3bec7f + SOURCE_DIR "${PROJECT_BINARY_DIR}/mcss" + UPDATE_DISCONNECTED YES + ${extract_timestamps} +) +FetchContent_MakeAvailable(mcss) + +find_package(Python3 3.6 REQUIRED) + +# ---- Declare documentation target ---- + +set(DOXYGEN_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/docs" CACHE PATH "Path for the generated Doxygen documentation") + +set(working_dir "${PROJECT_BINARY_DIR}/docs") + +foreach(file IN ITEMS Doxyfile conf.py) + configure_file("docs/${file}.in" "${working_dir}/${file}" @ONLY) +endforeach() + +set(mcss_script "${mcss_SOURCE_DIR}/documentation/doxygen.py") +set(config "${working_dir}/conf.py") + +add_custom_target( + docs + COMMAND "${CMAKE_COMMAND}" -E remove_directory "${DOXYGEN_OUTPUT_DIRECTORY}/html" "${DOXYGEN_OUTPUT_DIRECTORY}/xml" + COMMAND "${Python3_EXECUTABLE}" "${mcss_script}" "${config}" + COMMENT "Building documentation using Doxygen and m.css" + WORKING_DIRECTORY "${working_dir}" + VERBATIM +) diff --git a/asio/cmake/folders.cmake b/asio/cmake/folders.cmake new file mode 100644 index 0000000000..da7bd33a87 --- /dev/null +++ b/asio/cmake/folders.cmake @@ -0,0 +1,21 @@ +set_property(GLOBAL PROPERTY USE_FOLDERS YES) + +# Call this function at the end of a directory scope to assign a folder to +# targets created in that directory. Utility targets will be assigned to the +# UtilityTargets folder, otherwise to the ${name}Targets folder. If a target +# already has a folder assigned, then that target will be skipped. +function(add_folders name) + get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) + foreach(target IN LISTS targets) + get_property(folder TARGET "${target}" PROPERTY FOLDER) + if(DEFINED folder) + continue() + endif() + set(folder Utility) + get_property(type TARGET "${target}" PROPERTY TYPE) + if(NOT type STREQUAL "UTILITY") + set(folder "${name}") + endif() + set_property(TARGET "${target}" PROPERTY FOLDER "${folder}Targets") + endforeach() +endfunction() diff --git a/asio/cmake/install-config.cmake b/asio/cmake/install-config.cmake new file mode 100644 index 0000000000..a975c3d92e --- /dev/null +++ b/asio/cmake/install-config.cmake @@ -0,0 +1,30 @@ +include(CMakeFindDependencyMacro) +find_dependency(Threads) +find_dependency(OpenSSL) + +function(add_asio_module NAME) + set(ASIO_ROOT @CMAKE_INSTALL_PREFIX@) + message(STATUS "ASIO_ROOT is: ${ASIO_ROOT}") + + add_library(${NAME}) + target_include_directories(${NAME} PRIVATE ${ASIO_ROOT}/include) + target_compile_features(${NAME} PUBLIC cxx_std_23) + + set(CPPdefinitions "@CPPdefinitions@") + if(CPPdefinitions) + target_compile_definitions(${NAME} PUBLIC ${CPPdefinitions}) + endif() + + # cmake-format: off + target_sources(${NAME} PUBLIC + FILE_SET modules_public + TYPE CXX_MODULES + BASE_DIRS ${ASIO_ROOT} + FILES + ${ASIO_ROOT}/lib/cmake/asio/module/asio.cppm + ) + # cmake-format: on + target_link_libraries(${NAME} PUBLIC OpenSSL::SSL OpenSSL::Crypto) +endfunction() + +include("${CMAKE_CURRENT_LIST_DIR}/asioTargets.cmake") diff --git a/asio/cmake/install-rules.cmake b/asio/cmake/install-rules.cmake new file mode 100644 index 0000000000..8a34fee715 --- /dev/null +++ b/asio/cmake/install-rules.cmake @@ -0,0 +1,50 @@ +# if(PROJECT_IS_TOP_LEVEL) +# NO! set(CMAKE_INSTALL_INCLUDEDIR "include/asio-${PROJECT_VERSION}" CACHE PATH "") +# endif() + +# Project is configured with no languages, so tell GNUInstallDirs the lib dir +set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "") + +include(cmake/AddUninstallTarget.cmake) + +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +# Print Installing but not Up-to-date messages. +set(CMAKE_INSTALL_MESSAGE LAZY) + +# find_package( ...) +function(windows_set_path TEST) + if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + return() + endif() + + set(path "") + set(glue "") + foreach(target IN LISTS ARGN) + if(TARGET "${target}") + get_target_property(type "${target}" TYPE) + if(type STREQUAL "SHARED_LIBRARY") + set(path "${path}${glue}$") + set(glue "\;") # backslash is important + endif() + endif() + endforeach() + if(NOT path STREQUAL "") + set_property(TEST "${TEST}" PROPERTY ENVIRONMENT "PATH=${path}") + endif() +endfunction() diff --git a/asio/docs/Doxyfile.in b/asio/docs/Doxyfile.in new file mode 100644 index 0000000000..dc37a2ab80 --- /dev/null +++ b/asio/docs/Doxyfile.in @@ -0,0 +1,32 @@ +# Configuration for Doxygen for use with CMake +# Only options that deviate from the default are included +# To create a new Doxyfile containing all available options, call `doxygen -g` + +# Get Project name and version from CMake +PROJECT_NAME = "@PROJECT_NAME@" +PROJECT_NUMBER = "@PROJECT_VERSION@" + +# Add sources +INPUT = "@PROJECT_SOURCE_DIR@/README.md" "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/docs/pages" +EXTRACT_ALL = YES +RECURSIVE = YES +OUTPUT_DIRECTORY = "@DOXYGEN_OUTPUT_DIRECTORY@" + +# Use the README as a main page +USE_MDFILE_AS_MAINPAGE = "@PROJECT_SOURCE_DIR@/README.md" + +# set relative include paths +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@" +STRIP_FROM_INC_PATH = + +# We use m.css to generate the html documentation, so we only need XML output +GENERATE_XML = YES +GENERATE_HTML = NO +GENERATE_LATEX = NO +XML_PROGRAMLISTING = NO +CREATE_SUBDIRS = NO + +# Include all directories, files and namespaces in the documentation +# Disable to include only explicitly documented objects +M_SHOW_UNDOCUMENTED = YES diff --git a/asio/docs/conf.py.in b/asio/docs/conf.py.in new file mode 100644 index 0000000000..b81e3d92a8 --- /dev/null +++ b/asio/docs/conf.py.in @@ -0,0 +1,6 @@ +DOXYFILE = 'Doxyfile' + +LINKS_NAVBAR1 = [ + (None, 'pages', [(None, 'about')]), + (None, 'namespaces', []), +] diff --git a/asio/docs/pages/about.dox b/asio/docs/pages/about.dox new file mode 100644 index 0000000000..2efbda9369 --- /dev/null +++ b/asio/docs/pages/about.dox @@ -0,0 +1,7 @@ +/** + * @page about About + * @section about-doxygen Doxygen documentation + * This page is auto generated using + * Doxygen, making use of some useful + * special commands. + */ diff --git a/asio/include/asio/detail/impl/win_mutex.ipp b/asio/include/asio/detail/impl/win_mutex.ipp index 6340b6e125..581e3a352d 100644 --- a/asio/include/asio/detail/impl/win_mutex.ipp +++ b/asio/include/asio/detail/impl/win_mutex.ipp @@ -52,7 +52,7 @@ int win_mutex::do_init() # endif return 0; #else - __try + try { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); @@ -64,8 +64,7 @@ int win_mutex::do_init() return ::GetLastError(); # endif } - __except(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + catch (const std::bad_alloc&) { return ERROR_OUTOFMEMORY; } diff --git a/asio/include/asio/detail/impl/win_static_mutex.ipp b/asio/include/asio/detail/impl/win_static_mutex.ipp index 5b45984333..33c71c4158 100644 --- a/asio/include/asio/detail/impl/win_static_mutex.ipp +++ b/asio/include/asio/detail/impl/win_static_mutex.ipp @@ -89,7 +89,7 @@ int win_static_mutex::do_init() } # endif #else - __try + try { # if defined(UNDER_CE) ::InitializeCriticalSection(&crit_section_); @@ -111,8 +111,7 @@ int win_static_mutex::do_init() } # endif } - __except(GetExceptionCode() == STATUS_NO_MEMORY - ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) + catch (const std::bad_alloc&) { ::ReleaseMutex(mutex); ::CloseHandle(mutex); diff --git a/asio/module/asio.cppm b/asio/module/asio.cppm new file mode 100644 index 0000000000..767ca2e06e --- /dev/null +++ b/asio/module/asio.cppm @@ -0,0 +1,76 @@ +module; + +#include +#include + +export module asio; + +namespace asio +{ +export using asio::io_context; +export using asio::post; +export using asio::any_completion_executor; +export using asio::any_io_executor; +export using asio::bad_executor; +export using asio::cancellation_signal; +export using asio::cancellation_slot; +export using asio::cancellation_state; +export using asio::cancellation_type; +export using asio::coroutine; +export using asio::detached_t; +export using asio::execution_context; +export using asio::executor; +export using asio::executor_arg_t; +export using asio::invalid_service_owner; +export using asio::io_context; +export using asio::multiple_exceptions; +export using asio::service_already_exists; +export using asio::static_thread_pool; +export using asio::system_context; +export using asio::system_executor; +export using asio::thread_pool; +export using asio::awaitable; +export using asio::deferred; +export using asio::detached; +export using asio::connect; +export using asio::async_connect; +export using asio::buffer; +export using asio::socket_base; +export using asio::co_spawn; + +namespace error +{ +export using asio::error::make_error_code; +} // namespace error + +namespace this_coro +{ +export using asio::this_coro::executor; +} // namespace this_coro + +namespace ip +{ +export using asio::ip::tcp; +export using asio::ip::address; +export using asio::ip::address_v4; +} // namespace ip + +namespace ssl +{ +export using asio::ssl::context; +export using asio::ssl::context_base; +export using asio::ssl::host_name_verification; +export using asio::ssl::stream_base; +export using asio::ssl::verify_context; +export using asio::ssl::stream; +namespace error +{ +export using asio::ssl::error::stream_truncated; +export using asio::ssl::error::unspecified_system_error; +export using asio::ssl::error::unexpected_result; +export using asio::ssl::error::stream_errors; +export using asio::ssl::error::make_error_code; +} // namespace error +} // namespace ssl + +} // namespace asio diff --git a/asio/module/tests/CMakeLists.txt b/asio/module/tests/CMakeLists.txt new file mode 100644 index 0000000000..169241c479 --- /dev/null +++ b/asio/module/tests/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 3.25...3.31) + +project(asio_moddule_examples LANGUAGES CXX) + +if(PROJECT_IS_TOP_LEVEL) + # Find the Asio package containing the function to build the module + find_package(asio 1.32.0.1 EXACT REQUIRED HINT ../../stagedir/lib) + enable_testing() + + # Use modules? + unset(USE_MODULES) + set(CMAKE_CXX_STANDARD 23) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28.4 AND CMAKE_GENERATOR STREQUAL "Ninja") + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + set(USE_MODULES TRUE) + # see https://releases.llvm.org/15.0.0/projects/libcxx/docs/ReleaseNotes.html + # Always use libc++ + add_compile_options(-fexperimental-library) + add_link_options(-lc++experimental) + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + set(USE_MODULES TRUE) + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(USE_MODULES TRUE) + endif() + message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES=${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") + endif() + if(USE_MODULES) + # Build the asio module + add_asio_module(asio_module) + endif() + +endif() + +# list(APPEND ALL_EXAMPLES module/tests/main.cpp) +set(ALL_EXAMPLES main) + +message(STATUS "Module tests to be built: ${ALL_EXAMPLES}") + +foreach(example ${ALL_EXAMPLES}) + add_executable(${example}) + target_sources(${example} PRIVATE ${example}.cpp) + if(USE_MODULES) + target_link_libraries(${example} asio_module) + target_compile_definitions(${example} PUBLIC USE_MODULES) + else() + target_link_libraries(${example} asio::asio_header) + endif() + add_test(NAME module_test_${example} COMMAND echo Test | ${example}) +endforeach() diff --git a/asio/module/tests/main.cpp b/asio/module/tests/main.cpp new file mode 100644 index 0000000000..2b964dd2c5 --- /dev/null +++ b/asio/module/tests/main.cpp @@ -0,0 +1,7 @@ +#include "main.hpp" + +// NOLINTNEXTLINE(bugprone-exception-escape) +auto main() -> int +{ + return bench::main_impl(); // NOLINT(clang-analyzer-core.CallAndMessage) +} diff --git a/asio/module/tests/main.hpp b/asio/module/tests/main.hpp new file mode 100644 index 0000000000..8e0cc5411b --- /dev/null +++ b/asio/module/tests/main.hpp @@ -0,0 +1,119 @@ +#ifdef USE_MODULES +# ifdef HAS_STDLIB_MODULES +import std; +import std.compat; +# else +# include +# include +# include +# include +# endif +import asio; +#else +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + +namespace bench { + +namespace net = asio; +namespace ssl = asio::ssl; +using tcp = asio::ip::tcp; +using std::error_code; + +inline void fail(error_code ec, char const* what) +{ + if(ec == ssl::error::make_error_code(net::ssl::error::stream_truncated)) + return; + exit(1); +} + +inline net::awaitable do_session(tcp::socket client_sock) +{ + char buff [4096] {}; + // TODO(CK): Not used? auto ex = co_await net::this_coro::executor; + + ssl::context ctx {ssl::context::tls_client}; + ssl::stream stream {std::move(client_sock), ctx}; + + co_await stream.async_handshake(ssl::stream_base::server, net::deferred); + co_await stream.async_read_some(net::buffer(buff), net::deferred); + co_await stream.async_write_some(net::buffer(buff), net::deferred); + co_await stream.async_shutdown(net::deferred); + stream.next_layer().close(); +} + +inline net::awaitable do_listen() +{ + const auto ex = co_await net::this_coro::executor; + error_code ec; + tcp::endpoint endpoint {net::ip::address_v4::loopback(), 3000}; + + // Open the acceptor + tcp::acceptor acceptor{ex}; + acceptor.open(endpoint.protocol(), ec); + if(ec) + fail(ec, "open"); + + // Allow address reuse + acceptor.set_option(net::socket_base::reuse_address(true), ec); + if(ec) + fail(ec, "set_option"); + + // Bind to the server address + acceptor.bind(endpoint, ec); + if(ec) + fail(ec, "bind"); + + // Start listening for connections + acceptor.listen(net::socket_base::max_listen_connections, ec); + if(ec) + fail(ec, "listen"); + + for(;;) + { + tcp::socket socket{ex}; + co_await acceptor.async_accept(socket, net::deferred); + net::co_spawn(ex, [s = std::move(socket)]() mutable { + return do_session(std::move(s)); + }, net::detached); + } +} + +inline int main_impl() +{ + // The io_context is required for all I/O + net::io_context ioc; + + // Spawn a listening port + net::co_spawn( + ioc, + do_listen, + // on completion, spawn will call this function + [](std::exception_ptr ex) + { + // if an exception occurred in the coroutine, + // it's something critical, e.g. out of memory + // we capture normal errors in the ec + // so we just rethrow the exception here, + // which will cause `ioc.run()` to throw + if (ex) + std::rethrow_exception(ex); + }); + + ioc.run(); + + return 0; +} + +} diff --git a/asio/requirements.txt b/asio/requirements.txt new file mode 100644 index 0000000000..3d13e0dd7b --- /dev/null +++ b/asio/requirements.txt @@ -0,0 +1,14 @@ +# +# usage: pip install --user --upgrade -r requirements.txt +# +Pygments +PyYAML +cmake-init>=0.40.5 +cmake>=3.28.4 +cmakelint>=1.4.2 +codespell>=2.2.6 +gcovr>=7.2 +jinja2>=3.1.3 +ninja>=1.11.1 +yamllint +builddriver diff --git a/asio/src/tests/CMakeLists.txt b/asio/src/tests/CMakeLists.txt new file mode 100644 index 0000000000..cd3cc58826 --- /dev/null +++ b/asio/src/tests/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.25...3.31) + +project(asio_test LANGUAGES CXX) + +include(../../cmake/project-is-top-level.cmake OPTIONAL) +include(../../cmake/folders.cmake OPTIONAL) +include(../../cmake/windows-set-path.cmake OPTIONAL) + +# ---- Dependencies ---- + +if(PROJECT_IS_TOP_LEVEL) + find_package(asio 1.32.0.1 EXACT REQUIRED) + enable_testing() +endif() + +# ---- Tests ---- + +add_executable(asio_test unit/read_until.cpp) + +if(TARGET asio::asio) + target_link_libraries(asio_test asio::asio) +else() + target_link_libraries(asio_test asio::asio_header) +endif() + +if(NOT PROJECT_IS_TOP_LEVEL) + if(NOT DEFINED CMAKE_PREFIX_PATH) + set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + endif() + + # test if the targets are findable from the build directory + # NOTE: For an INTERFACE library and multi config generators, we may always use + # the -C Debug config type instead of $ to prevent problems! CK + if(CMAKE_BUILD_TYPE STREQUAL Debug) + add_test( + NAME find-package-test + COMMAND ${CMAKE_CTEST_COMMAND} --verbose --output-on-failure -C Debug --build-and-test + "${CMAKE_SOURCE_DIR}/module/tests" "${CMAKE_CURRENT_BINARY_DIR}/find-package-test" --build-generator + ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-options + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" + "-DCMAKE_BUILD_TYPE=Debug" "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" + ) + endif() +endif() + +# ---- Setup strict Compiler Warnings ---- + +add_test(NAME asio_test COMMAND asio_test) + +# ---- End-of-file commands ---- + +if(NOT PROJECT_IS_TOP_LEVEL) + add_folders(Tests) +endif()