CBuild
C++ build system with scripts written in c++
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Enumerations | Functions | Variables
CBuild Namespace Reference

Filebuffer for CBuild ecosystem. More...

Namespaces

namespace  consts
 Constants.
 
namespace  fs
 
namespace  Registry
 
namespace  types
 
namespace  vars
 

Classes

class  CBuildDependency
 
class  CBuildHash
 
class  CBuildHashV2
 
class  CBuildRebuildScript
 
class  ccj_out
 Generates compile_commands.json. More...
 
class  CLANG
 
class  CLANGMT
 
class  CLANGXX
 
class  CLANGXXMT
 
struct  cmd
 Command for compile_commands.json. More...
 
class  CmdList
 
class  ConfigToolchain
 
class  CrossCompiler
 
class  Dependency
 
class  filebuff
 Base class of filebuffer. More...
 
class  GCC
 
class  GCCHash
 
class  GCCMT
 
class  generator_base
 Base for any generator. More...
 
class  GeneratorList
 
class  GXX
 
class  GXXMT
 
class  Hash
 
class  Help
 
class  Init
 Init task. More...
 
class  line_filebuff
 
class  makefile_out
 Generate Makefile from task/target, works as command logger. More...
 
class  MetaToolchain
 
class  MINGW_GCC
 
class  MINGW_GCCMT
 
class  MINGW_GXX
 
class  MINGW_GXXMT
 
class  NetDependency
 
struct  package_info
 Package info struct for data for pkg-config. More...
 
struct  Path
 Path datatype. More...
 
struct  Project_dependency
 Project dependency data. More...
 
class  SimpleToolchain
 Very simple generic toolchain, rely on compiler to support '-c' flat to specify files to compile and '-o' flag to specify output object file, linker need to support '-o' flag to specify output binary. This should work with all gcc and clang variants. More...
 
struct  source_metadata_file
 Metadata for source files (.cpp/.c/etc) Structure of file: More...
 
class  str_filebuff
 
struct  target_metadata_file
 Metadata for a full toolchain Structure of file: More...
 
class  Task
 Task, can be runned from shell or code. More...
 
class  TaskList
 
class  Toolchain
 Toolchain class. More...
 
class  ToolchainList
 
struct  ToolState
 
class  Version
 Version task. More...
 

Concepts

concept  HashImpl
 Hasher implementation.
 
concept  ToolchainImpl
 Toolchain implementation.
 

Typedefs

typedef enum CBuild::ARG_TYPE ARG_TYPE
 
using handler = ARG_TYPE (*)(lib::map<std::string, std::string>*, char**, int, int, CBuild::RType*)
 Handler for specific argument.
 
typedef struct CBuild::package_info package_info
 Package info struct for data for pkg-config.
 

Enumerations

enum  stage { PRE , POST }
 Type of depencesies for toolchain. More...
 
enum  build_type { EXECUTABLE , STATIC_LIBRARY , DYNAMIC_LIBRARY }
 
enum  RType {
  TASK , BUILD , RUN , BUILD_RUN ,
  DEBUG , CLEAR , REBUILD , LOAD_DEPS ,
  ERROR
}
 Run mode. More...
 
enum  ARG_TYPE {
  BLANK_ARG = 0 , SIMPLE_ARG = 1 , TASK_ARG = 2 , TOOLCHAIN_ARG = 2 ,
  GENERICK_ARG = 2 , GENERATOR_ARG = 2 , INC_ONE = 1 , INC_TWO = 2 ,
  INC_THREE = 3 , INC_FOUR = 4 , INC_FIVE = 5 , INC_SIX = 6 ,
  INC_SEVEN = 7 , INC_EIGHT = 8 , INC_NINE = 9 , INC_TEN = 10
}
 Type of argument, indicate how many tokens this argument consumes, including self. More...
 
enum  buffer_state { MATCH , FILE_NEWER , BUFFER_NEWER }
 Represent atate of buffer. More...
 
enum  color {
  BLACK = 30 , RED = 31 , GREEN = 32 , YELLOW = 33 ,
  BLUE = 34 , MAGENTA = 35 , CYAN = 36 , WHITE = 37
}
 Text color. More...
 

Functions

int read_file_metadata (std::string target_id, std::string src_file, CBuild::source_metadata_file *metadata)
 Load metadata for source file.
 
int read_file_metadata_direct (std::string target_id, std::string file, CBuild::source_metadata_file *metadata)
 Load metadata for source file.
 
int read_target_metadata (std::string target_id, CBuild::target_metadata_file *metadata)
 Load metadata for a full target.
 
int read_target_metadata_direct (std::string path, CBuild::target_metadata_file *metadata)
 Load metadata for a full target using path to metdata file.
 
int read_file_hash (std::string target_id, std::string file, uint64_t *hash)
 Get a file hash (internally uses read_file_metadata, so no performance benefits, but easiier to use in hasher)
 
int write_file_metadata (std::string target_id, std::string src_file, CBuild::source_metadata_file *metadata)
 Write a metadata for a file to a file.
 
int write_target_metadata (std::string target_id, CBuild::target_metadata_file *metadata)
 Write a metadata for a full target.
 
int write_file_hash (std::string target_id, std::string file, uint64_t *hash)
 
std::string get_file_metadata_path (std::string target_id, std::string file)
 Get the path to a file metadata file.
 
std::string get_target_metadata_path (std::string target_id)
 Get the path to a target metadata file.
 
RType parse (lib::map< std::string, std::string > *args, int argc, char **argv)
 Parse arguments.
 
void loop (RType mode, lib::map< std::string, std::string > *args)
 loop of CBuild
 
void rebuild (std::string scripts)
 Rebuild userspace part of CBuild.
 
std::string get_version_string ()
 Return version as string.
 
int get_version_major ()
 Get major component of CBuild version.
 
int get_version_minor ()
 Get minor component of CBuild version.
 
int * get_version_array ()
 Get full CBuild version as int array of two components, no oveflow or rewrite check !
 
std::string get_random_string (unsigned int length)
 Generate random string with specified range, on Linux can use /dev/urandom.
 
void exit (int code)
 
bool register_parse_handler (std::string cmd, CBuild::handler parser)
 Register new handler for parsing cli args, see handler typedef comment to guide how to write handlers.
 
void add_env_var (std::string var, std::string value)
 Add environment variable to CBuild::system and CBuild::system_piped calls.
 
std::string remove_env_var (std::string var)
 Remove registered environment var.
 
void change_env_var (std::string var, std::string new_value)
 Change value for environment var.
 
std::vector< std::string > parse_lines (std::string in)
 Parse string to vector of strings.
 
std::vector< std::string > get_files (std::vector< std::string > files, std::vector< std::string > objects, std::string toolchain_id)
 Get changed files.
 
void print_files ()
 Print temporary file array.
 
lib::map< std::string, std::string > gcc_hash_impl (std::vector< std::string > file_list, std::vector< std::string > objects_list, std::string target_id)
 Implementation of GCC hasher.
 
uint64_t hash_djb2 (std::string str)
 djb2 hashing function for std::string
 
uint64_t hash_fnv_1a (std::string str)
 FNV-1a hashing function for std::string.
 
bool get_pkg_info (CBuild::package_info *package)
 Get the package info from pkg-config database.
 
void print (std::string msg, color fg=CBuild::WHITE)
 Print colored text to STDOUT.
 
void print_full (std::string msg, color fg=CBuild::WHITE)
 Print colored text to STDOUT if verbose flag is set.
 
void printf (color fg, const char *fmt,...) __attribute__((format(printf
 Some poor printf implementation.
 
void void printf_full (color fg, const char *fmt,...) __attribute__((format(printf
 Some poor printf implementation for verbouse-only prints.
 
void void void print_verbose ()
 Enable verbose flag.
 
void print_none ()
 Fully disable all print though CBuild::print.
 
void print_toggle ()
 Toogle print betwen none and currently selected level.
 
int system (std::string cmd)
 Call stdlib system() and print cmd to shell.
 
std::string system_piped (std::string cmd, unsigned int buffsize)
 Execute command and return it's output.
 
std::vector< std::string > * get_log ()
 Get the internall command log.
 
void disable_system ()
 Disable system commands execution.
 
void enable_system ()
 Reanable system commands execution, used only in pkg-config.
 
bool is_system_enabled ()
 Check if CBuild::system enabled.
 
ARG_TYPE force_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE out_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE generator_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE build_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE task_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE arg_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
ARG_TYPE rebuild_handler (lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
 
std::string eval_cmd (std::array< std::string, 4 > data)
 Evaluate compilation cmd.
 
std::string preprocess_json_str (std::string_view str)
 Preprocess string for json.
 
CBuild::types::file_content get_file_data (std::string path, std::string included_from="")
 Get content of file.
 
uint64_t hash (std::string str)
 FNV-1a hashing function for std::string.
 
void procces_files (std::vector< std::string > files, std::vector< std::string > objects, std::string toolchain_id)
 Procces file data.
 
void store_hash (std::string toolchain_id)
 Store new hashes to file.
 
void load_hash (std::string toolchain_id)
 Load old hashes.
 
void print_internal (std::string msg, CBuild::color fg)
 
void printf_internal (CBuild::color fg, std::string msg, va_list va)
 
std::string get_env_vars ()
 

Variables

int version [] = {CBUILD_VERSION_MAJOR, CBUILD_VERSION_MINOR}
 
bool real_exit = true
 
int arg = 0
 
int parg = 0
 
lib::map< std::string, handlerparsers_list
 All handlers.
 
bool verbose = false
 
bool none = false
 
bool toogle = true
 
std::vector< std::string > log
 
std::map< std::string, std::string > env_vars
 
bool enabled = true
 

Detailed Description

Filebuffer for CBuild ecosystem.

Hasher v3.0 implementation.

Hasher v3.0 for CBuild.

Author
WolodiaM (w_mel.nosp@m.nyk@.nosp@m.outlo.nosp@m.ok.c.nosp@m.om)
Date
Wed May 3 01:44:19 PM EEST 2023

@license GPL v3.0 or later

Copyright (C) 2022 WolodiaM This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Author
WolodiaM (w_mel.nosp@m.nyk@.nosp@m.outlo.nosp@m.ok.c.nosp@m.om)
Date
Fri May 19 11:21:22 AM EEST 2023

@license GPL v3.0 or later

Copyright (C) 2022 WolodiaM This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Author
WolodiaM (w_mel.nosp@m.nyk@.nosp@m.outlo.nosp@m.ok.c.nosp@m.om)
Date
Fri May 19 11:32:50 AM EEST 2023

@license GPL v3.0 or later

Copyright (C) 2022 WolodiaM This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Typedef Documentation

◆ ARG_TYPE

◆ handler

using CBuild::handler = ARG_TYPE (*)(lib::map<std::string, std::string>*, char**, int, int, CBuild::RType*)

Handler for specific argument.

Receives four arguments: lib::map<std::string, std::string> - arguments map char** - argv int - argc int - current parsing pointer, point to argument that call handler, default - 1 (self) CBuild::RType - type of run Returns int - consumed elements of argv

Possible internal args: out:none - disable cli out out:verbose - full cli out gen:<generator id> - pass used generator toolchain_id:<toolchain id> - pass used toolchain task_id:<task id> - pass used task id paX:<arg>, where X - unique number - pass arg to runned program (for -r and -br and possibly -d) aX:<arg>, where X - inique number - pass arg to runned toolchain/task

Definition at line 125 of file cli_parse_handler.hpp.

◆ package_info

typedef struct CBuild::package_info CBuild::package_info

Package info struct for data for pkg-config.

Enumeration Type Documentation

◆ ARG_TYPE

Type of argument, indicate how many tokens this argument consumes, including self.

Enumerator
BLANK_ARG 

No argument.

SIMPLE_ARG 

Only argument and no subarguments (like -f, -v)

TASK_ARG 

Task argument (-t <task_id>)

TOOLCHAIN_ARG 

Toolchain argument (-b/-r/-br/-c/-d <toolchain_id>)

GENERICK_ARG 

Generick argument with subargument (-<arg> <subarg>

GENERATOR_ARG 

Generator arg (-g <generator_id>)

INC_ONE 

Increment by one, consumes only self.

INC_TWO 

Increment by two, consumes self and 1 subarg.

INC_THREE 

Increment by two, consumes self and 2 subarg.

INC_FOUR 

Increment by two, consumes self and 3 subarg.

INC_FIVE 

Increment by two, consumes self and 4 subarg.

INC_SIX 

Increment by two, consumes self and 5 subarg.

INC_SEVEN 

Increment by two, consumes self and 6 subarg.

INC_EIGHT 

Increment by two, consumes self and 7 subarg.

INC_NINE 

Increment by two, consumes self and 8 subarg.

INC_TEN 

Increment by two, consumes self and 9 subarg.

Definition at line 37 of file cli_parse_handler.hpp.

◆ buffer_state

Represent atate of buffer.

Enumerator
MATCH 

File match buffer.

FILE_NEWER 

File is newer, buffer is not updated.

BUFFER_NEWER 

Buffer is newer and file need update.

Definition at line 57 of file filebuff.hpp.

◆ build_type

Enumerator
EXECUTABLE 
STATIC_LIBRARY 
DYNAMIC_LIBRARY 

Definition at line 55 of file Build.hpp.

◆ color

Text color.

Enumerator
BLACK 
RED 
GREEN 
YELLOW 
BLUE 
MAGENTA 
CYAN 
WHITE 

Definition at line 32 of file print.hpp.

◆ RType

Run mode.

Enumerator
TASK 

Run task.

BUILD 

Build target.

RUN 

Run target.

BUILD_RUN 

Build and run target.

DEBUG 

Build and run target in debug mode.

CLEAR 

Clear build output and cache.

REBUILD 

Rebuild user executable.

LOAD_DEPS 

Load other project deps.

ERROR 

Some error occurred.

Definition at line 34 of file CBuild.hpp.

◆ stage

Type of depencesies for toolchain.

Enumerator
PRE 
POST 

Definition at line 54 of file Build.hpp.

Function Documentation

◆ add_env_var()

void CBuild::add_env_var ( std::string var,
std::string value )

Add environment variable to CBuild::system and CBuild::system_piped calls.

Parameters
var=> std::string -> Var name
value=> std::string -> Var value

Definition at line 87 of file system.cpp.

References env_vars.

◆ arg_handler()

ARG_TYPE CBuild::arg_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

Definition at line 223 of file cli_parser.cpp.

References arg, exit(), GREEN, parg, print(), lib::map< _K, _D >::push_back_check(), and RED.

◆ build_handler()

ARG_TYPE CBuild::build_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

◆ change_env_var()

void CBuild::change_env_var ( std::string var,
std::string new_value )

Change value for environment var.

Parameters
var=> std::string -> Var name
new_value=> std::string -> New var value

Definition at line 95 of file system.cpp.

References env_vars.

◆ disable_system()

void CBuild::disable_system ( )

Disable system commands execution.

Definition at line 77 of file system.cpp.

References enabled.

Referenced by get_pkg_info(), and CBuild::ccj_out::init().

◆ enable_system()

void CBuild::enable_system ( )

Reanable system commands execution, used only in pkg-config.

Definition at line 80 of file system.cpp.

References enabled.

Referenced by get_pkg_info().

◆ eval_cmd()

std::string CBuild::eval_cmd ( std::array< std::string, 4 > data)

Evaluate compilation cmd.

Parameters
data=> std::array<std::string, 4> -> Data:
  • 0: File path
  • 1: Object file
  • 2: Compiler command
  • 3: Args
Returns
std::string -> Command

Definition at line 113 of file generator.cpp.

Referenced by CBuild::ccj_out::generate().

◆ exit()

void CBuild::exit ( int code)

◆ force_handler()

ARG_TYPE CBuild::force_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

Definition at line 39 of file cli_parser.cpp.

References print_full(), lib::map< _K, _D >::push_back_check(), and RED.

◆ gcc_hash_impl()

lib::map< std::string, std::string > CBuild::gcc_hash_impl ( std::vector< std::string > file_list,
std::vector< std::string > objects_list,
std::string target_id )

Implementation of GCC hasher.

Parameters
file_list=> std::vector<std::string> -> List of source files
objects_list=> std::vector<std::string> -> List of coresponding object files
target_id=> std::string -> ID of target that called hasher

Definition at line 76 of file gcc_hash.cpp.

References lib::map< _K, _D >::at(), check_mismatch_recursive(), CBuild::Registry::GetToolchain(), hash_fnv_1a(), CBuild::fs::normalize_relative_path(), print_full(), print_toggle(), lib::map< _K, _D >::ptr_at(), lib::map< _K, _D >::push_back(), lib::map< _K, _D >::push_back_check(), read_file_metadata(), lib::map< _K, _D >::size(), system_piped(), and write_file_metadata().

Referenced by CBuild::GCCHash::get_files_for_recompilation().

◆ generator_handler()

ARG_TYPE CBuild::generator_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

◆ get_env_vars()

std::string CBuild::get_env_vars ( )

Definition at line 35 of file system.cpp.

References env_vars.

Referenced by system(), and system_piped().

◆ get_file_data()

CBuild::types::file_content CBuild::get_file_data ( std::string path,
std::string included_from = "" )

Get content of file.

Parameters
path=> std::string -> Path to file
included_from=> std::string -> From what file included, for calculating path
Returns
std::string -> File content

Definition at line 148 of file hash.cpp.

References CBuild::fs::base(), CBuild::consts::c_multiline_comment(), CBuild::types::file_content::content, CBuild::consts::cxx_line_comment(), CBuild::consts::doxygen_comment(), CBuild::fs::exists(), exit(), CBuild::consts::include_parser(), CBuild::types::file_content::includes, CBuild::fs::normalize_relative_path(), CBuild::types::file_content::path, print_full(), and RED.

Referenced by procces_files().

◆ get_file_metadata_path()

std::string CBuild::get_file_metadata_path ( std::string target_id,
std::string file )

Get the path to a file metadata file.

Parameters
target_id=> std::string -> Id of target that has this file
file=> std::string -> File name
Returns
std::string -> Path to a metadata file

Definition at line 170 of file metadata_file.cpp.

References CBUILD_BUILD_DIR, CBUILD_METADATA_FILE_EXTENSION, and CBUILD_METADATA_FOLDER.

Referenced by read_file_metadata(), store_hash(), and write_file_metadata().

◆ get_files()

std::vector< std::string > CBuild::get_files ( std::vector< std::string > files,
std::vector< std::string > objects,
std::string toolchain_id )

Get changed files.

Parameters
files=> std::vector<std::string> -> List of code files (.cpp/.c)
objects=> std::vector<std::string> -> List of object files (.o/.obj)
toolchain_id=> std::string -> Id of toolchain, to get hash file

Definition at line 395 of file hash.cpp.

References CBuild::vars::filelist, CBuild::vars::headers, load_hash(), CBuild::vars::old_hashes, print_files(), procces_files(), and store_hash().

Referenced by CBuild::CBuildHash::get_files_for_recompilation().

◆ get_log()

std::vector< std::string > * CBuild::get_log ( )

Get the internall command log.

Returns
std::vector<std::string>* -> pointer to command log

Definition at line 74 of file system.cpp.

References log.

Referenced by CBuild::makefile_out::generate().

◆ get_pkg_info()

bool CBuild::get_pkg_info ( CBuild::package_info * package)

Get the package info from pkg-config database.

Parameters
package=> package_info* -> Input and output from function
Returns
true -> All good
false -> Eroor, package not found

Definition at line 28 of file pkgconfig.cpp.

References CBuild::package_info::cargs, disable_system(), enable_system(), is_system_enabled(), CBuild::package_info::largs, MAGENTA, CBuild::package_info::name, print(), RED, and system_piped().

Referenced by CBuild::Toolchain::stdargs().

◆ get_random_string()

std::string CBuild::get_random_string ( unsigned int length)

Generate random string with specified range, on Linux can use /dev/urandom.

Parameters
length=> usigned int -> String lenght
Returns
std::string -> Returned string

Definition at line 570 of file CBuild.cpp.

References MAGENTA, and print_full().

Referenced by CBuild::makefile_out::generate().

◆ get_target_metadata_path()

std::string CBuild::get_target_metadata_path ( std::string target_id)

Get the path to a target metadata file.

Parameters
target_id=> std::string -> Id of a target
Returns
std::string -> Path to a metadata file

Definition at line 179 of file metadata_file.cpp.

References CBUILD_BUILD_DIR, and CBUILD_METADATA_FILE_EXTENSION.

Referenced by read_target_metadata(), and write_target_metadata().

◆ get_version_array()

int * CBuild::get_version_array ( )

Get full CBuild version as int array of two components, no oveflow or rewrite check !

Returns
int* -> array of two parst of CBuild version

Definition at line 567 of file CBuild.cpp.

References version.

◆ get_version_major()

int CBuild::get_version_major ( )

Get major component of CBuild version.

Returns
int -> major version of CBuild

Definition at line 561 of file CBuild.cpp.

References CBUILD_VERSION_MAJOR.

◆ get_version_minor()

int CBuild::get_version_minor ( )

Get minor component of CBuild version.

Returns
int -> minor (patch) version of CBuild

Definition at line 564 of file CBuild.cpp.

References CBUILD_VERSION_MINOR.

◆ get_version_string()

std::string CBuild::get_version_string ( )

Return version as string.

Returns
std:;string -> version of CBuild

Definition at line 558 of file CBuild.cpp.

References CBUILD_VERSION_STR.

◆ hash()

uint64_t CBuild::hash ( std::string str)

◆ hash_djb2()

uint64_t CBuild::hash_djb2 ( std::string str)
inline

djb2 hashing function for std::string

Parameters
str=> std::string -> Input string
Returns
uint64_t -> Hash of data

Definition at line 41 of file hasher.hpp.

References hash().

◆ hash_fnv_1a()

uint64_t CBuild::hash_fnv_1a ( std::string str)
inline

FNV-1a hashing function for std::string.

Parameters
str=> std::string -> Input string
Returns
uint64_t -> Hash of data

Definition at line 54 of file hasher.hpp.

References hash().

Referenced by gcc_hash_impl(), and parse_file().

◆ is_system_enabled()

bool CBuild::is_system_enabled ( )

Check if CBuild::system enabled.

Returns
true -> Enabled
false -> Disabled

Definition at line 83 of file system.cpp.

References enabled.

Referenced by get_pkg_info().

◆ load_hash()

void CBuild::load_hash ( std::string toolchain_id)

Load old hashes.

Parameters
toolchain_id=> std::string -> Id of toolchain

Definition at line 329 of file hash.cpp.

References CBUILD_BUILD_DIR, CBUILD_METADATA_FOLDER, CBuild::fs::dir(), hash(), CBuild::source_metadata_file::hash, CBuild::vars::old_hashes, print_full(), read_file_metadata_direct(), RED, and CBuild::source_metadata_file::source.

Referenced by get_files().

◆ loop()

void CBuild::loop ( CBuild::RType mode,
lib::map< std::string, std::string > * args )

◆ out_handler()

ARG_TYPE CBuild::out_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

◆ parse()

CBuild::RType CBuild::parse ( lib::map< std::string, std::string > * args,
int argc,
char ** argv )

Parse arguments.

Parameters
args=> lib::map<std::string, std::string>* -> Returned arguments for other functions
argc=> int -> argc from main
argv=> char** -> argv from main
Returns
RType -> type of CBuild task

Definition at line 274 of file cli_parser.cpp.

References BLANK_ARG, ERROR, exit(), CBuild::Registry::GetKeywordsList(), CBuild::Registry::init(), parsers_list, print(), lib::map< _K, _D >::push_back_check(), RED, and TASK.

◆ parse_lines()

std::vector< std::string > CBuild::parse_lines ( std::string in)
inline

Parse string to vector of strings.

Parameters
in=> std::string -> Input string
Returns
std::vector<std::string> -> Returned list of lines

Definition at line 38 of file filebuff.hpp.

Referenced by CBuild::line_filebuff::set_str().

◆ preprocess_json_str()

std::string CBuild::preprocess_json_str ( std::string_view str)

Preprocess string for json.

Parameters
str=> std::string_view -> Input string
Returns
std::string -> Output string

Definition at line 149 of file generator.cpp.

Referenced by CBuild::ccj_out::generate().

◆ print()

void CBuild::print ( std::string msg,
color fg = CBuild::WHITE )

Print colored text to STDOUT.

Parameters
msg=> std::string -> text to print
fg=> CBuild::color -> color of text

Definition at line 70 of file print.cpp.

References none, print_internal(), and toogle.

Referenced by arg_handler(), CBuild::ConfigToolchain::build(), build_handler(), CBuild::Toolchain::call(), CBuild::ConfigToolchain::call(), CBuild::MetaToolchain::call(), CBuild::Help::call(), CBuild::Version::call(), CBuild::TaskList::call(), CBuild::ToolchainList::call(), CBuild::GeneratorList::call(), CBuild::CmdList::call(), CBuild::Registry::CallTask(), CBuild::ConfigToolchain::clear(), CBuild::MetaToolchain::clear(), CBuild::ConfigToolchain::compile(), CBuild::CBuildDependency::compile(), CBuild::Toolchain::crash(), CBuild::Toolchain::debug(), CBuild::ConfigToolchain::debug(), CBuild::MetaToolchain::debug(), CBuild::MINGW_GXX< hash >::debug(), CBuild::MINGW_GXXMT< hash >::debug(), CBuild::MINGW_GCC< hash >::debug(), CBuild::MINGW_GCCMT< hash >::debug(), CBuild::ccj_out::generate(), CBuild::makefile_out::generate(), generator_handler(), CBuild::ConfigToolchain::get_cmds(), get_pkg_info(), CBuild::ConfigToolchain::init(), CBuild::ConfigToolchain::link(), CBuild::ConfigToolchain::link_pack(), CBuild::ConfigToolchain::load_project_deps(), CBuild::MetaToolchain::load_project_deps(), out_handler(), parse(), CBuild::ConfigToolchain::post_build(), CBuild::ConfigToolchain::post_link(), CBuild::ConfigToolchain::pre_build(), CBuild::ConfigToolchain::pre_link(), CBuild::CBuildDependency::prepare(), rebuild(), CBuild::Toolchain::run(), CBuild::ConfigToolchain::run(), CBuild::MetaToolchain::run(), CBuild::MINGW_GXX< hash >::run(), CBuild::MINGW_GXXMT< hash >::run(), CBuild::ConfigToolchain::set_id(), CBuild::ConfigToolchain::set_name(), CBuild::ConfigToolchain::stdargs(), system(), system_piped(), and task_handler().

◆ print_files()

void CBuild::print_files ( )

Print temporary file array.

Definition at line 369 of file hash.cpp.

References CBuild::vars::filelist, MAGENTA, and print_full().

Referenced by get_files().

◆ print_full()

void CBuild::print_full ( std::string msg,
color fg = CBuild::WHITE )

◆ print_internal()

void CBuild::print_internal ( std::string msg,
CBuild::color fg )

Definition at line 30 of file print.cpp.

Referenced by print(), and print_full().

◆ print_none()

void CBuild::print_none ( )

Fully disable all print though CBuild::print.

Definition at line 101 of file print.cpp.

References none.

Referenced by loop(), and out_handler().

◆ print_toggle()

void CBuild::print_toggle ( )

Toogle print betwen none and currently selected level.

Definition at line 104 of file print.cpp.

References toogle.

Referenced by gcc_hash_impl().

◆ print_verbose()

void CBuild::print_verbose ( )

Enable verbose flag.

Definition at line 98 of file print.cpp.

References verbose.

Referenced by loop(), and out_handler().

◆ printf()

void CBuild::printf ( CBuild::color fg,
const char * fmt,
... )

Some poor printf implementation.

Parameters
fg=> CBuild:color -> Text color
fmt=> const char* -> Format string

Definition at line 80 of file print.cpp.

References none, printf_internal(), and toogle.

Referenced by CBuild::MetaToolchain::call(), CBuild::MetaToolchain::clear(), CBuild::MetaToolchain::debug(), CBuild::MetaToolchain::load_project_deps(), loop(), and CBuild::MetaToolchain::run().

◆ printf_full()

void CBuild::printf_full ( CBuild::color fg,
const char * fmt,
... )

◆ printf_internal()

void CBuild::printf_internal ( CBuild::color fg,
std::string msg,
va_list va )

Definition at line 49 of file print.cpp.

Referenced by printf(), and printf_full().

◆ procces_files()

void CBuild::procces_files ( std::vector< std::string > files,
std::vector< std::string > objects,
std::string toolchain_id )

Procces file data.

Parameters
files=> std::vector<std::string> -> File list
toolchain_id=> std::string -> used toolchain, for working with hash database

Definition at line 233 of file hash.cpp.

References CBuild::vars::filelist, get_file_data(), GREEN, hash(), CBuild::vars::headers, MAGENTA, CBuild::vars::old_hashes, print_full(), and RED.

Referenced by get_files().

◆ read_file_hash()

int CBuild::read_file_hash ( std::string target_id,
std::string file,
uint64_t * hash )

Get a file hash (internally uses read_file_metadata, so no performance benefits, but easiier to use in hasher)

Parameters
target_id=> std::string -> Id of target that has this file
file=> std::string -> File name
hash=> uint64_t -> Hash value
Returns
int -> Error code

Definition at line 120 of file metadata_file.cpp.

References hash(), CBuild::source_metadata_file::hash, and read_file_metadata().

◆ read_file_metadata()

int CBuild::read_file_metadata ( std::string target_id,
std::string src_file,
CBuild::source_metadata_file * metadata )

Load metadata for source file.

Parameters
target_id=> std::string -> Id of target that has this file
src_file=> std::string -> File name
metadata=> CBuild::source_metadata_file* -> Pointer to file metadata struct
Returns
int -> Error code

Definition at line 66 of file metadata_file.cpp.

References get_file_metadata_path(), and read_file_metadata_internal().

Referenced by gcc_hash_impl(), parse_file(), read_file_hash(), and write_file_hash().

◆ read_file_metadata_direct()

int CBuild::read_file_metadata_direct ( std::string target_id,
std::string file,
CBuild::source_metadata_file * metadata )

Load metadata for source file.

Parameters
target_id=> std::string -> Id of target that has this filelibsfml-dev
file=> std::string -> Metadata file name
metadata=> CBuild::source_metadata_file* -> Pointer to file metadata struct
Returns
int -> Error code

Definition at line 71 of file metadata_file.cpp.

References read_file_metadata_internal().

Referenced by load_hash(), and CBuild::CBuildDependency::prepare().

◆ read_target_metadata()

int CBuild::read_target_metadata ( std::string target_id,
CBuild::target_metadata_file * metadata )

◆ read_target_metadata_direct()

int CBuild::read_target_metadata_direct ( std::string path,
CBuild::target_metadata_file * metadata )

◆ rebuild()

void CBuild::rebuild ( std::string scripts)

Rebuild userspace part of CBuild.

Parameters
scripts=> std::string -> path to scripts dir

Definition at line 550 of file CBuild.cpp.

References print(), and RED.

◆ rebuild_handler()

ARG_TYPE CBuild::rebuild_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

Definition at line 254 of file cli_parser.cpp.

References lib::map< _K, _D >::push_back_check(), and REBUILD.

◆ register_parse_handler()

bool CBuild::register_parse_handler ( std::string cmd,
CBuild::handler parser )

Register new handler for parsing cli args, see handler typedef comment to guide how to write handlers.

Parameters
cmd=> std::string -> Command that trigers this parser
parser=> CBuild::handler -> Custom parsing function
Returns
bool -> true for success and false for failure

Definition at line 315 of file cli_parser.cpp.

References parsers_list.

◆ remove_env_var()

std::string CBuild::remove_env_var ( std::string var)

Remove registered environment var.

Parameters
var=> std::string -> Var name
Returns
std::string -> Var value

Definition at line 90 of file system.cpp.

References env_vars.

◆ store_hash()

void CBuild::store_hash ( std::string toolchain_id)

Store new hashes to file.

Parameters
toolchain_id=> std::string -> Id of toolchain

Definition at line 294 of file hash.cpp.

References CBuild::fs::create(), CBuild::source_metadata_file::deps, CBuild::fs::FILE, CBuild::vars::filelist, get_file_metadata_path(), CBuild::source_metadata_file::hash, CBuild::vars::headers, write_file_hash(), and write_file_metadata().

Referenced by get_files().

◆ system()

int CBuild::system ( std::string cmd)

◆ system_piped()

std::string CBuild::system_piped ( std::string cmd,
unsigned int buffsize )

Execute command and return it's output.

Parameters
cmd=> stt::string -> command
buffsize=> unsigned int -> Size of output buffer, malloc and fread
Returns
std::string -> Program output

Definition at line 58 of file system.cpp.

References BLUE, enabled, get_env_vars(), log, and print().

Referenced by gcc_hash_impl(), and get_pkg_info().

◆ task_handler()

ARG_TYPE CBuild::task_handler ( lib::map< std::string, std::string > * args,
char ** argv,
int argc,
int ptr,
CBuild::RType * type )

◆ write_file_hash()

int CBuild::write_file_hash ( std::string target_id,
std::string file,
uint64_t * hash )

@brief Write a file hash (internally uses write_file_metadata, so no performance benefits, but easiier to use in hasher)

Parameters
target_id=> std::string -> Id of target that has this file
file=> std::string -> File name
hash=> uint64_t -> Pointer to a hash value
Returns
int -> Error code

Definition at line 161 of file metadata_file.cpp.

References hash(), CBuild::source_metadata_file::hash, read_file_metadata(), and write_file_metadata().

Referenced by store_hash().

◆ write_file_metadata()

int CBuild::write_file_metadata ( std::string target_id,
std::string src_file,
CBuild::source_metadata_file * metadata )

Write a metadata for a file to a file.

Parameters
target_id=> std::string -> Id of a target that has this file
src_file=> std::string -> File name
metadata=> CBuild::source_metadata_file* -> Pointer to a file metadata struct
Returns
int -> Error code

Definition at line 126 of file metadata_file.cpp.

References CBuild::source_metadata_file::deps, get_file_metadata_path(), CBuild::source_metadata_file::hash, CBuild::source_metadata_file::object, and CBuild::source_metadata_file::source.

Referenced by gcc_hash_impl(), parse_file(), store_hash(), and write_file_hash().

◆ write_target_metadata()

int CBuild::write_target_metadata ( std::string target_id,
CBuild::target_metadata_file * metadata )

Variable Documentation

◆ arg

int CBuild::arg = 0

◆ enabled

bool CBuild::enabled = true

Definition at line 34 of file system.cpp.

Referenced by disable_system(), enable_system(), is_system_enabled(), system(), and system_piped().

◆ env_vars

std::map<std::string, std::string> CBuild::env_vars

Definition at line 33 of file system.cpp.

Referenced by add_env_var(), change_env_var(), get_env_vars(), and remove_env_var().

◆ log

std::vector<std::string> CBuild::log

Definition at line 32 of file system.cpp.

Referenced by CBuild::makefile_out::generate(), get_log(), and system_piped().

◆ none

bool CBuild::none = false

Definition at line 28 of file print.cpp.

Referenced by print(), print_full(), print_none(), printf(), and printf_full().

◆ parg

int CBuild::parg = 0

Definition at line 222 of file cli_parser.cpp.

Referenced by arg_handler().

◆ parsers_list

lib::map<std::string, handler> CBuild::parsers_list
Initial value:
= {
{"-f", &force_handler}, {"-v", &out_handler}, {"--no-cli-out", &out_handler},
{"-g", &generator_handler}, {"-b", &build_handler}, {"-r", &build_handler},
{"-br", &build_handler}, {"-d", &build_handler}, {"-ld", &build_handler},
{"-c", &build_handler}, {"-t", &task_handler}, {"-a", &arg_handler},
{"-pa", &arg_handler}, {"--rebuild", &rebuild_handler}}
ARG_TYPE force_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE out_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE task_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE arg_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE rebuild_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE generator_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)
ARG_TYPE build_handler(lib::map< std::string, std::string > *args, char **argv, int argc, int ptr, CBuild::RType *type)

All handlers.

Definition at line 266 of file cli_parser.cpp.

Referenced by parse(), and register_parse_handler().

◆ real_exit

bool CBuild::real_exit = true

Definition at line 33 of file cli_parser.cpp.

Referenced by exit().

◆ toogle

bool CBuild::toogle = true

Definition at line 29 of file print.cpp.

Referenced by print(), print_full(), print_toggle(), printf(), and printf_full().

◆ verbose

bool CBuild::verbose = false

Definition at line 27 of file print.cpp.

Referenced by print_full(), print_verbose(), and printf_full().

◆ version

int CBuild::version[] = {CBUILD_VERSION_MAJOR, CBUILD_VERSION_MINOR}