Skip to content

Commit 97ad77a

Browse files
committed
added nob.h support to quicksnip under new C category
1 parent ad64947 commit 97ad77a

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8+
"dev:serve": "vite dev",
89
"build": "tsc -b && vite build",
910
"lint": "eslint .",
1011
"format": "prettier --write .",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Basic Config
3+
description: The basic builder for C projects using the nob.h library (https://github.com/tsoding/nob.h).
4+
author: James-Beans
5+
tags: builder,basic,config
6+
---
7+
8+
```c
9+
// You can make a new nob-h project using one of these commands:
10+
// npm create nobuild@latest
11+
// yarn create nobuild@latest
12+
// pnpm create nobuild@latest
13+
14+
// This would be the nob.c config file.
15+
16+
#define NOB_IMPLEMENTATION
17+
18+
// The nob.h library has to be in the same folder as nob.c (this file).
19+
#include "nob.h"
20+
21+
#define BUILD_FOLDER "build/"
22+
#define SRC_FOLDER "src/"
23+
24+
int main(int argc, char **argv)
25+
{
26+
// This self-rebuild mechanism checks if nob.c was modified
27+
// If you’ve updated the build script, remove the existing binary to force a rebuild
28+
NOB_GO_REBUILD_URSELF(argc, argv);
29+
30+
Nob_Cmd cmd = {0};
31+
32+
if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1;
33+
34+
#ifdef _WIN32
35+
// On Windows, use clang.exe with Unix flags because of mingw64 providing clang
36+
nob_cmd_append(&cmd, "clang", "-Wall", "-Wextra", "-o", BUILD_FOLDER "main", SRC_FOLDER "main.c");
37+
#else
38+
// On non-Windows platforms, use cc with the typical Unix flags
39+
nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER "main", SRC_FOLDER "main.c");
40+
#endif
41+
42+
if (!nob_cmd_run_sync(cmd)) return 1;
43+
44+
return 0;
45+
}
46+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Wayland Config
3+
description: The nob.h builder but with Wayland flags.
4+
author: James-Beans
5+
tags: builder,config,Wayland,Linux
6+
---
7+
8+
```c
9+
// You can make a new nob-h project using one of these commands:
10+
// npm create nobuild@latest
11+
// yarn create nobuild@latest
12+
// pnpm create nobuild@latest
13+
14+
// This would be the nob.c config file.
15+
16+
// This will only work for Linux because it uses Wayland. And that is Linux only.
17+
18+
#define NOB_IMPLEMENTATION
19+
20+
// The nob.h library has to be in the same folder as nob.c (this file).
21+
#include "nob.h"
22+
23+
#define BUILD_FOLDER "build/"
24+
#define SRC_FOLDER "src/"
25+
#define FLAGS "-lwayland-client"
26+
27+
int main(int argc, char **argv)
28+
{
29+
// This self-rebuild mechanism checks if nob.c was modified
30+
// If you’ve updated the build script, remove the existing binary to force a rebuild
31+
NOB_GO_REBUILD_URSELF(argc, argv);
32+
33+
Nob_Cmd cmd = {0};
34+
35+
if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1;
36+
nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER"main", SRC_FOLDER"main.c", FLAGS);
37+
if (!nob_cmd_run_sync(cmd)) return 1;
38+
39+
return 0;
40+
}
41+
```

snippets/c/[nob]/flags/x11-config.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: X11 Config
3+
description: The nob.h builder but with X11 flags.
4+
author: James-Beans
5+
tags: builder,config,X11,Linux
6+
---
7+
8+
```c
9+
// You can make a new nob-h project using one of these commands:
10+
// npm create nobuild@latest
11+
// yarn create nobuild@latest
12+
// pnpm create nobuild@latest
13+
14+
// This would be the nob.c config file.
15+
16+
// This will only work for Linux because it uses X11. And that is Linux only.
17+
18+
#define NOB_IMPLEMENTATION
19+
20+
// The nob.h library has to be in the same folder as nob.c (this file).
21+
#include "nob.h"
22+
23+
#define BUILD_FOLDER "build/"
24+
#define SRC_FOLDER "src/"
25+
#define FLAGS "-lX11"
26+
27+
int main(int argc, char **argv)
28+
{
29+
// This self-rebuild mechanism checks if nob.c was modified
30+
// If you’ve updated the build script, remove the existing binary to force a rebuild
31+
NOB_GO_REBUILD_URSELF(argc, argv);
32+
33+
Nob_Cmd cmd = {0};
34+
35+
if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1;
36+
nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER"main", SRC_FOLDER"main.c", FLAGS);
37+
if (!nob_cmd_run_sync(cmd)) return 1;
38+
39+
return 0;
40+
}
41+
```

snippets/c/[nob]/icon.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy