Build & Test |
|
---|
Wanager (aka wng) is a package manager & build tool (like cargo for Rustlang) for the C programming language written in Rust. It allow you to create projects, headers, to install libraries & to compile and run fast and easily. It is different from CMake by its hability to manage libraries, packages and projects. The objective of this tool is to definitely give up Makefiles.
Make sure to have Git, tar & gcc installed on your computer.
To install wng you can either :
- Download the latest binary in the releases
- Run cargo install
- In /bin/ if you are on *nix
- In C:\Program Files\ if you are on Windows
Open the command prompt and run :
$ wng new <project_name>
$ cd project_name/
Three folders have been created, tests/
, src/
and build/
In src/
, you'll find file main.c
that contains a basic hello world program.
``` $ wng build
$ wng run
NOTE : wng build
will build a debug executable, with flags -W -Wall -Werror -Wextra. To disable this, build in release mode with : wng build --release
To build with a custom build, you have to create a build.py
file with your code to build.
If you want to specify a special python interpreter path, add the section "pyinterpreter" : "path2python"
to your project.json.
Minimal python version required : 3.5
Then run your script with wng build --custom
Wng API provides some useful things to compile your project as you want to.
```py from wngbuild import * # Import all from wngbuild module
build = BuildProfile(files="src/*.c",output="build/custom/prog.exe" ) # setup a build profile that will compile all files in src/ and place the binary in build/custom/prog.exe build.cc = "C:\MinGW\bin\gcc.exe" # Setup the compiler (optional, by default "gcc") build.flags = "-W -Wall -Werror -Wextra" # Setup the flags that the command will be run with (optional)
build.run() # Run the compilation command build.runOutput() # Run the binary produced by the compilation command (Will raise an error if the compilation command fails) ```
You can just check if there is any errors or warnings in your code without producing any binary with wng check
To create a gunzip archive of your project files, just run wng archive
and a file called project.tar.gz
will be created
$ wng reinit
Really want to reinit ? Y/N : Y
Project renitialized !
``` $ wng header foo $ cat foo.h
```
Tests have to be in tests/tests.c
To use functions that are in src/ files, just include the header with #include "../src/<header>.h
"
Then you can run them with wng test
$ cd yourproject/
$ wng install <source>:<username>/<repo_name>
Available sources are : github
,gitlab
& bitbucket
NOTE : Repository has to have a lib/
folder inside or wng will refuse to install it
Create a repository on GitHub, BitBucket or GitLab with your project, library files have to be in a lib/
folder
See our contribution guidelines.