From a29393bc186e93f969b2241902f5439ce4493ef5 Mon Sep 17 00:00:00 2001 From: Nikola Petrov Date: Mon, 1 Apr 2024 21:50:43 +0200 Subject: [PATCH] Update build --- .vscode/tasks.json | 2 +- Readme.md | 15 +++++--------- build.cpp | 9 +++++--- build.hpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 14 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 066e96a..3ab8118 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ "type": "shell", "command": "./build", "args": [ - "" + "run" ] }, { diff --git a/Readme.md b/Readme.md index 9e6a61a..43e0106 100644 --- a/Readme.md +++ b/Readme.md @@ -1,16 +1,11 @@ # how to build ``` g++ build.cpp -o build -``` - -after first emsdk clone run this - -``` -cd emsdk -./emsdk install latest -./emsdk activate latest -source ./emsdk_env.sh -cd .. +./build +or +./build run +or +./build cla build web // first clear all then build for web ``` # Code style diff --git a/build.cpp b/build.cpp index 30dbdf0..60864d6 100644 --- a/build.cpp +++ b/build.cpp @@ -214,13 +214,16 @@ int main(int argc, char const *argv[]) command = {"git", "clone", "https://github.com/emscripten-core/emsdk.git"}; nob_cmd_run_sync(command); std::filesystem::remove_all("emsdk/.git"); - return 0; + command = {"./emsdk/emsdk", "install", "latest"}; + nob_cmd_run_sync(command); + command = {"./emsdk/emsdk", "activate", "latest"}; + nob_cmd_run_sync(command); } if (web_build) { - cpp_compiler = "em++"; - c_compiler = "emcc"; + cpp_compiler = "./emsdk/upstream/emscripten/em++"; + c_compiler = "./emsdk/upstream/emscripten/emcc"; opt_flags = "-Os"; RAYINCLUDE.push_back("-DPLATFORM_WEB"); BUILD_FILE = BUILD_FILE.replace_extension(".html"); diff --git a/build.hpp b/build.hpp index 5e2e465..fcd4065 100644 --- a/build.hpp +++ b/build.hpp @@ -11,12 +11,63 @@ #include #include +enum class Color +{ + black, + red, + green, + yellow, + blue, + purple, + cyan, + white, + reset, +}; + +void pick_color(Color color) +{ + switch (color) + { + case Color::black: + printf("\033[0;30m"); + break; + case Color::red: + printf("\033[0;31m"); + break; + case Color::green: + printf("\033[0;32m"); + break; + case Color::yellow: + printf("\033[0;33m"); + break; + case Color::blue: + printf("\033[0;34m"); + break; + case Color::purple: + printf("\033[0;35m"); + break; + case Color::cyan: + printf("\033[0;36m"); + break; + case Color::white: + printf("\033[0;37m"); + break; + case Color::reset: + printf("\033[0m"); + break; + default: + break; + } +} + void print_command(std::vector &arguments) { + pick_color(Color::cyan); for (auto &&i : arguments) { printf("%s ", i.c_str()); } + pick_color(Color::white); printf("\n"); }