From 9b8a4960803e861e46016d78553a3e685f45def1 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Sat, 19 Dec 2020 23:46:20 -0800 Subject: [PATCH] Generating qvm.hpp and qvm_lite.hpp on GitHub Actions --- .github/workflows/ci.yml | 28 ++++++---- .github/workflows/gh-pages.yml | 6 +++ .gitignore | 4 +- .travis.yml | 2 +- .vscode/tasks.json | 7 +-- README.md | 35 ++++++++++--- appveyor.yml | 2 +- doc/qvm.adoc | 51 ++++++++++++------- gen/generate_single_header.py | 19 ++----- include/boost/qvm/all.hpp | 7 ++- .../qvm/{detail/all_light.hpp => lite.hpp} | 5 ++ meson.build | 4 +- test/Jamfile.v2 | 8 +-- 13 files changed, 113 insertions(+), 65 deletions(-) rename include/boost/qvm/{detail/all_light.hpp => lite.hpp} (92%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afeb903..d9fe206 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,6 @@ on: - feature/** env: - LIBRARY: qvm UBSAN_OPTIONS: print_stacktrace=1 jobs: @@ -125,9 +124,9 @@ jobs: cd .. git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root cd boost-root - cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + cp -r $GITHUB_WORKSPACE/* libs/qvm git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" qvm ./bootstrap.sh ./b2 -d0 headers @@ -136,10 +135,16 @@ jobs: run: | echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam + - name: Generate headers + run: | + cd ../boost-root/libs/qvm + python gen/generate_single_header.py -i include/boost/qvm/all.hpp -p include -o test/qvm.hpp boost/qvm + python gen/generate_single_header.py -i include/boost/qvm/lite.hpp -p include -o test/qvm_lite.hpp boost/qvm + - name: Run tests run: | cd ../boost-root - ./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release + ./b2 -j3 libs/qvm/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release,debug_qvm_hpp,release_qvm_hpp,debug_qvm_lite_hpp,release_qvm_lite_hpp windows: strategy: @@ -173,15 +178,20 @@ jobs: 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%\ + xcopy /s /e /q %GITHUB_WORKSPACE% libs\qvm\ git submodule update --init tools/boostdep - python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" qvm cmd /c bootstrap b2 -d0 headers + - name: Generate headers + run: | + cd ..\boost-root\libs\qvm + python gen/generate_single_header.py -i include/boost/qvm/all.hpp -p include -o test/qvm.hpp boost/qvm + python gen/generate_single_header.py -i include/boost/qvm/lite.hpp -p include -o test/qvm_lite.hpp boost/qvm + - name: Run tests shell: cmd run: | - cd ../boost-root - b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release - \ No newline at end of file + cd ..\boost-root + b2 -j3 libs/qvm/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release,debug_qvm_hpp,release_qvm_hpp,debug_qvm_lite_hpp,release_qvm_lite_hpp diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 4569be0..f8ae9e6 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -35,6 +35,12 @@ jobs: cd ../boost-root/libs/qvm/doc ../../../b2 + - name: Generate headers + run: | + cd ../boost-root/libs/qvm + python gen/generate_single_header.py -i include/boost/qvm/all.hpp -p include -o doc/html/qvm.hpp boost/qvm + python gen/generate_single_header.py -i include/boost/qvm/lite.hpp -p include -o doc/html/qvm_lite.hpp boost/qvm + - name: Deploy to GitHub Pages uses: JamesIves/github-pages-deploy-action@3.7.1 with: diff --git a/.gitignore b/.gitignore index 3ca0e72..623b44a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,5 @@ vcxproj.exe /doc/html/** /.vscode/c_cpp_properties.json /bld/* -/include/boost/qvm.hpp -/include/boost/qvm_lite.hpp +/test/qvm.hpp +/test/qvm_lite.hpp diff --git a/.travis.yml b/.travis.yml index 9bcd6c1..46436f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# Copyright 2018 Emil Dotchevski +# Copyright 2018-2021 Emil Dotchevski # Copyright 2016 Peter Dimov # 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) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 6a5b84f..cacd771 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -18,7 +18,7 @@ { "label": "Generate headers", "type": "shell", - "command": "cd ${workspaceRoot} && python3 gen/generate_single_header.py -guard BOOST_QVM_HPP_INCLUDED -i include/boost/qvm/all.hpp -p ${workspaceRoot}/include -o ${workspaceRoot}/include/boost/qvm.hpp boost/qvm && python3 gen/generate_single_header.py -guard BOOST_QVM_LIGHT_HPP_INCLUDED -i include/boost/qvm/detail/all_light.hpp -p ${workspaceRoot}/include -o ${workspaceRoot}/include/boost/qvm_lite.hpp boost/qvm", + "command": "cd ${workspaceRoot} && python gen/generate_single_header.py -i include/boost/qvm/all.hpp -p ${workspaceRoot}/include -o ${workspaceRoot}/test/qvm.hpp boost/qvm && python gen/generate_single_header.py -i include/boost/qvm/lite.hpp -p ${workspaceRoot}/include -o ${workspaceRoot}/test/qvm_lite.hpp boost/qvm", "problemMatcher": [] }, { @@ -99,10 +99,7 @@ "relative", "${workspaceRoot}/bld/debug" ] - }, - "windows": { - "command": "${workspaceRoot}/.vscode/msvc.bat && cd ${workspaceRoot}/bld/debug && meson test access_m_test" } } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index 40185be..16eb25f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,33 @@ -QVM: Generic C++ library for working with Quaternions, Vectors and Matrices +# QVM -Official documentation: https://boostorg.github.io/qvm/ +> A generic C++ library for working with `Q`uaternions, `V`ectors and `M`atrices. + +## Documentation + +https://boostorg.github.io/qvm/ + +## Features * Emphasis on 2, 3 and 4-dimensional operations needed in graphics, video games and simulation applications. -* Free function templates operate on any compatible user-defined quaternion, vector or matrix type. -* Quaternion, vector and matrix types from different libraries or subsystems can be safely mixed in the same expression. -* Type-safe mapping between compatible lvalue types with no temporary objects; e.g. transpose remaps the elements, rather than transforming the matrix. +* Free function templates operate on any compatible user-defined Quaternion, Vector or Matrix type. +* Enables Quaternion, Vector and Matrix types from different libraries to be safely mixed in the same expression. +* Type-safe mapping between compatible lvalue types with no temporary objects; f.ex. transpose remaps the access to the elements, rather than transforming the matrix. +* Requires only {CPP}03. +* Zero dependencies. -Copyright (c) 2018 Emil Dotchevski. Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). +## Support -Please post questions and feedback on the Boost Developers Mailing List. +* [cpplang on Slack](https://Cpplang.slack.com) (use the `#boost` channel) +* [Boost Users Mailing List](https://lists.boost.org/mailman/listinfo.cgi/boost-users) +* [Boost Developers Mailing List](https://lists.boost.org/mailman/listinfo.cgi/boost) + +## Distribution + +Besides GitHub, there are two other distribution channels: + +* QVM is included in official https://www.boost.org/[Boost] releases. +* For maximum portability, the library is also available in single-header format, in two variants (direct download links): + * [qvm.hpp](https://boostorg.github.io/qvm/qvm.hpp): single header containing the complete QVM source, including the complete set of swizzling overloads. + * [qvm_lite.hpp](https://boostorg.github.io/qvm/qvm_lite.hpp): single header containing everything except for the swizzling overloads. + +Copyright (C) 2008-2021 Emil Dotchevski. Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). diff --git a/appveyor.yml b/appveyor.yml index 2f26db2..3ba3958 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ # Copyright 2016, 2017 Peter Dimov -# Copyright 2018 Emil Dotchevski +# Copyright 2018-2021 Emil Dotchevski # 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) diff --git a/doc/qvm.adoc b/doc/qvm.adoc index 99ab34e..2173fe2 100644 --- a/doc/qvm.adoc +++ b/doc/qvm.adoc @@ -5,8 +5,13 @@ :stylesheet: zajo-dark.css :source-highlighter: rouge +ifdef::backend-pdf[] = QVM -Quaternion / Vector / Matrix Library for {CPP}03 | Emil Dotchevski +endif::[] +ifndef::backend-pdf[] += QVM pass:[
] +endif::[] +Quaternion / Vector / Matrix Library written in {CPP}03 | Emil Dotchevski ifndef::backend-pdf[] :toc: left :toclevels: 3 @@ -34,6 +39,32 @@ ifndef::backend-pdf[] <> | <> | <> endif::[] +[[support]] +== Support + +* https://Cpplang.slack.com[cpplang on Slack] (use the `#boost` channel) +* https://lists.boost.org/mailman/listinfo.cgi/boost-users[Boost Users Mailing List] +* https://lists.boost.org/mailman/listinfo.cgi/boost[Boost Developers Mailing List] +* https://github.com/boostorg/qvm/issues[Report an issue] on GitHub + +== Portability + +QVM requires only {CPP}03 but is tested on many compiler versions and {CPP} standards. + +== Distribution + +Copyright (C) 2008-2021 Emil Dotchevski. Distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0]. + +There are three distribution channels: + +* QVM is included in official https://www.boost.org/[Boost] releases. +* The source code is hosted on https://github.com/boostorg/qvm[GitHub]. +* For maximum portability, the library is also available in single-header format, in two variants (direct download links): +** link:qvm.hpp[qvm.hpp]: single header containing the complete QVM source, including the complete set of <> overloads. +** link:qvm_lite.hpp[qvm_lite.hpp]: single header containing everything except for the swizzling overloads. + +NOTE: QVM does not depend on Boost or other libraries. + [[tutorial]] == Tutorial @@ -350,6 +381,8 @@ The tables below list commonly used components and the headers they're found in. The header `boost/qvm/all.hpp` is provided for convenience. It includes all other QVM headers. +In addition, Boost QVM is available in single-header format for maximum portability. See <>. + .Quaternion header files [cols="1,2l"] |==== @@ -5126,22 +5159,6 @@ QVM itself defines specializations of the math function templates only for `floa Because of this, a call to e.g. `<>(axis,1)` will compile successfully but fail to link, since it calls e.g. `boost::qvm::sin`, which is undefined. Because rotations by integer number of radians are rarely needed, in QVM there is no protection against such errors. In such cases the solution is to use `rot_mat(axis,1.0f)` instead. -== Distribution - -QVM is part of https://www.boost.org/[Boost] and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0]. - -The source code is available in https://github.com/boostorg/qvm[QVM GitHub repository]. - -(C) 2008-2018 Emil Dotchevski and Reverge Studios, Inc. - -== Portability - -See the link:https://travis-ci.org/boostorg/qvm[QVM Travis CI Builds]. - -== Feedback / Support - -Please use the link:https://lists.boost.org/mailman/listinfo.cgi/boost[Boost Developers mailing list]. - == Q&A [qanda] diff --git a/gen/generate_single_header.py b/gen/generate_single_header.py index ed13a5c..397aabf 100644 --- a/gen/generate_single_header.py +++ b/gen/generate_single_header.py @@ -12,12 +12,7 @@ python3 generate_single_header.py --help - e.g. python3 generate_single_header.py -i include/boost/qvm/all.hpp -p include -o include/boost/qvm.hpp boost/qvm -guard BOOST_QVM_HPP_INCLUDED - - Note: - - If unit tests are build by meson, you can enable the 'leaf_hpp' option (see meson_options.txt), - in which case each time the tests are built, first boost/qvm.hpp will be rebuilt. + e.g. python3 generate_single_header.py -i include/boost/qvm/all.hpp -p include -o test/qvm.hpp boost/qvm """ @@ -38,7 +33,7 @@ def append(input_file_name, input_file, output_file, regex_includes, include_fol next_input_file_name = result.group("include") if next_input_file_name not in included: included.append(next_input_file_name) - print("%s" % next_input_file_name, flush=True) + print("%s" % next_input_file_name) with open(os.path.join(include_folder, next_input_file_name), "r") as next_input_file: output_file.write('// >>> %s#line 1 "%s"\n' % (line, next_input_file_name)) append(next_input_file_name, next_input_file, output_file, regex_includes, include_folder) @@ -63,28 +58,20 @@ def _main(): help="Include path") parser.add_argument("prefix", action="store", type=str, help="Non-empty include file prefix (e.g. a/b)") - parser.add_argument("-guard", action="store", type=str, - help="The include guard to use") args = parser.parse_args() regex_includes = re.compile(r"""^\s*#[\t\s]*include[\t\s]*("|\<)(?P%s.*)("|\>)""" % args.prefix) print("Rebuilding %s:" % args.input) with open(args.output, 'w') as output_file, open(args.input, 'r') as input_file: output_file.write( - '#ifndef ' + args.guard + '\n' - '#define ' + args.guard + '\n' - '\n' '// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc.\n' '// Copyright (c) 2018-2019 agate-pris\n' '\n' '// Distributed under the Boost Software License, Version 1.0. (See accompanying\n' '// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n' '\n' - '// This file was generated by a program. Do not edit manually.\n' ) + '// This file was generated by a program. Do not edit manually.\n\n' ) append(args.input, input_file, output_file, regex_includes, args.path) - output_file.write( - '\n' - '#endif\n' ) if __name__ == "__main__": _main() diff --git a/include/boost/qvm/all.hpp b/include/boost/qvm/all.hpp index fe153d3..ebb8f2e 100644 --- a/include/boost/qvm/all.hpp +++ b/include/boost/qvm/all.hpp @@ -1,7 +1,12 @@ +#ifndef BOOST_QVM_ALL_HPP_INCLUDED +#define BOOST_QVM_ALL_HPP_INCLUDED + /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc. /// 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) -#include +#include #include + +#endif diff --git a/include/boost/qvm/detail/all_light.hpp b/include/boost/qvm/lite.hpp similarity index 92% rename from include/boost/qvm/detail/all_light.hpp rename to include/boost/qvm/lite.hpp index 47350a9..dbbdad7 100644 --- a/include/boost/qvm/detail/all_light.hpp +++ b/include/boost/qvm/lite.hpp @@ -1,3 +1,6 @@ +#ifndef BOOST_QVM_LITE_HPP_INCLUDED +#define BOOST_QVM_LITE_HPP_INCLUDED + /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc. /// Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -25,3 +28,5 @@ #include #include #include + +#endif diff --git a/meson.build b/meson.build index cf15c53..0cb2461 100644 --- a/meson.build +++ b/meson.build @@ -151,9 +151,9 @@ if option_enable_unit_tests dep_header_inclusion_mode = [] if option_qvm_header_mode == 'single' - dep_header_inclusion_mode = declare_dependency(compile_args: ['-DBOOST_QVM_TEST_SINGLE_HEADER=']) + dep_header_inclusion_mode = declare_dependency(compile_args: ['-DBOOST_QVM_TEST_SINGLE_HEADER="qvm.hpp"']) elif option_qvm_header_mode == 'single_lite' - dep_header_inclusion_mode = declare_dependency(compile_args: ['-DBOOST_QVM_TEST_SINGLE_HEADER=', '-DBOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=']) + dep_header_inclusion_mode = declare_dependency(compile_args: ['-DBOOST_QVM_TEST_SINGLE_HEADER="qvm_lite.hpp"', '-DBOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=']) elif option_qvm_header_mode != 'multi' error('Bad qvm_header_mode='+option_qvm_header_mode+', valid values are multi, single, single_lite') endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 128ccec..a7df14d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,10 +8,10 @@ project ../include ; -variant debug_qvm_hpp : debug : BOOST_QVM_TEST_SINGLE_HEADER=\"\" ; -variant release_qvm_hpp : release : BOOST_QVM_TEST_SINGLE_HEADER=\"\" ; -variant debug_qvm_lite_hpp : debug : BOOST_QVM_TEST_SINGLE_HEADER=\"\" BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=\"\" ; -variant release_qvm_lite_hpp : release : BOOST_QVM_TEST_SINGLE_HEADER=\"\" BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=\"\" ; +variant debug_qvm_hpp : debug : BOOST_QVM_TEST_SINGLE_HEADER="\\\"qvm.hpp\\\"" ; +variant release_qvm_hpp : release : BOOST_QVM_TEST_SINGLE_HEADER="\\\"qvm.hpp\\\"" ; +variant debug_qvm_lite_hpp : debug : BOOST_QVM_TEST_SINGLE_HEADER="\\\"qvm_lite.hpp\\\"" BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=\"\" ; +variant release_qvm_lite_hpp : release : BOOST_QVM_TEST_SINGLE_HEADER="\\\"qvm_lite.hpp\\\"" BOOST_QVM_TEST_SINGLE_HEADER_SWIZZLE=\"\" ; import testing ; import path ;