Skip to content

Commit 09010df

Browse files
committed
docs: update example bundle
1 parent c38dfd5 commit 09010df

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

README.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ $ cbundl main.c -o final.c
133133
The above command will parse `main.c` and figure out what dependencies it has. In this example, `main.c` wants `stdio.h` and `frob.h`. Notice the comment above the `#include "frob.h"`. Comments that begin with `// cbundl:` are called "directives" and give special instructions to `cbundl`. The directive above `frob.h` tells `cbundl` that, to build the final bundle, it needs to include `frob.h`. The directive at the end of `frob.h` tells `cbundl` that the implementation for at least one of the symbols declared by `frob.h` lives in `frob.c`. This tells `cbundl` to include `frob.c` inside the resulting bundle. That's it. That's the entire tool :clap:. The file `final.c` then contains:
134134

135135
```c
136+
// My amazing header text!
137+
136138
/**
137139
*
138140
* ) ( (
@@ -149,8 +151,9 @@ The above command will parse `main.c` and figure out what dependencies it has. I
149151
* Generated at: XXX XX XXX XXX XX:XX:XX (UTC+XX:XX)
150152
*
151153
*
152-
* Time is an illusion. Lunchtime doubly so.
153-
* - The Hitchhiker's Guide to the Galaxy
154+
* Use a gun. And if that don't work...
155+
* use more gun.
156+
* - Dr. Dell Conagher
154157
*
155158
*/
156159

@@ -190,12 +193,14 @@ int main() {
190193

191194
#include <stdio.h>
192195

193-
static void update_frob_count(int* frob_count) { *frob_count += 1; }
196+
static void update_frob_count(int* frob_count) {
197+
*frob_count += 1;
198+
}
194199

195200
void frobinate(struct frobinator* frob) {
196201
printf("frobbed!\n");
197202
update_frob_count(&frob->frob_count);
198-
}
203+
}
199204
```
200205
201206
The compiler is now happy to make us our binary. :smiley: Congratulations, you now know everything about this tool. :clap: And because we were good programmer boys, girls and everything in between, `cbundl` will also pass the resulting bundle code through a code formatter of our choice (`clang-format` by default) so its nice and pretty.

cbundl.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ separators = true
88
# will always be the same. This switch is useful if you intend to check into
99
# source control the bundle, where you wouldn't want to pollute diffs with
1010
# changed to the generated date, or the quotes inside the bundle.
11-
deterministic = false
11+
deterministic = true
1212

1313
# Write the final bundle to this path.
1414
output = "test/frob/final.c"

test/frob/final.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// My amazing header text!
2+
13
/**
24
*
35
* ) ( (
@@ -8,14 +10,15 @@
810
* / _| | '_ \| || || ' \))/ _` || |
911
* \__| |_.__/ \_,_||_||_| \__,_||_|
1012
*
11-
* cbundl 0.1.2-debug (21b24e9+)
13+
* cbundl 0.1.2-debug (c38dfd5+)
1214
* https://github.com/threadexio/cbundl
1315
*
14-
* Generated at: Tue 31 Dec 2024 21:44:31 (UTC+02:00)
16+
* Generated at: Thu 01 Jan 1970 00:00:00 (UTC+00:00)
1517
*
1618
*
17-
* Every evening I died, and every evening I was born again, resurrected.
18-
* - Fight Club
19+
* Use a gun. And if that don't work...
20+
* use more gun.
21+
* - Dr. Dell Conagher
1922
*
2023
*/
2124

0 commit comments

Comments
 (0)