SilverChain is a unified import model for C, it allows you to import modules and use their functions and variables in a more organized and efficient way.
item | plataform |
---|---|
SilverChain.c | Source |
SilverChainApiOne.h | Source of The Lib |
SilverChainApiNoDependenciesIncluded.h | Lib without dependenies |
SilverChain.out | Linux Binary |
SilverChain64.exe | Windows 64 Binary |
SilverChaini32.exe | Windows i32 Binary |
SilverChain.rpm | fedora/rehl/centos package |
SilverChain.deb | debian/ubuntu package |
if you want to build the code from scracth you need to have Darwin installed on versio 0.020 and Docker our Podman installed on your machine. After install all dependecies,clone the repo on your machine , than run:
darwin run_blueprint build/ --mode folder amalgamation_build alpine_static_build windowsi32_build windowsi64_build rpm_static_build debian_static_build
this will generate a folder called "imports" with all the imports and their dependencies, and a main.c file with the main function and the imports.
./SilverChain.o -src <src_folder> -tags <tag1> <tag2> <tag3> ... <tagN>
Flag | Description | Default |
---|---|---|
-s, --src | The project folder (required) | - |
-i, --importdir | The directory to be used for saving imports | imports |
-t, --tags | The tags to be used (required) | - |
-p, --project_short_cut | The project shortcut to be used in #ifndef properties | silverchain |
-m, --implement_main | true or false to implement the main function | false |
-n, --main_name | The name of the main function | main.c or main.cpp |
-p, --main_path | The path of the main function | undefined |
-h, --help | Shows the help message | - |
-w, --watch | Watch the project files and rebuild if they change | - |
-s, --sleep_time | The time to sleep between each check (default: 0) | - |
-v, --version | Shows the version | - |
-r, --remove | Remove the imports folder | - |
basicly it makes a imports dir , giving visualization of the project modules tag after tag, lets pick the self project build comand:
./silverchain.out -src src -tags dependencies consts types globals func_declaration func_definition
the first tag its "dependencies" so all the files that starts with "dependencies." will be imported, after that it will see that the next tag its "consts" so all the files that starts with "consts." will be imported, and so on, the same proccess will ocurry for the types, globals, func_declaration and func_definition tags, but in this case the files need to starts with the same name of the tag but in lowercase
each tag can visualize the all the ancestors tags, for example:
./SilverChain.o -src src -tags dependencies consts types globals func_declaration func_definition
in this case the "func_declaration" and "func_definition" tags will see the "dependencies" and "consts" .
if you want to integrate silver chain into your build system, you can use it directly in c.
install SilverChainApiOne file by typing:
curl -L https://github.com/OUIsolutions/SilverChain/releases/download/v0.07/SilverChainApiOne.h -o SilverChainApiOne.h
then you can use the api like these:
#include "SilverChainApiOne.h"
SilverChainNamespace sc;
int main(){
sc = newSilverChainNamespace();
SilverChainStringArray * tags = sc.string_array.create();
sc.string_array.append(tags,"api_dependencies");
sc.string_array.append(tags,"api_const");
sc.string_array.append(tags,"api_type");
sc.string_array.append(tags,"api_declare");
sc.string_array.append(tags,"api_define");
sc.string_array.append(tags,"cli_dependencies");
sc.string_array.append(tags,"cli_consts");
sc.string_array.append(tags,"cli_type");
sc.string_array.append(tags,"cli_globals");
sc.string_array.append(tags,"cli_declare");
sc.string_array.append(tags,"cli_define");
const char *src = "src";
const char *import_dir = "src/imports";
const char *project_short_cut = "SilverChain";
bool implement_main = true;
const char *main_name = "main.c";
// these its not required when you have only one main
const char *main_path = "src/cli/main.c";
SilverChainError *possible_error = sc.generator.generate_code(
src,
import_dir,
project_short_cut,
tags,
implement_main,
main_name,
main_path
);
if(possible_error){
printf("%s\n",possible_error->error_msg);
sc.error.free(possible_error);
}
sc.string_array.free(tags);
}