cbuild 2.3.5

This commit is contained in:
2026-06-07 17:07:18 +05:00
parent ec781256cc
commit abb8d97a15
13 changed files with 106 additions and 102 deletions

View File

@@ -4,15 +4,16 @@
"name": "all",
"defines": [
"SDL_DISABLE_ANALYZE_MACROS",
"DEBUG=1"
"DEBUG=1",
],
"includePath": [
"dependencies/include",
"dependencies/include/SDL2",
"dependencies/cimgui/imgui",
"${default}"
"${default}",
],
"cppStandard": "c++20"
"cppStandard": "c++20",
"cStandard": "c11",
}
],
"version": 4

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env bash
CBUILD_VERSION=2.2.1
CBUILD_VERSION=2.3.5
CONFIG_VERSION=1
PROJECT="cimgui"
@@ -7,8 +7,8 @@ CMP_C="gcc"
CMP_CPP="g++"
STD_C="c11"
STD_CPP="c++11"
WARN_C="-Wall -Wno-discarded-qualifiers -Wno-unused-parameter"
WARN_CPP="-Wall -Wno-unused-parameter"
WARN_C=""
WARN_CPP=""
SRC_C=""
SRC_CPP="imgui/imgui.cpp
imgui/imgui_demo.cpp
@@ -42,12 +42,12 @@ case "$OS" in
WINDOWS)
SHARED_LIB_FILE="$PROJECT.dll"
LINKER_LIBS="-L../precompiled/$OS-$ARCH -l:SDL2.dll"
DEFINE="-DIMGUI_API=__declspec(dllexport)"
DEFINES="-DIMGUI_API=__declspec(dllexport)"
;;
LINUX)
SHARED_LIB_FILE="$PROJECT.so"
LINKER_LIBS="-lSDL2"
DEFINE="-DIMGUI_API=__attribute__((__visibility__(\"default\")))"
DEFINES="-DIMGUI_API=__attribute__((__visibility__(\"default\")))"
;;
*)
error "operating system $OS has no configuration variants"
@@ -58,41 +58,33 @@ esac
case "$TASK" in
# creates shared library
build_shared_lib)
C_ARGS="-O2 -fpic -shared $DEFINE"
C_ARGS="-O2 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
;;
# creates shared library with debug symbols and no optimizations
build_shared_lib_dbg)
C_ARGS="-O0 -g3 -fpic -shared $DEFINE"
C_ARGS="-O0 -g3 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
;;
# creates static library
build_static_lib)
C_ARGS="-O2 $DEFINE"
C_ARGS="-O2 $DEFINES"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
;;
# creates static library with debug symbols and no optimizations
build_static_lib_dbg)
C_ARGS="-O0 -g3 $DEFINE"
C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
;;
# deletes generated files
clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh
TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
;;
# nothing to do
"" | no_task)

View File

@@ -1,13 +1,24 @@
#!/usr/bin/env bash
CBUILD_VERSION=2.2.1
CBUILD_VERSION=2.3.5
PROJECT="ougge"
CMP_C="gcc"
CMP_CPP="g++"
STD_C="c11"
STD_CPP="c++20"
WARN_C="-Wall -Wno-discarded-qualifiers -Wextra -Wno-unused-parameter"
WARN_CPP="-Wall -Wextra -Wno-unused-parameter"
WARN_COMMON="-Wall -Wextra
-Wduplicated-branches
-Wduplicated-cond
-Wformat=2
-Wmissing-include-dirs
-Wshadow
-Werror=return-type
-Werror=pointer-arith
-Werror=init-self
-Wno-unused-parameter"
WARN_C="$WARN_COMMON
-Werror=incompatible-pointer-types"
WARN_CPP="$WARN_COMMON"
SRC_C="$(find src -name '*.c')"
SRC_CPP="$(find src -name '*.cpp')"
@@ -24,10 +35,11 @@ ENABLED_DEPENDENCIES='precompiled resources cimgui src-csharp'
# └── profile/ - gcc *.gcda profiling info files
OBJDIR="obj"
OUTDIR="bin"
STATIC_LIB_FILE="lib$PROJECT.a"
STATIC_LIB_FILE="$PROJECT.a"
# header include directories
INCLUDE="-I./dependencies/cimgui/imgui -I./dependencies/include -I./dependencies/include/SDL2"
DEFINES=""
# OS-specific options
case "$OS" in
@@ -35,18 +47,21 @@ case "$OS" in
EXEC_FILE="$PROJECT.exe"
SHARED_LIB_FILE="$PROJECT.dll"
LINKER_LIBS="-static -lstdc++ -lpthread"
INCLUDE="$INCLUDE "
DEFINES="$DEFINES "
;;
LINUX)
EXEC_FILE="$PROJECT"
SHARED_LIB_FILE="$PROJECT.so"
LINKER_LIBS="-lSDL2 -lSDL2_image"
INCLUDE="$INCLUDE "
DEFINES="$DEFINES "
;;
*)
error "operating system $OS has no configuration variants"
;;
esac
# TASKS
case "$TASK" in
# creates executable using profiling info if it exists
@@ -57,64 +72,56 @@ case "$TASK" in
# -fprofile-use enables compiler to use profiling info files to optimize executable
# -fprofile-prefix-path sets path where profiling info about objects are be saved
# -fdata-sections -ffunction-sections -Wl,--gc-sections removes unused code
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections"
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-use -fprofile-prefix-path=$(realpath $OBJDIR)/objects -fdata-sections -ffunction-sections -Wl,--gc-sections $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT=""
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT="@cbuild/default_tasks/strip_exec.sh"
;;
# creates executable with debug info and no optimizations
build_exec_dbg)
C_ARGS="-O0 -g3"
C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT=""
TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
POST_TASK_SCRIPT=""
;;
# creates shared library
build_shared_lib)
C_ARGS="-O2 -fpic -flto -shared"
C_ARGS="-O2 -fpic -flto -shared $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
;;
# creates shared library with debug symbols and no optimizations
build_shared_lib_dbg)
C_ARGS="-O0 -g3 -fpic -shared"
C_ARGS="-O0 -g3 -fpic -shared $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS -Wl,-soname,$SHARED_LIB_FILE"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_shared_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_shared_lib.sh"
;;
# creates static library
build_static_lib)
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections"
C_ARGS="-O2 -fpic -fdata-sections -ffunction-sections $DEFINES"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
;;
# creates static library with debug symbols and no optimizations
build_static_lib_dbg)
C_ARGS="-O0 -g3"
C_ARGS="-O0 -g3 $DEFINES"
CPP_ARGS="$C_ARGS"
PRE_TASK_SCRIPT=
TASK_SCRIPT=cbuild/default_tasks/build_static_lib.sh
POST_TASK_SCRIPT=
TASK_SCRIPT="@cbuild/default_tasks/build_static_lib.sh"
;;
# executes $EXEC_FILE
exec)
TASK_SCRIPT=cbuild/default_tasks/exec.sh
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
;;
# executes $EXEC_FILE with valgrind memory checker
valgrind)
VALGRIND_ARGS="-s --read-var-info=yes --track-origins=yes --fullpath-after=$(pwd)/ --leak-check=full --show-leak-kinds=all"
TASK_SCRIPT=cbuild/default_tasks/valgrind.sh
TASK_SCRIPT="@cbuild/default_tasks/valgrind.sh"
;;
# generates profiling info
profile)
@@ -125,25 +132,27 @@ case "$TASK" in
# -pg adds code to executable, that generates file containing function call info (gmon.out)
# -fprofile-generate generates executable with profiling code
# -fprofile-prefix-path sets path where profiling info about objects will be saved
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate -fprofile-prefix-path=$(realpath $OBJDIR)/objects"
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -fprofile-generate
-fprofile-prefix-path=$(realpath $OBJDIR)/objects $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/profile.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT="@cbuild/default_tasks/profile.sh"
;;
# compiles program with -pg and runs it with gprof
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
# requires graphviz (https://www.graphviz.org/download/source/)
gprof)
OUTDIR="$OUTDIR/gprof"
# -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-O2 -flto=auto -fuse-linker-plugin -pg"
# arguments that emit some call counter code and disable optimizations to see function names
# https://github.com/msys2/MINGW-packages/issues/8503#issuecomment-1365475205
C_ARGS="-O0 -g -pg -no-pie -fno-omit-frame-pointer
-fno-inline-functions -fno-inline-functions-called-once
-fno-optimize-sibling-calls -fopenmp $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/gprof.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT="@cbuild/default_tasks/gprof.sh"
;;
# compiles program and runs it with callgrind (part of valgrind)
# uses gprof2dot python script to generate function call tree (pip install gprof2dot)
@@ -152,35 +161,37 @@ case "$TASK" in
callgrind)
OUTDIR="$OUTDIR/callgrind"
# -pg adds code to executable, that generates file containing function call info (gmon.out)
C_ARGS="-O2 -flto=auto -fuse-linker-plugin"
C_ARGS="-O2 -flto=auto -fuse-linker-plugin $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/callgrind.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT="@cbuild/default_tasks/callgrind.sh"
;;
# compiles executable with sanitizers and executes it to find errors and warnings
sanitize)
OUTDIR="$OUTDIR/sanitize"
C_ARGS="-O0 -g3 -fsanitize=undefined,address"
C_ARGS="-O0 -g3 -fsanitize=undefined,address $DEFINES"
CPP_ARGS="$C_ARGS"
LINKER_ARGS="$CPP_ARGS $LINKER_LIBS"
PRE_TASK_SCRIPT=cbuild/default_tasks/build_exec.sh
TASK_SCRIPT=cbuild/default_tasks/exec.sh
POST_TASK_SCRIPT=
PRE_TASK_SCRIPT="@cbuild/default_tasks/build_exec.sh"
TASK_SCRIPT="@cbuild/default_tasks/exec.sh"
;;
# rebuilds specified dependencies
# EXAMPLE: `cbuild rebuild_dependencies=libexample1,fonts`
# 'all' can be specified to rebuild all dependencies
rebuild_dependencies)
TASK_SCRIPT=cbuild/default_tasks/rebuild_dependencies.sh
TASK_SCRIPT="@cbuild/default_tasks/rebuild_dependencies.sh"
;;
# Downloads mono runtime package from nuget.
# Extracts libs to dependencies/precompiled/$OS-$ARCH
# Extracts headers to dependencies/include/mono
# download_mono_from_nuget=VERSION
download_mono_from_nuget)
TASK_SCRIPT=tasks/download_mono_from_nuget.sh
;;
# deletes generated files
clean)
TASK_SCRIPT=cbuild/default_tasks/clean.sh
TASK_SCRIPT="@cbuild/default_tasks/clean.sh"
;;
# nothing to do
"" | no_task)

View File

@@ -7,8 +7,8 @@
namespace ougge {
IEngineModule::IEngineModule(Engine& engine)
: engine(engine)
IEngineModule::IEngineModule(Engine& _engine)
: engine(_engine)
{}
void IEngineModule::beginFrame() {}

View File

@@ -4,15 +4,15 @@
namespace ougge::game {
GameObjectPool::GameObjectPool(u32 size)
GameObjectPool::GameObjectPool(u32 _size)
: size(_size)
{
useful_assert(size % 64 == 0, "size of GameObjectPool must be a multiple of 64");
this->size = size;
useful_assert(_size % 64 == 0, "size of GameObjectPool must be a multiple of 64");
first_unused_index = 0;
buffer = new GameObject[size];
used_indices = new u64[size/64];
buffer = new GameObject[_size];
used_indices = new u64[_size/64];
// std::memset(buffer, 0, size*sizeof(GameObject));
std::memset(used_indices, 0, size/8);
std::memset(used_indices, 0, _size/8);
}
GameObjectPool::~GameObjectPool()
@@ -110,8 +110,8 @@ bool GameObjectPool::erase(u32 index)
return true;
}
GameObjectPool::iterator::iterator(GameObjectPool* pool, u32 index)
: pool(pool), index(index)
GameObjectPool::iterator::iterator(GameObjectPool* _pool, u32 _index)
: pool(_pool), index(_index)
{
}

View File

@@ -11,8 +11,8 @@ using namespace ougge;
class TutelModule : public IEngineModule {
resources::CacheStorage<resources::Texture> textures;
public:
TutelModule(Engine& engine, resources::ResourceManager& resourceManager) :
IEngineModule(engine),
TutelModule(Engine& _engine, resources::ResourceManager& resourceManager) :
IEngineModule(_engine),
textures(&resourceManager)
{
//TODO: add something like `assert(requireModule(MainWindow))`

View File

@@ -25,10 +25,10 @@ f32 MainWindowSDL2::getDPI(){
return dpi;
}
MainWindowSDL2::MainWindowSDL2(Engine& engine,
MainWindowSDL2::MainWindowSDL2(Engine& _engine,
const std::string& window_title,
resources::ResourceManager& resourceManager)
: IEngineModule(engine)
: IEngineModule(_engine)
{
SDL_TRY(SDL_Init(SDL_INIT_EVERYTHING));
SDL_version v;

View File

@@ -6,8 +6,8 @@ const std::string& MonoGameObjectSystem::getName() {
return ougge_type_name<MonoGameObjectSystem>();
}
MonoGameObjectSystem::MonoGameObjectSystem(Engine& engine, u32 max_game_objects) :
IEngineModule(engine),
MonoGameObjectSystem::MonoGameObjectSystem(Engine& _engine, u32 max_game_objects) :
IEngineModule(_engine),
gameObjectPool(max_game_objects)
{
engineManagedAssembly = mono.loadAssembly("Ougge.dll");
@@ -53,7 +53,7 @@ void MonoGameObjectSystem::beginFrame(){
// is used in NativeFunctions.cs
game::GameObject& MonoGameObjectSystem::createGameObjectInPool(u64* id_out, u32* index_out){
auto pair = gameObjectPool.emplace(game::GameObject(mono.createObject(gameObjectClass)));
*id_out = ++obj_id;
*id_out = ++last_obj_id;
*index_out = pair.first;
game::GameObject& obj = pair.second;
return obj;

View File

@@ -10,7 +10,7 @@ namespace ougge::modules {
class MonoGameObjectSystem : public IEngineModule {
Mono::RuntimeJIT mono;
game::GameObjectPool gameObjectPool;
u64 obj_id = 0;
u64 last_obj_id = 0;
MonoClass* gameObjectClass;
Mono::Method<void(u64, u32)> gameObjectCtor;
Mono::Method<void(f64)> gameObjectInvokeUpdate;

View File

@@ -2,8 +2,8 @@
namespace Mono {
Assembly::Assembly(MonoAssembly *ptr)
: ptr(ptr), image(mono_assembly_get_image(ptr))
Assembly::Assembly(MonoAssembly *_ptr)
: ptr(_ptr), image(mono_assembly_get_image(_ptr))
{
}

View File

@@ -8,8 +8,8 @@
namespace ougge::resources {
ResourceFactory::ResourceFactory(const std::string& path, const std::size_t size, StreamFactoryMethod open_read_steam_func)
: path(path), size(size), openStream(open_read_steam_func)
ResourceFactory::ResourceFactory(const std::string& _path, const std::size_t _size, StreamFactoryMethod _open_read_steam_func)
: path(_path), size(_size), openStream(_open_read_steam_func)
{}

View File

@@ -4,12 +4,12 @@
namespace ougge::resources {
Texture::Texture(ResourceFactory* r, SDL_Renderer* renderer)
: Texture(*r->openStream(), r->size, renderer)
Texture::Texture(ResourceFactory* r, SDL_Renderer* _renderer)
: Texture(*r->openStream(), r->size, _renderer)
{}
Texture::Texture(std::istream& s, size_t size, SDL_Renderer* renderer)
: renderer(renderer), texture(nullptr), w(0), h(0)
Texture::Texture(std::istream& s, size_t size, SDL_Renderer* _renderer)
: renderer(_renderer), texture(nullptr), w(0), h(0)
{
SDL_RWops* sdl_stream = SDL_RWFromIStream(s, size);
if(!sdl_stream)

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash
package_version="$TASK_ARGS"
if [ -z "$package_version" ]; then
package_version="8.0.15"
package_version="8.0.27"
myprint "${YELLOW}You can choose package version manually: cbuild get_mono_files_from=x.y.z"
fi
myprint "${BLUE}package_version: ${CYAN}$package_version"