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..bbb137be --- /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: +// npx create-nobuild@latest +// yarn create nobuild +// 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..ca175fec --- /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: +// npx create-nobuild@latest +// yarn create nobuild +// 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..4258f47e --- /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: +// npx create-nobuild@latest +// yarn create nobuild +// 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 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