Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
A tool written in node.js
designed to maintain C, C++ and ObjectiveC projects.
WORK-IN-PROGRESS!
This is a tool I use to manage my projects, it can change a bit, but the idea will stay the same. I don't wanna repeat the same things in every project I start or already maintain. This tool made it possible - it can auto-generate everything that is repeating, but necessary, thanks to diversity in CPU architectures, operating systems, and C/C++ compilers.
The best way to see what it really does is to check-out asmjit's build.h, where cxxtool
generates more than 90% of the file.
A multi-purpose tool for C/C++ projects that allows to verify and fix coding-style issues (end-of-line settings, TABs vs. spaces, etc), to pre-generate code based on built-in templates, and to evaluate JS code and generate C++ code. This tool has been designed for developers to help with project maintenance, it's not intended to be used by people that just want to compile or use the project.
Often, when doing a cross-platform development, some tools add wrong line-engings, TABs, trailing spaces/lines, etc..., and all of it together degrades a visual quality of the project's sources. It becomes a nightmare when these issues are not resolved from the beginning and when commits start fixing line endings, TABs, etc... The cxxtool
is not a complete solution, but running it before each commit should help to eliminate most of the issues mentioned and should enable project authors to use any editors they need, even those that cannot be configured properly, to work on the project and keep its quality at a high level.
In addition, cxxtool
contains also templates that can be used to generate a boilerplate code that is often found in many open-source and cross-platform projects, at various places, and has various quality and C/C++ compiler coverage.
Coding-style sanitizers - check and possibly fix the following:
NoTabs
- specifies that TABs are not allowed, and how many spaces per TABs should be used when replacing themNoTrailingSpaces
- specifies that no trailing spaces are allowed in source filesNoTrailingLines
- specifies that there shouldn't be empty lines at the end of source filesUnixEOL
and WindowsEOL
- specifies which line ending should be used in source filesSortIncludes
- specifies that all #include
directives should be sorted alphabeticallyBuilt-in template expansion (ExpandTemplates
option must be enabled)
@prefix@
By default, cxxtool
reads a file cxxconfig.js
, which should be located at the root of your project. Alternatively a configuration file can be passed through --config=your-config-file.js
option.
The configuration file is imported by node.js, so basically it's executed. It looks like this:
module.exports = {
// Name of your product, usually lowercase, but can be anything.
product: "superlib",
// Version of the product (you can use this to substitute numbers in your sources).
version: "1.0.0",
// Prefix used by template expansion to fit into your project.
prefix: "SUPERLIB",
// Where source files are located. Can be an array as well.
source: "src/superlib",
// Specifies which tools to enable. All tools have to be enabled explicitly.
tools: {
NoTabs : true,
NoTrailingLines : true,
NoTrailingSpaces: true,
UnixEOL : true,
SortIncludes : true,
ExpandTemplates : true
}
};
Once the configuration is loaded the cxxtool
will try to read all source files and verify that they are fine.
Usage:
cxxtool <command> [...]
Where command could be:
purge
- Removes all generated code from all source files. After done all source files contains only markers where the code can be generated again. It's perfectly safe to purge
and generate
againgenerate
- Preprocesses and sanitizes all source filessanitize
- Does only sanitization of all source fileslist-tools
- Prints all built-in toolslist-templates
- Prints all built-in templatesOther important options:
--config=file
- Selects which configuration to use--test
- Test mode, won't overwrite files, only lists which files should be updated;--verbose
- Display verbose messagesThe ExpandTemplates
tool can be also used to generate C/C++ code based on an embedded javascript. The following example shows how to generate a static table with logic implemented directly in the source file itself (the example has been taken from Blend2D's deflate decoder implementation):
// This is a special marker recognized by `ExpandTemplates` tool. It parses
// it and stores it as a template. The JS code within must be a valid JS code.
//
// [%DEFLATE_TABLE%{
// var table = [];
// for (var i = 0; i < 288; i++) {
// table.push(i <= 143 ? 8 :
// i <= 255 ? 9 :
// i <= 279 ? 7 : 8);
// }
// return string.formatTable(table, 78);
// }%]
static const uint8_t builtinDeflateTable[288] = {
// This is again a special marker, but it doesn't define a template, but it
// will expand it (% is a template-definition, @ is a template-use).
// [@DEFLATE_TABLE@]
};
When you run cxxtool generate
at your project's root, it should result in following:
// This is a special marker recognized by `ExpandTemplates` tool. It parses
// it and stores it as a template. The JS code within must be a valid JS code.
//
// [%DEFLATE_TABLE%{
// var table = [];
// for (var i = 0; i < 288; i++) {
// table.push(i <= 143 ? 8 :
// i <= 255 ? 9 :
// i <= 279 ? 7 : 8);
// }
// return string.formatTable(table, 78);
// }%]
static const uint8_t builtinDeflateTable[288] = {
// This is again a special marker, but it doesn't define a template, but it
// will expand it (% is a template-definition, @ is a template-use).
// [@DEFLATE_TABLE{@]
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
8, 8
// [@DEFLATE_TABLE}@]
};
The cxxtool
found [%DEFLATE_TABLE%{...}%]
template definition (it's actually a code-generator, but it doesn't really matter here) and then found template substitution mark [@DEFLATE_TABLE@]
, which it then expanded. Notice that it only reads comments, it won't expand anything outside comments, however, it may overwrite anything that is within start and end marks.
When you run cxxtool purge
you will get the initial code back:
// This is a special marker recognized by `ExpandTemplates` tool. It parses
// it and stores it as a template. The JS code within must be a valid JS code.
//
// [%DEFLATE_TABLE%{
// var table = [];
// for (var i = 0; i < 288; i++) {
// table.push(i <= 143 ? 8 :
// i <= 255 ? 9 :
// i <= 279 ? 7 : 8);
// }
// return string.formatTable(table, 78);
// }%]
static const uint8_t builtinDeflateTable[288] = {
// This is again a special marker, but it doesn't define a template, but it
// will expand it (% is a template-definition, @ is a template-use).
// [@DEFLATE_TABLE@]
};
FAQs
A tool designed to maintain C, C++ and ObjectiveC projects.
The npm package cxxtool receives a total of 1 weekly downloads. As such, cxxtool popularity was classified as not popular.
We found that cxxtool demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.