Stdx is a comprehensive and ever-expanding C++ standard library extension library, additionally featuring multiple utilities for Zig-build powered C++ projects. This library is closely tied to my other C++ work and development is typically done in tandem.
This is by far the easiest way to get started with development. Just run nix develop to get started and automatically get the correct Zig version as well as some other important development tools. Note that this provides optional preconfigured tools such as LLDB, Clangd, and ZLS to further enhance the developer experience.
All you need to get started with stdx development is git and a valid 0.16.0 Zig installation, which can be found here.
git clone https://github.com/trevorswan11/stdx
cd stdx
zig buildRun the following in an environment where you have a C++ oriented build.zig:
zig fetch --save git+https://github.com/trevorswan11/stdx.gitAt this point you can use the library in your build.zig via:
const profile = b.option(bool, "profile", "Enable chromium tracing") orelse false;
const stdx_dep = b.dependency("stdx", .{
.target = b.graph.host,
.optimize = optimize,
.profile = profile,
.building_for_dep = true,
.run_cdb_gen = false,
});
const libstdx = stdx_dep.artifact("stdx");To reduce shared complexity across different projects, stdx provides the following fully-wired dependencies via the Zig build system:
- Catch2's amalgamated source code is compiled from source for test running. It is automatically configured in the project's build script and links statically to the test builds.
- cppcheck is compiled from source for static analysis. It is licensed under the GNU GPLv3, but the associated compiled artifacts are neither linked with output artifacts nor shipped with releases.
- magic_enum is used as a utility to reflect on enum values. Is is licensed under the permissive MIT License.
- fmt is used as a formatting utility in place of std::format, which is not as performant or feature-full. Is is licensed under the permissive MIT License.
- unordered_dense provides a vastly improved hash map/set implementation that is used over the inefficient C++ standard implementation. Is is licensed under the permissive MIT License.
- gsl is used for enforcing best practices and supporting the standard template library. Is is licensed under the permissive MIT License.
- kcov is used for test coverage reporting. The licensing of this tool and its dependencies are not explicitly listed here as they are not shipped with releases of stdx. It has multiple dependencies, but they are all fetched lazily as kcov is only supported on Linux, MacOS, and FreeBSD:
- curl is required by all builds of kcov and is used for pulling the resulting badge. It has a single extra dependency which is chosen for cross-platform support:
- binutils is required for all kcov builds
- elfutils is required on linux only. It has a single extra dependency:
- libdwarf-code is required on MacOS only.
- libarchive is used for packaging releases, making use of zlib and zstd to create
zipandzstarchives. It is license under the BSD 2-Clause License, but the associated compiled artifacts are neither linked with output artifacts nor shipped with releases.
Distributed under the MIT License. See LICENSE for more information.
Project Link: https://github.com/trevorswan11/stdx