ccc
The ccc is a cross platform (currently only supported on Windows and Linux) build tool for C/C++ projects, using C++ as the configuration language for the project.
- gnu toolchain
- gnu toolchain
- python
- gnu toolchain
git clone https://github.com/buttfa/ccc.git
cd cccmake release
# or
ccc release # If you have installed cccmake installmake uninstallccc help1. Execution(Hello world)
#include <iostream>
using namespace std;
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}#include "ccc/project.h"
#include <string>
#include <vector>
using namespace ccc;
using namespace std;
/* In the init_project function, we can describe and add the libraries and
* applications that make up the project. */
void init_project(project* self, string cmd, vector<string> args) {
// Create an application, hello_world is the name of the application.
execution exe("hello_world", "Say hello world!");
exe.add_source_files({"./src"}, {".cpp"}); // Add source files
self->add_task(&exe); // Add the application to the project
}
/* We did not request any resources that need to be manually processed in
* init_project, so we did nothing in exit_project. */
void exit_project(project* self, string cmd, vector<string> args) {}
/* Register a project and specify its initialization and exit functions. */
project my_project("hello_world", init_project, exit_project,
"Say hello world!");ccc build && ./build/hello_world$ ccc build && ./build/hello_world
g++ -c src\main.cpp -o ./build/obj//src\main.obj -fdiagnostics-color=always 2>&1
g++ ./build/obj//src\main.obj -o ./build//hello_world
Hello, World!2. Library(Math library)
There are two types of libraries in ccc: static library and shared library. The type of library is defined as follows(The static library is the default type).
enum library_type { static_library, shared_library };#include "ccc/project.h"
#include <string>
#include <vector>
using namespace std;
using namespace ccc;
void init_project(project* self, string cmd, vector<string> args) {
/* Create a library, When the suffix of 'name' is not written, ccc will
* automatically add the prefix and suffix of the library based on the
* platform. For example, under the Windows operating system, the name of a
* static library will be changed to lib<name>.lib */
library mathlib("mymath", library_type::static_library, "My Math Library");
/* Change to shared library(Default is static library). */
// mathlib.type = shared_library;
mathlib.add_source_files({"./src/my_math.cpp"}); // Add source file
mathlib.add_header_folder_paths({
"./inc/", // Add header folder path
});
self->add_task(&mathlib); // Add library to project
}
void exit_project(project* self, string cmd, vector<string> args) {}
project my_project("Math_Lib", init_project, exit_project, "My Math Project");ccc build$ ccc build
g++ -c ./src/my_math.cpp -o ./build/obj//./src/my_math.obj -I./inc/ -fdiagnostics-color=always 2>&1
ar rcs ./build//libmymath.lib ./build/obj//./src/my_math.obj3. Dependency(My Math)
#include "ccc/project.h"
#include <string>
#include <vector>
using namespace std;
using namespace ccc;
void init_project(project* self, string cmd, vector<string> args) {
// Describe the library
library mathlib("mymath", library_type::static_library, "My Math Library");
mathlib.add_source_files({"./math_lib/src/my_math.cpp"}); // Add source file
mathlib.add_header_folder_paths({
"./math_lib/inc/", // Add header folder path
});
// Describe the executable
execution myexe("myexe", "My Executable to test my math library.");
myexe.add_source_files({"./math_exe/src/main.cpp"});
// Add dependency
// The first true indicates adding the dependency directly to the target,
// and the second true indicates compiling it if the dependency does not
// exist.
myexe.add_dependency(&mathlib, true, true);
self->add_task(&myexe);
}
void exit_project(project* self, string cmd, vector<string> args) {}
project my_project("Math", init_project, exit_project, "My Math Project");ccc build && ./build/myexe$ ccc build && ./build/myexe
g++ -c ./math_lib/src/my_math.cpp -o ./build/obj//./math_lib/src/my_math.obj -I./math_lib/inc/ -fdiagnostics-color=always 2>&1
ar rcs ./build//libmymath.lib ./build/obj//./math_lib/src/my_math.obj
g++ -c ./math_exe/src/main.cpp -o ./build/obj//./math_exe/src/main.obj -I./math_lib/inc/ -fdiagnostics-color=always 2>&1
g++ ./build/obj//./math_exe/src/main.obj ./build//libmymath.lib -o ./build//myexe
1 + 2 = 3
1 - 2 = -1- build
ccc::command build_cmd("build", build, "Build the projects based on project.cpp.");
- clean
ccc::command clean_cmd("clean", clean, "Remove products from the projects.");
- describe
The 'describe' command is used to get the description about something and its delcaration is as follows.
ccc::command desc_cmd({"desc", "describe"}, describe, "Get a description of what you want to know.");
- version
For example, We use 'ccc release' instead of 'ccc build release' by defining the 'release' command in this project.
command release_cmd(
"release",
[](vector<string> args) {
cout << "Compile the ccc in release mode." << endl;
std::string cmd = "ccc build release";
for (size_t i = 0; i < args.size(); i++) {
cmd += " " + args[i];
}
#ifdef _WIN32
system(cmd.c_str());
#endif
#ifdef __linux__
system(("bash -c '" + cmd + "'").c_str());
#endif
},
"Compile the ccc in release mode.");ccc project -g




