summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevent Kaya <levent@dev>2025-11-06 01:53:28 +0300
committerLevent Kaya <levent@dev>2025-11-06 01:53:28 +0300
commitd2bb3c90b4e8dffaabb2315df13a2dbd362bb1b7 (patch)
tree7dbf1bf2302ce14de55b6545507274c12c3d7d3b
parent2140653c001a2ac415fb717d48ca2b55ff2aa037 (diff)
[feature] basic demo screen
-rw-r--r--CMakePresets.json87
-rw-r--r--cmake/BoltDBGConfig.cmake.in31
-rw-r--r--cmake/CompilerWarnings.cmake96
-rw-r--r--imgui.ini10
-rwxr-xr-xscripts/fetch_deps.sh166
-rw-r--r--src/dummy.cpp1
6 files changed, 391 insertions, 0 deletions
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 0000000..51f1a86
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,87 @@
+{
+ "version": 3,
+ "configurePresets": [
+ {
+ "name": "debug",
+ "displayName": "Debug Build",
+ "description": "Debug build with symbols",
+ "binaryDir": "${sourceDir}/build/debug",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+ "BOLTDBG_BUILD_TESTS": "ON",
+ "BOLTDBG_BUILD_EXAMPLES": "ON",
+ "BOLTDBG_USE_SYSTEM_LIBS": "ON"
+ }
+ },
+ {
+ "name": "release",
+ "displayName": "Release Build",
+ "description": "Optimized release build",
+ "binaryDir": "${sourceDir}/build/release",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Release",
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+ "BOLTDBG_BUILD_TESTS": "OFF",
+ "BOLTDBG_BUILD_EXAMPLES": "OFF",
+ "BOLTDBG_USE_SYSTEM_LIBS": "ON"
+ }
+ },
+ {
+ "name": "debug-asan",
+ "displayName": "Debug with Address Sanitizer",
+ "description": "Debug build with ASAN enabled",
+ "binaryDir": "${sourceDir}/build/debug-asan",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+ "BOLTDBG_BUILD_TESTS": "ON",
+ "BOLTDBG_ENABLE_ASAN": "ON",
+ "BOLTDBG_USE_SYSTEM_LIBS": "ON"
+ }
+ },
+ {
+ "name": "debug-ubsan",
+ "displayName": "Debug with UBSan",
+ "description": "Debug build with Undefined Behavior Sanitizer",
+ "binaryDir": "${sourceDir}/build/debug-ubsan",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+ "BOLTDBG_BUILD_TESTS": "ON",
+ "BOLTDBG_ENABLE_UBSAN": "ON",
+ "BOLTDBG_USE_SYSTEM_LIBS": "ON"
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "debug",
+ "configurePreset": "debug"
+ },
+ {
+ "name": "release",
+ "configurePreset": "release"
+ },
+ {
+ "name": "debug-asan",
+ "configurePreset": "debug-asan"
+ }
+ ],
+ "testPresets": [
+ {
+ "name": "debug",
+ "configurePreset": "debug",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "debug-asan",
+ "configurePreset": "debug-asan",
+ "output": {
+ "outputOnFailure": true
+ }
+ }
+ ]
+}
diff --git a/cmake/BoltDBGConfig.cmake.in b/cmake/BoltDBGConfig.cmake.in
new file mode 100644
index 0000000..db91ae1
--- /dev/null
+++ b/cmake/BoltDBGConfig.cmake.in
@@ -0,0 +1,31 @@
+# BoltDBGConfig.cmake.in
+# Package configuration file for BoltDBG
+
+@PACKAGE_INIT@
+
+# Provide package version
+set(BOLTDBG_VERSION @PROJECT_VERSION@)
+
+# Check if dependencies are available
+include(CMakeFindDependencyMacro)
+
+# Find required dependencies
+find_dependency(OpenGL REQUIRED)
+
+# Optional: Find GLFW if needed
+# find_dependency(glfw3 3.3)
+
+# Include the targets file
+include("${CMAKE_CURRENT_LIST_DIR}/BoltDBGTargets.cmake")
+
+# Provide variables for users
+set(BoltDBG_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
+set(BoltDBG_LIBRARIES BoltDBG::Core)
+
+# Check all required components are available
+check_required_components(BoltDBG)
+
+# Print info message
+if(NOT BoltDBG_FIND_QUIETLY)
+ message(STATUS "Found BoltDBG ${BOLTDBG_VERSION}")
+endif() \ No newline at end of file
diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake
new file mode 100644
index 0000000..662b142
--- /dev/null
+++ b/cmake/CompilerWarnings.cmake
@@ -0,0 +1,96 @@
+# cmake/CompilerWarnings.cmake
+# Comprehensive compiler warnings for C++
+
+function(set_project_warnings target_name)
+ set(MSVC_WARNINGS
+ /W4 # Baseline reasonable warnings
+ /w14242 # Conversion possible loss of data
+ /w14254 # Operator conversions
+ /w14263 # Member function does not override
+ /w14265 # Class has virtual functions but destructor is not virtual
+ /w14287 # Unsigned/negative constant mismatch
+ /we4289 # Loop variable used outside loop (error)
+ /w14296 # Expression is always true/false
+ /w14311 # Pointer truncation
+ /w14545 # Expression before comma evaluates to function
+ /w14546 # Function call before comma missing argument list
+ /w14547 # Operator before comma has no effect
+ /w14549 # Operator before comma has no effect
+ /w14555 # Expression has no effect
+ /w14619 # Unknown pragma warning
+ /w14640 # Thread-unsafe static member initialization
+ /w14826 # Conversion is sign-extended
+ /w14905 # Wide string literal cast
+ /w14906 # String literal cast
+ /w14928 # Illegal copy-initialization
+ /permissive- # Conformance mode
+ )
+
+ set(CLANG_WARNINGS
+ -Wall
+ -Wextra
+ -Wshadow
+ -Wnon-virtual-dtor
+ -Wold-style-cast
+ -Wcast-align
+ -Wunused
+ -Woverloaded-virtual
+ -Wpedantic
+ -Wconversion
+ -Wsign-conversion
+ -Wnull-dereference
+ -Wdouble-promotion
+ -Wformat=2
+ -Wimplicit-fallthrough
+ )
+
+ set(GCC_WARNINGS
+ ${CLANG_WARNINGS}
+ -Wmisleading-indentation
+ -Wduplicated-cond
+ -Wduplicated-branches
+ -Wlogical-op
+ -Wuseless-cast
+ )
+
+ if(MSVC)
+ set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS})
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
+ set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS})
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS})
+ else()
+ message(WARNING "No compiler warnings set for CXX compiler: ${CMAKE_CXX_COMPILER_ID}")
+ endif()
+
+ # C warnings (similar but adapted)
+ set(CLANG_C_WARNINGS
+ -Wall
+ -Wextra
+ -Wshadow
+ -Wcast-align
+ -Wunused
+ -Wpedantic
+ -Wconversion
+ -Wsign-conversion
+ -Wnull-dereference
+ -Wdouble-promotion
+ -Wformat=2
+ -Wimplicit-fallthrough
+ )
+
+ set(GCC_C_WARNINGS ${CLANG_C_WARNINGS})
+
+ if(CMAKE_C_COMPILER_ID MATCHES ".*Clang")
+ set(PROJECT_WARNINGS_C ${CLANG_C_WARNINGS})
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(PROJECT_WARNINGS_C ${GCC_C_WARNINGS})
+ endif()
+
+ target_compile_options(${target_name}
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>
+ $<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>
+ )
+
+endfunction() \ No newline at end of file
diff --git a/imgui.ini b/imgui.ini
new file mode 100644
index 0000000..9452231
--- /dev/null
+++ b/imgui.ini
@@ -0,0 +1,10 @@
+[Window][Debug##Default]
+Pos=60,60
+Size=400,400
+Collapsed=0
+
+[Window][BoltDBG - Demo]
+Pos=60,20
+Size=393,352
+Collapsed=0
+
diff --git a/scripts/fetch_deps.sh b/scripts/fetch_deps.sh
new file mode 100755
index 0000000..8177fcf
--- /dev/null
+++ b/scripts/fetch_deps.sh
@@ -0,0 +1,166 @@
+#!/usr/bin/env bash
+# scripts/fetch_deps.sh
+# Idempotent dependency fetcher for BoltDBG.
+# - clones lightweight (shallow) tagged commits into external/
+# - safe to run repeatedly
+# - respects GIT_CLONE_DEPTH and DRY_RUN env vars
+#
+# Defaults can be overridden via environment variables:
+# DRY_RUN=1 (don't actually clone)
+# GIT_CLONE_DEPTH=1 (use 0 for full clone)
+# IMGUITAG=... GLFWTAG=... SPDLOGTAG=... GLADTAG=...
+#
+# Examples:
+# ./scripts/fetch_deps.sh
+# DRY_RUN=1 ./scripts/fetch_deps.sh
+# IMGUITAG=v1.89.8 ./scripts/fetch_deps.sh
+
+set -euo pipefail
+
+# Configurable env vars with sane defaults
+: "${DRY_RUN:=0}"
+: "${GIT_CLONE_DEPTH:=1}" # 1 = shallow, 0 = full clone
+ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
+EXTERNAL_DIR="${ROOT_DIR}/external"
+
+# Repos & tags (pin here; override with env)
+IMGUI_REPO="https://github.com/ocornut/imgui.git"
+IMGUI_TAG="${IMGUITAG:-v1.89.8}"
+
+GLFW_REPO="https://github.com/glfw/glfw.git"
+GLFW_TAG="${GLFWTAG:-3.3.8}"
+
+SPDLOG_REPO="https://github.com/gabime/spdlog.git"
+SPDLOG_TAG="${SPDLOGTAG:-v1.11.0}"
+
+GLAD_REPO="https://github.com/Dav1dde/glad.git"
+GLAD_TAG="${GLADTAG:-v0.1.36}"
+
+# Helper utils
+echo_header() {
+ echo "================================================================="
+ echo "$*"
+ echo "-----------------------------------------------------------------"
+}
+
+require_cmd() {
+ if ! command -v "$1" >/dev/null 2>&1; then
+ echo "ERROR: required command '$1' not found in PATH. Install it and retry."
+ exit 2
+ fi
+}
+
+# Check prerequisites (git required to clone)
+require_cmd git
+
+# Prepare external dir
+mkdir -p "${EXTERNAL_DIR}"
+
+# normalize depth option for git clone
+git_depth_arg=()
+if [ "${GIT_CLONE_DEPTH}" != "0" ]; then
+ git_depth_arg=(--depth "${GIT_CLONE_DEPTH}")
+fi
+
+# Clone helper: idempotent and safe
+clone_if_missing() {
+ local target_dir="$1"; shift
+ local repo="$1"; shift
+ local tag="$1"; shift
+
+ # If exists and is a git repo, skip
+ if [ -d "${target_dir}" ] && [ -d "${target_dir}/.git" ]; then
+ echo ">>> ${target_dir} already exists and is a git repo. Skipping."
+ return 0
+ fi
+
+ # If exists but not a git repo, avoid overwriting
+ if [ -d "${target_dir}" ] && [ ! -d "${target_dir}/.git" ]; then
+ echo ">>> ${target_dir} exists but is not a git repo. Skipping to avoid overwrite."
+ return 0
+ fi
+
+ # Dry-run mode: just print what would be done
+ if [ "${DRY_RUN}" = "1" ]; then
+ echo "[DRY RUN] git clone ${git_depth_arg[*]} --branch ${tag} ${repo} ${target_dir}"
+ return 0
+ fi
+
+ # Attempt clone; if tag isn't found, try fallback to branch/commit directly
+ echo "Cloning ${repo} (ref=${tag}) into ${target_dir} (depth=${GIT_CLONE_DEPTH:-full})..."
+ set +e
+ git clone "${git_depth_arg[@]}" --branch "${tag}" "${repo}" "${target_dir}"
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "Warning: clone with --branch ${tag} failed, attempting clone of default branch then checkout..."
+ git clone "${git_depth_arg[@]}" "${repo}" "${target_dir}"
+ (
+ cd "${target_dir}"
+ # try to checkout tag/commit; ignore failures but warn
+ if ! git checkout "${tag}"; then
+ echo "Warning: could not checkout '${tag}' in ${target_dir}; repository left on default branch."
+ fi
+ )
+ fi
+ echo "Cloned ${repo} -> ${target_dir}"
+}
+
+# Small network check (best-effort)
+check_network() {
+ if command -v curl >/dev/null 2>&1; then
+ curl -fsS --max-time 5 https://github.com >/dev/null 2>&1 || {
+ echo "WARNING: network check to github.com failed. If you are offline, fetch will fail."
+ }
+ elif command -v ping >/dev/null 2>&1; then
+ ping -c1 github.com >/dev/null 2>&1 || {
+ echo "WARNING: unable to ping github.com. If you are offline, fetch will fail."
+ }
+ fi
+}
+
+# Begin
+echo_header "BoltDBG: fetching external dependencies into ${EXTERNAL_DIR}"
+echo "DRY_RUN=${DRY_RUN} GIT_CLONE_DEPTH=${GIT_CLONE_DEPTH}"
+echo "Pins: IMGUITAG=${IMGUI_TAG} GLFWTAG=${GLFW_TAG} SPDLOGTAG=${SPDLOG_TAG} GLADTAG=${GLAD_TAG}"
+echo
+
+check_network
+
+# --- Clone sequence (order chosen to satisfy typical needs) ---
+
+# ImGui: we want core + backends (we will keep repo as-is)
+IMGUI_DIR="${EXTERNAL_DIR}/imgui"
+clone_if_missing "${IMGUI_DIR}" "${IMGUI_REPO}" "${IMGUI_TAG}"
+
+# GLFW: vendor if missing (many systems provide system package)
+GLFW_DIR="${EXTERNAL_DIR}/glfw"
+clone_if_missing "${GLFW_DIR}" "${GLFW_REPO}" "${GLFW_TAG}"
+
+# spdlog: logging library
+SPDLOG_DIR="${EXTERNAL_DIR}/spdlog"
+clone_if_missing "${SPDLOG_DIR}" "${SPDLOG_REPO}" "${SPDLOG_TAG}"
+
+# glad: OpenGL loader (optional but recommended)
+GLAD_DIR="${EXTERNAL_DIR}/glad"
+clone_if_missing "${GLAD_DIR}" "${GLAD_REPO}" "${GLAD_TAG}"
+
+# Optional: prune heavy demo directories for space (shallow clones make this minor)
+# e.g. remove example heavy files from imgui if you want:
+if [ "${DRY_RUN}" != "1" ]; then
+ # If a full clone was used, consider removing unnecessary files (uncomment if desired)
+ # find "${IMGUI_DIR}" -name 'examples' -type d -exec rm -rf {} +
+ :
+fi
+
+echo
+echo_header "Done"
+echo "Fetched dependencies are placed under ${EXTERNAL_DIR}."
+echo "Note: external/ should be listed in .gitignore so these sources are not committed."
+echo "If you prefer FetchContent at configure-time, CMake fallback will handle it automatically."
+echo
+echo "Tip: To force re-fetch (fresh clone), remove the target dir and run again:"
+echo " rm -rf ${EXTERNAL_DIR}/imgui ${EXTERNAL_DIR}/glfw ${EXTERNAL_DIR}/spdlog ${EXTERNAL_DIR}/glad && ./scripts/fetch_deps.sh"
+echo_header "Finished fetching deps"
+
+exit 0
diff --git a/src/dummy.cpp b/src/dummy.cpp
new file mode 100644
index 0000000..34889fd
--- /dev/null
+++ b/src/dummy.cpp
@@ -0,0 +1 @@
+#include <iostream> \ No newline at end of file