Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/depau/c2singlefile
Turns a bunch of specially formatted c files into a single file
https://github.com/depau/c2singlefile
c parser singlefile
Last synced: 3 days ago
JSON representation
Turns a bunch of specially formatted c files into a single file
- Host: GitHub
- URL: https://github.com/depau/c2singlefile
- Owner: depau
- License: gpl-3.0
- Created: 2017-08-17T20:07:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-17T20:13:52.000Z (over 7 years ago)
- Last Synced: 2024-11-15T00:41:53.591Z (2 months ago)
- Topics: c, parser, singlefile
- Language: Python
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C to Single File
Simple script to turn a C project into a single file for online tests submission.
## Usage
All files need to be formatted properly.
There are 5 type of parts that this program reads:
* includes
* macros
* datatypes
* declarations
* definitionsEvery part in each file needs to be surrounded by
```c
// start:PARTNAME
// end:PARTNAME
```For example:
`my_lib.h`
```c
// start:includes
#include
// end:includes// start:macros
#define true 0 // I'm funny
#define false 1 // aren't I?
// end:macros// start:datatypes
typedef enum _my_enum {
SINGLE_FILE,
SUBMISSIONS,
SUCK
} singlefile_is_cancer_t;
// end:datatypes// start:declarations
singlefile_is_cancer_t i_really_mean_it();
// end:declarations
```
`my_lib.c````c
// start:includes
#include "my_lib.h"
// end:includes// start:definitions
singlefile_is_cancer_t i_really_mean_it() {
return SUCK;
}
// end:definitions```
Will result in:
`$ c2singlefile my_lib.h my_lib.c`
```c
// AUTOMATICALLY GENERATED, DO NOT EDIT
// This file was generated by c2singlefile
// https://github.com/Depaulicious/c2singlefile// Files included here:
// - my_lib.h
// - my_lib.c#include
// Macros
// From my_lib.h#define true 0 // I'm funny
#define false 1 // aren't I?// Datatypes
// From my_lib.htypedef enum _my_enum {
SINGLE_FILE,
SUBMISSIONS,
SUCK
} singlefile_is_cancer_t;// Declarations
// From my_lib.hsinglefile_is_cancer_t i_really_mean_it();
// Definitions
// From my_lib.csinglefile_is_cancer_t i_really_mean_it() {
return SUCK;
}
```Everything between `start` and `end` comments will be kept as it is, except for includes.
Only `#include <*>` will be kept, and multiple occurrences of the same include statement are only repeated once.
## Syntax
Simply pass the program a list of files, starting from the least important, dependency-wise. The output will follow the same order.
## Installation
```shell
pip install https://github.com/Depaulicious/c2singlefile/archive/master.zip
```