Update build

This commit is contained in:
Nikola Petrov 2024-04-01 21:50:43 +02:00
parent b87dd4203b
commit a29393bc18
4 changed files with 63 additions and 14 deletions

2
.vscode/tasks.json vendored
View File

@ -6,7 +6,7 @@
"type": "shell", "type": "shell",
"command": "./build", "command": "./build",
"args": [ "args": [
"" "run"
] ]
}, },
{ {

View File

@ -1,16 +1,11 @@
# how to build # how to build
``` ```
g++ build.cpp -o build g++ build.cpp -o build
``` ./build
or
after first emsdk clone run this ./build run
or
``` ./build cla build web // first clear all then build for web
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ..
``` ```
# Code style # Code style

View File

@ -214,13 +214,16 @@ int main(int argc, char const *argv[])
command = {"git", "clone", "https://github.com/emscripten-core/emsdk.git"}; command = {"git", "clone", "https://github.com/emscripten-core/emsdk.git"};
nob_cmd_run_sync(command); nob_cmd_run_sync(command);
std::filesystem::remove_all("emsdk/.git"); 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) if (web_build)
{ {
cpp_compiler = "em++"; cpp_compiler = "./emsdk/upstream/emscripten/em++";
c_compiler = "emcc"; c_compiler = "./emsdk/upstream/emscripten/emcc";
opt_flags = "-Os"; opt_flags = "-Os";
RAYINCLUDE.push_back("-DPLATFORM_WEB"); RAYINCLUDE.push_back("-DPLATFORM_WEB");
BUILD_FILE = BUILD_FILE.replace_extension(".html"); BUILD_FILE = BUILD_FILE.replace_extension(".html");

View File

@ -11,12 +11,63 @@
#include <list> #include <list>
#include <filesystem> #include <filesystem>
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<std::string> &arguments) void print_command(std::vector<std::string> &arguments)
{ {
pick_color(Color::cyan);
for (auto &&i : arguments) for (auto &&i : arguments)
{ {
printf("%s ", i.c_str()); printf("%s ", i.c_str());
} }
pick_color(Color::white);
printf("\n"); printf("\n");
} }