C Transpiler --- for submitting multi-file C projects as one file.
CTP recursively follows #includes to grab all source code referenced by a main file, and transpiles it into a single .c file. Folders can be used by specifying relative filepaths in #includes (i.e. #include "module/filename.h"
). .c files are assumed to be associated with a .h file with the same name; .c files without a corresponding .h file that is included somewhere in the dependency tree are ignored.
- Python 3 (Python 2 is not supported)
- print:
pip install printtools
python ctp.py <target_file> <output_file>
- target_file: Target file to transpile. The transpiler will follow #includes as appropriate. If a .h file is included, the corresponding .c file will be as well (if it exists).
- output_file: Target file to save to. If no output file is specified, the output will be sent to stdout.
Configuration options are specified in the code using special #defines.
#define __NAME__ "Project name"
: Project name; is placed at the top of the output file as a large ascii art comment.#define __AUTHOR__ "Author name[s]
: Project author; placed just under the name.#include "__header__.h"
,__header__.h
: If any file contains#include "__header__.h"
, the__header__.h
file is loaded and placed at the top of the output file instead of the__AUTHOR__
and__NAME__
.
#load "filename"
: drop-in 'filename' into the file.