- C++ 96.4%
- Nix 2.5%
- Shell 1.1%
| logo | Added logos | |
| src | Changed OPT_UseNix back to true | |
| .gitignore | Added a specific commit for default.nix to use | |
| build.sh | Changed defaults to use the more common gcc instead of clang | |
| cbuild.toml | Finished adding and testing new toml parser | |
| default.nix | Updated default.nix | |
| LICENSE | Initial commit | |
| README.md | Updated README.md and added a shell.nix | |
| shell.nix | Updated README.md and added a shell.nix | |
CBuild
NOTICE
I will eventually change the name and licensing of CBuild in the near future as/if the project grows.
What is it?
CBuild is a small command-line build utility I made for myself as a small and portable alternative to make and cmake. Keep in mind that this is not being pitched as a competitior in the slightest.
Originally this was written in C but my original code was not the best when it came to scalability, plus I want to get more into writing C++ code, so I thought I might as well do a full rewrite and language change.
What chenges came from the rewrite?
With the rewrite I also added a couple QoL changes, main big ones include:
- Better config file structure, along with a better and more expandable parser.
- Better source directory includes. Now you just specify a source directory and CBuild will recursivley search it.
- More options to set, mainly adding seperate flags and test cases for
debugandreleasebuilds. - Better info printing, CBuild now displays a full command that it'll use for building.
- Better code (I think), although it can always be improved. Most of it is making the Builder a class (fancy).
Usage and building
To build the project you can use CBuild, but obviously to build it for the first time building it, so I included a build.sh script. Run:
bash build.sh
and it'll create a cbuild binary in the current directory.
I have tried to keep decent compatibility with the old CBuild (apart from the config file), so for the 0 people that use it in scripts, its not gonna be broken.
Running CBuild is pretty straightforward:
cbuild -<options> @<standard> %<git_branch> <name>
When CBuild checks the arguments passed to it, it checks what type of argument it is with the leading character:
-means its an options argument.@means its a standard (C/C++ standard) argument.%means its a git branch argument (name to use for the "main" branch)- Default means its a name argument that sets the projects name.
The options you can have (and string together in one argument):
iinitialises a project.ooverwrites a project file (cbuild.toml) and makes a new one. Has to be used alongsidei. Good for making old CBuild projects into modern ones.ppurge everything in the current directory. Has to be used alongsidei.cmake the new project be a C project instead of C++.ginitiate git in the current directory and create a branch with a select name (git support needs to be compiled in).ncreate a basic shell.nix file (nix support needs to be compiled in).rbuild a release build of the project.ddo a dry run (print the build command but DONT run it).tperform a test run on the newly built program.
The standard argument is preceeded with an @, and then the standard you want the project to be afterwards.
A few usage examples:
cbuild -cip @c99 testmakes a C project calledtestwith the C99 standard. It also purges everything in the current directory.cbuild -io testoverwrites the project file in the current directory, and makes the new project file use the nametest.cbuild -rtbuilds a release build of the project and runs it afterwards.cbuild @c++20builds a debug build using the C++20 standard.
Intitialising will make a project tree of:
.
|-- cbuild.toml
|-- src/
| \-- main.cpp (or main.c)
\-- target/
|-- debug/
\-- release/
To the keen-eyed individual, it is blatantly obvious I ripped off the cargo project tree. The main.cpp file will have whatever extension is set to default for C++, and if its a C project it will just be main.c instead. The main project file has a small Hello World program already written inside, ripping cargo off even more. The release builds will go into target/release/ and debug builds wil go into target/debug/, obviously.
The default project file is:
[project]
name = "a.out"
source = "src"
compiler = "g++"
standard = "default"
defenitions = []
[flags]
debug = "-Wall -g"
release = "-O2 -Wall"
global = none
[file]
extension = "cpp"
[test]
debug = none
release = none
All the options I believe to be pretty self explanatory. In the future I'll add being able to change these with environment variables, but it is not added yet.
Future of this project?
Im currently still studying in college, so there wont be any frequent updates, although I do have a lot in mind for this, some stuff ambitious other stuff not as much.
Stuff I do wanna add though will include:
- Other language support, maybe.
- Certain C/C++ project types, such as
ncursesorsdl2and whatnot, which will add all the needed flags for that library. - Reading environment variables and using that to assign certain internal variables, kinda like how make and cmake do it.
Some notes
- If this project grows to be big enough I might change the license to be GPLv3+, although right now I'm not bothered enough.
- Will take name suggestions, if its even worth changing the name. CBuild is a bit generic.