A C amalgamator cli to join all files in one, build to be rich in features and also provide a api for you to use in your building programs
to use the cli, just clone the amalgamated c code
curl -L https://github.com/OUIsolutions/CAmalgamator/releases/download/0.001/CAmalgamator.c -o CAmalgamator.c
then compile the c file with
gcc CAmalgamator.c -o CAmalgamator.o
than you can run the cli , by:
./CAmalgamator.o --file your_main.c -o your_dest_amalgamation.c
Aditionaly , you can pass flags to help you in the usage
Flag | Description | Default |
---|---|---|
--f, --file | The start file (required) | - |
--o, --out, output | The dest output(required) | - |
--maxbyte | The max bytes of the final output(optional) | 100mb |
--maxmega | The max mebagytes of the final output(optional) | 100mb |
--maxreq | The max recursion to be used (optional) | 1000 |
--nc, --nochange | The files or dirs you dont want to be changed if ocours a #include (optional) | - |
--ni, --noinclude | The files or dirs you dont want to be include if ocours a #include (the dif betwen no change, its that it will be hidded) (optional) | - |
--p, --perpetual | the files or dir you will need to include more than one time (double inclusion) (optional) | - |
in these case, I want to not include nothing inside dependencies, so i type:
./CAmalgamator.o --file src/imports/imports.api_define.h -o release/CAmalgamatorApiNoDependenciesIncluded.h \
--noinclude dependencies
note that you can pass any files or dirs you want in (--noinclude , --nochange,--perpetual )
you also can use the code into your build programs, using the public api, for downloading it, just type
curl -L https://github.com/OUIsolutions/CAmalgamator/releases/download/0.001/CAmalgamatorApiOne.h -o CAmalgamatorApiOne.h
#include "CAmalgamatorApiOne.h"
CAmalgamatorNamesapce amalgamator;
int main(){
amalgamator = newCAmalgamatorNamesapce();
const char *entrie = "src/cli/main.c";
int max_recursion = 1000;
int max_size = amalgamator.ONE_MB * 10;
CAmalgamatorErrorOrContent *error_or_content =amalgamator.generate_amalgamation_simple(
entrie,
max_size,
max_recursion
);
if(error_or_content->error){
printf("%s\n",error_or_content->error_msg);
amalgamator.free_error_or_string(error_or_content);
return 1;
}
printf("%s",error_or_content->content);
amalgamator.free_error_or_string(error_or_content);
}
with the generator callback you can determine ,the exact type of file you want to return based on the code return
#include "CAmalgamatorApiOne.h"
CAmalgamatorNamesapce amalgamator;
short generator_callback(const char *filename,const char *include_name,void *args){
printf("amalgamated the : %s file with the include %s\n\n",filename,include_name);
return amalgamator.INCLUDE_ONCE;
}
int main(){
amalgamator = newCAmalgamatorNamesapce();
const char *entrie = "src/cli/main.c";
int max_recursion = 1000;
int max_size = amalgamator.ONE_MB * 10;
void *external_args_you_want_to_use = NULL;
CAmalgamatorErrorOrContent *error_or_content =amalgamator.generate_amalgamation(
entrie,
max_size,
max_recursion,
generator_callback,
external_args_you_want_to_use
);
if(error_or_content->error){
printf("%s\n",error_or_content->error_msg);
amalgamator.free_error_or_string(error_or_content);
return 1;
}
printf("%s",error_or_content->content);
amalgamator.free_error_or_string(error_or_content);
}
the code return can be betwen
Namespace | Pure Var | Description |
---|---|---|
amalgamator.DONT_INCLUDE | CAMALGAMATOR_DONT_INCLUDE | dont make the inclusion and hide the text of #include |
amalgamator.DONT_CHANGE | CAMALGAMATOR_DONT_CHANGE | dont change the #include |
amalgamator.INCLUDE_ONCE | CAMALGAMATOR_INCLUDE_ONCE | include the content once |
amalgamator.INCLUDE_PERPETUAL | CAMALGAMATOR_INCLUDE_PERPETUAL | include the content, every time it founds it |
if you want to build the code from scracth clone ,the repo on your machine , than run
sh install_dependencies.sh
than you can build the project with:
sh build.sh
these will generate the releases in the release folder
These project uses CilverChain as dependencie to organize the files, to use it , download Silverchain and run
sh watch.sh
MIT License DoTHeWorld from: https://github.com/OUIsolutions/DoTheWorld Copyright (c) 2023 Mateus Moutinho Queiroz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CJson: from https://github.com/DaveGamble/cJSON
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
sha-256: from https://github.com/amosnier/sha-2
Zero Clause BSD License © 2021 Alain Mosnier
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
CTextEngine: from https://github.com/OUIsolutions/CTextEngine MIT License
Copyright (c) 2023 OUI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Universal-Garbage-Colector: from https://github.com/OUIsolutions/Universal-Garbage-Colector
MIT License
Copyright (c) 2023 OUI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
C-Cli-Entry: from https://github.com/OUIsolutions/C-Cli-Entry MIT License
Copyright (c) 2023 OUI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.