From 97ad77ab6cd27db958bc2385a13b8bf5471800d8 Mon Sep 17 00:00:00 2001 From: obvbeans Date: Sat, 8 Mar 2025 16:44:45 +0000 Subject: [PATCH 1/2] added nob.h support to quicksnip under new C category --- package.json | 1 + snippets/c/[nob]/basics/basic-config.md | 46 ++++++++++++++++++++++++ snippets/c/[nob]/flags/wayland-config.md | 41 +++++++++++++++++++++ snippets/c/[nob]/flags/x11-config.md | 41 +++++++++++++++++++++ snippets/c/[nob]/icon.svg | 1 + 5 files changed, 130 insertions(+) create mode 100644 snippets/c/[nob]/basics/basic-config.md create mode 100644 snippets/c/[nob]/flags/wayland-config.md create mode 100644 snippets/c/[nob]/flags/x11-config.md create mode 100644 snippets/c/[nob]/icon.svg diff --git a/package.json b/package.json index a37cd9c2..80519063 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "dev": "vite", + "dev:serve": "vite dev", "build": "tsc -b && vite build", "lint": "eslint .", "format": "prettier --write .", diff --git a/snippets/c/[nob]/basics/basic-config.md b/snippets/c/[nob]/basics/basic-config.md new file mode 100644 index 00000000..182d043f --- /dev/null +++ b/snippets/c/[nob]/basics/basic-config.md @@ -0,0 +1,46 @@ +--- +title: Basic Config +description: The basic builder for C projects using the nob.h library (https://github.com/tsoding/nob.h). +author: James-Beans +tags: builder,basic,config +--- + +```c +// You can make a new nob-h project using one of these commands: +// npm create nobuild@latest +// yarn create nobuild@latest +// pnpm create nobuild@latest + +// This would be the nob.c config file. + +#define NOB_IMPLEMENTATION + +// The nob.h library has to be in the same folder as nob.c (this file). +#include "nob.h" + +#define BUILD_FOLDER "build/" +#define SRC_FOLDER "src/" + +int main(int argc, char **argv) +{ + // This self-rebuild mechanism checks if nob.c was modified + // If you’ve updated the build script, remove the existing binary to force a rebuild + NOB_GO_REBUILD_URSELF(argc, argv); + + Nob_Cmd cmd = {0}; + + if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1; + +#ifdef _WIN32 + // On Windows, use clang.exe with Unix flags because of mingw64 providing clang + nob_cmd_append(&cmd, "clang", "-Wall", "-Wextra", "-o", BUILD_FOLDER "main", SRC_FOLDER "main.c"); +#else + // On non-Windows platforms, use cc with the typical Unix flags + nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER "main", SRC_FOLDER "main.c"); +#endif + + if (!nob_cmd_run_sync(cmd)) return 1; + + return 0; +} +``` diff --git a/snippets/c/[nob]/flags/wayland-config.md b/snippets/c/[nob]/flags/wayland-config.md new file mode 100644 index 00000000..61af0462 --- /dev/null +++ b/snippets/c/[nob]/flags/wayland-config.md @@ -0,0 +1,41 @@ +--- +title: Wayland Config +description: The nob.h builder but with Wayland flags. +author: James-Beans +tags: builder,config,Wayland,Linux +--- + +```c +// You can make a new nob-h project using one of these commands: +// npm create nobuild@latest +// yarn create nobuild@latest +// pnpm create nobuild@latest + +// This would be the nob.c config file. + +// This will only work for Linux because it uses Wayland. And that is Linux only. + +#define NOB_IMPLEMENTATION + +// The nob.h library has to be in the same folder as nob.c (this file). +#include "nob.h" + +#define BUILD_FOLDER "build/" +#define SRC_FOLDER "src/" +#define FLAGS "-lwayland-client" + +int main(int argc, char **argv) +{ + // This self-rebuild mechanism checks if nob.c was modified + // If you’ve updated the build script, remove the existing binary to force a rebuild + NOB_GO_REBUILD_URSELF(argc, argv); + + Nob_Cmd cmd = {0}; + + if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1; + nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER"main", SRC_FOLDER"main.c", FLAGS); + if (!nob_cmd_run_sync(cmd)) return 1; + + return 0; +} +``` diff --git a/snippets/c/[nob]/flags/x11-config.md b/snippets/c/[nob]/flags/x11-config.md new file mode 100644 index 00000000..3ee0f69e --- /dev/null +++ b/snippets/c/[nob]/flags/x11-config.md @@ -0,0 +1,41 @@ +--- +title: X11 Config +description: The nob.h builder but with X11 flags. +author: James-Beans +tags: builder,config,X11,Linux +--- + +```c +// You can make a new nob-h project using one of these commands: +// npm create nobuild@latest +// yarn create nobuild@latest +// pnpm create nobuild@latest + +// This would be the nob.c config file. + +// This will only work for Linux because it uses X11. And that is Linux only. + +#define NOB_IMPLEMENTATION + +// The nob.h library has to be in the same folder as nob.c (this file). +#include "nob.h" + +#define BUILD_FOLDER "build/" +#define SRC_FOLDER "src/" +#define FLAGS "-lX11" + +int main(int argc, char **argv) +{ + // This self-rebuild mechanism checks if nob.c was modified + // If you’ve updated the build script, remove the existing binary to force a rebuild + NOB_GO_REBUILD_URSELF(argc, argv); + + Nob_Cmd cmd = {0}; + + if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1; + nob_cmd_append(&cmd, "cc", "-Wall", "-Wextra", "-o", BUILD_FOLDER"main", SRC_FOLDER"main.c", FLAGS); + if (!nob_cmd_run_sync(cmd)) return 1; + + return 0; +} +``` diff --git a/snippets/c/[nob]/icon.svg b/snippets/c/[nob]/icon.svg new file mode 100644 index 00000000..9bbc0def --- /dev/null +++ b/snippets/c/[nob]/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file From 25d674fdeb6a7fa6cd2db21fbd51d8ea9f33e4c4 Mon Sep 17 00:00:00 2001 From: obvbeans Date: Sat, 8 Mar 2025 17:53:34 +0000 Subject: [PATCH 2/2] fixed spelling in code comments --- snippets/c/[nob]/basics/basic-config.md | 4 ++-- snippets/c/[nob]/flags/wayland-config.md | 4 ++-- snippets/c/[nob]/flags/x11-config.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/snippets/c/[nob]/basics/basic-config.md b/snippets/c/[nob]/basics/basic-config.md index 182d043f..bbb137be 100644 --- a/snippets/c/[nob]/basics/basic-config.md +++ b/snippets/c/[nob]/basics/basic-config.md @@ -7,8 +7,8 @@ tags: builder,basic,config ```c // You can make a new nob-h project using one of these commands: -// npm create nobuild@latest -// yarn create nobuild@latest +// npx create-nobuild@latest +// yarn create nobuild // pnpm create nobuild@latest // This would be the nob.c config file. diff --git a/snippets/c/[nob]/flags/wayland-config.md b/snippets/c/[nob]/flags/wayland-config.md index 61af0462..ca175fec 100644 --- a/snippets/c/[nob]/flags/wayland-config.md +++ b/snippets/c/[nob]/flags/wayland-config.md @@ -7,8 +7,8 @@ tags: builder,config,Wayland,Linux ```c // You can make a new nob-h project using one of these commands: -// npm create nobuild@latest -// yarn create nobuild@latest +// npx create-nobuild@latest +// yarn create nobuild // pnpm create nobuild@latest // This would be the nob.c config file. diff --git a/snippets/c/[nob]/flags/x11-config.md b/snippets/c/[nob]/flags/x11-config.md index 3ee0f69e..4258f47e 100644 --- a/snippets/c/[nob]/flags/x11-config.md +++ b/snippets/c/[nob]/flags/x11-config.md @@ -7,8 +7,8 @@ tags: builder,config,X11,Linux ```c // You can make a new nob-h project using one of these commands: -// npm create nobuild@latest -// yarn create nobuild@latest +// npx create-nobuild@latest +// yarn create nobuild // pnpm create nobuild@latest // This would be the nob.c config file. 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