├── .clang-format ├── .dockerignore ├── .github └── workflows │ ├── dist_publish.yml │ └── doc.yml ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── bindings └── python │ ├── CMakeLists.txt │ ├── README.md │ ├── examples │ ├── miasm_macho_x64.py │ ├── run_macho.py │ └── triton_macho_x64.py │ ├── pyQBDL.cpp │ ├── pyQBDL.hpp │ ├── setup.cfg │ └── setup.py ├── ci └── build_wheels_manylinux.sh ├── cmake └── QBDLConfig.cmake ├── docker └── qbdl.dockerfile ├── docs ├── CMakeLists.txt ├── anroid_lib.rst ├── conf.py.in ├── doxygen │ ├── CMakeLists.txt │ └── Doxyfile.in ├── index.rst ├── intro.rst ├── macho_linux.rst ├── miasm.rst ├── reference_cxx.rst ├── reference_py.rst ├── requirements.txt └── use_cases.rst ├── examples ├── CMakeLists.txt ├── binaries │ ├── SECCON2016_whitebox.so │ ├── elf-android-arm64-hello.bin │ ├── elf-android-x86-64-hello.bin │ ├── elf-linux-x86-64-hello.bin │ ├── macho-arm64-osx-hello.bin │ ├── macho-arm64-osx-print.bin │ ├── macho-x86-64-hello.bin │ └── src │ │ ├── android-test.cpp │ │ └── hello-world.c └── tools │ ├── CMakeLists.txt │ ├── elf_run │ ├── CMakeLists.txt │ └── main.cpp │ ├── macho_run │ ├── CMakeLists.txt │ ├── darwin_aarch64_libc.cpp │ ├── darwin_aarch64_libc.h │ └── main.cpp │ ├── pe_run │ ├── CMakeLists.txt │ └── main.cpp │ └── whitebox_reloaded │ ├── CMakeLists.txt │ └── main.cpp ├── include └── QBDL │ ├── Engine.hpp │ ├── Loader.hpp │ ├── arch.hpp │ ├── engines │ └── Native.hpp │ ├── exports.hpp │ ├── loaders │ ├── ELF.hpp │ ├── MachO.hpp │ └── PE.hpp │ ├── log.hpp │ ├── macros.hpp │ └── utils.hpp ├── src ├── CMakeLists.txt ├── Engine.cpp ├── Loader.cpp ├── arch.cpp ├── engines │ ├── CMakeLists.txt │ ├── Native.cpp │ ├── native_posix.inc │ └── native_win.inc ├── intmem.hpp ├── loaders │ ├── CMakeLists.txt │ ├── ELF.cpp │ ├── MachO.cpp │ └── PE.cpp ├── logging.cpp └── logging.hpp └── third-party ├── pybind11-2.6.2 ├── .appveyor.yml ├── .clang-format ├── .clang-tidy ├── .cmake-format.yaml ├── .github │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE │ │ ├── bug-report.md │ │ ├── config.yml │ │ ├── feature-request.md │ │ └── question.md │ ├── dependabot.yml │ ├── labeler.yml │ ├── labeler_merged.yml │ ├── pull_request_template.md │ └── workflows │ │ ├── ci.yml │ │ ├── configure.yml │ │ ├── format.yml │ │ ├── labeler.yml │ │ └── pip.yml ├── .pre-commit-config.yaml ├── .readthedocs.yml ├── CMakeLists.txt ├── LICENSE ├── MANIFEST.in ├── README.rst ├── docs │ ├── Doxyfile │ ├── _static │ │ └── theme_overrides.css │ ├── advanced │ │ ├── cast │ │ │ ├── chrono.rst │ │ │ ├── custom.rst │ │ │ ├── eigen.rst │ │ │ ├── functional.rst │ │ │ ├── index.rst │ │ │ ├── overview.rst │ │ │ ├── stl.rst │ │ │ └── strings.rst │ │ ├── classes.rst │ │ ├── embedding.rst │ │ ├── exceptions.rst │ │ ├── functions.rst │ │ ├── misc.rst │ │ ├── pycpp │ │ │ ├── index.rst │ │ │ ├── numpy.rst │ │ │ ├── object.rst │ │ │ └── utilities.rst │ │ └── smart_ptrs.rst │ ├── basics.rst │ ├── benchmark.py │ ├── benchmark.rst │ ├── changelog.rst │ ├── classes.rst │ ├── cmake │ │ └── index.rst │ ├── compiling.rst │ ├── conf.py │ ├── faq.rst │ ├── index.rst │ ├── installing.rst │ ├── limitations.rst │ ├── pybind11-logo.png │ ├── pybind11_vs_boost_python1.png │ ├── pybind11_vs_boost_python1.svg │ ├── pybind11_vs_boost_python2.png │ ├── pybind11_vs_boost_python2.svg │ ├── reference.rst │ ├── release.rst │ ├── requirements.txt │ └── upgrade.rst ├── include │ └── pybind11 │ │ ├── attr.h │ │ ├── buffer_info.h │ │ ├── cast.h │ │ ├── chrono.h │ │ ├── common.h │ │ ├── complex.h │ │ ├── detail │ │ ├── class.h │ │ ├── common.h │ │ ├── descr.h │ │ ├── init.h │ │ ├── internals.h │ │ └── typeid.h │ │ ├── eigen.h │ │ ├── embed.h │ │ ├── eval.h │ │ ├── functional.h │ │ ├── iostream.h │ │ ├── numpy.h │ │ ├── operators.h │ │ ├── options.h │ │ ├── pybind11.h │ │ ├── pytypes.h │ │ ├── stl.h │ │ └── stl_bind.h ├── pybind11 │ ├── __init__.py │ ├── __main__.py │ ├── _version.py │ ├── _version.pyi │ ├── commands.py │ ├── py.typed │ ├── setup_helpers.py │ └── setup_helpers.pyi ├── pyproject.toml ├── setup.cfg ├── setup.py ├── tests │ ├── CMakeLists.txt │ ├── conftest.py │ ├── constructor_stats.h │ ├── cross_module_gil_utils.cpp │ ├── env.py │ ├── extra_python_package │ │ ├── pytest.ini │ │ └── test_files.py │ ├── extra_setuptools │ │ ├── pytest.ini │ │ └── test_setuphelper.py │ ├── local_bindings.h │ ├── object.h │ ├── pybind11_cross_module_tests.cpp │ ├── pybind11_tests.cpp │ ├── pybind11_tests.h │ ├── pytest.ini │ ├── requirements.txt │ ├── test_async.cpp │ ├── test_async.py │ ├── test_buffers.cpp │ ├── test_buffers.py │ ├── test_builtin_casters.cpp │ ├── test_builtin_casters.py │ ├── test_call_policies.cpp │ ├── test_call_policies.py │ ├── test_callbacks.cpp │ ├── test_callbacks.py │ ├── test_chrono.cpp │ ├── test_chrono.py │ ├── test_class.cpp │ ├── test_class.py │ ├── test_cmake_build │ │ ├── CMakeLists.txt │ │ ├── embed.cpp │ │ ├── installed_embed │ │ │ └── CMakeLists.txt │ │ ├── installed_function │ │ │ └── CMakeLists.txt │ │ ├── installed_target │ │ │ └── CMakeLists.txt │ │ ├── main.cpp │ │ ├── subdirectory_embed │ │ │ └── CMakeLists.txt │ │ ├── subdirectory_function │ │ │ └── CMakeLists.txt │ │ ├── subdirectory_target │ │ │ └── CMakeLists.txt │ │ └── test.py │ ├── test_constants_and_functions.cpp │ ├── test_constants_and_functions.py │ ├── test_copy_move.cpp │ ├── test_copy_move.py │ ├── test_custom_type_casters.cpp │ ├── test_custom_type_casters.py │ ├── test_docstring_options.cpp │ ├── test_docstring_options.py │ ├── test_eigen.cpp │ ├── test_eigen.py │ ├── test_embed │ │ ├── CMakeLists.txt │ │ ├── catch.cpp │ │ ├── external_module.cpp │ │ ├── test_interpreter.cpp │ │ └── test_interpreter.py │ ├── test_enum.cpp │ ├── test_enum.py │ ├── test_eval.cpp │ ├── test_eval.py │ ├── test_eval_call.py │ ├── test_exceptions.cpp │ ├── test_exceptions.py │ ├── test_factory_constructors.cpp │ ├── test_factory_constructors.py │ ├── test_gil_scoped.cpp │ ├── test_gil_scoped.py │ ├── test_iostream.cpp │ ├── test_iostream.py │ ├── test_kwargs_and_defaults.cpp │ ├── test_kwargs_and_defaults.py │ ├── test_local_bindings.cpp │ ├── test_local_bindings.py │ ├── test_methods_and_attributes.cpp │ ├── test_methods_and_attributes.py │ ├── test_modules.cpp │ ├── test_modules.py │ ├── test_multiple_inheritance.cpp │ ├── test_multiple_inheritance.py │ ├── test_numpy_array.cpp │ ├── test_numpy_array.py │ ├── test_numpy_dtypes.cpp │ ├── test_numpy_dtypes.py │ ├── test_numpy_vectorize.cpp │ ├── test_numpy_vectorize.py │ ├── test_opaque_types.cpp │ ├── test_opaque_types.py │ ├── test_operator_overloading.cpp │ ├── test_operator_overloading.py │ ├── test_pickling.cpp │ ├── test_pickling.py │ ├── test_pytypes.cpp │ ├── test_pytypes.py │ ├── test_sequences_and_iterators.cpp │ ├── test_sequences_and_iterators.py │ ├── test_smart_ptr.cpp │ ├── test_smart_ptr.py │ ├── test_stl.cpp │ ├── test_stl.py │ ├── test_stl_binders.cpp │ ├── test_stl_binders.py │ ├── test_tagbased_polymorphic.cpp │ ├── test_tagbased_polymorphic.py │ ├── test_union.cpp │ ├── test_union.py │ ├── test_virtual_functions.cpp │ ├── test_virtual_functions.py │ ├── valgrind-numpy-scipy.supp │ └── valgrind-python.supp └── tools │ ├── FindCatch.cmake │ ├── FindEigen3.cmake │ ├── FindPythonLibsNew.cmake │ ├── check-style.sh │ ├── cmake_uninstall.cmake.in │ ├── libsize.py │ ├── make_changelog.py │ ├── pybind11Common.cmake │ ├── pybind11Config.cmake.in │ ├── pybind11NewTools.cmake │ ├── pybind11Tools.cmake │ ├── pyproject.toml │ ├── setup_global.py.in │ └── setup_main.py.in └── spdlog-1.8.2 ├── .clang-format ├── .clang-tidy ├── .gitattributes ├── .travis.yml ├── CMakeLists.txt ├── INSTALL ├── LICENSE ├── README.md ├── appveyor.yml ├── bench ├── CMakeLists.txt ├── async_bench.cpp ├── bench.cpp ├── formatter-bench.cpp ├── latency.cpp └── utils.h ├── cmake ├── ide.cmake ├── pch.h.in ├── spdlog.pc.in ├── spdlogCPack.cmake ├── spdlogConfig.cmake.in ├── utils.cmake └── version.rc.in ├── example ├── CMakeLists.txt └── example.cpp ├── include └── spdlog │ ├── async.h │ ├── async_logger-inl.h │ ├── async_logger.h │ ├── cfg │ ├── argv.h │ ├── env.h │ ├── helpers-inl.h │ └── helpers.h │ ├── common-inl.h │ ├── common.h │ ├── details │ ├── backtracer-inl.h │ ├── backtracer.h │ ├── circular_q.h │ ├── console_globals.h │ ├── file_helper-inl.h │ ├── file_helper.h │ ├── fmt_helper.h │ ├── log_msg-inl.h │ ├── log_msg.h │ ├── log_msg_buffer-inl.h │ ├── log_msg_buffer.h │ ├── mpmc_blocking_q.h │ ├── null_mutex.h │ ├── os-inl.h │ ├── os.h │ ├── periodic_worker-inl.h │ ├── periodic_worker.h │ ├── registry-inl.h │ ├── registry.h │ ├── synchronous_factory.h │ ├── tcp_client-windows.h │ ├── tcp_client.h │ ├── thread_pool-inl.h │ ├── thread_pool.h │ └── windows_include.h │ ├── fmt │ ├── bin_to_hex.h │ ├── bundled │ │ ├── LICENSE.rst │ │ ├── chrono.h │ │ ├── color.h │ │ ├── compile.h │ │ ├── core.h │ │ ├── format-inl.h │ │ ├── format.h │ │ ├── locale.h │ │ ├── os.h │ │ ├── ostream.h │ │ ├── posix.h │ │ ├── printf.h │ │ └── ranges.h │ ├── chrono.h │ ├── fmt.h │ └── ostr.h │ ├── formatter.h │ ├── fwd.h │ ├── logger-inl.h │ ├── logger.h │ ├── pattern_formatter-inl.h │ ├── pattern_formatter.h │ ├── sinks │ ├── android_sink.h │ ├── ansicolor_sink-inl.h │ ├── ansicolor_sink.h │ ├── base_sink-inl.h │ ├── base_sink.h │ ├── basic_file_sink-inl.h │ ├── basic_file_sink.h │ ├── daily_file_sink.h │ ├── dist_sink.h │ ├── dup_filter_sink.h │ ├── msvc_sink.h │ ├── null_sink.h │ ├── ostream_sink.h │ ├── ringbuffer_sink.h │ ├── rotating_file_sink-inl.h │ ├── rotating_file_sink.h │ ├── sink-inl.h │ ├── sink.h │ ├── stdout_color_sinks-inl.h │ ├── stdout_color_sinks.h │ ├── stdout_sinks-inl.h │ ├── stdout_sinks.h │ ├── syslog_sink.h │ ├── systemd_sink.h │ ├── tcp_sink.h │ ├── win_eventlog_sink.h │ ├── wincolor_sink-inl.h │ └── wincolor_sink.h │ ├── spdlog-inl.h │ ├── spdlog.h │ ├── stopwatch.h │ ├── tweakme.h │ └── version.h ├── install ├── include │ └── spdlog │ │ ├── async.h │ │ ├── async_logger-inl.h │ │ ├── async_logger.h │ │ ├── cfg │ │ ├── argv.h │ │ ├── env.h │ │ ├── helpers-inl.h │ │ └── helpers.h │ │ ├── common-inl.h │ │ ├── common.h │ │ ├── details │ │ ├── backtracer-inl.h │ │ ├── backtracer.h │ │ ├── circular_q.h │ │ ├── console_globals.h │ │ ├── file_helper-inl.h │ │ ├── file_helper.h │ │ ├── fmt_helper.h │ │ ├── log_msg-inl.h │ │ ├── log_msg.h │ │ ├── log_msg_buffer-inl.h │ │ ├── log_msg_buffer.h │ │ ├── mpmc_blocking_q.h │ │ ├── null_mutex.h │ │ ├── os-inl.h │ │ ├── os.h │ │ ├── periodic_worker-inl.h │ │ ├── periodic_worker.h │ │ ├── registry-inl.h │ │ ├── registry.h │ │ ├── synchronous_factory.h │ │ ├── tcp_client-windows.h │ │ ├── tcp_client.h │ │ ├── thread_pool-inl.h │ │ ├── thread_pool.h │ │ └── windows_include.h │ │ ├── fmt │ │ ├── bin_to_hex.h │ │ ├── bundled │ │ │ ├── LICENSE.rst │ │ │ ├── chrono.h │ │ │ ├── color.h │ │ │ ├── compile.h │ │ │ ├── core.h │ │ │ ├── format-inl.h │ │ │ ├── format.h │ │ │ ├── locale.h │ │ │ ├── os.h │ │ │ ├── ostream.h │ │ │ ├── posix.h │ │ │ ├── printf.h │ │ │ └── ranges.h │ │ ├── chrono.h │ │ ├── fmt.h │ │ └── ostr.h │ │ ├── formatter.h │ │ ├── fwd.h │ │ ├── logger-inl.h │ │ ├── logger.h │ │ ├── pattern_formatter-inl.h │ │ ├── pattern_formatter.h │ │ ├── sinks │ │ ├── android_sink.h │ │ ├── ansicolor_sink-inl.h │ │ ├── ansicolor_sink.h │ │ ├── base_sink-inl.h │ │ ├── base_sink.h │ │ ├── basic_file_sink-inl.h │ │ ├── basic_file_sink.h │ │ ├── daily_file_sink.h │ │ ├── dist_sink.h │ │ ├── dup_filter_sink.h │ │ ├── msvc_sink.h │ │ ├── null_sink.h │ │ ├── ostream_sink.h │ │ ├── ringbuffer_sink.h │ │ ├── rotating_file_sink-inl.h │ │ ├── rotating_file_sink.h │ │ ├── sink-inl.h │ │ ├── sink.h │ │ ├── stdout_color_sinks-inl.h │ │ ├── stdout_color_sinks.h │ │ ├── stdout_sinks-inl.h │ │ ├── stdout_sinks.h │ │ ├── syslog_sink.h │ │ ├── systemd_sink.h │ │ ├── tcp_sink.h │ │ ├── win_eventlog_sink.h │ │ ├── wincolor_sink-inl.h │ │ └── wincolor_sink.h │ │ ├── spdlog-inl.h │ │ ├── spdlog.h │ │ ├── stopwatch.h │ │ ├── tweakme.h │ │ └── version.h └── lib │ ├── cmake │ └── spdlog │ │ ├── spdlogConfig.cmake │ │ ├── spdlogConfigTargets-release.cmake │ │ ├── spdlogConfigTargets.cmake │ │ └── spdlogConfigVersion.cmake │ └── pkgconfig │ └── spdlog.pc ├── logos └── jetbrains-variant-4.svg ├── scripts ├── extract_version.py └── format.sh ├── src ├── async.cpp ├── cfg.cpp ├── color_sinks.cpp ├── file_sinks.cpp ├── fmt.cpp ├── spdlog.cpp └── stdout_sinks.cpp └── tests ├── CMakeLists.txt ├── catch.hpp ├── catch.license ├── includes.h ├── main.cpp ├── test_async.cpp ├── test_backtrace.cpp ├── test_cfg.cpp ├── test_create_dir.cpp ├── test_daily_logger.cpp ├── test_dup_filter.cpp ├── test_errors.cpp ├── test_eventlog.cpp ├── test_file_helper.cpp ├── test_file_logging.cpp ├── test_fmt_helper.cpp ├── test_macros.cpp ├── test_misc.cpp ├── test_mpmc_q.cpp ├── test_pattern_formatter.cpp ├── test_registry.cpp ├── test_sink.h ├── test_stdout_api.cpp ├── test_stopwatch.cpp ├── test_systemd.cpp ├── test_time_point.cpp ├── utils.cpp └── utils.h /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | build* 2 | bindings/python/*.so 3 | bindings/python/build 4 | bindings/python/*.egg-info 5 | -------------------------------------------------------------------------------- /.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Documentation 4 | 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | release: 11 | types: [created] 12 | 13 | jobs: 14 | doc: 15 | runs-on: ubuntu-20.04 16 | container: quay.io/pypa/manylinux2014_x86_64 17 | 18 | env: 19 | LIEF_VERSION: 0.11.5 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | 24 | - name: Build doc 25 | run: | 26 | yum install -y doxygen graphviz rsync 27 | export PATH=/opt/python/cp39-cp39/bin:$PATH 28 | pip install lief==$LIEF_VERSION 29 | pip install -r docs/requirements.txt 30 | curl -sSL -o LIEF.tar.bz2 https://github.com/lief-project/LIEF/releases/download/$LIEF_VERSION/LIEF-${LIEF_VERSION}-Linux-x86_64-manylinux2014.tar.bz2 31 | tar xf LIEF.tar.bz2 && rm LIEF.tar.bz2 && mv LIEF-* LIEF 32 | mkdir build_doc && cd build_doc 33 | cmake -DQBDL_BUILD_DOCS=ON -DCMAKE_BUILD_TYPE=Release -DQBDL_PYTHON_BINDING=ON -DLIEF_DIR=$PWD/../LIEF/share/LIEF/cmake .. 34 | make doc -j$(nproc) 35 | 36 | - uses: actions/upload-artifact@v1 37 | with: 38 | name: qbdl-doc 39 | path: build_doc/docs/qbdl-doc 40 | 41 | - name: Prepare deployment 42 | if: ${{ !github.event.pull_request }} 43 | id: doc_name 44 | run: | 45 | NAME=${GITHUB_REF##*/} 46 | echo "::set-output name=directory::$NAME" 47 | 48 | - name: Deploy to Github Pages 49 | if: ${{ !github.event.pull_request }} 50 | uses: JamesIves/github-pages-deploy-action@4.1.3 51 | with: 52 | branch: gh-pages 53 | folder: build_doc/docs/qbdl-doc 54 | target-folder: ${{ steps.doc_name.outputs.directory }} 55 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.18) 2 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") 3 | set(THIRD_PARTY_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/third-party/") 4 | 5 | project(QBDL VERSION 0.1.0 LANGUAGES CXX) 6 | 7 | option(QBDL_PYTHON_BINDING "Build Python bindings" OFF) 8 | option(QBDL_BUILD_DOCS "Build documentation" OFF) 9 | option(QBDL_BUILD_EXAMPLES "Build examples" ON) 10 | 11 | set(CMAKE_CXX_STANDARD 17) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | # Dependencies 15 | find_package(LIEF REQUIRED COMPONENTS STATIC) 16 | 17 | enable_testing() 18 | add_subdirectory(src) 19 | if (QBDL_BUILD_EXAMPLES) 20 | add_subdirectory(examples) 21 | endif() 22 | if (QBDL_BUILD_DOCS) 23 | add_subdirectory(docs) 24 | endif() 25 | 26 | if(QBDL_PYTHON_BINDING) 27 | add_subdirectory(bindings/python) 28 | endif() 29 | 30 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/QBDLConfig.cmake" 31 | DESTINATION share/QBDL/cmake) 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QuarkslaB Dynamic Loader 2 | 3 | The QuarkslaB Dynamic Linker (QBDL) library aims at providing a modular and 4 | portable way to dynamically load and link binaries. 5 | 6 | ## Documentation 7 | 8 | See [here](https://quarkslab.github.io/QBDL/0.1.0). 9 | 10 | ## Quick example 11 | 12 | Here is a quick example using the Python API to run simple MachO binaries under 13 | Linux: 14 | 15 | ```python 16 | import pyqbdl 17 | import lief 18 | import sys 19 | import ctypes 20 | 21 | class TargetSystem(pyqbdl.engines.Native.TargetSystem): 22 | def __init__(self): 23 | super().__init__(pyqbdl.engines.Native.memory()) 24 | self.libc = ctypes.CDLL("libc.so.6") 25 | 26 | def symlink(self, loader: pyqbdl.Loader, sym: lief.Symbol) -> int: 27 | if not sym.name.startswith("_"): 28 | return 0 29 | ptr = getattr(self.libc, sym.name[1:], 0) 30 | if ptr != 0: 31 | ptr = ctypes.cast(ptr, ctypes.c_void_p).value 32 | return ptr 33 | 34 | loader = pyqbdl.loaders.MachO.from_file(sys.argv[1], pyqbdl.engines.Native.arch(), TargetSystem(), 35 | pyqbdl.Loader.BIND.NOW) 36 | main_type = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_voidp) 37 | main_ptr = main_type(loader.entrypoint) 38 | main_ptr(0, ctypes.c_void_p(0)) 39 | ``` 40 | 41 | For more detailed use cases, please refer to [the documentation](docs/use_cases.rst). 42 | -------------------------------------------------------------------------------- /bindings/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Python3 COMPONENTS Development.Module REQUIRED) 2 | set(PYBIND11_VERSION 2.6.2) 3 | 4 | Python3_add_library(pyqbdl MODULE 5 | pyQBDL.cpp 6 | ) 7 | 8 | set_target_properties(pyqbdl PROPERTIES PREFIX "") 9 | if (UNIX) 10 | set_target_properties(pyqbdl PROPERTIES SUFFIX ".so") 11 | elseif(WIN32) 12 | set_target_properties(pyqbdl PROPERTIES SUFFIX ".pyd") 13 | endif() 14 | 15 | target_include_directories(pyqbdl 16 | PRIVATE 17 | ${THIRD_PARTY_DIRECTORY}/pybind11-${PYBIND11_VERSION}/include) 18 | 19 | target_link_libraries(pyqbdl PRIVATE QBDL) 20 | set_property(TARGET pyqbdl PROPERTY 21 | MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") 22 | -------------------------------------------------------------------------------- /bindings/python/README.md: -------------------------------------------------------------------------------- 1 | ## QBDL Python Bindings 2 | 3 | ### From PyPi 4 | 5 | ```bash 6 | $ pip install [--user] pyqbdl 7 | ``` 8 | 9 | ### From sources 10 | 11 | ```bash 12 | python ./setup.py \ 13 | --lief-dir=/share/cmake \ 14 | --spdlog-dir=/cmake \ 15 | [--ninja] \ 16 | install [--user] 17 | ``` 18 | 19 | -------------------------------------------------------------------------------- /bindings/python/examples/run_macho.py: -------------------------------------------------------------------------------- 1 | import pyqbdl 2 | import lief 3 | import sys 4 | import ctypes 5 | 6 | class TargetSystem(pyqbdl.engines.Native.TargetSystem): 7 | def __init__(self): 8 | super().__init__(pyqbdl.engines.Native.memory()) 9 | self.libc = ctypes.CDLL("libc.so.6") 10 | 11 | def symlink(self, loader: pyqbdl.Loader, sym: lief.Symbol) -> int: 12 | if not sym.name.startswith("_"): 13 | return 0 14 | ptr = getattr(self.libc, sym.name[1:], 0) 15 | if ptr != 0: 16 | ptr = ctypes.cast(ptr, ctypes.c_void_p).value 17 | return ptr 18 | 19 | loader = pyqbdl.loaders.MachO.from_file(sys.argv[1], pyqbdl.engines.Native.arch(), TargetSystem(), 20 | pyqbdl.Loader.BIND.NOW) 21 | 22 | main_type = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_voidp) 23 | main_ptr = main_type(loader.entrypoint) 24 | main_ptr(0, ctypes.c_void_p(0)) 25 | -------------------------------------------------------------------------------- /bindings/python/pyQBDL.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PY_QBDL_H_ 2 | #define PY_QBDL_H_ 3 | 4 | #include 5 | namespace py = pybind11; 6 | 7 | using namespace pybind11::literals; 8 | 9 | namespace QBDL { 10 | void pyinit(py::module &); 11 | void pyinit_engine(py::module &); 12 | void pyinit_loaders(py::module &); 13 | void pyinit_arch(py::module &); 14 | } // namespace QBDL 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /bindings/python/setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = pyqbdl 3 | author = Adrien Guinet, Romain Thomas 4 | classifiers = 5 | Development Status :: 4 - Beta 6 | Programming Language :: Python 7 | Programming Language :: C++ 8 | Topic :: Software Development :: Libraries 9 | 10 | [options] 11 | zip_safe = False 12 | packages = find: 13 | include_package_data = True 14 | python_requires = >=3.6 15 | 16 | [build_ext] 17 | inplace=1 18 | -------------------------------------------------------------------------------- /ci/build_wheels_manylinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Usage: script.sh /path/to/qbdl /path/to/lief python_versions 3 | 4 | set -ex 5 | 6 | QBDL_ROOT=$1 7 | shift 8 | LIEF_DIR=$1 9 | shift 10 | 11 | export MAKEFLAGS="-j$(nproc)" 12 | 13 | cd "$QBDL_ROOT/bindings/python" 14 | for PY in $*; do 15 | /opt/python/$PY/bin/python ./setup.py --lief-dir=$LIEF_DIR bdist_wheel 16 | rm -rf build 17 | done 18 | for f in dist/*.whl; do 19 | auditwheel repair $f 20 | done 21 | 22 | # Tests 23 | 24 | # Download a specific version of miasm 25 | (cd /tmp && git clone https://github.com/cea-sec/miasm && cd miasm && git checkout 6285271a95f3ec9815728fb808a69bb21b50f770) 26 | 27 | for PY in $*; do 28 | PYTHONBIN=/opt/python/$PY/bin/ 29 | $PYTHONBIN/pip install pyparsing future wheelhouse/pyqbdl*$PY*.whl 30 | (cd /tmp/miasm && LDFLAGS="" $PYTHONBIN/python ./setup.py install && rm -rf build) 31 | $PYTHONBIN/python ./examples/miasm_macho_x64.py ../../examples/binaries/macho-x86-64-hello.bin |grep coucou 32 | done 33 | -------------------------------------------------------------------------------- /cmake/QBDLConfig.cmake: -------------------------------------------------------------------------------- 1 | get_filename_component(QBDL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | include("${QBDL_CMAKE_DIR}/QBDLTargets.cmake") 3 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (NOT QBDL_PYTHON_BINDING) 2 | message(FATAL_ERROR "Python bindings must be built to generate the documentation.") 3 | endif() 4 | 5 | add_subdirectory(doxygen) 6 | 7 | find_program(SPHINX_BUILD_BIN NAMES sphinx-build) 8 | 9 | set(QBDL_DOC_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/_build") 10 | set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_doctrees") 11 | set(QBDL_DOC_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/qbdl-doc") 12 | 13 | file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/qbdl_include.py" 14 | CONTENT "import sys,os\nsys.path.insert(0, os.path.abspath(\"$\"))\n") 15 | 16 | configure_file( 17 | "${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" 18 | "${QBDL_DOC_BUILD_DIR}/conf.py" 19 | @ONLY) 20 | 21 | add_custom_target(doc ALL 22 | COMMAND 23 | "${SPHINX_BUILD_BIN}" 24 | -c "${QBDL_DOC_BUILD_DIR}" 25 | -d "${SPHINX_CACHE_DIR}" 26 | "${CMAKE_CURRENT_SOURCE_DIR}" 27 | "${QBDL_DOC_OUT_DIR}" 28 | COMMENT "Building documentation with Sphinx..." 29 | ) 30 | 31 | add_dependencies(doc doc_doxygen QBDL pyqbdl) 32 | -------------------------------------------------------------------------------- /docs/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen REQUIRED) 2 | 3 | set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) 4 | set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) 5 | 6 | configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) 7 | 8 | # note the option ALL which allows to build the docs together with the application 9 | add_custom_target(doc_doxygen ALL 10 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} 11 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 12 | COMMENT "Generating documentation with Doxygen" 13 | # TODO DEPENDS 14 | ) 15 | 16 | set(QBDL_DOXYGEN_XML_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/xml" PARENT_SCOPE) 17 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to QBDL's documentation! 2 | ================================ 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | intro.rst 8 | use_cases.rst 9 | reference_cxx.rst 10 | reference_py.rst 11 | -------------------------------------------------------------------------------- /docs/intro.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ============ 3 | 4 | The QuarkslaB Dynamic Linker (QBDL) library aims at providing a modular and 5 | portable way to dynamically load and link binaries. 6 | 7 | The goals of the library are: 8 | 9 | * provide a simple-to-use abstraction to load dynamically linked binaries 10 | * modular enough to be able to load binaries in foreign systems or lightweight sandboxes (e.g. `Miasm`_'s sandbox, or `Triton`_'s engine) 11 | * support loading and dynamic linking of PE/ELF/MachO binaries 12 | * cross-platform and portable library 13 | 14 | Notable non goals of the library: 15 | 16 | * provide full operating system (re)implementations, like `Wine`_ or 17 | `Darling`_. 18 | * get the best performance out of all dynamic linkers. Said differently, 19 | performance can be scarified for better modularity, in order to make the 20 | library usable in various reverse engineering scenarios. 21 | * supports architectures where pointer values are bigger than 64 bits. 22 | 23 | 24 | .. _Miasm: https://miasm.re/ 25 | .. _Triton: https://triton.quarkslab.com/ 26 | .. _Wine: https://www.winehq.org/ 27 | .. _Darling: https://darlinghq.org/ 28 | -------------------------------------------------------------------------------- /docs/reference_cxx.rst: -------------------------------------------------------------------------------- 1 | C++ API reference 2 | ================= 3 | 4 | .. doxygennamespace:: QBDL 5 | :project: qbdl 6 | :members: 7 | :undoc-members: 8 | -------------------------------------------------------------------------------- /docs/reference_py.rst: -------------------------------------------------------------------------------- 1 | Python API reference 2 | ==================== 3 | 4 | .. automodule:: pyqbdl 5 | :members: 6 | :undoc-members: 7 | 8 | .. automodule:: pyqbdl.loaders 9 | :members: 10 | :undoc-members: 11 | 12 | .. automodule:: pyqbdl.engines 13 | :members: 14 | :undoc-members: 15 | 16 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx_rtd_theme 3 | breathe 4 | -------------------------------------------------------------------------------- /docs/use_cases.rst: -------------------------------------------------------------------------------- 1 | Use cases 2 | ========= 3 | 4 | This section describes use cases of QBDL, with C++ and Python code examples on how to use the library. 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | miasm.rst 10 | macho_linux.rst 11 | anroid_lib.rst 12 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(QBDL_EXAMPLES_BINARIES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/binaries") 2 | add_subdirectory(tools) 3 | -------------------------------------------------------------------------------- /examples/binaries/SECCON2016_whitebox.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/SECCON2016_whitebox.so -------------------------------------------------------------------------------- /examples/binaries/elf-android-arm64-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/elf-android-arm64-hello.bin -------------------------------------------------------------------------------- /examples/binaries/elf-android-x86-64-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/elf-android-x86-64-hello.bin -------------------------------------------------------------------------------- /examples/binaries/elf-linux-x86-64-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/elf-linux-x86-64-hello.bin -------------------------------------------------------------------------------- /examples/binaries/macho-arm64-osx-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/macho-arm64-osx-hello.bin -------------------------------------------------------------------------------- /examples/binaries/macho-arm64-osx-print.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/macho-arm64-osx-print.bin -------------------------------------------------------------------------------- /examples/binaries/macho-x86-64-hello.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/examples/binaries/macho-x86-64-hello.bin -------------------------------------------------------------------------------- /examples/binaries/src/android-test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char **argv) { 6 | __android_log_print(ANDROID_LOG_INFO, "hello", "Hello World"); 7 | printf("Hello from: %d\n", getpid()); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /examples/binaries/src/hello-world.c: -------------------------------------------------------------------------------- 1 | // gcc -O0 -g hello-world.c -o hello-world 2 | #include 3 | #include 4 | 5 | __attribute__((constructor)) void ctor() { printf("In ctor\n"); } 6 | 7 | int main(int argc, char **argv) { 8 | 9 | for (int i = 0; i < argc; ++i) { 10 | printf("argv[%d] = %s", i, argv[i]); 11 | } 12 | return 0; 13 | } 14 | 15 | __attribute__((destructor)) void dtor() { printf("In dtor!\n"); } 16 | -------------------------------------------------------------------------------- /examples/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(elf_run) 2 | if (UNIX) 3 | add_subdirectory(macho_run) 4 | add_subdirectory(pe_run) 5 | add_subdirectory(whitebox_reloaded) 6 | endif() 7 | -------------------------------------------------------------------------------- /examples/tools/elf_run/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(elf_run 2 | main.cpp 3 | ) 4 | target_link_libraries(elf_run PRIVATE QBDL) 5 | if (UNIX) 6 | target_link_libraries(elf_run PRIVATE dl) 7 | endif() 8 | set_target_properties(elf_run PROPERTIES 9 | POSITION_INDEPENDENT_CODE ON 10 | ) 11 | 12 | if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") 13 | add_test(NAME elf_run_simple COMMAND elf_run "${QBDL_EXAMPLES_BINARIES_DIR}/elf-linux-x86-64-hello.bin") 14 | endif() 15 | -------------------------------------------------------------------------------- /examples/tools/macho_run/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(macho_run 2 | main.cpp 3 | darwin_aarch64_libc.cpp 4 | ) 5 | target_link_libraries(macho_run PRIVATE QBDL) 6 | set_target_properties(macho_run PROPERTIES 7 | POSITION_INDEPENDENT_CODE ON 8 | ) 9 | 10 | if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") 11 | add_test(NAME macho_run_simple COMMAND macho_run "${QBDL_EXAMPLES_BINARIES_DIR}/macho-x86-64-hello.bin") 12 | endif() 13 | -------------------------------------------------------------------------------- /examples/tools/macho_run/darwin_aarch64_libc.cpp: -------------------------------------------------------------------------------- 1 | #ifdef __aarch64__ 2 | #include "darwin_aarch64_libc.h" 3 | #include 4 | 5 | int darwin_aarch64_printf(const char *format, ...) { 6 | va_list args; 7 | va_start(args, format); 8 | const int ret = vprintf(format, args); 9 | va_end(args); 10 | return ret; 11 | } 12 | 13 | int darwin_aarch64_puts(const char *format) { return puts(format); } 14 | #endif 15 | -------------------------------------------------------------------------------- /examples/tools/macho_run/darwin_aarch64_libc.h: -------------------------------------------------------------------------------- 1 | #ifndef DARWIN_AARCH64_LIBC 2 | #define DARWIN_AARCH64_LIBC 3 | 4 | extern "C" { 5 | __attribute__((darwin_abi)) int darwin_aarch64_printf(const char *format, ...); 6 | __attribute__((darwin_abi)) int darwin_aarch64_puts(const char *s); 7 | } 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /examples/tools/macho_run/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef __aarch64__ 13 | #include "darwin_aarch64_libc.h" 14 | #define SYM_ARCH(name) darwin_aarch64_##name 15 | #else 16 | #define SYM_ARCH(name) ::name 17 | #endif 18 | 19 | static std::unordered_map SYMS{ 20 | {"_puts", reinterpret_cast(&SYM_ARCH(puts))}, 21 | {"_printf", reinterpret_cast(&SYM_ARCH(printf))}}; 22 | 23 | using namespace QBDL; 24 | 25 | namespace { 26 | struct FinalTargetSystem: public Engines::Native::TargetSystem { 27 | using Engines::Native::TargetSystem::TargetSystem; 28 | 29 | uint64_t symlink(Loader &loader, const LIEF::Symbol &sym) override { 30 | const std::string &name = sym.name(); 31 | auto it_sym = SYMS.find(name); 32 | if (it_sym == std::end(SYMS)) { 33 | fprintf(stderr, "Symbol %s not resolved!\n", name.c_str()); 34 | return 0; 35 | } 36 | return it_sym->second; 37 | } 38 | }; 39 | } 40 | 41 | int main(int argc, char **argv) { 42 | if (argc < 2) { 43 | fprintf(stderr, "Usage: %s args\n", argv[0]); 44 | return EXIT_FAILURE; 45 | } 46 | 47 | auto mem = std::make_unique(); 48 | auto system = std::make_unique(*mem); 49 | 50 | const char *path = argv[1]; 51 | 52 | std::unique_ptr loader = Loaders::MachO::from_file( 53 | path, Engines::Native::arch(), *system, Loader::BIND::NOW); 54 | if (!loader) { 55 | fprintf(stderr, "unable to load binary!\n"); 56 | return EXIT_FAILURE; 57 | } 58 | auto main = reinterpret_cast(loader->entrypoint()); 59 | return main(argc - 1, &argv[1]); 60 | } 61 | -------------------------------------------------------------------------------- /examples/tools/pe_run/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(pe_run 2 | main.cpp 3 | ) 4 | target_link_libraries(pe_run PRIVATE QBDL) 5 | set_target_properties(pe_run PROPERTIES 6 | POSITION_INDEPENDENT_CODE ON 7 | ) 8 | -------------------------------------------------------------------------------- /examples/tools/whitebox_reloaded/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(whitebox_reloaded 2 | main.cpp 3 | ) 4 | target_link_libraries(whitebox_reloaded PRIVATE QBDL dl) 5 | set_target_properties(whitebox_reloaded PROPERTIES 6 | POSITION_INDEPENDENT_CODE ON 7 | ) 8 | -------------------------------------------------------------------------------- /examples/tools/whitebox_reloaded/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | using namespace QBDL; 15 | 16 | namespace { 17 | 18 | struct FinalTargetSystem: public Engines::Native::TargetSystem { 19 | using Engines::Native::TargetSystem::TargetSystem; 20 | inline static void* libc_hdl = dlopen("libc.so.6", RTLD_NOW); 21 | 22 | uint64_t symlink(Loader &loader, const LIEF::Symbol &sym) override { 23 | printf("Resolving %s\n", sym.name().c_str()); 24 | return reinterpret_cast(dlsym(libc_hdl, sym.name().c_str())); 25 | } 26 | }; 27 | 28 | } 29 | 30 | int main(int argc, char **argv) { 31 | if (argc < 2) { 32 | fprintf(stderr, "Usage: %s whitebox.so\n", argv[0]); 33 | return EXIT_FAILURE; 34 | } 35 | 36 | auto mem = std::make_unique(); 37 | auto system = std::make_unique(*mem); 38 | 39 | const char *path = argv[1]; 40 | 41 | std::unique_ptr loader = Loaders::ELF::from_file( 42 | path, *system, Loader::BIND::NOW); 43 | if (!loader) { 44 | fprintf(stderr, "unable to load binary!\n"); 45 | return EXIT_FAILURE; 46 | } 47 | using wb_fcn_t = uint64_t(*)(unsigned char*, unsigned char*); 48 | auto aes_128_encrypt = 49 | reinterpret_cast(loader->get_address("_Z48TfcqPqf1lNhu0DC2qGsAAeML0SEmOBYX4jpYUnyT8qYWIlEqPhS_")); 50 | if (aes_128_encrypt == nullptr) { 51 | fprintf(stderr, "Can't find symbol 'find'\n"); 52 | return 1; 53 | } 54 | unsigned char plaintext[16] = {0}; 55 | unsigned char ciphertext[16]; 56 | 57 | aes_128_encrypt(plaintext, ciphertext); 58 | for (unsigned char c : ciphertext) { 59 | printf("%02x ", c); 60 | } 61 | printf("\n"); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /include/QBDL/Loader.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_LOADER_H_ 2 | #define QBDL_LOADER_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace QBDL { 11 | class TargetSystem; 12 | 13 | /** Base class for a Loader 14 | */ 15 | class QBDL_API Loader { 16 | public: 17 | enum class BIND { NOT_BIND, NOW, LAZY }; 18 | static constexpr inline BIND BIND_DEFAULT = BIND::NOW; 19 | 20 | public: 21 | /** Get the resolved absolute virtual address of a symbol. 22 | */ 23 | virtual uint64_t get_address(const std::string &sym) const = 0; 24 | 25 | /** Compute the absolute virtual address of on offset. This is basically 26 | * `base_address + offset`. 27 | */ 28 | virtual uint64_t get_address(uint64_t offset) const = 0; 29 | 30 | /** Get the absolute virtual address of the entrypoint. 31 | */ 32 | virtual uint64_t entrypoint() const = 0; 33 | 34 | /** Get the absolute virtual address of the base address. 35 | */ 36 | virtual uint64_t base_address() const = 0; 37 | 38 | /** Get the size of the binary after being mapped in memory 39 | */ 40 | virtual uint64_t mem_size() const = 0; 41 | 42 | /** Checks if `ptr` belongs to the memory mapped binary 43 | */ 44 | bool contains_address(uint64_t ptr) const; 45 | 46 | virtual ~Loader(); 47 | 48 | /** Get the architecture targeted by the loaded binary. 49 | */ 50 | virtual Arch arch() const = 0; 51 | 52 | protected: 53 | Loader(); 54 | Loader(TargetSystem &engine); 55 | TargetSystem *engine_{nullptr}; 56 | 57 | private: 58 | DISALLOW_COPY_AND_ASSIGN(Loader); 59 | }; 60 | } // namespace QBDL 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/QBDL/arch.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_ARCH_H_ 2 | #define QBDL_ARCH_H_ 3 | 4 | #include 5 | #include 6 | 7 | namespace LIEF { 8 | class Binary; 9 | } // namespace LIEF 10 | 11 | namespace QBDL { 12 | 13 | /** Define a binary architecture 14 | * 15 | * It is based on LIEF's description of an architecture. Based on this 16 | * description, we need three fields to completely target a binary 17 | * architecture: 18 | * 19 | * - the architecture as per LIEF's description 20 | * - the endianness of the CPU 21 | * - whether the CPU is 64bit 22 | * 23 | * This is a bit unfortunate that LIEF does not have a simple enum that would 24 | * map every possible architectures. 25 | * 26 | * Here are a few common architectures description that are used: 27 | * 28 | * \code 29 | * const auto x86 = Arch{LIEF::ARCHITECTURES::X86, LIEF::ENDIANNESS::LITTLE, 30 | * false}; const auto x64 = Arch{LIEF::ARCHITECTURES::X86, 31 | * LIEF::ENDIANNESS::LITTLE, true}; const auto armv8 = 32 | * Arch{LIEF::ARCHITECTURES::ARM64, LIEF::ENDIANNESS::LITTLE, true}; \endcode 33 | */ 34 | struct Arch { 35 | /** Architecture as defined by LIEF. 36 | */ 37 | LIEF::ARCHITECTURES arch; 38 | 39 | /** Endianness of the binary's architecture 40 | */ 41 | LIEF::ENDIANNESS endianness; 42 | 43 | /** Whether this is a 64bit CPU 44 | */ 45 | bool is64; 46 | 47 | constexpr Arch(LIEF::ARCHITECTURES arch, LIEF::ENDIANNESS endianness, 48 | bool is64) 49 | : arch(arch), endianness(endianness), is64(is64) {} 50 | 51 | constexpr bool operator==(Arch const &o) const { 52 | return arch == o.arch && endianness == o.endianness && is64 == o.is64; 53 | } 54 | 55 | constexpr bool operator!=(Arch const &o) const { return !(*this == o); } 56 | 57 | /** Construct an `Arch` object from a LIEF binary object 58 | */ 59 | static QBDL_API Arch from_bin(LIEF::Binary const &bin); 60 | }; 61 | 62 | } // namespace QBDL 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/QBDL/exports.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_EXPORTS_HPP 2 | #define QBDL_EXPORTS_HPP 3 | 4 | #if defined _WIN32 || defined __CYGWIN__ 5 | #define QBDL_HELPER_IMPORT __declspec(dllimport) 6 | #define QBDL_HELPER_EXPORT __declspec(dllexport) 7 | #define QBDL_HELPER_LOCAL 8 | #else 9 | #define QBDL_HELPER_IMPORT __attribute__((visibility("default"))) 10 | #define QBDL_HELPER_EXPORT __attribute__((visibility("default"))) 11 | #define QBDL_HELPER_LOCAL __attribute__((visibility("hidden"))) 12 | #endif 13 | 14 | #ifdef QBDL_EXPORTS 15 | #define QBDL_API QBDL_HELPER_EXPORT 16 | #define QBDL_LOCAL QBDL_HELPER_LOCAL 17 | #elif defined(QBDL_STATIC) 18 | #define QBDL_API 19 | #define QBDL_LOCAL 20 | #else 21 | #define QBDL_API QBDL_HELPER_IMPORT 22 | #define QBDL_LOCAL QBDL_HELPER_LOCAL 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/QBDL/log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_LOG_H_ 2 | #define QBDL_LOG_H_ 3 | 4 | namespace QBDL { 5 | 6 | enum LogLevel : int { 7 | trace, 8 | debug, 9 | info, 10 | warn, 11 | err, 12 | critical, 13 | }; 14 | 15 | void setLogLevel(LogLevel level); 16 | 17 | } // namespace QBDL 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/QBDL/macros.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_MACROS_H_ 2 | #define QBDL_MACROS_H_ 3 | 4 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 5 | TypeName(const TypeName &) = delete; \ 6 | void operator=(const TypeName &) = delete 7 | 8 | #define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ 9 | TypeName() = delete; \ 10 | DISALLOW_COPY_AND_ASSIGN(TypeName) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /include/QBDL/utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_UTILS_H_ 2 | #define QBDL_UTILS_H_ 3 | 4 | #include 5 | 6 | static inline constexpr uintptr_t page_mask(uintptr_t page_size) { 7 | return ~(page_size - 1); 8 | } 9 | 10 | static inline constexpr uintptr_t page_start(uintptr_t address, 11 | uintptr_t page_size = 0x1000) { 12 | return address & page_mask(page_size); 13 | } 14 | 15 | static inline constexpr uintptr_t page_align(uintptr_t address, 16 | uintptr_t page_size = 0x1000) { 17 | return (address + (page_size - 1)) & page_mask(page_size); 18 | } 19 | 20 | static inline constexpr uintptr_t page_offset(uintptr_t address, 21 | uintptr_t page_size = 0x1000) { 22 | return (address & (page_size - 1)); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/Engine.cpp: -------------------------------------------------------------------------------- 1 | #include "intmem.hpp" 2 | #include 3 | #include 4 | 5 | namespace QBDL { 6 | 7 | namespace { 8 | template struct Tag { using type = T; }; 9 | 10 | template 11 | static constexpr auto archPtrType(Arch const &arch, Func F) { 12 | // TODO: more precise tests 13 | if (arch.is64) { 14 | return F(Tag{}); 15 | } 16 | return F(Tag{}); 17 | } 18 | 19 | template 20 | void write_ptr_impl(TargetMemory &mem, uint64_t addr, uint64_t ptr, 21 | LIEF::ENDIANNESS endian) { 22 | T data; 23 | const T ptr_ = static_cast(ptr); 24 | if (endian == LIEF::ENDIANNESS::ENDIAN_LITTLE) { 25 | intmem::store_le(&data, ptr_); 26 | } else { 27 | intmem::store_be(&data, ptr_); 28 | } 29 | mem.write(addr, &data, sizeof(data)); 30 | } 31 | template 32 | uint64_t read_ptr_impl(TargetMemory &mem, uint64_t addr, 33 | LIEF::ENDIANNESS endian) { 34 | T ret; 35 | mem.read(&ret, addr, sizeof(ret)); 36 | if (endian == LIEF::ENDIANNESS::ENDIAN_LITTLE) { 37 | return intmem::bswap_le(ret); 38 | } 39 | return intmem::bswap_be(ret); 40 | } 41 | 42 | } // namespace 43 | 44 | void TargetMemory::write_ptr(Arch const &arch, uint64_t addr, uint64_t ptr) { 45 | archPtrType(arch, [&](auto tag) { 46 | using T = typename decltype(tag)::type; 47 | write_ptr_impl(*this, addr, ptr, arch.endianness); 48 | }); 49 | } 50 | 51 | uint64_t TargetMemory::read_ptr(Arch const &arch, uint64_t addr) { 52 | return archPtrType(arch, [&](auto tag) { 53 | using T = typename decltype(tag)::type; 54 | return read_ptr_impl(*this, addr, arch.endianness); 55 | }); 56 | } 57 | 58 | } // namespace QBDL 59 | -------------------------------------------------------------------------------- /src/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace QBDL { 4 | 5 | Loader::Loader() = default; 6 | Loader::Loader(TargetSystem &engine) : engine_{&engine} {} 7 | Loader::~Loader() = default; 8 | 9 | bool Loader::contains_address(uint64_t ptr) const { 10 | const uint64_t BA = base_address(); 11 | return (ptr >= BA) && (ptr < (BA + mem_size())); 12 | } 13 | 14 | } // namespace QBDL 15 | -------------------------------------------------------------------------------- /src/arch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace QBDL { 5 | 6 | Arch Arch::from_bin(LIEF::Binary const &bin) { 7 | const auto &header = bin.header(); 8 | return {header.architecture(), header.endianness(), header.is_64()}; 9 | } 10 | 11 | } // namespace QBDL 12 | -------------------------------------------------------------------------------- /src/engines/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(QBDL_ENGINE_SRC 2 | "${CMAKE_CURRENT_LIST_DIR}/Native.cpp" 3 | ) 4 | 5 | set(QBDL_ENGINE_INC ) 6 | 7 | target_sources(QBDL PRIVATE 8 | ${QBDL_ENGINE_SRC} 9 | ${QBDL_ENGINE_INC} 10 | ) 11 | -------------------------------------------------------------------------------- /src/engines/Native.cpp: -------------------------------------------------------------------------------- 1 | #include "logging.hpp" 2 | #include 3 | 4 | static_assert( 5 | sizeof(uintptr_t) <= sizeof(uint64_t), 6 | "native target with pointer integer type > 64 bits are not supported"); 7 | 8 | namespace QBDL::Engines::Native { 9 | 10 | void TargetMemory::write(uint64_t addr, const void *ptr, size_t size) { 11 | memcpy(reinterpret_cast(addr), ptr, size); 12 | } 13 | 14 | void TargetMemory::read(void *buf, uint64_t addr, size_t size) { 15 | memcpy(buf, reinterpret_cast(addr), size); 16 | } 17 | 18 | bool TargetSystem::supports(LIEF::Binary const &bin) { 19 | return Arch::from_bin(bin) == arch(); 20 | } 21 | 22 | uint64_t TargetSystem::base_address_hint(uint64_t binary_base_address, 23 | uint64_t virtual_size) { 24 | // Mean a random base address 25 | return 0; 26 | } 27 | 28 | QBDL_API std::unique_ptr memory() { 29 | QBDL::TargetMemory *Ret = new Native::TargetMemory{}; 30 | return std::unique_ptr{Ret}; 31 | } 32 | 33 | } 34 | 35 | #if defined(__linux__) or defined(__APPLE__) 36 | #include "native_posix.inc" 37 | #elif defined(_WIN32) 38 | #include "native_win.inc" 39 | #else 40 | #error Unsupported OS 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /src/engines/native_posix.inc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace QBDL::Engines::Native { 4 | 5 | uint64_t TargetMemory::mmap(uint64_t addr, size_t size) { 6 | void *ret = ::mmap(reinterpret_cast(addr), size, 7 | PROT_READ | PROT_WRITE | PROT_EXEC, 8 | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 9 | 10 | if (ret == MAP_FAILED) { 11 | Logger::err("Error while trying mmap: {}", strerror(errno)); 12 | return 0; 13 | } 14 | 15 | Logger::debug("mmap(0x{:x}, 0x{:x}): 0x{:x}", addr, size, 16 | reinterpret_cast(ret)); 17 | return reinterpret_cast(ret); 18 | } 19 | 20 | bool TargetMemory::mprotect(uint64_t addr, size_t size, int prot) { 21 | Logger::warn("mprotect not implemented!"); 22 | return false; 23 | } 24 | 25 | } // namespace QBDL::Engines::Native 26 | -------------------------------------------------------------------------------- /src/engines/native_win.inc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace QBDL::Engines::Native { 5 | 6 | uint64_t TargetMemory::mmap(uint64_t addr, size_t size) { 7 | void *ret = VirtualAlloc((void*)addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 8 | 9 | if (ret == nullptr) { 10 | Logger::err("Error while trying mmap: {}", strerror(errno)); 11 | return 0; 12 | } 13 | 14 | Logger::debug("mmap(0x{:x}, 0x{:x}): 0x{:x}", addr, size, 15 | reinterpret_cast(ret)); 16 | return reinterpret_cast(ret); 17 | } 18 | 19 | bool TargetMemory::mprotect(uint64_t addr, size_t size, int prot) { 20 | Logger::warn("mprotect not implemented!"); 21 | return false; 22 | } 23 | 24 | } // namespace QBDL::Engines::Native 25 | -------------------------------------------------------------------------------- /src/loaders/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(QBDL_LOADERS_SRC 2 | "${CMAKE_CURRENT_LIST_DIR}/MachO.cpp" 3 | "${CMAKE_CURRENT_LIST_DIR}/ELF.cpp" 4 | "${CMAKE_CURRENT_LIST_DIR}/PE.cpp" 5 | ) 6 | 7 | set(QBDL_LOADERS_INC ) 8 | 9 | target_sources(QBDL PRIVATE 10 | ${QBDL_LOADERS_SRC} 11 | ${QBDL_LOADERS_INC} 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /src/logging.cpp: -------------------------------------------------------------------------------- 1 | #include "logging.hpp" 2 | #include "spdlog/sinks/stdout_color_sinks.h" 3 | 4 | namespace QBDL { 5 | 6 | Logger::Logger(void) { 7 | sink_ = spdlog::stdout_color_mt("qbdl"); 8 | sink_->set_level(spdlog::level::trace); 9 | sink_->set_pattern("%v"); 10 | sink_->flush_on(spdlog::level::trace); 11 | } 12 | 13 | void Logger::setLogLevel(LogLevel level) { 14 | spdlog::level::level_enum slevel; 15 | switch (level) { 16 | #define LLMAP(ours, lspd) \ 17 | case LogLevel::ours: \ 18 | slevel = spdlog::level::lspd; \ 19 | break; 20 | 21 | LLMAP(trace, trace) 22 | LLMAP(debug, debug) 23 | LLMAP(info, info) 24 | LLMAP(warn, warn) 25 | LLMAP(err, err) 26 | LLMAP(critical, critical) 27 | #undef LLMAP 28 | } 29 | sink_->set_level(slevel); 30 | } 31 | 32 | static std::unique_ptr logger_instance_; 33 | 34 | Logger &Logger::instance() { 35 | if (!logger_instance_) { 36 | logger_instance_.reset(new Logger{}); 37 | } 38 | return *logger_instance_; 39 | } 40 | 41 | void setLogLevel(LogLevel level) { Logger::instance().setLogLevel(level); } 42 | 43 | } // namespace QBDL 44 | -------------------------------------------------------------------------------- /src/logging.hpp: -------------------------------------------------------------------------------- 1 | #ifndef QBDL_LOGGING_H_ 2 | #define QBDL_LOGGING_H_ 3 | 4 | #include "spdlog/spdlog.h" 5 | #include 6 | 7 | #ifdef NDEBUG 8 | static constexpr bool QBDL_DEBUG_ENABLED = false; 9 | #else 10 | static constexpr bool QBDL_DEBUG_ENABLED = true; 11 | #endif 12 | 13 | #define QBDL_DEBUG(...) QBDL::Logger::debug(__VA_ARGS__) 14 | #define QBDL_INFO(...) QBDL::Logger::info(__VA_ARGS__) 15 | #define QBDL_ERROR(...) QBDL::Logger::err(__VA_ARGS__) 16 | #define QBDL_WARN(...) QBDL::Logger::warn(__VA_ARGS__) 17 | 18 | namespace QBDL { 19 | class Logger { 20 | public: 21 | static Logger &instance(); 22 | 23 | void setLogLevel(LogLevel level); 24 | 25 | template 26 | static void debug(const char *fmt, const Args &...args) { 27 | if constexpr (QBDL_DEBUG_ENABLED) { 28 | Logger::instance().sink_->debug(fmt, args...); 29 | } 30 | } 31 | 32 | template 33 | static void info(const char *fmt, const Args &...args) { 34 | Logger::instance().sink_->info(fmt, args...); 35 | } 36 | 37 | template 38 | static void err(const char *fmt, const Args &...args) { 39 | Logger::instance().sink_->error(fmt, args...); 40 | } 41 | 42 | template 43 | static void warn(const char *fmt, const Args &...args) { 44 | Logger::instance().sink_->warn(fmt, args...); 45 | } 46 | 47 | private: 48 | Logger(void); 49 | Logger(const Logger &) = delete; 50 | Logger &operator=(const Logger &) = delete; 51 | 52 | std::shared_ptr sink_; 53 | }; 54 | 55 | } // namespace QBDL 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: 3 | - Visual Studio 2015 4 | test: off 5 | skip_branch_with_pr: true 6 | build: 7 | parallel: true 8 | platform: 9 | - x86 10 | environment: 11 | matrix: 12 | - PYTHON: 36 13 | CONFIG: Debug 14 | - PYTHON: 27 15 | CONFIG: Debug 16 | install: 17 | - ps: | 18 | $env:CMAKE_GENERATOR = "Visual Studio 14 2015" 19 | if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } 20 | $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" 21 | python -W ignore -m pip install --upgrade pip wheel 22 | python -W ignore -m pip install pytest numpy --no-warn-script-location pytest-timeout 23 | - ps: | 24 | Start-FileDownload 'https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip' 25 | 7z x eigen-3.3.7.zip -y > $null 26 | $env:CMAKE_INCLUDE_PATH = "eigen-3.3.7;$env:CMAKE_INCLUDE_PATH" 27 | build_script: 28 | - cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" 29 | -DCMAKE_CXX_STANDARD=14 30 | -DPYBIND11_WERROR=ON 31 | -DDOWNLOAD_CATCH=ON 32 | -DCMAKE_SUPPRESS_REGENERATION=1 33 | . 34 | - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 35 | - cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% 36 | - cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% 37 | on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* 38 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # See all possible options and defaults with: 3 | # clang-format --style=llvm --dump-config 4 | BasedOnStyle: LLVM 5 | AccessModifierOffset: -4 6 | AlignConsecutiveAssignments: true 7 | AlwaysBreakTemplateDeclarations: Yes 8 | BinPackArguments: false 9 | BinPackParameters: false 10 | BreakBeforeBinaryOperators: All 11 | BreakConstructorInitializers: BeforeColon 12 | ColumnLimit: 99 13 | IndentCaseLabels: true 14 | IndentPPDirectives: AfterHash 15 | IndentWidth: 4 16 | Language: Cpp 17 | SpaceAfterCStyleCast: true 18 | # SpaceInEmptyBlock: true # too new 19 | Standard: Cpp11 20 | TabWidth: 4 21 | ... 22 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.clang-tidy: -------------------------------------------------------------------------------- 1 | FormatStyle: file 2 | 3 | Checks: ' 4 | llvm-namespace-comment, 5 | modernize-use-override, 6 | readability-container-size-empty, 7 | modernize-use-using, 8 | modernize-use-equals-default, 9 | modernize-use-auto, 10 | modernize-use-emplace, 11 | ' 12 | 13 | HeaderFilterRegex: 'pybind11/.*h' 14 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: File an issue about a bug 4 | title: "[BUG] " 5 | --- 6 | 7 | 8 | Make sure you've completed the following steps before submitting your issue -- thank you! 9 | 10 | 1. Make sure you've read the [documentation][]. Your issue may be addressed there. 11 | 2. Search the [issue tracker][] to verify that this hasn't already been reported. +1 or comment there if it has. 12 | 3. Consider asking first in the [Gitter chat room][]. 13 | 4. Include a self-contained and minimal piece of code that reproduces the problem. If that's not possible, try to make the description as clear as possible. 14 | a. If possible, make a PR with a new, failing test to give us a starting point to work on! 15 | 16 | [documentation]: https://pybind11.readthedocs.io 17 | [issue tracker]: https://github.com/pybind/pybind11/issues 18 | [Gitter chat room]: https://gitter.im/pybind/Lobby 19 | 20 | *After reading, remove this checklist and the template text in parentheses below.* 21 | 22 | ## Issue description 23 | 24 | (Provide a short description, state the expected behavior and what actually happens.) 25 | 26 | ## Reproducible example code 27 | 28 | (The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.) 29 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Gitter room 4 | url: https://gitter.im/pybind/Lobby 5 | about: A room for discussing pybind11 with an active community 6 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: File an issue about adding a feature 4 | title: "[FEAT] " 5 | --- 6 | 7 | 8 | Make sure you've completed the following steps before submitting your issue -- thank you! 9 | 10 | 1. Check if your feature has already been mentioned / rejected / planned in other issues. 11 | 2. If those resources didn't help, consider asking in the [Gitter chat room][] to see if this is interesting / useful to a larger audience and possible to implement reasonably, 12 | 4. If you have a useful feature that passes the previous items (or not suitable for chat), please fill in the details below. 13 | 14 | [Gitter chat room]: https://gitter.im/pybind/Lobby 15 | 16 | *After reading, remove this checklist.* 17 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: File an issue about unexplained behavior 4 | title: "[QUESTION] " 5 | --- 6 | 7 | If you have a question, please check the following first: 8 | 9 | 1. Check if your question has already been answered in the [FAQ][] section. 10 | 2. Make sure you've read the [documentation][]. Your issue may be addressed there. 11 | 3. If those resources didn't help and you only have a short question (not a bug report), consider asking in the [Gitter chat room][] 12 | 4. Search the [issue tracker][], including the closed issues, to see if your question has already been asked/answered. +1 or comment if it has been asked but has no answer. 13 | 5. If you have a more complex question which is not answered in the previous items (or not suitable for chat), please fill in the details below. 14 | 6. Include a self-contained and minimal piece of code that illustrates your question. If that's not possible, try to make the description as clear as possible. 15 | 16 | [FAQ]: http://pybind11.readthedocs.io/en/latest/faq.html 17 | [documentation]: https://pybind11.readthedocs.io 18 | [issue tracker]: https://github.com/pybind/pybind11/issues 19 | [Gitter chat room]: https://gitter.im/pybind/Lobby 20 | 21 | *After reading, remove this checklist.* 22 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Maintain dependencies for GitHub Actions 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "daily" 8 | ignore: 9 | # Official actions have moving tags like v1 10 | # that are used, so they don't need updates here 11 | - dependency-name: "actions/checkout" 12 | - dependency-name: "actions/setup-python" 13 | - dependency-name: "actions/cache" 14 | - dependency-name: "actions/upload-artifact" 15 | - dependency-name: "actions/download-artifact" 16 | - dependency-name: "actions/labeler" 17 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/labeler.yml: -------------------------------------------------------------------------------- 1 | docs: 2 | - any: 3 | - 'docs/**/*.rst' 4 | - '!docs/changelog.rst' 5 | - '!docs/upgrade.rst' 6 | 7 | ci: 8 | - '.github/workflows/*.yml' 9 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/labeler_merged.yml: -------------------------------------------------------------------------------- 1 | needs changelog: 2 | - all: 3 | - '!docs/changelog.rst' 4 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Description 2 | 3 | 4 | 5 | 6 | ## Suggested changelog entry: 7 | 8 | 10 | 11 | ```rst 12 | 13 | ``` 14 | 15 | 16 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/workflows/format.yml: -------------------------------------------------------------------------------- 1 | # This is a format job. Pre-commit has a first-party GitHub action, so we use 2 | # that: https://github.com/pre-commit/action 3 | 4 | name: Format 5 | 6 | on: 7 | workflow_dispatch: 8 | pull_request: 9 | push: 10 | branches: 11 | - master 12 | - stable 13 | - "v*" 14 | 15 | jobs: 16 | pre-commit: 17 | name: Format 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v2 21 | - uses: actions/setup-python@v2 22 | - uses: pre-commit/action@v2.0.0 23 | with: 24 | # Slow hooks are marked with manual - slow is okay here, run them too 25 | extra_args: --hook-stage manual --all-files 26 | 27 | clang-tidy: 28 | name: Clang-Tidy 29 | runs-on: ubuntu-latest 30 | container: silkeh/clang:10 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - name: Install requirements 35 | run: apt-get update && apt-get install -y python3-dev python3-pytest 36 | 37 | - name: Configure 38 | run: > 39 | cmake -S . -B build 40 | -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--warnings-as-errors=*" 41 | -DDOWNLOAD_EIGEN=ON 42 | -DDOWNLOAD_CATCH=ON 43 | -DCMAKE_CXX_STANDARD=17 44 | 45 | - name: Build 46 | run: cmake --build build -j 2 47 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.github/workflows/labeler.yml: -------------------------------------------------------------------------------- 1 | name: Labeler 2 | on: 3 | pull_request_target: 4 | types: [closed] 5 | 6 | jobs: 7 | label: 8 | name: Labeler 9 | runs-on: ubuntu-latest 10 | steps: 11 | 12 | - uses: actions/labeler@main 13 | if: github.event.pull_request.merged == true 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | configuration-path: .github/labeler_merged.yml 17 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | python: 2 | version: 3 3 | requirements_file: docs/requirements.txt 4 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Wenzel Jakob , All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of 29 | external contributions to this project including patches, pull requests, etc. 30 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include pybind11/include/pybind11 *.h 2 | recursive-include pybind11 *.py 3 | recursive-include pybind11 py.typed 4 | recursive-include pybind11 *.pyi 5 | include pybind11/share/cmake/pybind11/*.cmake 6 | include LICENSE README.rst pyproject.toml setup.py setup.cfg 7 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = pybind11 2 | INPUT = ../include/pybind11/ 3 | RECURSIVE = YES 4 | 5 | GENERATE_HTML = NO 6 | GENERATE_LATEX = NO 7 | GENERATE_XML = YES 8 | XML_OUTPUT = .build/doxygenxml 9 | XML_PROGRAMLISTING = YES 10 | 11 | MACRO_EXPANSION = YES 12 | EXPAND_ONLY_PREDEF = YES 13 | EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION 14 | 15 | ALIASES = "rst=\verbatim embed:rst" 16 | ALIASES += "endrst=\endverbatim" 17 | 18 | QUIET = YES 19 | WARNINGS = YES 20 | WARN_IF_UNDOCUMENTED = NO 21 | PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \ 22 | PY_MAJOR_VERSION=3 \ 23 | PYBIND11_NOINLINE 24 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | .wy-table-responsive table td, 2 | .wy-table-responsive table th { 3 | white-space: initial !important; 4 | } 5 | .rst-content table.docutils td { 6 | vertical-align: top !important; 7 | } 8 | div[class^='highlight'] pre { 9 | white-space: pre; 10 | white-space: pre-wrap; 11 | } 12 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/advanced/cast/index.rst: -------------------------------------------------------------------------------- 1 | .. _type-conversions: 2 | 3 | Type conversions 4 | ################ 5 | 6 | Apart from enabling cross-language function calls, a fundamental problem 7 | that a binding tool like pybind11 must address is to provide access to 8 | native Python types in C++ and vice versa. There are three fundamentally 9 | different ways to do this—which approach is preferable for a particular type 10 | depends on the situation at hand. 11 | 12 | 1. Use a native C++ type everywhere. In this case, the type must be wrapped 13 | using pybind11-generated bindings so that Python can interact with it. 14 | 15 | 2. Use a native Python type everywhere. It will need to be wrapped so that 16 | C++ functions can interact with it. 17 | 18 | 3. Use a native C++ type on the C++ side and a native Python type on the 19 | Python side. pybind11 refers to this as a *type conversion*. 20 | 21 | Type conversions are the most "natural" option in the sense that native 22 | (non-wrapped) types are used everywhere. The main downside is that a copy 23 | of the data must be made on every Python ↔ C++ transition: this is 24 | needed since the C++ and Python versions of the same type generally won't 25 | have the same memory layout. 26 | 27 | pybind11 can perform many kinds of conversions automatically. An overview 28 | is provided in the table ":ref:`conversion_table`". 29 | 30 | The following subsections discuss the differences between these options in more 31 | detail. The main focus in this section is on type conversions, which represent 32 | the last case of the above list. 33 | 34 | .. toctree:: 35 | :maxdepth: 1 36 | 37 | overview 38 | strings 39 | stl 40 | functional 41 | chrono 42 | eigen 43 | custom 44 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/advanced/pycpp/index.rst: -------------------------------------------------------------------------------- 1 | Python C++ interface 2 | #################### 3 | 4 | pybind11 exposes Python types and functions using thin C++ wrappers, which 5 | makes it possible to conveniently call Python code from C++ without resorting 6 | to Python's C API. 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | object 12 | numpy 13 | utilities 14 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/cmake/index.rst: -------------------------------------------------------------------------------- 1 | CMake helpers 2 | ------------- 3 | 4 | Pybind11 can be used with ``add_subdirectory(extern/pybind11)``, or from an 5 | install with ``find_package(pybind11 CONFIG)``. The interface provided in 6 | either case is functionally identical. 7 | 8 | .. cmake-module:: ../../tools/pybind11Config.cmake.in 9 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. only:: latex 2 | 3 | Intro 4 | ===== 5 | 6 | .. include:: readme.rst 7 | 8 | .. only:: not latex 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | changelog 16 | upgrade 17 | 18 | .. toctree:: 19 | :caption: The Basics 20 | :maxdepth: 2 21 | 22 | installing 23 | basics 24 | classes 25 | compiling 26 | 27 | .. toctree:: 28 | :caption: Advanced Topics 29 | :maxdepth: 2 30 | 31 | advanced/functions 32 | advanced/classes 33 | advanced/exceptions 34 | advanced/smart_ptrs 35 | advanced/cast/index 36 | advanced/pycpp/index 37 | advanced/embedding 38 | advanced/misc 39 | 40 | .. toctree:: 41 | :caption: Extra Information 42 | :maxdepth: 1 43 | 44 | faq 45 | benchmark 46 | limitations 47 | reference 48 | cmake/index 49 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/pybind11-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/docs/pybind11-logo.png -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/pybind11_vs_boost_python1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/docs/pybind11_vs_boost_python1.png -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/pybind11_vs_boost_python2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/docs/pybind11_vs_boost_python2.png -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | breathe==4.25.1 2 | commonmark==0.9.1 3 | recommonmark==0.7.1 4 | sphinx==3.3.1 5 | sphinx_rtd_theme==0.5.0 6 | sphinxcontrib-moderncmakedomain==3.17 7 | sphinxcontrib-svg2pdfconverter==1.1.0 8 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/include/pybind11/detail/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | #include 17 | #endif 18 | 19 | #include "common.h" 20 | 21 | PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 22 | PYBIND11_NAMESPACE_BEGIN(detail) 23 | /// Erase all occurrences of a substring 24 | inline void erase_all(std::string &string, const std::string &search) { 25 | for (size_t pos = 0;;) { 26 | pos = string.find(search, pos); 27 | if (pos == std::string::npos) break; 28 | string.erase(pos, search.length()); 29 | } 30 | } 31 | 32 | PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { 33 | #if defined(__GNUG__) 34 | int status = 0; 35 | std::unique_ptr res { 36 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; 37 | if (status == 0) 38 | name = res.get(); 39 | #else 40 | detail::erase_all(name, "class "); 41 | detail::erase_all(name, "struct "); 42 | detail::erase_all(name, "enum "); 43 | #endif 44 | detail::erase_all(name, "pybind11::"); 45 | } 46 | PYBIND11_NAMESPACE_END(detail) 47 | 48 | /// Return a string representation of a C++ type 49 | template static std::string type_id() { 50 | std::string name(typeid(T).name()); 51 | detail::clean_type_id(name); 52 | return name; 53 | } 54 | 55 | PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) 56 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ._version import version_info, __version__ 4 | from .commands import get_include, get_cmake_dir 5 | 6 | 7 | __all__ = ( 8 | "version_info", 9 | "__version__", 10 | "get_include", 11 | "get_cmake_dir", 12 | ) 13 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/__main__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import print_function 3 | 4 | import argparse 5 | import sys 6 | import sysconfig 7 | 8 | from .commands import get_include, get_cmake_dir 9 | 10 | 11 | def print_includes(): 12 | # type: () -> None 13 | dirs = [ 14 | sysconfig.get_path("include"), 15 | sysconfig.get_path("platinclude"), 16 | get_include(), 17 | ] 18 | 19 | # Make unique but preserve order 20 | unique_dirs = [] 21 | for d in dirs: 22 | if d and d not in unique_dirs: 23 | unique_dirs.append(d) 24 | 25 | print(" ".join("-I" + d for d in unique_dirs)) 26 | 27 | 28 | def main(): 29 | # type: () -> None 30 | 31 | parser = argparse.ArgumentParser() 32 | parser.add_argument( 33 | "--includes", 34 | action="store_true", 35 | help="Include flags for both pybind11 and Python headers.", 36 | ) 37 | parser.add_argument( 38 | "--cmakedir", 39 | action="store_true", 40 | help="Print the CMake module directory, ideal for setting -Dpybind11_ROOT in CMake.", 41 | ) 42 | args = parser.parse_args() 43 | if not sys.argv[1:]: 44 | parser.print_help() 45 | if args.includes: 46 | print_includes() 47 | if args.cmakedir: 48 | print(get_cmake_dir()) 49 | 50 | 51 | if __name__ == "__main__": 52 | main() 53 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/_version.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | def _to_int(s): 5 | try: 6 | return int(s) 7 | except ValueError: 8 | return s 9 | 10 | 11 | __version__ = "2.6.2" 12 | version_info = tuple(_to_int(s) for s in __version__.split(".")) 13 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/_version.pyi: -------------------------------------------------------------------------------- 1 | from typing import Union, Tuple 2 | 3 | def _to_int(s: str) -> Union[int, str]: ... 4 | 5 | __version__: str 6 | version_info: Tuple[Union[int, str], ...] 7 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/commands.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | 4 | 5 | DIR = os.path.abspath(os.path.dirname(__file__)) 6 | 7 | 8 | def get_include(user=False): 9 | # type: (bool) -> str 10 | installed_path = os.path.join(DIR, "include") 11 | source_path = os.path.join(os.path.dirname(DIR), "include") 12 | return installed_path if os.path.exists(installed_path) else source_path 13 | 14 | 15 | def get_cmake_dir(): 16 | # type: () -> str 17 | cmake_installed_path = os.path.join(DIR, "share", "cmake", "pybind11") 18 | if os.path.exists(cmake_installed_path): 19 | return cmake_installed_path 20 | else: 21 | msg = "pybind11 not installed, installation required to access the CMake files" 22 | raise ImportError(msg) 23 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pybind11/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/pybind11/py.typed -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel", "cmake>=3.18", "ninja"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/env.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import platform 3 | import sys 4 | 5 | LINUX = sys.platform.startswith("linux") 6 | MACOS = sys.platform.startswith("darwin") 7 | WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin") 8 | 9 | CPYTHON = platform.python_implementation() == "CPython" 10 | PYPY = platform.python_implementation() == "PyPy" 11 | 12 | PY2 = sys.version_info.major == 2 13 | 14 | PY = sys.version_info 15 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/extra_python_package/pytest.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/tests/extra_python_package/pytest.ini -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/extra_setuptools/pytest.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quarkslab/QBDL/856e0513b69a7d6076e485e01219cf2433911e10/third-party/pybind11-2.6.2/tests/extra_setuptools/pytest.ini -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | minversion = 3.1 3 | norecursedirs = test_* extra_* 4 | xfail_strict = True 5 | addopts = 6 | # show summary of skipped tests 7 | -rs 8 | # capture only Python print and C++ py::print, but not C output (low-level Python errors) 9 | --capture=sys 10 | # enable all warnings 11 | -Wa 12 | filterwarnings = 13 | # make warnings into errors but ignore certain third-party extension issues 14 | error 15 | # importing scipy submodules on some version of Python 16 | ignore::ImportWarning 17 | # bogus numpy ABI warning (see numpy/#432) 18 | ignore:.*numpy.dtype size changed.*:RuntimeWarning 19 | ignore:.*numpy.ufunc size changed.*:RuntimeWarning 20 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | --extra-index-url https://antocuni.github.io/pypy-wheels/manylinux2010/ 2 | numpy==1.16.6; python_version<"3.6" and sys_platform!="win32" 3 | numpy==1.18.0; platform_python_implementation=="PyPy" and sys_platform=="darwin" and python_version>="3.6" 4 | numpy==1.19.3; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version>="3.6" and python_version<"3.10" 5 | pytest==4.6.9; python_version<"3.5" 6 | pytest==6.1.2; python_version=="3.5" 7 | pytest==6.2.1; python_version>="3.6" 8 | pytest-timeout 9 | scipy==1.2.3; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version<"3.6" 10 | scipy==1.5.4; (platform_python_implementation!="PyPy" or sys_platform=="linux") and python_version>="3.6" and python_version<"3.10" 11 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_async.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_async.cpp -- __await__ support 3 | 4 | Copyright (c) 2019 Google Inc. 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #include "pybind11_tests.h" 11 | 12 | TEST_SUBMODULE(async_module, m) { 13 | struct DoesNotSupportAsync {}; 14 | py::class_(m, "DoesNotSupportAsync") 15 | .def(py::init<>()); 16 | struct SupportsAsync {}; 17 | py::class_(m, "SupportsAsync") 18 | .def(py::init<>()) 19 | .def("__await__", [](const SupportsAsync& self) -> py::object { 20 | static_cast(self); 21 | py::object loop = py::module_::import("asyncio.events").attr("get_event_loop")(); 22 | py::object f = loop.attr("create_future")(); 23 | f.attr("set_result")(5); 24 | return f.attr("__await__")(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_async.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | asyncio = pytest.importorskip("asyncio") 5 | m = pytest.importorskip("pybind11_tests.async_module") 6 | 7 | 8 | @pytest.fixture 9 | def event_loop(): 10 | loop = asyncio.new_event_loop() 11 | yield loop 12 | loop.close() 13 | 14 | 15 | async def get_await_result(x): 16 | return await x 17 | 18 | 19 | def test_await(event_loop): 20 | assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync())) 21 | 22 | 23 | def test_await_missing(event_loop): 24 | with pytest.raises(TypeError): 25 | event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync())) 26 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/embed.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_EMBEDDED_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | 8 | int main(int argc, char *argv[]) { 9 | if (argc != 2) 10 | throw std::runtime_error("Expected test.py file as the first argument"); 11 | auto test_py_file = argv[1]; 12 | 13 | py::scoped_interpreter guard{}; 14 | 15 | auto m = py::module_::import("test_cmake_build"); 16 | if (m.attr("add")(1, 2).cast() != 3) 17 | throw std::runtime_error("embed.cpp failed"); 18 | 19 | py::module_::import("sys").attr("argv") = py::make_tuple("test.py", "embed.cpp"); 20 | py::eval_file(test_py_file, py::globals()); 21 | } 22 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/installed_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 4 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 5 | # the behavior using the following workaround: 6 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 7 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 8 | else() 9 | cmake_policy(VERSION 3.18) 10 | endif() 11 | 12 | project(test_installed_embed CXX) 13 | 14 | find_package(pybind11 CONFIG REQUIRED) 15 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 16 | 17 | add_executable(test_installed_embed ../embed.cpp) 18 | target_link_libraries(test_installed_embed PRIVATE pybind11::embed) 19 | set_target_properties(test_installed_embed PROPERTIES OUTPUT_NAME test_cmake_build) 20 | 21 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::embed). 22 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 23 | set_target_properties(test_installed_embed PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 24 | 25 | add_custom_target(check_installed_embed $ 26 | ${PROJECT_SOURCE_DIR}/../test.py) 27 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/installed_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | project(test_installed_module CXX) 3 | 4 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 5 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 6 | # the behavior using the following workaround: 7 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 8 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 9 | else() 10 | cmake_policy(VERSION 3.18) 11 | endif() 12 | 13 | project(test_installed_function CXX) 14 | 15 | find_package(pybind11 CONFIG REQUIRED) 16 | message( 17 | STATUS "Found pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}: ${pybind11_INCLUDE_DIRS}") 18 | 19 | pybind11_add_module(test_installed_function SHARED NO_EXTRAS ../main.cpp) 20 | set_target_properties(test_installed_function PROPERTIES OUTPUT_NAME test_cmake_build) 21 | 22 | if(DEFINED Python_EXECUTABLE) 23 | set(_Python_EXECUTABLE "${Python_EXECUTABLE}") 24 | elseif(DEFINED PYTHON_EXECUTABLE) 25 | set(_Python_EXECUTABLE "${PYTHON_EXECUTABLE}") 26 | else() 27 | message(FATAL_ERROR "No Python executable defined (should not be possible at this stage)") 28 | endif() 29 | 30 | add_custom_target( 31 | check_installed_function 32 | ${CMAKE_COMMAND} 33 | -E 34 | env 35 | PYTHONPATH=$ 36 | ${_Python_EXECUTABLE} 37 | ${PROJECT_SOURCE_DIR}/../test.py 38 | ${PROJECT_NAME}) 39 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/installed_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 4 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 5 | # the behavior using the following workaround: 6 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 7 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 8 | else() 9 | cmake_policy(VERSION 3.18) 10 | endif() 11 | 12 | project(test_installed_target CXX) 13 | 14 | find_package(pybind11 CONFIG REQUIRED) 15 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 16 | 17 | add_library(test_installed_target MODULE ../main.cpp) 18 | 19 | target_link_libraries(test_installed_target PRIVATE pybind11::module) 20 | set_target_properties(test_installed_target PROPERTIES OUTPUT_NAME test_cmake_build) 21 | 22 | # Make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 23 | pybind11_extension(test_installed_target) 24 | 25 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module). 26 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 27 | set_target_properties(test_installed_target PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 28 | 29 | if(DEFINED Python_EXECUTABLE) 30 | set(_Python_EXECUTABLE "${Python_EXECUTABLE}") 31 | elseif(DEFINED PYTHON_EXECUTABLE) 32 | set(_Python_EXECUTABLE "${PYTHON_EXECUTABLE}") 33 | else() 34 | message(FATAL_ERROR "No Python executable defined (should not be possible at this stage)") 35 | endif() 36 | 37 | add_custom_target( 38 | check_installed_target 39 | ${CMAKE_COMMAND} 40 | -E 41 | env 42 | PYTHONPATH=$ 43 | ${_Python_EXECUTABLE} 44 | ${PROJECT_SOURCE_DIR}/../test.py 45 | ${PROJECT_NAME}) 46 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 4 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 5 | # the behavior using the following workaround: 6 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 7 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 8 | else() 9 | cmake_policy(VERSION 3.18) 10 | endif() 11 | 12 | project(test_subdirectory_embed CXX) 13 | 14 | set(PYBIND11_INSTALL 15 | ON 16 | CACHE BOOL "") 17 | set(PYBIND11_EXPORT_NAME test_export) 18 | 19 | add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) 20 | 21 | # Test basic target functionality 22 | add_executable(test_subdirectory_embed ../embed.cpp) 23 | target_link_libraries(test_subdirectory_embed PRIVATE pybind11::embed) 24 | set_target_properties(test_subdirectory_embed PROPERTIES OUTPUT_NAME test_cmake_build) 25 | 26 | add_custom_target(check_subdirectory_embed $ 27 | "${PROJECT_SOURCE_DIR}/../test.py") 28 | 29 | # Test custom export group -- PYBIND11_EXPORT_NAME 30 | add_library(test_embed_lib ../embed.cpp) 31 | target_link_libraries(test_embed_lib PRIVATE pybind11::embed) 32 | 33 | install( 34 | TARGETS test_embed_lib 35 | EXPORT test_export 36 | ARCHIVE DESTINATION bin 37 | LIBRARY DESTINATION lib 38 | RUNTIME DESTINATION lib) 39 | install(EXPORT test_export DESTINATION lib/cmake/test_export/test_export-Targets.cmake) 40 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/subdirectory_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 4 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 5 | # the behavior using the following workaround: 6 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 7 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 8 | else() 9 | cmake_policy(VERSION 3.18) 10 | endif() 11 | 12 | project(test_subdirectory_function CXX) 13 | 14 | add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) 15 | pybind11_add_module(test_subdirectory_function ../main.cpp) 16 | set_target_properties(test_subdirectory_function PROPERTIES OUTPUT_NAME test_cmake_build) 17 | 18 | if(DEFINED Python_EXECUTABLE) 19 | set(_Python_EXECUTABLE "${Python_EXECUTABLE}") 20 | elseif(DEFINED PYTHON_EXECUTABLE) 21 | set(_Python_EXECUTABLE "${PYTHON_EXECUTABLE}") 22 | else() 23 | message(FATAL_ERROR "No Python executable defined (should not be possible at this stage)") 24 | endif() 25 | 26 | add_custom_target( 27 | check_subdirectory_function 28 | ${CMAKE_COMMAND} 29 | -E 30 | env 31 | PYTHONPATH=$ 32 | ${_Python_EXECUTABLE} 33 | ${PROJECT_SOURCE_DIR}/../test.py 34 | ${PROJECT_NAME}) 35 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/subdirectory_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4) 2 | 3 | # The `cmake_minimum_required(VERSION 3.4...3.18)` syntax does not work with 4 | # some versions of VS that have a patched CMake 3.11. This forces us to emulate 5 | # the behavior using the following workaround: 6 | if(${CMAKE_VERSION} VERSION_LESS 3.18) 7 | cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 8 | else() 9 | cmake_policy(VERSION 3.18) 10 | endif() 11 | 12 | project(test_subdirectory_target CXX) 13 | 14 | add_subdirectory("${pybind11_SOURCE_DIR}" pybind11) 15 | 16 | add_library(test_subdirectory_target MODULE ../main.cpp) 17 | set_target_properties(test_subdirectory_target PROPERTIES OUTPUT_NAME test_cmake_build) 18 | 19 | target_link_libraries(test_subdirectory_target PRIVATE pybind11::module) 20 | 21 | # Make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 22 | pybind11_extension(test_subdirectory_target) 23 | 24 | if(DEFINED Python_EXECUTABLE) 25 | set(_Python_EXECUTABLE "${Python_EXECUTABLE}") 26 | elseif(DEFINED PYTHON_EXECUTABLE) 27 | set(_Python_EXECUTABLE "${PYTHON_EXECUTABLE}") 28 | else() 29 | message(FATAL_ERROR "No Python executable defined (should not be possible at this stage)") 30 | endif() 31 | 32 | add_custom_target( 33 | check_subdirectory_target 34 | ${CMAKE_COMMAND} 35 | -E 36 | env 37 | PYTHONPATH=$ 38 | ${_Python_EXECUTABLE} 39 | ${PROJECT_SOURCE_DIR}/../test.py 40 | ${PROJECT_NAME}) 41 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_cmake_build/test.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | import test_cmake_build 4 | 5 | assert test_cmake_build.add(1, 2) == 3 6 | print("{} imports, runs, and adds: 1 + 2 = 3".format(sys.argv[1])) 7 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_constants_and_functions.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | m = pytest.importorskip("pybind11_tests.constants_and_functions") 5 | 6 | 7 | def test_constants(): 8 | assert m.some_constant == 14 9 | 10 | 11 | def test_function_overloading(): 12 | assert m.test_function() == "test_function()" 13 | assert m.test_function(7) == "test_function(7)" 14 | assert m.test_function(m.MyEnum.EFirstEntry) == "test_function(enum=1)" 15 | assert m.test_function(m.MyEnum.ESecondEntry) == "test_function(enum=2)" 16 | 17 | assert m.test_function() == "test_function()" 18 | assert m.test_function("abcd") == "test_function(char *)" 19 | assert m.test_function(1, 1.0) == "test_function(int, float)" 20 | assert m.test_function(1, 1.0) == "test_function(int, float)" 21 | assert m.test_function(2.0, 2) == "test_function(float, int)" 22 | 23 | 24 | def test_bytes(): 25 | assert m.print_bytes(m.return_bytes()) == "bytes[1 0 2 0]" 26 | 27 | 28 | def test_exception_specifiers(): 29 | c = m.C() 30 | assert c.m1(2) == 1 31 | assert c.m2(3) == 1 32 | assert c.m3(5) == 2 33 | assert c.m4(7) == 3 34 | assert c.m5(10) == 5 35 | assert c.m6(14) == 8 36 | assert c.m7(20) == 13 37 | assert c.m8(29) == 21 38 | 39 | assert m.f1(33) == 34 40 | assert m.f2(53) == 55 41 | assert m.f3(86) == 89 42 | assert m.f4(140) == 144 43 | 44 | 45 | def test_function_record_leaks(): 46 | class RaisingRepr: 47 | def __repr__(self): 48 | raise RuntimeError("Surprise!") 49 | 50 | with pytest.raises(RuntimeError): 51 | m.register_large_capture_with_invalid_arguments(m) 52 | with pytest.raises(RuntimeError): 53 | m.register_with_raising_repr(m, RaisingRepr()) 54 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_docstring_options.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import docstring_options as m 3 | 4 | 5 | def test_docstring_options(): 6 | # options.disable_function_signatures() 7 | assert not m.test_function1.__doc__ 8 | 9 | assert m.test_function2.__doc__ == "A custom docstring" 10 | 11 | # docstring specified on just the first overload definition: 12 | assert m.test_overloaded1.__doc__ == "Overload docstring" 13 | 14 | # docstring on both overloads: 15 | assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2" 16 | 17 | # docstring on only second overload: 18 | assert m.test_overloaded3.__doc__ == "Overload docstr" 19 | 20 | # options.enable_function_signatures() 21 | assert m.test_function3.__doc__.startswith("test_function3(a: int, b: int) -> None") 22 | 23 | assert m.test_function4.__doc__.startswith("test_function4(a: int, b: int) -> None") 24 | assert m.test_function4.__doc__.endswith("A custom docstring\n") 25 | 26 | # options.disable_function_signatures() 27 | # options.disable_user_defined_docstrings() 28 | assert not m.test_function5.__doc__ 29 | 30 | # nested options.enable_user_defined_docstrings() 31 | assert m.test_function6.__doc__ == "A custom docstring" 32 | 33 | # RAII destructor 34 | assert m.test_function7.__doc__.startswith("test_function7(a: int, b: int) -> None") 35 | assert m.test_function7.__doc__.endswith("A custom docstring\n") 36 | 37 | # when all options are disabled, no docstring (instead of an empty one) should be generated 38 | assert m.test_function8.__doc__ is None 39 | 40 | # Suppression of user-defined docstrings for non-function objects 41 | assert not m.DocstringTestFoo.__doc__ 42 | assert not m.DocstringTestFoo.value_prop.__doc__ 43 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | possibly_uninitialized(PYTHON_MODULE_EXTENSION Python_INTERPRETER_ID) 2 | 3 | if("${PYTHON_MODULE_EXTENSION}" MATCHES "pypy" OR "${Python_INTERPRETER_ID}" STREQUAL "PyPy") 4 | message(STATUS "Skipping embed test on PyPy") 5 | add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported. 6 | set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}") 7 | return() 8 | endif() 9 | 10 | find_package(Catch 2.13.2) 11 | 12 | if(CATCH_FOUND) 13 | message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}") 14 | else() 15 | message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers" 16 | " manually or use `cmake -DDOWNLOAD_CATCH=ON` to fetch them automatically.") 17 | return() 18 | endif() 19 | 20 | find_package(Threads REQUIRED) 21 | 22 | add_executable(test_embed catch.cpp test_interpreter.cpp) 23 | pybind11_enable_warnings(test_embed) 24 | 25 | target_link_libraries(test_embed PRIVATE pybind11::embed Catch2::Catch2 Threads::Threads) 26 | 27 | if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 28 | file(COPY test_interpreter.py DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") 29 | endif() 30 | 31 | add_custom_target( 32 | cpptest 33 | COMMAND "$" 34 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") 35 | 36 | pybind11_add_module(external_module THIN_LTO external_module.cpp) 37 | set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY 38 | "${CMAKE_CURRENT_BINARY_DIR}") 39 | foreach(config ${CMAKE_CONFIGURATION_TYPES}) 40 | string(TOUPPER ${config} config) 41 | set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${config} 42 | "${CMAKE_CURRENT_BINARY_DIR}") 43 | endforeach() 44 | add_dependencies(cpptest external_module) 45 | 46 | add_dependencies(check cpptest) 47 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_embed/catch.cpp: -------------------------------------------------------------------------------- 1 | // The Catch implementation is compiled here. This is a standalone 2 | // translation unit to avoid recompiling it for every test change. 3 | 4 | #include 5 | 6 | #ifdef _MSC_VER 7 | // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch 8 | // 2.0.1; this should be fixed in the next catch release after 2.0.1). 9 | # pragma warning(disable: 4996) 10 | #endif 11 | 12 | #define CATCH_CONFIG_RUNNER 13 | #include 14 | 15 | namespace py = pybind11; 16 | 17 | int main(int argc, char *argv[]) { 18 | py::scoped_interpreter guard{}; 19 | auto result = Catch::Session().run(argc, argv); 20 | 21 | return result < 0xff ? result : 0xff; 22 | } 23 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_embed/external_module.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace py = pybind11; 4 | 5 | /* Simple test module/test class to check that the referenced internals data of external pybind11 6 | * modules aren't preserved over a finalize/initialize. 7 | */ 8 | 9 | PYBIND11_MODULE(external_module, m) { 10 | class A { 11 | public: 12 | A(int value) : v{value} {}; 13 | int v; 14 | }; 15 | 16 | py::class_(m, "A") 17 | .def(py::init()) 18 | .def_readwrite("value", &A::v); 19 | 20 | m.def("internals_at", []() { 21 | return reinterpret_cast(&py::detail::get_internals()); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_embed/test_interpreter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from widget_module import Widget 3 | 4 | 5 | class DerivedWidget(Widget): 6 | def __init__(self, message): 7 | super(DerivedWidget, self).__init__(message) 8 | 9 | def the_answer(self): 10 | return 42 11 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_eval.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import os 3 | 4 | import pytest 5 | 6 | import env # noqa: F401 7 | 8 | from pybind11_tests import eval_ as m 9 | 10 | 11 | def test_evals(capture): 12 | with capture: 13 | assert m.test_eval_statements() 14 | assert capture == "Hello World!" 15 | 16 | assert m.test_eval() 17 | assert m.test_eval_single_statement() 18 | 19 | assert m.test_eval_failure() 20 | 21 | 22 | @pytest.mark.xfail("env.PYPY and not env.PY2", raises=RuntimeError) 23 | def test_eval_file(): 24 | filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py") 25 | assert m.test_eval_file(filename) 26 | 27 | assert m.test_eval_file_failure() 28 | 29 | 30 | def test_eval_empty_globals(): 31 | assert "__builtins__" in m.eval_empty_globals(None) 32 | 33 | g = {} 34 | assert "__builtins__" in m.eval_empty_globals(g) 35 | assert "__builtins__" in g 36 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_eval_call.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # This file is called from 'test_eval.py' 3 | 4 | if "call_test2" in locals(): 5 | call_test2(y) # noqa: F821 undefined name 6 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_gil_scoped.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_gil_scoped.cpp -- acquire and release gil 3 | 4 | Copyright (c) 2017 Borja Zarco (Google LLC) 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #include "pybind11_tests.h" 11 | #include 12 | 13 | 14 | class VirtClass { 15 | public: 16 | virtual ~VirtClass() = default; 17 | VirtClass() = default; 18 | VirtClass(const VirtClass&) = delete; 19 | virtual void virtual_func() {} 20 | virtual void pure_virtual_func() = 0; 21 | }; 22 | 23 | class PyVirtClass : public VirtClass { 24 | void virtual_func() override { 25 | PYBIND11_OVERRIDE(void, VirtClass, virtual_func,); 26 | } 27 | void pure_virtual_func() override { 28 | PYBIND11_OVERRIDE_PURE(void, VirtClass, pure_virtual_func,); 29 | } 30 | }; 31 | 32 | TEST_SUBMODULE(gil_scoped, m) { 33 | py::class_(m, "VirtClass") 34 | .def(py::init<>()) 35 | .def("virtual_func", &VirtClass::virtual_func) 36 | .def("pure_virtual_func", &VirtClass::pure_virtual_func); 37 | 38 | m.def("test_callback_py_obj", 39 | [](py::object func) { func(); }); 40 | m.def("test_callback_std_func", 41 | [](const std::function &func) { func(); }); 42 | m.def("test_callback_virtual_func", 43 | [](VirtClass &virt) { virt.virtual_func(); }); 44 | m.def("test_callback_pure_virtual_func", 45 | [](VirtClass &virt) { virt.pure_virtual_func(); }); 46 | m.def("test_cross_module_gil", 47 | []() { 48 | auto cm = py::module_::import("cross_module_gil_utils"); 49 | auto gil_acquire = reinterpret_cast( 50 | PyLong_AsVoidPtr(cm.attr("gil_acquire_funcaddr").ptr())); 51 | py::gil_scoped_release gil_release; 52 | gil_acquire(); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_pickling.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pytest 3 | 4 | import env # noqa: F401 5 | 6 | from pybind11_tests import pickling as m 7 | 8 | try: 9 | import cPickle as pickle # Use cPickle on Python 2.7 10 | except ImportError: 11 | import pickle 12 | 13 | 14 | @pytest.mark.parametrize("cls_name", ["Pickleable", "PickleableNew"]) 15 | def test_roundtrip(cls_name): 16 | cls = getattr(m, cls_name) 17 | p = cls("test_value") 18 | p.setExtra1(15) 19 | p.setExtra2(48) 20 | 21 | data = pickle.dumps(p, 2) # Must use pickle protocol >= 2 22 | p2 = pickle.loads(data) 23 | assert p2.value() == p.value() 24 | assert p2.extra1() == p.extra1() 25 | assert p2.extra2() == p.extra2() 26 | 27 | 28 | @pytest.mark.xfail("env.PYPY") 29 | @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"]) 30 | def test_roundtrip_with_dict(cls_name): 31 | cls = getattr(m, cls_name) 32 | p = cls("test_value") 33 | p.extra = 15 34 | p.dynamic = "Attribute" 35 | 36 | data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL) 37 | p2 = pickle.loads(data) 38 | assert p2.value == p.value 39 | assert p2.extra == p.extra 40 | assert p2.dynamic == p.dynamic 41 | 42 | 43 | def test_enum_pickle(): 44 | from pybind11_tests import enums as e 45 | 46 | data = pickle.dumps(e.EOne, 2) 47 | assert e.EOne == pickle.loads(data) 48 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_tagbased_polymorphic.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import tagbased_polymorphic as m 3 | 4 | 5 | def test_downcast(): 6 | zoo = m.create_zoo() 7 | assert [type(animal) for animal in zoo] == [ 8 | m.Labrador, 9 | m.Dog, 10 | m.Chihuahua, 11 | m.Cat, 12 | m.Panther, 13 | ] 14 | assert [animal.name for animal in zoo] == [ 15 | "Fido", 16 | "Ginger", 17 | "Hertzl", 18 | "Tiger", 19 | "Leo", 20 | ] 21 | zoo[1].sound = "woooooo" 22 | assert [dog.bark() for dog in zoo[:3]] == [ 23 | "Labrador Fido goes WOOF!", 24 | "Dog Ginger goes woooooo", 25 | "Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles", 26 | ] 27 | assert [cat.purr() for cat in zoo[3:]] == ["mrowr", "mrrrRRRRRR"] 28 | zoo[0].excitement -= 1000 29 | assert zoo[0].excitement == 14000 30 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_union.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_class.cpp -- test py::class_ definitions and basic functionality 3 | 4 | Copyright (c) 2019 Roland Dreier 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #include "pybind11_tests.h" 11 | 12 | TEST_SUBMODULE(union_, m) { 13 | union TestUnion { 14 | int value_int; 15 | unsigned value_uint; 16 | }; 17 | 18 | py::class_(m, "TestUnion") 19 | .def(py::init<>()) 20 | .def_readonly("as_int", &TestUnion::value_int) 21 | .def_readwrite("as_uint", &TestUnion::value_uint); 22 | } 23 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tests/test_union.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from pybind11_tests import union_ as m 3 | 4 | 5 | def test_union(): 6 | instance = m.TestUnion() 7 | 8 | instance.as_uint = 10 9 | assert instance.as_int == 10 10 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/check-style.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Script to check include/test code for common pybind11 code style errors. 4 | # 5 | # This script currently checks for 6 | # 7 | # 1. missing space between keyword and parenthesis, e.g.: for(, if(, while( 8 | # 2. Missing space between right parenthesis and brace, e.g. 'for (...){' 9 | # 3. opening brace on its own line. It should always be on the same line as the 10 | # if/while/for/do statement. 11 | # 12 | # Invoke as: tools/check-style.sh 13 | # 14 | 15 | check_style_errors=0 16 | IFS=$'\n' 17 | 18 | 19 | found="$(grep '\<\(if\|for\|while\|catch\)(\|){' $@ -rn --color=always)" 20 | if [ -n "$found" ]; then 21 | echo -e '\033[31;01mError: found the following coding style problems:\033[0m' 22 | check_style_errors=1 23 | echo "$found" | sed -e 's/^/ /' 24 | fi 25 | 26 | found="$(awk ' 27 | function prefix(filename, lineno) { 28 | return " \033[35m" filename "\033[36m:\033[32m" lineno "\033[36m:\033[0m" 29 | } 30 | function mark(pattern, string) { sub(pattern, "\033[01;31m&\033[0m", string); return string } 31 | last && /^\s*{/ { 32 | print prefix(FILENAME, FNR-1) mark("\\)\\s*$", last) 33 | print prefix(FILENAME, FNR) mark("^\\s*{", $0) 34 | last="" 35 | } 36 | { last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" } 37 | ' $(find include -type f) $@)" 38 | if [ -n "$found" ]; then 39 | check_style_errors=1 40 | echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m' 41 | echo "$found" 42 | fi 43 | 44 | exit $check_style_errors 45 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake 2 | 3 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 5 | endif() 6 | 7 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program( 13 | "@CMAKE_COMMAND@" ARGS 14 | "-E remove \"$ENV{DESTDIR}${file}\"" 15 | OUTPUT_VARIABLE rm_out 16 | RETURN_VALUE rm_retval) 17 | if(NOT "${rm_retval}" STREQUAL 0) 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 19 | endif() 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 22 | endif() 23 | endforeach() 24 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/libsize.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from __future__ import print_function, division 3 | import os 4 | import sys 5 | 6 | # Internal build script for generating debugging test .so size. 7 | # Usage: 8 | # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the 9 | # size in it, then overwrites save.txt with the new size for future runs. 10 | 11 | if len(sys.argv) != 3: 12 | sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt") 13 | 14 | lib = sys.argv[1] 15 | save = sys.argv[2] 16 | 17 | if not os.path.exists(lib): 18 | sys.exit("Error: requested file ({}) does not exist".format(lib)) 19 | 20 | libsize = os.path.getsize(lib) 21 | 22 | print("------", os.path.basename(lib), "file size:", libsize, end="") 23 | 24 | if os.path.exists(save): 25 | with open(save) as sf: 26 | oldsize = int(sf.readline()) 27 | 28 | if oldsize > 0: 29 | change = libsize - oldsize 30 | if change == 0: 31 | print(" (no change)") 32 | else: 33 | print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize)) 34 | else: 35 | print() 36 | 37 | with open(save, "w") as sf: 38 | sf.write(str(libsize)) 39 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/make_changelog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import re 5 | 6 | import ghapi.all 7 | 8 | from rich import print 9 | from rich.syntax import Syntax 10 | 11 | 12 | ENTRY = re.compile( 13 | r""" 14 | Suggested \s changelog \s entry: 15 | .* 16 | ```rst 17 | \s* 18 | (.*?) 19 | \s* 20 | ``` 21 | """, 22 | re.DOTALL | re.VERBOSE, 23 | ) 24 | 25 | print() 26 | 27 | 28 | api = ghapi.all.GhApi(owner="pybind", repo="pybind11") 29 | 30 | issues = api.issues.list_for_repo(labels="needs changelog", state="closed") 31 | missing = [] 32 | 33 | for issue in issues: 34 | changelog = ENTRY.findall(issue.body) 35 | if changelog: 36 | (msg,) = changelog 37 | if not msg.startswith("* "): 38 | msg = "* " + msg 39 | if not msg.endswith("."): 40 | msg += "." 41 | 42 | msg += f"\n `#{issue.number} <{issue.html_url}>`_" 43 | 44 | print(Syntax(msg, "rst", theme="ansi_light")) 45 | print() 46 | 47 | else: 48 | missing.append(issue) 49 | 50 | if missing: 51 | print() 52 | print("[blue]" + "-" * 30) 53 | print() 54 | 55 | for issue in missing: 56 | print(f"[red bold]Missing:[/red bold][red] {issue.title}") 57 | print(f"[red] {issue.html_url}\n") 58 | 59 | print("[bold]Template:\n") 60 | msg = "## Suggested changelog entry:\n\n```rst\n\n```" 61 | print(Syntax(msg, "md", theme="ansi_light")) 62 | 63 | print() 64 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /third-party/pybind11-2.6.2/tools/setup_main.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Setup script (in the sdist or in tools/setup_main.py in the repository) 5 | 6 | from setuptools import setup 7 | 8 | cmdclass = {} 9 | $extra_cmd 10 | 11 | setup( 12 | name="pybind11", 13 | version="$version", 14 | download_url='https://github.com/pybind/pybind11/tarball/v$version', 15 | packages=[ 16 | "pybind11", 17 | "pybind11.include.pybind11", 18 | "pybind11.include.pybind11.detail", 19 | "pybind11.share.cmake.pybind11", 20 | ], 21 | package_data={ 22 | "pybind11": ["py.typed", "*.pyi"], 23 | "pybind11.include.pybind11": ["*.h"], 24 | "pybind11.include.pybind11.detail": ["*.h"], 25 | "pybind11.share.cmake.pybind11": ["*.cmake"], 26 | }, 27 | extras_require={ 28 | "global": ["pybind11_global==$version"] 29 | }, 30 | entry_points={ 31 | "console_scripts": [ 32 | "pybind11-config = pybind11.__main__:main", 33 | ] 34 | }, 35 | cmdclass=cmdclass 36 | ) 37 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'cppcoreguidelines-*, 2 | performance-*, 3 | modernize-*, 4 | google-*, 5 | misc-*, 6 | cert-*, 7 | readability-*, 8 | clang-analyzer-*, 9 | -performance-unnecessary-value-param, 10 | -modernize-use-trailing-return-type, 11 | -google-runtime-references, 12 | -misc-non-private-member-variables-in-classes, 13 | -readability-braces-around-statements, 14 | -google-readability-braces-around-statements, 15 | -cppcoreguidelines-avoid-magic-numbers, 16 | -readability-magic-numbers, 17 | -readability-magic-numbers, 18 | -cppcoreguidelines-pro-type-vararg, 19 | -cppcoreguidelines-pro-bounds-pointer-arithmetic, 20 | -cppcoreguidelines-avoid-c-arrays, 21 | -modernize-avoid-c-arrays, 22 | -cppcoreguidelines-pro-bounds-array-to-pointer-decay, 23 | -readability-named-parameter, 24 | -cert-env33-c 25 | ' 26 | 27 | 28 | WarningsAsErrors: '' 29 | HeaderFilterRegex: '*spdlog/[^f].*' 30 | AnalyzeTemporaryDtors: false 31 | FormatStyle: none 32 | 33 | CheckOptions: 34 | - key: google-readability-braces-around-statements.ShortStatementLines 35 | value: '1' 36 | - key: google-readability-function-size.StatementThreshold 37 | value: '800' 38 | - key: google-readability-namespace-comments.ShortNamespaceLines 39 | value: '10' 40 | - key: google-readability-namespace-comments.SpacesBeforeComments 41 | value: '2' 42 | - key: modernize-loop-convert.MaxCopySize 43 | value: '16' 44 | - key: modernize-loop-convert.MinConfidence 45 | value: reasonable 46 | - key: modernize-loop-convert.NamingStyle 47 | value: CamelCase 48 | - key: modernize-pass-by-value.IncludeStyle 49 | value: llvm 50 | - key: modernize-replace-auto-ptr.IncludeStyle 51 | value: llvm 52 | - key: modernize-use-nullptr.NullMacros 53 | value: 'NULL' 54 | 55 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=false 2 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/INSTALL: -------------------------------------------------------------------------------- 1 | Header only version: 2 | ================================================================== 3 | Just copy the files to your build tree and use a C++11 compiler. 4 | Or use CMake: 5 | add_executable(example_header_only example.cpp) 6 | target_link_libraries(example_header_only spdlog::spdlog_header_only) 7 | 8 | 9 | Compiled library version: 10 | ================================================================== 11 | CMake: 12 | add_executable(example example.cpp) 13 | target_link_libraries(example spdlog::spdlog) 14 | 15 | Or copy src/spdlog.cpp to your build tree and pass the -DSPDLOG_COMPILED_LIB to the compiler. 16 | 17 | Tested on: 18 | gcc 4.8.1 and above 19 | clang 3.5 20 | Visual Studio 2013 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Gabi Melman. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -- NOTE: Third party dependency used by this software -- 24 | This software depends on the fmt lib (MIT License), 25 | and users must comply to its license: https://github.com/fmtlib/fmt/blob/master/LICENSE.rst 26 | 27 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: Visual Studio 2017 3 | environment: 4 | matrix: 5 | - GENERATOR: '"Visual Studio 14 2015"' 6 | BUILD_TYPE: Debug 7 | WCHAR: 'OFF' 8 | BUILD_SHARED: 'OFF' 9 | - GENERATOR: '"Visual Studio 14 2015"' 10 | BUILD_TYPE: Release 11 | WCHAR: 'ON' 12 | BUILD_SHARED: 'OFF' 13 | - GENERATOR: '"Visual Studio 14 2015 Win64"' 14 | BUILD_TYPE: Debug 15 | WCHAR: 'ON' 16 | BUILD_SHARED: 'OFF' 17 | - GENERATOR: '"Visual Studio 14 2015 Win64"' 18 | BUILD_TYPE: Release 19 | WCHAR: 'ON' 20 | BUILD_SHARED: 'OFF' 21 | - GENERATOR: '"Visual Studio 15 2017 Win64"' 22 | BUILD_TYPE: Debug 23 | WCHAR: 'ON' 24 | BUILD_SHARED: 'OFF' 25 | - GENERATOR: '"Visual Studio 15 2017 Win64"' 26 | BUILD_TYPE: Release 27 | WCHAR: 'OFF' 28 | BUILD_SHARED: 'OFF' 29 | - GENERATOR: '"Visual Studio 15 2017 Win64"' 30 | BUILD_TYPE: Release 31 | WCHAR: 'OFF' 32 | BUILD_SHARED: 'ON' 33 | build_script: 34 | - cmd: >- 35 | set 36 | 37 | mkdir build 38 | 39 | cd build 40 | 41 | set PATH=%PATH%;C:\Program Files\Git\usr\bin 42 | 43 | cmake .. -G %GENERATOR% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DSPDLOG_WCHAR_SUPPORT=%WCHAR% -DSPDLOG_BUILD_SHARED=%BUILD_SHARED% -DSPDLOG_BUILD_EXAMPLE=ON -DSPDLOG_BUILD_EXAMPLE_HO=ON -DSPDLOG_BUILD_TESTS=ON -DSPDLOG_BUILD_TESTS_HO=OFF -DSPDLOG_BUILD_WARNINGS=ON 44 | 45 | cmake --build . --config %BUILD_TYPE% 46 | 47 | before_test: 48 | - set PATH=%PATH%;C:\projects\spdlog\build\%BUILD_TYPE% 49 | 50 | test_script: 51 | - C:\projects\spdlog\build\tests\%BUILD_TYPE%\spdlog-utests.exe 52 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/bench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT) 2 | 3 | cmake_minimum_required(VERSION 3.10) 4 | project(spdlog_bench CXX) 5 | 6 | if(NOT TARGET spdlog) 7 | # Stand-alone build 8 | find_package(spdlog CONFIG REQUIRED) 9 | endif() 10 | 11 | find_package(Threads REQUIRED) 12 | find_package(benchmark CONFIG) 13 | if (NOT benchmark_FOUND) 14 | message(STATUS "Using CMake Version ${CMAKE_VERSION}") 15 | if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0") 16 | # User can fetch googlebenchmark 17 | message(STATUS "Downloading GoogleBenchmark") 18 | include(FetchContent) 19 | set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "") 20 | # Do not build and run googlebenchmark tests 21 | FetchContent_Declare(googlebenchmark 22 | GIT_REPOSITORY https://github.com/google/benchmark.git 23 | GIT_TAG v1.5.2) 24 | 25 | FetchContent_MakeAvailable(googlebenchmark) 26 | else() 27 | message(FATAL_ERROR "GoogleBenchmark is missing. Use CMake >= 3.11 or download it") 28 | endif() 29 | endif() 30 | 31 | add_executable(bench bench.cpp) 32 | spdlog_enable_warnings(bench) 33 | target_link_libraries(bench PRIVATE spdlog::spdlog) 34 | 35 | add_executable(async_bench async_bench.cpp) 36 | target_link_libraries(async_bench PRIVATE spdlog::spdlog) 37 | 38 | add_executable(latency latency.cpp) 39 | target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog) 40 | 41 | add_executable(formatter-bench formatter-bench.cpp) 42 | target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog) 43 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/bench/utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2015 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace utils { 13 | 14 | template 15 | inline std::string format(const T &value) 16 | { 17 | static std::locale loc(""); 18 | std::stringstream ss; 19 | ss.imbue(loc); 20 | ss << value; 21 | return ss.str(); 22 | } 23 | 24 | template<> 25 | inline std::string format(const double &value) 26 | { 27 | static std::locale loc(""); 28 | std::stringstream ss; 29 | ss.imbue(loc); 30 | ss << std::fixed << std::setprecision(1) << value; 31 | return ss.str(); 32 | } 33 | 34 | } // namespace utils 35 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/cmake/ide.cmake: -------------------------------------------------------------------------------- 1 | # --------------------------------------------------------------------------------------- 2 | # IDE support for headers 3 | # --------------------------------------------------------------------------------------- 4 | set(SPDLOG_HEADERS_DIR "${CMAKE_CURRENT_LIST_DIR}/../include") 5 | 6 | file(GLOB SPDLOG_TOP_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/*.h") 7 | file(GLOB SPDLOG_DETAILS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/details/*.h") 8 | file(GLOB SPDLOG_SINKS_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/sinks/*.h") 9 | file(GLOB SPDLOG_FMT_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/*.h") 10 | file(GLOB SPDLOG_FMT_BUNDELED_HEADERS "${SPDLOG_HEADERS_DIR}/spdlog/fmt/bundled/*.h") 11 | set(SPDLOG_ALL_HEADERS ${SPDLOG_TOP_HEADERS} ${SPDLOG_DETAILS_HEADERS} ${SPDLOG_SINKS_HEADERS} ${SPDLOG_FMT_HEADERS} 12 | ${SPDLOG_FMT_BUNDELED_HEADERS}) 13 | 14 | source_group("Header Files\\spdlog" FILES ${SPDLOG_TOP_HEADERS}) 15 | source_group("Header Files\\spdlog\\details" FILES ${SPDLOG_DETAILS_HEADERS}) 16 | source_group("Header Files\\spdlog\\sinks" FILES ${SPDLOG_SINKS_HEADERS}) 17 | source_group("Header Files\\spdlog\\fmt" FILES ${SPDLOG_FMT_HEADERS}) 18 | source_group("Header Files\\spdlog\\fmt\\bundled\\" FILES ${SPDLOG_FMT_BUNDELED_HEADERS}) 19 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/cmake/spdlog.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 5 | 6 | Name: lib@PROJECT_NAME@ 7 | Description: Fast C++ logging library. 8 | URL: https://github.com/gabime/@PROJECT_NAME@ 9 | Version: @SPDLOG_VERSION@ 10 | CFlags: -I${includedir} @PKG_CONFIG_DEFINES@ 11 | Libs: -L${libdir} -lspdlog -pthread 12 | Requires: @PKG_CONFIG_REQUIRES@ 13 | 14 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/cmake/spdlogConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2019 spdlog authors 2 | # Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | find_package(Threads REQUIRED) 5 | 6 | set(SPDLOG_FMT_EXTERNAL @SPDLOG_FMT_EXTERNAL@) 7 | set(config_targets_file @config_targets_file@) 8 | 9 | if(SPDLOG_FMT_EXTERNAL) 10 | include(CMakeFindDependencyMacro) 11 | find_dependency(fmt CONFIG) 12 | endif() 13 | 14 | 15 | include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}") 16 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/cmake/version.rc.in: -------------------------------------------------------------------------------- 1 | #define APSTUDIO_READONLY_SYMBOLS 2 | #include 3 | #undef APSTUDIO_READONLY_SYMBOLS 4 | 5 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 6 | 7 | 8 | VS_VERSION_INFO VERSIONINFO 9 | FILEVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0 10 | PRODUCTVERSION @SPDLOG_VERSION_MAJOR@,@SPDLOG_VERSION_MINOR@,@SPDLOG_VERSION_PATCH@,0 11 | FILEFLAGSMASK 0x3fL 12 | #ifdef _DEBUG 13 | FILEFLAGS 0x1L 14 | #else 15 | FILEFLAGS 0x0L 16 | #endif 17 | FILEOS 0x40004L 18 | FILETYPE 0x2L 19 | FILESUBTYPE 0x0L 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904b0" 24 | BEGIN 25 | VALUE "FileDescription", "spdlog dll\0" 26 | VALUE "FileVersion", "@SPDLOG_VERSION@.0\0" 27 | VALUE "InternalName", "spdlog.dll\0" 28 | VALUE "LegalCopyright", "Copyright (C) spdlog\0" 29 | VALUE "ProductName", "spdlog\0" 30 | VALUE "ProductVersion", "@SPDLOG_VERSION@.0\0" 31 | END 32 | END 33 | BLOCK "VarFileInfo" 34 | BEGIN 35 | VALUE "Translation", 0x409, 1200 36 | END 37 | END 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT) 2 | 3 | cmake_minimum_required(VERSION 3.10) 4 | project(spdlog_examples CXX) 5 | 6 | if(NOT TARGET spdlog) 7 | # Stand-alone build 8 | find_package(spdlog REQUIRED) 9 | endif() 10 | 11 | # --------------------------------------------------------------------------------------- 12 | # Example of using pre-compiled library 13 | # --------------------------------------------------------------------------------------- 14 | add_executable(example example.cpp) 15 | target_link_libraries(example PRIVATE spdlog::spdlog) 16 | 17 | # --------------------------------------------------------------------------------------- 18 | # Example of using header-only library 19 | # --------------------------------------------------------------------------------------- 20 | if(SPDLOG_BUILD_EXAMPLE_HO) 21 | add_executable(example_header_only example.cpp) 22 | target_link_libraries(example_header_only PRIVATE spdlog::spdlog_header_only) 23 | endif() 24 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/cfg/argv.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | // 9 | // Init log levels using each argv entry that starts with "SPDLOG_LEVEL=" 10 | // 11 | // set all loggers to debug level: 12 | // example.exe "SPDLOG_LEVEL=debug" 13 | 14 | // set logger1 to trace level 15 | // example.exe "SPDLOG_LEVEL=logger1=trace" 16 | 17 | // turn off all logging except for logger1 and logger2: 18 | // example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info" 19 | 20 | namespace spdlog { 21 | namespace cfg { 22 | 23 | // search for SPDLOG_LEVEL= in the args and use it to init the levels 24 | inline void load_argv_levels(int argc, const char **argv) 25 | { 26 | const std::string spdlog_level_prefix = "SPDLOG_LEVEL="; 27 | for (int i = 1; i < argc; i++) 28 | { 29 | std::string arg = argv[i]; 30 | if (arg.find(spdlog_level_prefix) == 0) 31 | { 32 | auto levels_string = arg.substr(spdlog_level_prefix.size()); 33 | helpers::load_levels(levels_string); 34 | } 35 | } 36 | } 37 | 38 | inline void load_argv_levels(int argc, char **argv) 39 | { 40 | load_argv_levels(argc, const_cast(argv)); 41 | } 42 | 43 | } // namespace cfg 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/cfg/env.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | // 10 | // Init levels and patterns from env variables SPDLOG_LEVEL 11 | // Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger). 12 | // Note - fallback to "info" level on unrecognized levels 13 | // 14 | // Examples: 15 | // 16 | // set global level to debug: 17 | // export SPDLOG_LEVEL=debug 18 | // 19 | // turn off all logging except for logger1: 20 | // export SPDLOG_LEVEL="*=off,logger1=debug" 21 | // 22 | 23 | // turn off all logging except for logger1 and logger2: 24 | // export SPDLOG_LEVEL="off,logger1=debug,logger2=info" 25 | 26 | namespace spdlog { 27 | namespace cfg { 28 | inline void load_env_levels() 29 | { 30 | auto env_val = details::os::getenv("SPDLOG_LEVEL"); 31 | if (!env_val.empty()) 32 | { 33 | helpers::load_levels(env_val); 34 | } 35 | } 36 | 37 | } // namespace cfg 38 | } // namespace spdlog 39 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/cfg/helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace cfg { 11 | namespace helpers { 12 | // 13 | // Init levels from given string 14 | // 15 | // Examples: 16 | // 17 | // set global level to debug: "debug" 18 | // turn off all logging except for logger1: "off,logger1=debug" 19 | // turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info" 20 | // 21 | SPDLOG_API void load_levels(const std::string &txt); 22 | } // namespace helpers 23 | 24 | } // namespace cfg 25 | } // namespace spdlog 26 | 27 | #ifdef SPDLOG_HEADER_ONLY 28 | #include "helpers-inl.h" 29 | #endif // SPDLOG_HEADER_ONLY 30 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/backtracer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Store log messages in circular buffer. 14 | // Useful for storing debug data in case of error/warning happens. 15 | 16 | namespace spdlog { 17 | namespace details { 18 | class SPDLOG_API backtracer 19 | { 20 | mutable std::mutex mutex_; 21 | std::atomic enabled_{false}; 22 | circular_q messages_; 23 | 24 | public: 25 | backtracer() = default; 26 | backtracer(const backtracer &other); 27 | 28 | backtracer(backtracer &&other) SPDLOG_NOEXCEPT; 29 | backtracer &operator=(backtracer other); 30 | 31 | void enable(size_t size); 32 | void disable(); 33 | bool enabled() const; 34 | void push_back(const log_msg &msg); 35 | 36 | // pop all items in the q and apply the given fun on each of them. 37 | void foreach_pop(std::function fun); 38 | }; 39 | 40 | } // namespace details 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "backtracer-inl.h" 45 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/console_globals.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | struct console_mutex 13 | { 14 | using mutex_t = std::mutex; 15 | static mutex_t &mutex() 16 | { 17 | static mutex_t s_mutex; 18 | return s_mutex; 19 | } 20 | }; 21 | 22 | struct console_nullmutex 23 | { 24 | using mutex_t = null_mutex; 25 | static mutex_t &mutex() 26 | { 27 | static mutex_t s_mutex; 28 | return s_mutex; 29 | } 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/file_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | // Helper class for file sinks. 13 | // When failing to open a file, retry several times(5) with a delay interval(10 ms). 14 | // Throw spdlog_ex exception on errors. 15 | 16 | class SPDLOG_API file_helper 17 | { 18 | public: 19 | explicit file_helper() = default; 20 | 21 | file_helper(const file_helper &) = delete; 22 | file_helper &operator=(const file_helper &) = delete; 23 | ~file_helper(); 24 | 25 | void open(const filename_t &fname, bool truncate = false); 26 | void reopen(bool truncate); 27 | void flush(); 28 | void close(); 29 | void write(const memory_buf_t &buf); 30 | size_t size() const; 31 | const filename_t &filename() const; 32 | 33 | // 34 | // return file path and its extension: 35 | // 36 | // "mylog.txt" => ("mylog", ".txt") 37 | // "mylog" => ("mylog", "") 38 | // "mylog." => ("mylog.", "") 39 | // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") 40 | // 41 | // the starting dot in filenames is ignored (hidden files): 42 | // 43 | // ".mylog" => (".mylog". "") 44 | // "my_folder/.mylog" => ("my_folder/.mylog", "") 45 | // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") 46 | static std::tuple split_by_extension(const filename_t &fname); 47 | 48 | private: 49 | const int open_tries_ = 5; 50 | const int open_interval_ = 10; 51 | std::FILE *fd_{nullptr}; 52 | filename_t filename_; 53 | }; 54 | } // namespace details 55 | } // namespace spdlog 56 | 57 | #ifdef SPDLOG_HEADER_ONLY 58 | #include "file_helper-inl.h" 59 | #endif 60 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/log_msg-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace details { 14 | 15 | SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time, spdlog::source_loc loc, string_view_t a_logger_name, 16 | spdlog::level::level_enum lvl, spdlog::string_view_t msg) 17 | : logger_name(a_logger_name) 18 | , level(lvl) 19 | , time(log_time) 20 | #ifndef SPDLOG_NO_THREAD_ID 21 | , thread_id(os::thread_id()) 22 | #endif 23 | , source(loc) 24 | , payload(msg) 25 | {} 26 | 27 | SPDLOG_INLINE log_msg::log_msg( 28 | spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 29 | : log_msg(os::now(), loc, a_logger_name, lvl, msg) 30 | {} 31 | 32 | SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 33 | : log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) 34 | {} 35 | 36 | } // namespace details 37 | } // namespace spdlog 38 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/log_msg.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | struct SPDLOG_API log_msg 12 | { 13 | log_msg() = default; 14 | log_msg(log_clock::time_point log_time, source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 15 | log_msg(source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 16 | log_msg(string_view_t logger_name, level::level_enum lvl, string_view_t msg); 17 | log_msg(const log_msg &other) = default; 18 | 19 | string_view_t logger_name; 20 | level::level_enum level{level::off}; 21 | log_clock::time_point time; 22 | size_t thread_id{0}; 23 | 24 | // wrapping the formatted text with color (updated by pattern_formatter). 25 | mutable size_t color_range_start{0}; 26 | mutable size_t color_range_end{0}; 27 | 28 | source_loc source; 29 | string_view_t payload; 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | 34 | #ifdef SPDLOG_HEADER_ONLY 35 | #include "log_msg-inl.h" 36 | #endif 37 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/log_msg_buffer-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg) 14 | : log_msg{orig_msg} 15 | { 16 | buffer.append(logger_name.begin(), logger_name.end()); 17 | buffer.append(payload.begin(), payload.end()); 18 | update_string_views(); 19 | } 20 | 21 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other) 22 | : log_msg{other} 23 | { 24 | buffer.append(logger_name.begin(), logger_name.end()); 25 | buffer.append(payload.begin(), payload.end()); 26 | update_string_views(); 27 | } 28 | 29 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT : log_msg{other}, buffer{std::move(other.buffer)} 30 | { 31 | update_string_views(); 32 | } 33 | 34 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) 35 | { 36 | log_msg::operator=(other); 37 | buffer.clear(); 38 | buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size()); 39 | update_string_views(); 40 | return *this; 41 | } 42 | 43 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT 44 | { 45 | log_msg::operator=(other); 46 | buffer = std::move(other.buffer); 47 | update_string_views(); 48 | return *this; 49 | } 50 | 51 | SPDLOG_INLINE void log_msg_buffer::update_string_views() 52 | { 53 | logger_name = string_view_t{buffer.data(), logger_name.size()}; 54 | payload = string_view_t{buffer.data() + logger_name.size(), payload.size()}; 55 | } 56 | 57 | } // namespace details 58 | } // namespace spdlog 59 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/log_msg_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace spdlog { 9 | namespace details { 10 | 11 | // Extend log_msg with internal buffer to store its payload. 12 | // This is needed since log_msg holds string_views that points to stack data. 13 | 14 | class SPDLOG_API log_msg_buffer : public log_msg 15 | { 16 | memory_buf_t buffer; 17 | void update_string_views(); 18 | 19 | public: 20 | log_msg_buffer() = default; 21 | explicit log_msg_buffer(const log_msg &orig_msg); 22 | log_msg_buffer(const log_msg_buffer &other); 23 | log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 24 | log_msg_buffer &operator=(const log_msg_buffer &other); 25 | log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 26 | }; 27 | 28 | } // namespace details 29 | } // namespace spdlog 30 | 31 | #ifdef SPDLOG_HEADER_ONLY 32 | #include "log_msg_buffer-inl.h" 33 | #endif 34 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/null_mutex.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | // null, no cost dummy "mutex" and dummy "atomic" int 9 | 10 | namespace spdlog { 11 | namespace details { 12 | struct null_mutex 13 | { 14 | void lock() const {} 15 | void unlock() const {} 16 | bool try_lock() const 17 | { 18 | return true; 19 | } 20 | }; 21 | 22 | struct null_atomic_int 23 | { 24 | int value; 25 | null_atomic_int() = default; 26 | 27 | explicit null_atomic_int(int new_value) 28 | : value(new_value) 29 | {} 30 | 31 | int load(std::memory_order = std::memory_order_relaxed) const 32 | { 33 | return value; 34 | } 35 | 36 | void store(int new_value, std::memory_order = std::memory_order_relaxed) 37 | { 38 | value = new_value; 39 | } 40 | 41 | int exchange(int new_value, std::memory_order = std::memory_order_relaxed) 42 | { 43 | std::swap(new_value, value); 44 | return new_value; // return value before the call 45 | } 46 | }; 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/periodic_worker-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE periodic_worker::periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) 14 | { 15 | active_ = (interval > std::chrono::seconds::zero()); 16 | if (!active_) 17 | { 18 | return; 19 | } 20 | 21 | worker_thread_ = std::thread([this, callback_fun, interval]() { 22 | for (;;) 23 | { 24 | std::unique_lock lock(this->mutex_); 25 | if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) 26 | { 27 | return; // active_ == false, so exit this thread 28 | } 29 | callback_fun(); 30 | } 31 | }); 32 | } 33 | 34 | // stop the worker thread and join it 35 | SPDLOG_INLINE periodic_worker::~periodic_worker() 36 | { 37 | if (worker_thread_.joinable()) 38 | { 39 | { 40 | std::lock_guard lock(mutex_); 41 | active_ = false; 42 | } 43 | cv_.notify_one(); 44 | worker_thread_.join(); 45 | } 46 | } 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/periodic_worker.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // periodic worker thread - periodically executes the given callback function. 7 | // 8 | // RAII over the owned thread: 9 | // creates the thread on construction. 10 | // stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first). 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | namespace spdlog { 18 | namespace details { 19 | 20 | class SPDLOG_API periodic_worker 21 | { 22 | public: 23 | periodic_worker(const std::function &callback_fun, std::chrono::seconds interval); 24 | periodic_worker(const periodic_worker &) = delete; 25 | periodic_worker &operator=(const periodic_worker &) = delete; 26 | // stop the worker thread and join it 27 | ~periodic_worker(); 28 | 29 | private: 30 | bool active_; 31 | std::thread worker_thread_; 32 | std::mutex mutex_; 33 | std::condition_variable cv_; 34 | }; 35 | } // namespace details 36 | } // namespace spdlog 37 | 38 | #ifdef SPDLOG_HEADER_ONLY 39 | #include "periodic_worker-inl.h" 40 | #endif 41 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/synchronous_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "registry.h" 7 | 8 | namespace spdlog { 9 | 10 | // Default logger factory- creates synchronous loggers 11 | class logger; 12 | 13 | struct synchronous_factory 14 | { 15 | template 16 | static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) 17 | { 18 | auto sink = std::make_shared(std::forward(args)...); 19 | auto new_logger = std::make_shared(std::move(logger_name), std::move(sink)); 20 | details::registry::instance().initialize_logger(new_logger); 21 | return new_logger; 22 | } 23 | }; 24 | } // namespace spdlog -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/details/windows_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NOMINMAX 4 | #define NOMINMAX // prevent windows redefining min/max 5 | #endif 6 | 7 | #ifndef WIN32_LEAN_AND_MEAN 8 | #define WIN32_LEAN_AND_MEAN 9 | #endif 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fmt/bundled/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - present, Victor Zverovich 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | --- Optional exception to the license --- 23 | 24 | As an exception, if, as a result of your compiling your source code, portions 25 | of this Software are embedded into a machine-executable object form of such 26 | source code, you may redistribute such embedded portions in such object form 27 | without including the above copyright and permission notices. 28 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fmt/bundled/posix.h: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #warning "fmt/posix.h is deprecated; use fmt/os.h instead" 3 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fmt/chrono.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's chrono support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fmt/fmt.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016-2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | // 9 | // Include a bundled header-only copy of fmtlib or an external one. 10 | // By default spdlog include its own copy. 11 | // 12 | 13 | #if !defined(SPDLOG_FMT_EXTERNAL) 14 | #if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY) 15 | #define FMT_HEADER_ONLY 16 | #endif 17 | #ifndef FMT_USE_WINDOWS_H 18 | #define FMT_USE_WINDOWS_H 0 19 | #endif 20 | // enable the 'n' flag in for backward compatibility with fmt 6.x 21 | #define FMT_DEPRECATED_N_SPECIFIER 22 | #include 23 | #include 24 | #else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib 25 | #include 26 | #include 27 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fmt/ostr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/formatter.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | class formatter 12 | { 13 | public: 14 | virtual ~formatter() = default; 15 | virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0; 16 | virtual std::unique_ptr clone() const = 0; 17 | }; 18 | } // namespace spdlog 19 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | namespace spdlog { 7 | class logger; 8 | class formatter; 9 | 10 | namespace sinks { 11 | class sink; 12 | } 13 | 14 | } // namespace spdlog 15 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/base_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template 16 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink() 17 | : formatter_{details::make_unique()} 18 | {} 19 | 20 | template 21 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink(std::unique_ptr formatter) 22 | : formatter_{std::move(formatter)} 23 | {} 24 | 25 | template 26 | void SPDLOG_INLINE spdlog::sinks::base_sink::log(const details::log_msg &msg) 27 | { 28 | std::lock_guard lock(mutex_); 29 | sink_it_(msg); 30 | } 31 | 32 | template 33 | void SPDLOG_INLINE spdlog::sinks::base_sink::flush() 34 | { 35 | std::lock_guard lock(mutex_); 36 | flush_(); 37 | } 38 | 39 | template 40 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern(const std::string &pattern) 41 | { 42 | std::lock_guard lock(mutex_); 43 | set_pattern_(pattern); 44 | } 45 | 46 | template 47 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter(std::unique_ptr sink_formatter) 48 | { 49 | std::lock_guard lock(mutex_); 50 | set_formatter_(std::move(sink_formatter)); 51 | } 52 | 53 | template 54 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern_(const std::string &pattern) 55 | { 56 | set_formatter_(details::make_unique(pattern)); 57 | } 58 | 59 | template 60 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter_(std::unique_ptr sink_formatter) 61 | { 62 | formatter_ = std::move(sink_formatter); 63 | } 64 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/base_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | // 6 | // base sink templated over a mutex (either dummy or real) 7 | // concrete implementation should override the sink_it_() and flush_() methods. 8 | // locking is taken care of in this class - no locking needed by the 9 | // implementers.. 10 | // 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace spdlog { 17 | namespace sinks { 18 | template 19 | class base_sink : public sink 20 | { 21 | public: 22 | base_sink(); 23 | explicit base_sink(std::unique_ptr formatter); 24 | ~base_sink() override = default; 25 | 26 | base_sink(const base_sink &) = delete; 27 | base_sink(base_sink &&) = delete; 28 | 29 | base_sink &operator=(const base_sink &) = delete; 30 | base_sink &operator=(base_sink &&) = delete; 31 | 32 | void log(const details::log_msg &msg) final; 33 | void flush() final; 34 | void set_pattern(const std::string &pattern) final; 35 | void set_formatter(std::unique_ptr sink_formatter) final; 36 | 37 | protected: 38 | // sink formatter 39 | std::unique_ptr formatter_; 40 | Mutex mutex_; 41 | 42 | virtual void sink_it_(const details::log_msg &msg) = 0; 43 | virtual void flush_() = 0; 44 | virtual void set_pattern_(const std::string &pattern); 45 | virtual void set_formatter_(std::unique_ptr sink_formatter); 46 | }; 47 | } // namespace sinks 48 | } // namespace spdlog 49 | 50 | #ifdef SPDLOG_HEADER_ONLY 51 | #include "base_sink-inl.h" 52 | #endif 53 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/basic_file_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | namespace sinks { 15 | 16 | template 17 | SPDLOG_INLINE basic_file_sink::basic_file_sink(const filename_t &filename, bool truncate) 18 | { 19 | file_helper_.open(filename, truncate); 20 | } 21 | 22 | template 23 | SPDLOG_INLINE const filename_t &basic_file_sink::filename() const 24 | { 25 | return file_helper_.filename(); 26 | } 27 | 28 | template 29 | SPDLOG_INLINE void basic_file_sink::sink_it_(const details::log_msg &msg) 30 | { 31 | memory_buf_t formatted; 32 | base_sink::formatter_->format(msg, formatted); 33 | file_helper_.write(formatted); 34 | } 35 | 36 | template 37 | SPDLOG_INLINE void basic_file_sink::flush_() 38 | { 39 | file_helper_.flush(); 40 | } 41 | 42 | } // namespace sinks 43 | } // namespace spdlog 44 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/basic_file_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | /* 17 | * Trivial file sink with single file as target 18 | */ 19 | template 20 | class basic_file_sink final : public base_sink 21 | { 22 | public: 23 | explicit basic_file_sink(const filename_t &filename, bool truncate = false); 24 | const filename_t &filename() const; 25 | 26 | protected: 27 | void sink_it_(const details::log_msg &msg) override; 28 | void flush_() override; 29 | 30 | private: 31 | details::file_helper file_helper_; 32 | }; 33 | 34 | using basic_file_sink_mt = basic_file_sink; 35 | using basic_file_sink_st = basic_file_sink; 36 | 37 | } // namespace sinks 38 | 39 | // 40 | // factory functions 41 | // 42 | template 43 | inline std::shared_ptr basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false) 44 | { 45 | return Factory::template create(logger_name, filename, truncate); 46 | } 47 | 48 | template 49 | inline std::shared_ptr basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false) 50 | { 51 | return Factory::template create(logger_name, filename, truncate); 52 | } 53 | 54 | } // namespace spdlog 55 | 56 | #ifdef SPDLOG_HEADER_ONLY 57 | #include "basic_file_sink-inl.h" 58 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/msvc_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 Alexander Dalshov. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #if defined(_WIN32) 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | // Avoid including windows.h (https://stackoverflow.com/a/30741042) 16 | extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString); 17 | 18 | namespace spdlog { 19 | namespace sinks { 20 | /* 21 | * MSVC sink (logging using OutputDebugStringA) 22 | */ 23 | template 24 | class msvc_sink : public base_sink 25 | { 26 | public: 27 | msvc_sink() = default; 28 | 29 | protected: 30 | void sink_it_(const details::log_msg &msg) override 31 | { 32 | memory_buf_t formatted; 33 | base_sink::formatter_->format(msg, formatted); 34 | OutputDebugStringA(fmt::to_string(formatted).c_str()); 35 | } 36 | 37 | void flush_() override {} 38 | }; 39 | 40 | using msvc_sink_mt = msvc_sink; 41 | using msvc_sink_st = msvc_sink; 42 | 43 | using windebug_sink_mt = msvc_sink_mt; 44 | using windebug_sink_st = msvc_sink_st; 45 | 46 | } // namespace sinks 47 | } // namespace spdlog 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/null_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | 15 | template 16 | class null_sink : public base_sink 17 | { 18 | protected: 19 | void sink_it_(const details::log_msg &) override {} 20 | void flush_() override {} 21 | }; 22 | 23 | using null_sink_mt = null_sink; 24 | using null_sink_st = null_sink; 25 | 26 | } // namespace sinks 27 | 28 | template 29 | inline std::shared_ptr null_logger_mt(const std::string &logger_name) 30 | { 31 | auto null_logger = Factory::template create(logger_name); 32 | null_logger->set_level(level::off); 33 | return null_logger; 34 | } 35 | 36 | template 37 | inline std::shared_ptr null_logger_st(const std::string &logger_name) 38 | { 39 | auto null_logger = Factory::template create(logger_name); 40 | null_logger->set_level(level::off); 41 | return null_logger; 42 | } 43 | 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/ostream_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | template 15 | class ostream_sink final : public base_sink 16 | { 17 | public: 18 | explicit ostream_sink(std::ostream &os, bool force_flush = false) 19 | : ostream_(os) 20 | , force_flush_(force_flush) 21 | {} 22 | ostream_sink(const ostream_sink &) = delete; 23 | ostream_sink &operator=(const ostream_sink &) = delete; 24 | 25 | protected: 26 | void sink_it_(const details::log_msg &msg) override 27 | { 28 | memory_buf_t formatted; 29 | base_sink::formatter_->format(msg, formatted); 30 | ostream_.write(formatted.data(), static_cast(formatted.size())); 31 | if (force_flush_) 32 | { 33 | ostream_.flush(); 34 | } 35 | } 36 | 37 | void flush_() override 38 | { 39 | ostream_.flush(); 40 | } 41 | 42 | std::ostream &ostream_; 43 | bool force_flush_; 44 | }; 45 | 46 | using ostream_sink_mt = ostream_sink; 47 | using ostream_sink_st = ostream_sink; 48 | 49 | } // namespace sinks 50 | } // namespace spdlog 51 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const 13 | { 14 | return msg_level >= level_.load(std::memory_order_relaxed); 15 | } 16 | 17 | SPDLOG_INLINE void spdlog::sinks::sink::set_level(level::level_enum log_level) 18 | { 19 | level_.store(log_level, std::memory_order_relaxed); 20 | } 21 | 22 | SPDLOG_INLINE spdlog::level::level_enum spdlog::sinks::sink::level() const 23 | { 24 | return static_cast(level_.load(std::memory_order_relaxed)); 25 | } 26 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | namespace sinks { 12 | class SPDLOG_API sink 13 | { 14 | public: 15 | virtual ~sink() = default; 16 | virtual void log(const details::log_msg &msg) = 0; 17 | virtual void flush() = 0; 18 | virtual void set_pattern(const std::string &pattern) = 0; 19 | virtual void set_formatter(std::unique_ptr sink_formatter) = 0; 20 | 21 | void set_level(level::level_enum log_level); 22 | level::level_enum level() const; 23 | bool should_log(level::level_enum msg_level) const; 24 | 25 | protected: 26 | // sink log level - default is all 27 | level_t level_{level::trace}; 28 | }; 29 | 30 | } // namespace sinks 31 | } // namespace spdlog 32 | 33 | #ifdef SPDLOG_HEADER_ONLY 34 | #include "sink-inl.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/stdout_color_sinks-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | 15 | template 16 | SPDLOG_INLINE std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode) 17 | { 18 | return Factory::template create(logger_name, mode); 19 | } 20 | 21 | template 22 | SPDLOG_INLINE std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode) 23 | { 24 | return Factory::template create(logger_name, mode); 25 | } 26 | 27 | template 28 | SPDLOG_INLINE std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode) 29 | { 30 | return Factory::template create(logger_name, mode); 31 | } 32 | 33 | template 34 | SPDLOG_INLINE std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode) 35 | { 36 | return Factory::template create(logger_name, mode); 37 | } 38 | } // namespace spdlog -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/sinks/stdout_color_sinks.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifdef _WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | #ifdef _WIN32 17 | using stdout_color_sink_mt = wincolor_stdout_sink_mt; 18 | using stdout_color_sink_st = wincolor_stdout_sink_st; 19 | using stderr_color_sink_mt = wincolor_stderr_sink_mt; 20 | using stderr_color_sink_st = wincolor_stderr_sink_st; 21 | #else 22 | using stdout_color_sink_mt = ansicolor_stdout_sink_mt; 23 | using stdout_color_sink_st = ansicolor_stdout_sink_st; 24 | using stderr_color_sink_mt = ansicolor_stderr_sink_mt; 25 | using stderr_color_sink_st = ansicolor_stderr_sink_st; 26 | #endif 27 | } // namespace sinks 28 | 29 | template 30 | std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 31 | 32 | template 33 | std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 34 | 35 | template 36 | std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 37 | 38 | template 39 | std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 40 | 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "stdout_color_sinks-inl.h" 45 | #endif 46 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/stopwatch.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | // Stopwatch support for spdlog (using std::chrono::steady_clock). 9 | // Displays elapsed seconds since construction as double. 10 | // 11 | // Usage: 12 | // 13 | // spdlog::stopwatch sw; 14 | // ... 15 | // spdlog::debug("Elapsed: {} seconds", sw); => "Elapsed 0.005116733 seconds" 16 | // spdlog::info("Elapsed: {:.6} seconds", sw); => "Elapsed 0.005163 seconds" 17 | // 18 | // 19 | // If other units are needed (e.g. millis instead of double), include "fmt/chrono.h" and use "duration_cast<..>(sw.elapsed())": 20 | // 21 | // #include 22 | //.. 23 | // using std::chrono::duration_cast; 24 | // using std::chrono::milliseconds; 25 | // spdlog::info("Elapsed {}", duration_cast(sw.elapsed())); => "Elapsed 5ms" 26 | 27 | namespace spdlog { 28 | class stopwatch 29 | { 30 | using clock = std::chrono::steady_clock; 31 | std::chrono::time_point start_tp_; 32 | 33 | public: 34 | stopwatch() 35 | : start_tp_{clock::now()} 36 | {} 37 | 38 | std::chrono::duration elapsed() const 39 | { 40 | return std::chrono::duration(clock::now() - start_tp_); 41 | } 42 | 43 | void reset() 44 | { 45 | start_tp_ = clock ::now(); 46 | } 47 | }; 48 | } // namespace spdlog 49 | 50 | // Support for fmt formatting (e.g. "{:012.9}" or just "{}") 51 | namespace fmt { 52 | template<> 53 | struct formatter : formatter 54 | { 55 | template 56 | auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out()) 57 | { 58 | return formatter::format(sw.elapsed().count(), ctx); 59 | } 60 | }; 61 | } // namespace fmt 62 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/include/spdlog/version.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #define SPDLOG_VER_MAJOR 1 7 | #define SPDLOG_VER_MINOR 8 8 | #define SPDLOG_VER_PATCH 2 9 | 10 | #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH) 11 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/cfg/argv.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | // 9 | // Init log levels using each argv entry that starts with "SPDLOG_LEVEL=" 10 | // 11 | // set all loggers to debug level: 12 | // example.exe "SPDLOG_LEVEL=debug" 13 | 14 | // set logger1 to trace level 15 | // example.exe "SPDLOG_LEVEL=logger1=trace" 16 | 17 | // turn off all logging except for logger1 and logger2: 18 | // example.exe "SPDLOG_LEVEL=off,logger1=debug,logger2=info" 19 | 20 | namespace spdlog { 21 | namespace cfg { 22 | 23 | // search for SPDLOG_LEVEL= in the args and use it to init the levels 24 | inline void load_argv_levels(int argc, const char **argv) 25 | { 26 | const std::string spdlog_level_prefix = "SPDLOG_LEVEL="; 27 | for (int i = 1; i < argc; i++) 28 | { 29 | std::string arg = argv[i]; 30 | if (arg.find(spdlog_level_prefix) == 0) 31 | { 32 | auto levels_string = arg.substr(spdlog_level_prefix.size()); 33 | helpers::load_levels(levels_string); 34 | } 35 | } 36 | } 37 | 38 | inline void load_argv_levels(int argc, char **argv) 39 | { 40 | load_argv_levels(argc, const_cast(argv)); 41 | } 42 | 43 | } // namespace cfg 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/cfg/env.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | #include 6 | #include 7 | #include 8 | 9 | // 10 | // Init levels and patterns from env variables SPDLOG_LEVEL 11 | // Inspired from Rust's "env_logger" crate (https://crates.io/crates/env_logger). 12 | // Note - fallback to "info" level on unrecognized levels 13 | // 14 | // Examples: 15 | // 16 | // set global level to debug: 17 | // export SPDLOG_LEVEL=debug 18 | // 19 | // turn off all logging except for logger1: 20 | // export SPDLOG_LEVEL="*=off,logger1=debug" 21 | // 22 | 23 | // turn off all logging except for logger1 and logger2: 24 | // export SPDLOG_LEVEL="off,logger1=debug,logger2=info" 25 | 26 | namespace spdlog { 27 | namespace cfg { 28 | inline void load_env_levels() 29 | { 30 | auto env_val = details::os::getenv("SPDLOG_LEVEL"); 31 | if (!env_val.empty()) 32 | { 33 | helpers::load_levels(env_val); 34 | } 35 | } 36 | 37 | } // namespace cfg 38 | } // namespace spdlog 39 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/cfg/helpers.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace cfg { 11 | namespace helpers { 12 | // 13 | // Init levels from given string 14 | // 15 | // Examples: 16 | // 17 | // set global level to debug: "debug" 18 | // turn off all logging except for logger1: "off,logger1=debug" 19 | // turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info" 20 | // 21 | SPDLOG_API void load_levels(const std::string &txt); 22 | } // namespace helpers 23 | 24 | } // namespace cfg 25 | } // namespace spdlog 26 | 27 | #ifdef SPDLOG_HEADER_ONLY 28 | #include "helpers-inl.h" 29 | #endif // SPDLOG_HEADER_ONLY 30 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/backtracer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Store log messages in circular buffer. 14 | // Useful for storing debug data in case of error/warning happens. 15 | 16 | namespace spdlog { 17 | namespace details { 18 | class SPDLOG_API backtracer 19 | { 20 | mutable std::mutex mutex_; 21 | std::atomic enabled_{false}; 22 | circular_q messages_; 23 | 24 | public: 25 | backtracer() = default; 26 | backtracer(const backtracer &other); 27 | 28 | backtracer(backtracer &&other) SPDLOG_NOEXCEPT; 29 | backtracer &operator=(backtracer other); 30 | 31 | void enable(size_t size); 32 | void disable(); 33 | bool enabled() const; 34 | void push_back(const log_msg &msg); 35 | 36 | // pop all items in the q and apply the given fun on each of them. 37 | void foreach_pop(std::function fun); 38 | }; 39 | 40 | } // namespace details 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "backtracer-inl.h" 45 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/console_globals.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | struct console_mutex 13 | { 14 | using mutex_t = std::mutex; 15 | static mutex_t &mutex() 16 | { 17 | static mutex_t s_mutex; 18 | return s_mutex; 19 | } 20 | }; 21 | 22 | struct console_nullmutex 23 | { 24 | using mutex_t = null_mutex; 25 | static mutex_t &mutex() 26 | { 27 | static mutex_t s_mutex; 28 | return s_mutex; 29 | } 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/file_helper.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | 12 | // Helper class for file sinks. 13 | // When failing to open a file, retry several times(5) with a delay interval(10 ms). 14 | // Throw spdlog_ex exception on errors. 15 | 16 | class SPDLOG_API file_helper 17 | { 18 | public: 19 | explicit file_helper() = default; 20 | 21 | file_helper(const file_helper &) = delete; 22 | file_helper &operator=(const file_helper &) = delete; 23 | ~file_helper(); 24 | 25 | void open(const filename_t &fname, bool truncate = false); 26 | void reopen(bool truncate); 27 | void flush(); 28 | void close(); 29 | void write(const memory_buf_t &buf); 30 | size_t size() const; 31 | const filename_t &filename() const; 32 | 33 | // 34 | // return file path and its extension: 35 | // 36 | // "mylog.txt" => ("mylog", ".txt") 37 | // "mylog" => ("mylog", "") 38 | // "mylog." => ("mylog.", "") 39 | // "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt") 40 | // 41 | // the starting dot in filenames is ignored (hidden files): 42 | // 43 | // ".mylog" => (".mylog". "") 44 | // "my_folder/.mylog" => ("my_folder/.mylog", "") 45 | // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") 46 | static std::tuple split_by_extension(const filename_t &fname); 47 | 48 | private: 49 | const int open_tries_ = 5; 50 | const int open_interval_ = 10; 51 | std::FILE *fd_{nullptr}; 52 | filename_t filename_; 53 | }; 54 | } // namespace details 55 | } // namespace spdlog 56 | 57 | #ifdef SPDLOG_HEADER_ONLY 58 | #include "file_helper-inl.h" 59 | #endif 60 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/log_msg-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace details { 14 | 15 | SPDLOG_INLINE log_msg::log_msg(spdlog::log_clock::time_point log_time, spdlog::source_loc loc, string_view_t a_logger_name, 16 | spdlog::level::level_enum lvl, spdlog::string_view_t msg) 17 | : logger_name(a_logger_name) 18 | , level(lvl) 19 | , time(log_time) 20 | #ifndef SPDLOG_NO_THREAD_ID 21 | , thread_id(os::thread_id()) 22 | #endif 23 | , source(loc) 24 | , payload(msg) 25 | {} 26 | 27 | SPDLOG_INLINE log_msg::log_msg( 28 | spdlog::source_loc loc, string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 29 | : log_msg(os::now(), loc, a_logger_name, lvl, msg) 30 | {} 31 | 32 | SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name, spdlog::level::level_enum lvl, spdlog::string_view_t msg) 33 | : log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) 34 | {} 35 | 36 | } // namespace details 37 | } // namespace spdlog 38 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/log_msg.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | namespace details { 11 | struct SPDLOG_API log_msg 12 | { 13 | log_msg() = default; 14 | log_msg(log_clock::time_point log_time, source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 15 | log_msg(source_loc loc, string_view_t logger_name, level::level_enum lvl, string_view_t msg); 16 | log_msg(string_view_t logger_name, level::level_enum lvl, string_view_t msg); 17 | log_msg(const log_msg &other) = default; 18 | 19 | string_view_t logger_name; 20 | level::level_enum level{level::off}; 21 | log_clock::time_point time; 22 | size_t thread_id{0}; 23 | 24 | // wrapping the formatted text with color (updated by pattern_formatter). 25 | mutable size_t color_range_start{0}; 26 | mutable size_t color_range_end{0}; 27 | 28 | source_loc source; 29 | string_view_t payload; 30 | }; 31 | } // namespace details 32 | } // namespace spdlog 33 | 34 | #ifdef SPDLOG_HEADER_ONLY 35 | #include "log_msg-inl.h" 36 | #endif 37 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/log_msg_buffer-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg) 14 | : log_msg{orig_msg} 15 | { 16 | buffer.append(logger_name.begin(), logger_name.end()); 17 | buffer.append(payload.begin(), payload.end()); 18 | update_string_views(); 19 | } 20 | 21 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other) 22 | : log_msg{other} 23 | { 24 | buffer.append(logger_name.begin(), logger_name.end()); 25 | buffer.append(payload.begin(), payload.end()); 26 | update_string_views(); 27 | } 28 | 29 | SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT : log_msg{other}, buffer{std::move(other.buffer)} 30 | { 31 | update_string_views(); 32 | } 33 | 34 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) 35 | { 36 | log_msg::operator=(other); 37 | buffer.clear(); 38 | buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size()); 39 | update_string_views(); 40 | return *this; 41 | } 42 | 43 | SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT 44 | { 45 | log_msg::operator=(other); 46 | buffer = std::move(other.buffer); 47 | update_string_views(); 48 | return *this; 49 | } 50 | 51 | SPDLOG_INLINE void log_msg_buffer::update_string_views() 52 | { 53 | logger_name = string_view_t{buffer.data(), logger_name.size()}; 54 | payload = string_view_t{buffer.data() + logger_name.size(), payload.size()}; 55 | } 56 | 57 | } // namespace details 58 | } // namespace spdlog 59 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/log_msg_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | namespace spdlog { 9 | namespace details { 10 | 11 | // Extend log_msg with internal buffer to store its payload. 12 | // This is needed since log_msg holds string_views that points to stack data. 13 | 14 | class SPDLOG_API log_msg_buffer : public log_msg 15 | { 16 | memory_buf_t buffer; 17 | void update_string_views(); 18 | 19 | public: 20 | log_msg_buffer() = default; 21 | explicit log_msg_buffer(const log_msg &orig_msg); 22 | log_msg_buffer(const log_msg_buffer &other); 23 | log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 24 | log_msg_buffer &operator=(const log_msg_buffer &other); 25 | log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT; 26 | }; 27 | 28 | } // namespace details 29 | } // namespace spdlog 30 | 31 | #ifdef SPDLOG_HEADER_ONLY 32 | #include "log_msg_buffer-inl.h" 33 | #endif 34 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/null_mutex.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | // null, no cost dummy "mutex" and dummy "atomic" int 9 | 10 | namespace spdlog { 11 | namespace details { 12 | struct null_mutex 13 | { 14 | void lock() const {} 15 | void unlock() const {} 16 | bool try_lock() const 17 | { 18 | return true; 19 | } 20 | }; 21 | 22 | struct null_atomic_int 23 | { 24 | int value; 25 | null_atomic_int() = default; 26 | 27 | explicit null_atomic_int(int new_value) 28 | : value(new_value) 29 | {} 30 | 31 | int load(std::memory_order = std::memory_order_relaxed) const 32 | { 33 | return value; 34 | } 35 | 36 | void store(int new_value, std::memory_order = std::memory_order_relaxed) 37 | { 38 | value = new_value; 39 | } 40 | 41 | int exchange(int new_value, std::memory_order = std::memory_order_relaxed) 42 | { 43 | std::swap(new_value, value); 44 | return new_value; // return value before the call 45 | } 46 | }; 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/periodic_worker-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | namespace spdlog { 11 | namespace details { 12 | 13 | SPDLOG_INLINE periodic_worker::periodic_worker(const std::function &callback_fun, std::chrono::seconds interval) 14 | { 15 | active_ = (interval > std::chrono::seconds::zero()); 16 | if (!active_) 17 | { 18 | return; 19 | } 20 | 21 | worker_thread_ = std::thread([this, callback_fun, interval]() { 22 | for (;;) 23 | { 24 | std::unique_lock lock(this->mutex_); 25 | if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) 26 | { 27 | return; // active_ == false, so exit this thread 28 | } 29 | callback_fun(); 30 | } 31 | }); 32 | } 33 | 34 | // stop the worker thread and join it 35 | SPDLOG_INLINE periodic_worker::~periodic_worker() 36 | { 37 | if (worker_thread_.joinable()) 38 | { 39 | { 40 | std::lock_guard lock(mutex_); 41 | active_ = false; 42 | } 43 | cv_.notify_one(); 44 | worker_thread_.join(); 45 | } 46 | } 47 | 48 | } // namespace details 49 | } // namespace spdlog 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/periodic_worker.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | // periodic worker thread - periodically executes the given callback function. 7 | // 8 | // RAII over the owned thread: 9 | // creates the thread on construction. 10 | // stops and joins the thread on destruction (if the thread is executing a callback, wait for it to finish first). 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | namespace spdlog { 18 | namespace details { 19 | 20 | class SPDLOG_API periodic_worker 21 | { 22 | public: 23 | periodic_worker(const std::function &callback_fun, std::chrono::seconds interval); 24 | periodic_worker(const periodic_worker &) = delete; 25 | periodic_worker &operator=(const periodic_worker &) = delete; 26 | // stop the worker thread and join it 27 | ~periodic_worker(); 28 | 29 | private: 30 | bool active_; 31 | std::thread worker_thread_; 32 | std::mutex mutex_; 33 | std::condition_variable cv_; 34 | }; 35 | } // namespace details 36 | } // namespace spdlog 37 | 38 | #ifdef SPDLOG_HEADER_ONLY 39 | #include "periodic_worker-inl.h" 40 | #endif 41 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/synchronous_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include "registry.h" 7 | 8 | namespace spdlog { 9 | 10 | // Default logger factory- creates synchronous loggers 11 | class logger; 12 | 13 | struct synchronous_factory 14 | { 15 | template 16 | static std::shared_ptr create(std::string logger_name, SinkArgs &&...args) 17 | { 18 | auto sink = std::make_shared(std::forward(args)...); 19 | auto new_logger = std::make_shared(std::move(logger_name), std::move(sink)); 20 | details::registry::instance().initialize_logger(new_logger); 21 | return new_logger; 22 | } 23 | }; 24 | } // namespace spdlog -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/details/windows_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NOMINMAX 4 | #define NOMINMAX // prevent windows redefining min/max 5 | #endif 6 | 7 | #ifndef WIN32_LEAN_AND_MEAN 8 | #define WIN32_LEAN_AND_MEAN 9 | #endif 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fmt/bundled/LICENSE.rst: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - present, Victor Zverovich 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | --- Optional exception to the license --- 23 | 24 | As an exception, if, as a result of your compiling your source code, portions 25 | of this Software are embedded into a machine-executable object form of such 26 | source code, you may redistribute such embedded portions in such object form 27 | without including the above copyright and permission notices. 28 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fmt/bundled/posix.h: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #warning "fmt/posix.h is deprecated; use fmt/os.h instead" 3 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fmt/chrono.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's chrono support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fmt/fmt.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016-2018 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | 8 | // 9 | // Include a bundled header-only copy of fmtlib or an external one. 10 | // By default spdlog include its own copy. 11 | // 12 | 13 | #if !defined(SPDLOG_FMT_EXTERNAL) 14 | #if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY) 15 | #define FMT_HEADER_ONLY 16 | #endif 17 | #ifndef FMT_USE_WINDOWS_H 18 | #define FMT_USE_WINDOWS_H 0 19 | #endif 20 | // enable the 'n' flag in for backward compatibility with fmt 6.x 21 | #define FMT_DEPRECATED_N_SPECIFIER 22 | #include 23 | #include 24 | #else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib 25 | #include 26 | #include 27 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fmt/ostr.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright(c) 2016 Gabi Melman. 3 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 4 | // 5 | 6 | #pragma once 7 | // 8 | // include bundled or external copy of fmtlib's ostream support 9 | // 10 | 11 | #if !defined(SPDLOG_FMT_EXTERNAL) 12 | #ifdef SPDLOG_HEADER_ONLY 13 | #ifndef FMT_HEADER_ONLY 14 | #define FMT_HEADER_ONLY 15 | #endif 16 | #endif 17 | #include 18 | #else 19 | #include 20 | #endif 21 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/formatter.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | class formatter 12 | { 13 | public: 14 | virtual ~formatter() = default; 15 | virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0; 16 | virtual std::unique_ptr clone() const = 0; 17 | }; 18 | } // namespace spdlog 19 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | namespace spdlog { 7 | class logger; 8 | class formatter; 9 | 10 | namespace sinks { 11 | class sink; 12 | } 13 | 14 | } // namespace spdlog 15 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/base_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template 16 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink() 17 | : formatter_{details::make_unique()} 18 | {} 19 | 20 | template 21 | SPDLOG_INLINE spdlog::sinks::base_sink::base_sink(std::unique_ptr formatter) 22 | : formatter_{std::move(formatter)} 23 | {} 24 | 25 | template 26 | void SPDLOG_INLINE spdlog::sinks::base_sink::log(const details::log_msg &msg) 27 | { 28 | std::lock_guard lock(mutex_); 29 | sink_it_(msg); 30 | } 31 | 32 | template 33 | void SPDLOG_INLINE spdlog::sinks::base_sink::flush() 34 | { 35 | std::lock_guard lock(mutex_); 36 | flush_(); 37 | } 38 | 39 | template 40 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern(const std::string &pattern) 41 | { 42 | std::lock_guard lock(mutex_); 43 | set_pattern_(pattern); 44 | } 45 | 46 | template 47 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter(std::unique_ptr sink_formatter) 48 | { 49 | std::lock_guard lock(mutex_); 50 | set_formatter_(std::move(sink_formatter)); 51 | } 52 | 53 | template 54 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_pattern_(const std::string &pattern) 55 | { 56 | set_formatter_(details::make_unique(pattern)); 57 | } 58 | 59 | template 60 | void SPDLOG_INLINE spdlog::sinks::base_sink::set_formatter_(std::unique_ptr sink_formatter) 61 | { 62 | formatter_ = std::move(sink_formatter); 63 | } 64 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/base_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | // 6 | // base sink templated over a mutex (either dummy or real) 7 | // concrete implementation should override the sink_it_() and flush_() methods. 8 | // locking is taken care of in this class - no locking needed by the 9 | // implementers.. 10 | // 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace spdlog { 17 | namespace sinks { 18 | template 19 | class base_sink : public sink 20 | { 21 | public: 22 | base_sink(); 23 | explicit base_sink(std::unique_ptr formatter); 24 | ~base_sink() override = default; 25 | 26 | base_sink(const base_sink &) = delete; 27 | base_sink(base_sink &&) = delete; 28 | 29 | base_sink &operator=(const base_sink &) = delete; 30 | base_sink &operator=(base_sink &&) = delete; 31 | 32 | void log(const details::log_msg &msg) final; 33 | void flush() final; 34 | void set_pattern(const std::string &pattern) final; 35 | void set_formatter(std::unique_ptr sink_formatter) final; 36 | 37 | protected: 38 | // sink formatter 39 | std::unique_ptr formatter_; 40 | Mutex mutex_; 41 | 42 | virtual void sink_it_(const details::log_msg &msg) = 0; 43 | virtual void flush_() = 0; 44 | virtual void set_pattern_(const std::string &pattern); 45 | virtual void set_formatter_(std::unique_ptr sink_formatter); 46 | }; 47 | } // namespace sinks 48 | } // namespace spdlog 49 | 50 | #ifdef SPDLOG_HEADER_ONLY 51 | #include "base_sink-inl.h" 52 | #endif 53 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/basic_file_sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | namespace sinks { 15 | 16 | template 17 | SPDLOG_INLINE basic_file_sink::basic_file_sink(const filename_t &filename, bool truncate) 18 | { 19 | file_helper_.open(filename, truncate); 20 | } 21 | 22 | template 23 | SPDLOG_INLINE const filename_t &basic_file_sink::filename() const 24 | { 25 | return file_helper_.filename(); 26 | } 27 | 28 | template 29 | SPDLOG_INLINE void basic_file_sink::sink_it_(const details::log_msg &msg) 30 | { 31 | memory_buf_t formatted; 32 | base_sink::formatter_->format(msg, formatted); 33 | file_helper_.write(formatted); 34 | } 35 | 36 | template 37 | SPDLOG_INLINE void basic_file_sink::flush_() 38 | { 39 | file_helper_.flush(); 40 | } 41 | 42 | } // namespace sinks 43 | } // namespace spdlog 44 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/basic_file_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | /* 17 | * Trivial file sink with single file as target 18 | */ 19 | template 20 | class basic_file_sink final : public base_sink 21 | { 22 | public: 23 | explicit basic_file_sink(const filename_t &filename, bool truncate = false); 24 | const filename_t &filename() const; 25 | 26 | protected: 27 | void sink_it_(const details::log_msg &msg) override; 28 | void flush_() override; 29 | 30 | private: 31 | details::file_helper file_helper_; 32 | }; 33 | 34 | using basic_file_sink_mt = basic_file_sink; 35 | using basic_file_sink_st = basic_file_sink; 36 | 37 | } // namespace sinks 38 | 39 | // 40 | // factory functions 41 | // 42 | template 43 | inline std::shared_ptr basic_logger_mt(const std::string &logger_name, const filename_t &filename, bool truncate = false) 44 | { 45 | return Factory::template create(logger_name, filename, truncate); 46 | } 47 | 48 | template 49 | inline std::shared_ptr basic_logger_st(const std::string &logger_name, const filename_t &filename, bool truncate = false) 50 | { 51 | return Factory::template create(logger_name, filename, truncate); 52 | } 53 | 54 | } // namespace spdlog 55 | 56 | #ifdef SPDLOG_HEADER_ONLY 57 | #include "basic_file_sink-inl.h" 58 | #endif -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/msvc_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 Alexander Dalshov. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #if defined(_WIN32) 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | // Avoid including windows.h (https://stackoverflow.com/a/30741042) 16 | extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char *lpOutputString); 17 | 18 | namespace spdlog { 19 | namespace sinks { 20 | /* 21 | * MSVC sink (logging using OutputDebugStringA) 22 | */ 23 | template 24 | class msvc_sink : public base_sink 25 | { 26 | public: 27 | msvc_sink() = default; 28 | 29 | protected: 30 | void sink_it_(const details::log_msg &msg) override 31 | { 32 | memory_buf_t formatted; 33 | base_sink::formatter_->format(msg, formatted); 34 | OutputDebugStringA(fmt::to_string(formatted).c_str()); 35 | } 36 | 37 | void flush_() override {} 38 | }; 39 | 40 | using msvc_sink_mt = msvc_sink; 41 | using msvc_sink_st = msvc_sink; 42 | 43 | using windebug_sink_mt = msvc_sink_mt; 44 | using windebug_sink_st = msvc_sink_st; 45 | 46 | } // namespace sinks 47 | } // namespace spdlog 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/null_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | 15 | template 16 | class null_sink : public base_sink 17 | { 18 | protected: 19 | void sink_it_(const details::log_msg &) override {} 20 | void flush_() override {} 21 | }; 22 | 23 | using null_sink_mt = null_sink; 24 | using null_sink_st = null_sink; 25 | 26 | } // namespace sinks 27 | 28 | template 29 | inline std::shared_ptr null_logger_mt(const std::string &logger_name) 30 | { 31 | auto null_logger = Factory::template create(logger_name); 32 | null_logger->set_level(level::off); 33 | return null_logger; 34 | } 35 | 36 | template 37 | inline std::shared_ptr null_logger_st(const std::string &logger_name) 38 | { 39 | auto null_logger = Factory::template create(logger_name); 40 | null_logger->set_level(level::off); 41 | return null_logger; 42 | } 43 | 44 | } // namespace spdlog 45 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/ostream_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | namespace spdlog { 13 | namespace sinks { 14 | template 15 | class ostream_sink final : public base_sink 16 | { 17 | public: 18 | explicit ostream_sink(std::ostream &os, bool force_flush = false) 19 | : ostream_(os) 20 | , force_flush_(force_flush) 21 | {} 22 | ostream_sink(const ostream_sink &) = delete; 23 | ostream_sink &operator=(const ostream_sink &) = delete; 24 | 25 | protected: 26 | void sink_it_(const details::log_msg &msg) override 27 | { 28 | memory_buf_t formatted; 29 | base_sink::formatter_->format(msg, formatted); 30 | ostream_.write(formatted.data(), static_cast(formatted.size())); 31 | if (force_flush_) 32 | { 33 | ostream_.flush(); 34 | } 35 | } 36 | 37 | void flush_() override 38 | { 39 | ostream_.flush(); 40 | } 41 | 42 | std::ostream &ostream_; 43 | bool force_flush_; 44 | }; 45 | 46 | using ostream_sink_mt = ostream_sink; 47 | using ostream_sink_st = ostream_sink; 48 | 49 | } // namespace sinks 50 | } // namespace spdlog 51 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/sink-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | SPDLOG_INLINE bool spdlog::sinks::sink::should_log(spdlog::level::level_enum msg_level) const 13 | { 14 | return msg_level >= level_.load(std::memory_order_relaxed); 15 | } 16 | 17 | SPDLOG_INLINE void spdlog::sinks::sink::set_level(level::level_enum log_level) 18 | { 19 | level_.store(log_level, std::memory_order_relaxed); 20 | } 21 | 22 | SPDLOG_INLINE spdlog::level::level_enum spdlog::sinks::sink::level() const 23 | { 24 | return static_cast(level_.load(std::memory_order_relaxed)); 25 | } 26 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/sink.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace spdlog { 10 | 11 | namespace sinks { 12 | class SPDLOG_API sink 13 | { 14 | public: 15 | virtual ~sink() = default; 16 | virtual void log(const details::log_msg &msg) = 0; 17 | virtual void flush() = 0; 18 | virtual void set_pattern(const std::string &pattern) = 0; 19 | virtual void set_formatter(std::unique_ptr sink_formatter) = 0; 20 | 21 | void set_level(level::level_enum log_level); 22 | level::level_enum level() const; 23 | bool should_log(level::level_enum msg_level) const; 24 | 25 | protected: 26 | // sink log level - default is all 27 | level_t level_{level::trace}; 28 | }; 29 | 30 | } // namespace sinks 31 | } // namespace spdlog 32 | 33 | #ifdef SPDLOG_HEADER_ONLY 34 | #include "sink-inl.h" 35 | #endif 36 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/stdout_color_sinks-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifndef SPDLOG_HEADER_ONLY 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | namespace spdlog { 14 | 15 | template 16 | SPDLOG_INLINE std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode) 17 | { 18 | return Factory::template create(logger_name, mode); 19 | } 20 | 21 | template 22 | SPDLOG_INLINE std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode) 23 | { 24 | return Factory::template create(logger_name, mode); 25 | } 26 | 27 | template 28 | SPDLOG_INLINE std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode) 29 | { 30 | return Factory::template create(logger_name, mode); 31 | } 32 | 33 | template 34 | SPDLOG_INLINE std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode) 35 | { 36 | return Factory::template create(logger_name, mode); 37 | } 38 | } // namespace spdlog -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/sinks/stdout_color_sinks.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #ifdef _WIN32 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #include 13 | 14 | namespace spdlog { 15 | namespace sinks { 16 | #ifdef _WIN32 17 | using stdout_color_sink_mt = wincolor_stdout_sink_mt; 18 | using stdout_color_sink_st = wincolor_stdout_sink_st; 19 | using stderr_color_sink_mt = wincolor_stderr_sink_mt; 20 | using stderr_color_sink_st = wincolor_stderr_sink_st; 21 | #else 22 | using stdout_color_sink_mt = ansicolor_stdout_sink_mt; 23 | using stdout_color_sink_st = ansicolor_stdout_sink_st; 24 | using stderr_color_sink_mt = ansicolor_stderr_sink_mt; 25 | using stderr_color_sink_st = ansicolor_stderr_sink_st; 26 | #endif 27 | } // namespace sinks 28 | 29 | template 30 | std::shared_ptr stdout_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 31 | 32 | template 33 | std::shared_ptr stdout_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 34 | 35 | template 36 | std::shared_ptr stderr_color_mt(const std::string &logger_name, color_mode mode = color_mode::automatic); 37 | 38 | template 39 | std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); 40 | 41 | } // namespace spdlog 42 | 43 | #ifdef SPDLOG_HEADER_ONLY 44 | #include "stdout_color_sinks-inl.h" 45 | #endif 46 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/stopwatch.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | // Stopwatch support for spdlog (using std::chrono::steady_clock). 9 | // Displays elapsed seconds since construction as double. 10 | // 11 | // Usage: 12 | // 13 | // spdlog::stopwatch sw; 14 | // ... 15 | // spdlog::debug("Elapsed: {} seconds", sw); => "Elapsed 0.005116733 seconds" 16 | // spdlog::info("Elapsed: {:.6} seconds", sw); => "Elapsed 0.005163 seconds" 17 | // 18 | // 19 | // If other units are needed (e.g. millis instead of double), include "fmt/chrono.h" and use "duration_cast<..>(sw.elapsed())": 20 | // 21 | // #include 22 | //.. 23 | // using std::chrono::duration_cast; 24 | // using std::chrono::milliseconds; 25 | // spdlog::info("Elapsed {}", duration_cast(sw.elapsed())); => "Elapsed 5ms" 26 | 27 | namespace spdlog { 28 | class stopwatch 29 | { 30 | using clock = std::chrono::steady_clock; 31 | std::chrono::time_point start_tp_; 32 | 33 | public: 34 | stopwatch() 35 | : start_tp_{clock::now()} 36 | {} 37 | 38 | std::chrono::duration elapsed() const 39 | { 40 | return std::chrono::duration(clock::now() - start_tp_); 41 | } 42 | 43 | void reset() 44 | { 45 | start_tp_ = clock ::now(); 46 | } 47 | }; 48 | } // namespace spdlog 49 | 50 | // Support for fmt formatting (e.g. "{:012.9}" or just "{}") 51 | namespace fmt { 52 | template<> 53 | struct formatter : formatter 54 | { 55 | template 56 | auto format(const spdlog::stopwatch &sw, FormatContext &ctx) -> decltype(ctx.out()) 57 | { 58 | return formatter::format(sw.elapsed().count(), ctx); 59 | } 60 | }; 61 | } // namespace fmt 62 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/include/spdlog/version.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #pragma once 5 | 6 | #define SPDLOG_VER_MAJOR 1 7 | #define SPDLOG_VER_MINOR 8 8 | #define SPDLOG_VER_PATCH 2 9 | 10 | #define SPDLOG_VERSION (SPDLOG_VER_MAJOR * 10000 + SPDLOG_VER_MINOR * 100 + SPDLOG_VER_PATCH) 11 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/lib/cmake/spdlog/spdlogConfig.cmake: -------------------------------------------------------------------------------- 1 | # Copyright(c) 2019 spdlog authors 2 | # Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | find_package(Threads REQUIRED) 5 | 6 | set(SPDLOG_FMT_EXTERNAL OFF) 7 | set(config_targets_file spdlogConfigTargets.cmake) 8 | 9 | if(SPDLOG_FMT_EXTERNAL) 10 | include(CMakeFindDependencyMacro) 11 | find_dependency(fmt CONFIG) 12 | endif() 13 | 14 | 15 | include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}") 16 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/lib/cmake/spdlog/spdlogConfigTargets-release.cmake: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------- 2 | # Generated CMake target import file for configuration "Release". 3 | #---------------------------------------------------------------- 4 | 5 | # Commands may need to know the format version. 6 | set(CMAKE_IMPORT_FILE_VERSION 1) 7 | 8 | # Import target "spdlog::spdlog" for configuration "Release" 9 | set_property(TARGET spdlog::spdlog APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 10 | set_target_properties(spdlog::spdlog PROPERTIES 11 | IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" 12 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libspdlog.a" 13 | ) 14 | 15 | list(APPEND _IMPORT_CHECK_TARGETS spdlog::spdlog ) 16 | list(APPEND _IMPORT_CHECK_FILES_FOR_spdlog::spdlog "${_IMPORT_PREFIX}/lib/libspdlog.a" ) 17 | 18 | # Commands beyond this point should not need to know the version. 19 | set(CMAKE_IMPORT_FILE_VERSION) 20 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/install/lib/pkgconfig/spdlog.pc: -------------------------------------------------------------------------------- 1 | prefix=/home/romain/dev/QBDL/_work/spdlog-1.8.2/install 2 | exec_prefix=${prefix} 3 | includedir=${prefix}/include 4 | libdir=${exec_prefix}/lib 5 | 6 | Name: libspdlog 7 | Description: Fast C++ logging library. 8 | URL: https://github.com/gabime/spdlog 9 | Version: 1.8.2 10 | CFlags: -I${includedir} -DSPDLOG_COMPILED_LIB 11 | Libs: -L${libdir} -lspdlog -pthread 12 | Requires: 13 | 14 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/scripts/extract_version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import re 5 | 6 | base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 7 | config_h = os.path.join(base_path, 'include', 'spdlog', 'version.h') 8 | data = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0} 9 | reg = re.compile(r'^\s*#define\s+SPDLOG_VER_([A-Z]+)\s+([0-9]+).*$') 10 | 11 | with open(config_h, 'r') as fp: 12 | for l in fp: 13 | m = reg.match(l) 14 | if m: 15 | data[m.group(1)] = int(m.group(2)) 16 | 17 | print('{}.{}.{}'.format(data['MAJOR'], data['MINOR'], data['PATCH'])) 18 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/scripts/format.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "$0")"/.. 4 | pwd 5 | echo -n "Running dos2unix " 6 | find . -name "*\.h" -o -name "*\.cpp"|grep -v bundled|xargs -I {} sh -c "dos2unix '{}' 2>/dev/null; echo -n '.'" 7 | echo 8 | echo -n "Running clang-format " 9 | find . -name "*\.h" -o -name "*\.cpp"|grep -v bundled|xargs -I {} sh -c "clang-format -i {}; echo -n '.'" 10 | echo 11 | echo -n "Running cmake-format " 12 | find . -name "CMakeLists.txt" -o -name "*\.cmake"|grep -v bundled|xargs -I {} sh -c "cmake-format --line-width 120 --tab-size 4 --max-subgroups-hwrap 4 -i {}; echo -n '.'" 13 | echo 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/src/async.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | template class SPDLOG_API spdlog::details::mpmc_blocking_queue; -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/src/cfg.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/src/file_sinks.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 16 | template class SPDLOG_API spdlog::sinks::basic_file_sink; 17 | 18 | #include 19 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; 20 | template class SPDLOG_API spdlog::sinks::rotating_file_sink; -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/src/spdlog.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors. 2 | // Distributed under the MIT License (http://opensource.org/licenses/MIT) 3 | 4 | #ifndef SPDLOG_COMPILED_LIB 5 | #error Please define SPDLOG_COMPILED_LIB to compile this file. 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | // template instantiate logger constructor with sinks init list 24 | template SPDLOG_API spdlog::logger::logger(std::string name, sinks_init_list::iterator begin, sinks_init_list::iterator end); 25 | template class SPDLOG_API spdlog::sinks::base_sink; 26 | template class SPDLOG_API spdlog::sinks::base_sink; -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/catch.license: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/includes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "catch.hpp" 4 | #include "utils.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG 17 | 18 | #include "spdlog/spdlog.h" 19 | #include "spdlog/async.h" 20 | #include "spdlog/sinks/basic_file_sink.h" 21 | #include "spdlog/sinks/daily_file_sink.h" 22 | #include "spdlog/sinks/null_sink.h" 23 | #include "spdlog/sinks/ostream_sink.h" 24 | #include "spdlog/sinks/rotating_file_sink.h" 25 | #include "spdlog/sinks/stdout_color_sinks.h" 26 | #include "spdlog/pattern_formatter.h" -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch.hpp" -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/test_stopwatch.cpp: -------------------------------------------------------------------------------- 1 | #include "includes.h" 2 | #include "test_sink.h" 3 | #include "spdlog/stopwatch.h" 4 | 5 | TEST_CASE("stopwatch1", "[stopwatch]") 6 | { 7 | using std::chrono::milliseconds; 8 | milliseconds wait_ms(250); 9 | milliseconds tolerance_ms(250); 10 | 11 | spdlog::stopwatch sw; 12 | std::this_thread::sleep_for(wait_ms); 13 | REQUIRE(sw.elapsed() >= wait_ms); 14 | REQUIRE(sw.elapsed() <= wait_ms + tolerance_ms); 15 | } 16 | 17 | TEST_CASE("stopwatch2", "[stopwatch]") 18 | { 19 | using spdlog::sinks::test_sink_st; 20 | 21 | std::chrono::duration wait_duration(0.250); 22 | std::chrono::duration tolerance_duration(0.250); 23 | 24 | auto test_sink = std::make_shared(); 25 | 26 | spdlog::stopwatch sw; 27 | spdlog::logger logger("test-stopwatch", test_sink); 28 | logger.set_pattern("%v"); 29 | std::this_thread::sleep_for(wait_duration); 30 | logger.info("{}", sw); 31 | auto val = std::stod(test_sink->lines()[0]); 32 | 33 | REQUIRE(val >= wait_duration.count()); 34 | REQUIRE(val <= (wait_duration + tolerance_duration).count()); 35 | } 36 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/test_systemd.cpp: -------------------------------------------------------------------------------- 1 | #include "includes.h" 2 | #include "spdlog/sinks/systemd_sink.h" 3 | 4 | TEST_CASE("systemd", "[all]") 5 | { 6 | auto systemd_sink = std::make_shared(); 7 | spdlog::logger logger("spdlog_systemd_test", systemd_sink); 8 | logger.set_level(spdlog::level::trace); 9 | logger.trace("test spdlog trace"); 10 | logger.debug("test spdlog debug"); 11 | SPDLOG_LOGGER_INFO((&logger), "test spdlog info"); 12 | SPDLOG_LOGGER_WARN((&logger), "test spdlog warn"); 13 | SPDLOG_LOGGER_ERROR((&logger), "test spdlog error"); 14 | SPDLOG_LOGGER_CRITICAL((&logger), "test spdlog critical"); 15 | } 16 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/test_time_point.cpp: -------------------------------------------------------------------------------- 1 | #include "includes.h" 2 | #include "test_sink.h" 3 | #include "spdlog/async.h" 4 | 5 | TEST_CASE("time_point1", "[time_point log_msg]") 6 | { 7 | std::shared_ptr test_sink(new spdlog::sinks::test_sink_st); 8 | spdlog::logger logger("test-time_point", test_sink); 9 | 10 | spdlog::source_loc source{}; 11 | std::chrono::system_clock::time_point tp{std::chrono::system_clock::now()}; 12 | test_sink->set_pattern("%T.%F"); // interested in the time_point 13 | 14 | // all the following should have the same time 15 | test_sink->set_delay(std::chrono::milliseconds(10)); 16 | for (int i = 0; i < 5; i++) 17 | { 18 | spdlog::details::log_msg msg{tp, source, "test_logger", spdlog::level::info, "message"}; 19 | test_sink->log(msg); 20 | } 21 | 22 | logger.log(tp, source, spdlog::level::info, "formatted message"); 23 | logger.log(tp, source, spdlog::level::info, "formatted message"); 24 | logger.log(tp, source, spdlog::level::info, "formatted message"); 25 | logger.log(tp, source, spdlog::level::info, "formatted message"); 26 | logger.log(source, spdlog::level::info, "formatted message"); // last line has different time_point 27 | 28 | // now the real test... that the times are the same. 29 | std::vector lines = test_sink->lines(); 30 | REQUIRE(lines[0] == lines[1]); 31 | REQUIRE(lines[2] == lines[3]); 32 | REQUIRE(lines[4] == lines[5]); 33 | REQUIRE(lines[6] == lines[7]); 34 | REQUIRE(lines[8] != lines[9]); 35 | spdlog::drop_all(); 36 | } 37 | -------------------------------------------------------------------------------- /third-party/spdlog-1.8.2/tests/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | std::size_t count_files(const std::string &folder); 7 | 8 | void prepare_logdir(); 9 | 10 | std::string file_contents(const std::string &filename); 11 | 12 | std::size_t count_lines(const std::string &filename); 13 | 14 | void require_message_count(const std::string &filename, const std::size_t messages); 15 | 16 | std::size_t get_filesize(const std::string &filename); 17 | 18 | bool ends_with(std::string const &value, std::string const &ending); --------------------------------------------------------------------------------