up build windows
This commit is contained in:
parent
390c81b30b
commit
34e8e7421a
9
.gitignore
vendored
9
.gitignore
vendored
@ -2,4 +2,11 @@ obj/
|
|||||||
raylib/
|
raylib/
|
||||||
build
|
build
|
||||||
treender
|
treender
|
||||||
.vscode/settings.json
|
.vscode/
|
||||||
|
*.exe
|
||||||
|
*.pdb
|
||||||
|
*.lib
|
||||||
|
.vs/
|
||||||
|
*.sln
|
||||||
|
*.vcxproj*
|
||||||
|
Console*/
|
21
.vscode/c_cpp_properties.json
vendored
21
.vscode/c_cpp_properties.json
vendored
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Linux",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/inc",
|
|
||||||
"${workspaceFolder}/raylib/src"
|
|
||||||
],
|
|
||||||
"defines": [
|
|
||||||
"GRAPHICS_API_OPENGL_33",
|
|
||||||
"PLATFORM_DESKTOP",
|
|
||||||
"_GNU_SOURCE"
|
|
||||||
],
|
|
||||||
"compilerPath": "/usr/bin/gcc",
|
|
||||||
"cStandard": "c23",
|
|
||||||
"cppStandard": "gnu++23",
|
|
||||||
"intelliSenseMode": "linux-gcc-x64"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
60
.vscode/launch.json
vendored
60
.vscode/launch.json
vendored
@ -1,60 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Debug",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/treender",
|
|
||||||
"args": [],
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"environment": [],
|
|
||||||
"externalConsole": false,
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Set Disassembly Flavor to Intel",
|
|
||||||
"text": "-gdb-set disassembly-flavor intel",
|
|
||||||
"ignoreFailures": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"preLaunchTask": "build-deb"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Debug builder",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/build",
|
|
||||||
"args": [
|
|
||||||
"build"
|
|
||||||
],
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"environment": [],
|
|
||||||
"externalConsole": false,
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"description": "Set Disassembly Flavor to Intel",
|
|
||||||
"text": "-gdb-set disassembly-flavor intel",
|
|
||||||
"ignoreFailures": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"preLaunchTask": "build-builder"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
32
.vscode/tasks.json
vendored
32
.vscode/tasks.json
vendored
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"label": "build",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "./build",
|
|
||||||
"args": [
|
|
||||||
"run"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "build-deb",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "./build",
|
|
||||||
"args": [
|
|
||||||
"build"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "build-builder",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "g++",
|
|
||||||
"args": [
|
|
||||||
"build.cpp",
|
|
||||||
"-ggdb",
|
|
||||||
"-o",
|
|
||||||
"build"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
16
build.cpp
16
build.cpp
@ -1,15 +1,14 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define EXT_LINK
|
#define EXT_LINK
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EXT_INC
|
#define EXT_INC
|
||||||
#include "build.hpp"
|
#include "build.hpp"
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
std::vector<std::string> LINK = {"-lopengl32", "-lkernel32", "-luser32", "-lshell32","-lwinmm","-lgdi32"};
|
std::vector<std::string> LINK = {"-lopengl32", "-lkernel32", "-luser32", "-lshell32", "-lwinmm", "-lgdi32"};
|
||||||
|
#else
|
||||||
|
std::vector<std::string> LINK = {};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<std::string> RAYINCLUDE = {"-Iraylib/src", "-Iraylib/src/external/glfw/include", "-Iraylib/src/external/glfw/deps/mingw"};
|
std::vector<std::string> RAYINCLUDE = {"-Iraylib/src", "-Iraylib/src/external/glfw/include", "-Iraylib/src/external/glfw/deps/mingw"};
|
||||||
std::filesystem::path RAYLIB_DIR = "raylib";
|
std::filesystem::path RAYLIB_DIR = "raylib";
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ void compile_raylib_dir()
|
|||||||
{
|
{
|
||||||
command[src_loc] = src.string();
|
command[src_loc] = src.string();
|
||||||
command[obj_loc] = out.string();
|
command[obj_loc] = out.string();
|
||||||
nob_cmd_run_sync(command);
|
run_command(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +83,7 @@ int main(int argc, char const *argv[])
|
|||||||
if (!std::filesystem::is_directory(RAYLIB_DIR))
|
if (!std::filesystem::is_directory(RAYLIB_DIR))
|
||||||
{
|
{
|
||||||
command = {"git", "clone", "--depth", "1", "--branch", "5.0", "https://github.com/raysan5/raylib.git"};
|
command = {"git", "clone", "--depth", "1", "--branch", "5.0", "https://github.com/raysan5/raylib.git"};
|
||||||
nob_cmd_run_sync(command);
|
run_command(command);
|
||||||
std::filesystem::remove_all("raylib/.git");
|
std::filesystem::remove_all("raylib/.git");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +109,7 @@ int main(int argc, char const *argv[])
|
|||||||
|
|
||||||
if (run)
|
if (run)
|
||||||
{
|
{
|
||||||
command = {"./" + BUILD_FILE.string()};
|
run_main();
|
||||||
nob_cmd_run_sync(command);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
96
build.hpp
96
build.hpp
@ -7,10 +7,12 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
// #define EXT_ARGS
|
||||||
// #define EXT_LINK
|
// #define EXT_LINK
|
||||||
// #define EXT_INC
|
// #define EXT_INC
|
||||||
// #define EXT_OBJ
|
// #define EXT_OBJ
|
||||||
// #define NO_Werror
|
// #define Werror
|
||||||
|
// #define Wextra
|
||||||
|
|
||||||
std::filesystem::path OBJ_DIR = "obj";
|
std::filesystem::path OBJ_DIR = "obj";
|
||||||
std::filesystem::path INC_DIR = "inc";
|
std::filesystem::path INC_DIR = "inc";
|
||||||
@ -89,7 +91,7 @@ void print_command(std::vector<std::string> &arguments)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nob_cmd_run_sync(std::vector<std::string> &arguments)
|
bool run_command(std::vector<std::string> &arguments)
|
||||||
{
|
{
|
||||||
print_command(arguments);
|
print_command(arguments);
|
||||||
std::string command = "";
|
std::string command = "";
|
||||||
@ -115,46 +117,58 @@ bool check_if_rebuild(const std::filesystem::path &org_path, const std::filesyst
|
|||||||
return file_time_one > file_time_two;
|
return file_time_one > file_time_two;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool try_remove(std::filesystem::path path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::filesystem::remove("old_build");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool rebuild_my_self(std::filesystem::path src_path, int argc, const char **exec_path)
|
bool rebuild_my_self(std::filesystem::path src_path, int argc, const char **exec_path)
|
||||||
{
|
{
|
||||||
std::filesystem::path exec = exec_path[0];
|
std::filesystem::path exec = exec_path[0];
|
||||||
|
|
||||||
|
try_remove("old_build");
|
||||||
|
|
||||||
if (!check_if_rebuild(src_path, exec) && !check_if_rebuild(__FILE__, exec))
|
if (!check_if_rebuild(src_path, exec) && !check_if_rebuild(__FILE__, exec))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifndef _WIN32
|
std::filesystem::rename(exec, "old_build");
|
||||||
|
|
||||||
std::vector<std::string> input;
|
std::vector<std::string> input;
|
||||||
|
|
||||||
for (int i = 0; i < argc; ++i)
|
for (int i = 0; i < argc; ++i)
|
||||||
input.push_back(exec_path[i]);
|
input.push_back(exec_path[i]);
|
||||||
|
|
||||||
std::vector<std::string> comand = {cpp_compiler, src_path.string(), "-o", exec_path[0], "-g"};
|
std::vector<std::string> comand = {cpp_compiler, src_path.string(), "-o", exec_path[0], "-ggdb"};
|
||||||
if (!nob_cmd_run_sync(comand))
|
if (!run_command(comand))
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!nob_cmd_run_sync(input))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
printf("rebuild\n");
|
printf("rebuild\n");
|
||||||
#else
|
|
||||||
pick_color(Color::red);
|
if (!run_command(input))
|
||||||
printf("rebuild me\n");
|
return false;
|
||||||
pick_color(Color::white);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct nob_directory
|
struct all_in_directory
|
||||||
{
|
{
|
||||||
std::vector<std::filesystem::path> files;
|
std::vector<std::filesystem::path> files;
|
||||||
std::vector<std::filesystem::path> dirs;
|
std::vector<std::filesystem::path> dirs;
|
||||||
};
|
};
|
||||||
|
|
||||||
nob_directory get_all_files_in_dir(std::filesystem::path directory_path)
|
all_in_directory get_all_files_in_dir(std::filesystem::path directory_path)
|
||||||
{
|
{
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
nob_directory dir;
|
all_in_directory dir;
|
||||||
if (!fs::is_directory(directory_path))
|
if (!fs::is_directory(directory_path))
|
||||||
return dir;
|
return dir;
|
||||||
|
|
||||||
@ -223,8 +237,8 @@ int compile_src_dir(std::vector<std::string> ext_inc)
|
|||||||
int compile_src_dir()
|
int compile_src_dir()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
nob_directory src_dir = get_all_files_in_dir(SRC_DIR);
|
all_in_directory src_dir = get_all_files_in_dir(SRC_DIR);
|
||||||
nob_directory obj_dir;
|
all_in_directory obj_dir;
|
||||||
|
|
||||||
for (auto &&i : src_dir.dirs)
|
for (auto &&i : src_dir.dirs)
|
||||||
{
|
{
|
||||||
@ -232,7 +246,7 @@ int compile_src_dir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_set<std::string> modified_heders;
|
std::unordered_set<std::string> modified_heders;
|
||||||
nob_directory inc_dir = get_all_files_in_dir(INC_DIR);
|
all_in_directory inc_dir = get_all_files_in_dir(INC_DIR);
|
||||||
|
|
||||||
for (size_t i = 0; i < inc_dir.files.size(); i++)
|
for (size_t i = 0; i < inc_dir.files.size(); i++)
|
||||||
{
|
{
|
||||||
@ -260,7 +274,10 @@ int compile_src_dir()
|
|||||||
command.push_back("-I" + INC_DIR.string());
|
command.push_back("-I" + INC_DIR.string());
|
||||||
command.push_back("-std=c++23");
|
command.push_back("-std=c++23");
|
||||||
command.push_back("-Wall");
|
command.push_back("-Wall");
|
||||||
#ifndef NO_Werror
|
#ifdef Wextra
|
||||||
|
command.push_back("-Wextra");
|
||||||
|
#endif
|
||||||
|
#ifdef Werror
|
||||||
command.push_back("-Werror");
|
command.push_back("-Werror");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -292,7 +309,7 @@ int compile_src_dir()
|
|||||||
{
|
{
|
||||||
command[src_loc] = i.string();
|
command[src_loc] = i.string();
|
||||||
command[obj_loc] = out.string();
|
command[obj_loc] = out.string();
|
||||||
if (!nob_cmd_run_sync(command))
|
if (!run_command(command))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
build = 1;
|
build = 1;
|
||||||
@ -302,12 +319,12 @@ int compile_src_dir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXT_LINK)
|
#if defined(EXT_LINK)
|
||||||
void compile_obj_dir(std::vector<std::string> ext_link)
|
bool compile_obj_dir(std::vector<std::string> ext_link)
|
||||||
#else
|
#else
|
||||||
void compile_obj_dir()
|
bool compile_obj_dir()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
nob_directory obj_dir = get_all_files_in_dir(OBJ_DIR);
|
all_in_directory obj_dir = get_all_files_in_dir(OBJ_DIR);
|
||||||
|
|
||||||
command.clear();
|
command.clear();
|
||||||
command.push_back(cpp_compiler);
|
command.push_back(cpp_compiler);
|
||||||
@ -324,7 +341,7 @@ void compile_obj_dir()
|
|||||||
command.insert(command.end(), ext_link.begin(), ext_link.end());
|
command.insert(command.end(), ext_link.begin(), ext_link.end());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nob_cmd_run_sync(command);
|
return run_command(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXT_OBJ) && defined(EXT_INC)
|
#if defined(EXT_OBJ) && defined(EXT_INC)
|
||||||
@ -337,7 +354,7 @@ void build_as_one(std::vector<std::string> ext_inc)
|
|||||||
void build_as_one()
|
void build_as_one()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
nob_directory src_dir = get_all_files_in_dir(SRC_DIR);
|
all_in_directory src_dir = get_all_files_in_dir(SRC_DIR);
|
||||||
|
|
||||||
command.clear();
|
command.clear();
|
||||||
command.push_back(cpp_compiler);
|
command.push_back(cpp_compiler);
|
||||||
@ -352,7 +369,10 @@ void build_as_one()
|
|||||||
command.push_back("-I" + INC_DIR.string());
|
command.push_back("-I" + INC_DIR.string());
|
||||||
command.push_back("-std=c++23");
|
command.push_back("-std=c++23");
|
||||||
command.push_back("-Wall");
|
command.push_back("-Wall");
|
||||||
#ifndef NO_Werror
|
#ifdef Wextra
|
||||||
|
command.push_back("-Wextra");
|
||||||
|
#endif
|
||||||
|
#ifdef Werror
|
||||||
command.push_back("-Werror");
|
command.push_back("-Werror");
|
||||||
#endif
|
#endif
|
||||||
for (auto &&i : src_dir.files)
|
for (auto &&i : src_dir.files)
|
||||||
@ -363,5 +383,25 @@ void build_as_one()
|
|||||||
#ifdef EXT_OBJ
|
#ifdef EXT_OBJ
|
||||||
command.insert(command.end(), ext_obj.begin(), ext_obj.end());
|
command.insert(command.end(), ext_obj.begin(), ext_obj.end());
|
||||||
#endif
|
#endif
|
||||||
nob_cmd_run_sync(command);
|
run_command(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef EXT_ARGS
|
||||||
|
bool run_main(std::vector<std::string> ext_args)
|
||||||
|
#else
|
||||||
|
bool run_main()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
command.clear();
|
||||||
|
#ifndef _WIN32
|
||||||
|
command.push_back("./" + BUILD_FILE.string());
|
||||||
|
#else
|
||||||
|
command.push_back(BUILD_FILE.string());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef EXT_ARGS
|
||||||
|
command.insert(command.end(), ext_args.begin(), ext_args.end());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return run_command(command);
|
||||||
}
|
}
|
@ -60,13 +60,13 @@ void Tree::drawBranch()
|
|||||||
for (size_t i = 0; i < branches[arg.dep].numOfBranches; i++)
|
for (size_t i = 0; i < branches[arg.dep].numOfBranches; i++)
|
||||||
{
|
{
|
||||||
float newAngle = arg.angleDeg - 90 + (degres * (i + 1));
|
float newAngle = arg.angleDeg - 90 + (degres * (i + 1));
|
||||||
draw_calls.push_back((DrawArgs){next, newAngle, arg.lenghth * next_len, arg.dep + 1});
|
draw_calls.push_back({ next, newAngle, arg.lenghth * next_len, arg.dep + 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tree::drawTree()
|
void Tree::drawTree()
|
||||||
{
|
{
|
||||||
draw_calls.push_back((DrawArgs){start, 0, (float)size / 4, 1});
|
draw_calls.push_back({start, 0, (float)size / 4, 1});
|
||||||
|
|
||||||
while (!draw_calls.empty())
|
while (!draw_calls.empty())
|
||||||
{
|
{
|
||||||
@ -82,7 +82,7 @@ void Tree::generateBranches()
|
|||||||
uint8_t r = GetRandomValue(0, 255);
|
uint8_t r = GetRandomValue(0, 255);
|
||||||
uint8_t g = GetRandomValue(0, 255);
|
uint8_t g = GetRandomValue(0, 255);
|
||||||
uint8_t b = GetRandomValue(0, 255);
|
uint8_t b = GetRandomValue(0, 255);
|
||||||
branches[i].color = (Color){r, g, b, 255};
|
branches[i].color = {r, g, b, 255};
|
||||||
|
|
||||||
branches[i].numOfBranches = GetRandomValue(1, 3);
|
branches[i].numOfBranches = GetRandomValue(1, 3);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user