Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/billsioros/cereal

A surreal C++ project manager
https://github.com/billsioros/cereal

bash bash-completion bash-script bash-scripting build-automation build-system build-tool builder cplusplus cpp cpp-builder generator makefile makefile-generation module module-loader module-system project-management project-manager

Last synced: 13 days ago
JSON representation

A surreal C++ project manager

Awesome Lists containing this project

README

        

![alt text](img/cereal.png)

## Features

* Project management tools
* Makefile and module generation utilities
* A macro definition shortcut system
* Context aware autocompletion

## Installation

```bash
git clone https://github.com/billsioros/cereal; cd cereal/; ./install.sh
```

![alt text](img/install.png)

* Running the installation script with the **--uninstall** option, will walk you through uninstalling **_cereal_**

## Dependencies
* [python3](https://www.python.org/download/releases/3.0/)

## Programmatic usage

* Firstly, let's run **_cereal_** with the **--config** option, so that a configuration file is generated for our project
* An input consisting only of whitespace characters results in the field at hand taking its default value
* The **--config** option can be used in the future to edit the configuration file
* Bare in mind that, in case you alter your configuration file, updating the makefile is probably going to be required for some changes to take effect

![alt text](img/config.png)

* Let's now create a class named 'Point' using the **--class** option

![alt text](img/class.png)

```cpp

#include

Point::Point()
{

}

Point::Point(const Point& other)
{

}

Point::Point(Point&& other) noexcept
{

}

Point::~Point()
{

}

Point& Point::operator=(const Point& other)
{

}

Point& Point::operator=(Point&& other) noexcept
{

}

```

* Let's add some funtionality to its methods

```cpp

#include

#include
#include

Point::Point() : x(0.0f), y(0.0f)
{
}

Point::Point(float x, float y) : x(x), y(y)
{
}

Point::Point(const Point& other) : x(other.x), y(other.y)
{
}

Point::Point(Point&& other) noexcept : x(std::move(other.x)), y(std::move(other.y))
{
}

Point& Point::operator=(const Point& other)
{
x = other.x; y = other.y; return *this;
}

Point& Point::operator=(Point&& other) noexcept
{
x = std::move(other.x); y = std::move(other.y); return *this;
}

std::ostream& operator<<(std::ostream& os, const Point& point)
{
return os
<< "[ " << point.x
<< ", " << point.y
<< " ]";
}

```

* Let's finally create a test unit and place it in the directory we designated as 'test-path' during the configuration stage

```cpp

#include

#include
#include

#if defined (__ARBITARY__)
#include
#include

#define rand01 (static_cast(std::rand()) / static_cast(RAND_MAX))

#define frand(min, max) ((max - min) * rand01 + min)
#endif

#define SIZE (10UL)

int main()
{
std::vector points;

#if defined (__ARBITARY__)
std::srand(static_cast(std::time(nullptr)));

for (std::size_t i = 0UL; i < SIZE; i++)
points.emplace_back(frand(-10.0f, 10.0f), frand(-10.0f, 10.0f));
#else
for (std::size_t i = 0UL; i < SIZE; i++)
points.emplace_back(0.0f, 0.0f);
#endif

for (const auto& point : points)
std::cout << point << std::endl;

return 0;
}

```

* Let's now run **_cereal_** with the **--makefile** option to generate a makefile for our project

![alt text](img/makefile.png)

* Running **_cereal_** with the **--help** option results in the following output

![alt text](img/help.png)

* Let's now run **_cereal_** with the **--shortcuts** option and check if anything has changed

![alt text](img/shortcuts.png)

* As you can see, **_cereal_** has detected the macro **\_\_ARBITARY\_\_** and created a shortcut for defining it
* I should mention at this point that **_cereal_** does not bother itself with the macro **SIZE**, as it does not take part in any conditional preprocessing block and thus it is considered a _statement_ rather than an _option_

* The output of the final executable when compiled with and without the '-a' shortcut

![alt text](img/with.png)

![alt text](img/without.png)

* The shortcut system works by expanding a _shortcut_ into its corresponding _value_, so you can easily create new shortcuts whose role is not defining a macro. For example:

```json
{
"compiler": "g++",
"compiler-flags": [
"-Wall",
"-Wextra",
"-std=c++17",
"-g3"
],
"external-libraries": [],
"include-path": "./inc",
"source-path": "./src",
"test-path": "./test",
"binaries-path": "./bin",
"shortcuts": {
"-a": "--local __ARBITARY__",
"--reset": "--config --makefile"
}
}
```

![alt text](img/reset.png)

## License

The **_cereal_** project is licensed under the [MIT License](https://opensource.org/licenses/MIT)