Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CheckOptions:
value: "std::string_view;std::span;std::experimental::string_view"

- key: readability-function-cognitive-complexity.Threshold
value: 30
value: 60
- key: readability-function-size.LineThreshold
value: 150
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ jobs:
matrix:
include:
- os: macos-latest
configure_preset: macos-arm64-debug
configure_preset: macos-arm64-debug

- os: macos-latest
configure_preset: macos-x64-debug

- os: ubuntu-latest
configure_preset: linux-x64-gcc-debug
configure_preset: linux-x64-gcc-debug

- os: ubuntu-latest
configure_preset: linux-x64-clang-debug
configure_preset: linux-x64-clang-debug
do_format: true
do_tidy: true

- os: windows-latest
configure_preset: windows-x64-msvc-debug
configure_preset: windows-x64-msvc-debug

runs-on: ${{ matrix.os }}

Expand All @@ -33,26 +36,42 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build cmake g++ clang
sudo apt-get install -y \
ninja-build \
cmake \
g++ \
clang \
libxinerama-dev \
libxcursor-dev \
xorg-dev \
libglu1-mesa-dev \
pkg-config

- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install ninja cmake
command -v ninja >/dev/null 2>&1 || brew install ninja
command -v cmake >/dev/null 2>&1 || brew install cmake

- name: Set up MSVC dev cmd (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install -y ninja cmake
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
choco install -y cmake
}
if (-not (Get-Command ninja -ErrorAction SilentlyContinue)) {
choco install -y ninja
}

- name: Bootstrap vcpkg (macOS/Linux)
if: runner.os != 'Windows'
run: make deps
run: make deps

- name: Bootstrap vcpkg (Windows)
if: runner.os == 'Windows'
Expand Down
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# workspace
build/
compile_commands.json

.cache
logs/
CMakeFiles/
latex
html
# macOS
.DS_Store

.idea
# i was trying jet brains lol
# vcpkg
vcpkg/buildtrees/
vcpkg/downloads/
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ project(Quark LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(QuarkOptions)

find_package(Vulkan REQUIRED)
if(NOT Vulkan_FOUND)
message(
FATAL_ERROR
"Vulkan SDK/loader was not found. If you use vcpkg, ensure the vcpkg submodule is initialised and bootstrapped (make deps) and that dependencies from vcpkg.json are installed for the active triplet."
)
endif()

find_package(glfw3 CONFIG REQUIRED)
find_package(tl-expected CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)

add_subdirectory(src)
110 changes: 93 additions & 17 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_FEATURE_FLAGS": "manifests",
"QUARK_ENABLE_ASAN": "OFF",
"QUARK_ENABLE_UBSAN": "OFF",
"QUARK_ENABLE_TSAN": "OFF",
Expand All @@ -20,10 +21,21 @@
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64",
"VCPKG_TARGET_TRIPLET": "arm64-osx",
"VCPKG_HOST_TRIPLET": "arm64-osx"
}
},
{
"name": "macos-x64",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "x86_64",
"VCPKG_TARGET_TRIPLET": "x64-osx",
"VCPKG_HOST_TRIPLET": "x64-osx"
}
},
{
"name": "linux-x64-gcc",
"hidden": true,
Expand Down Expand Up @@ -62,6 +74,14 @@
"binaryDir": "${sourceDir}/build/macos-arm64-debug",
"cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
},
{
"name": "macos-x64-debug",
"inherits": "macos-x64",
"binaryDir": "${sourceDir}/build/macos-x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "macos-arm64-asan-ubsan",
"inherits": "macos-arm64",
Expand Down Expand Up @@ -194,25 +214,81 @@
],

"buildPresets": [
{ "name": "macos-arm64-debug", "configurePreset": "macos-arm64-debug" },
{ "name": "macos-arm64-asan-ubsan", "configurePreset": "macos-arm64-asan-ubsan" },
{ "name": "macos-arm64-release", "configurePreset": "macos-arm64-release" },
{ "name": "macos-arm64-release-lto", "configurePreset": "macos-arm64-release-lto" },
{
"name": "macos-arm64-debug",
"configurePreset": "macos-arm64-debug"
},
{
"name": "macos-arm64-asan-ubsan",
"configurePreset": "macos-arm64-asan-ubsan"
},
{
"name": "macos-arm64-release",
"configurePreset": "macos-arm64-release"
},
{
"name": "macos-arm64-release-lto",
"configurePreset": "macos-arm64-release-lto"
},

{
"name": "macos-x64-debug",
"configurePreset": "macos-x64-debug"
},

{ "name": "linux-x64-gcc-debug", "configurePreset": "linux-x64-gcc-debug" },
{ "name": "linux-x64-gcc-asan-ubsan", "configurePreset": "linux-x64-gcc-asan-ubsan" },
{ "name": "linux-x64-gcc-tsan", "configurePreset": "linux-x64-gcc-tsan" },
{ "name": "linux-x64-gcc-release", "configurePreset": "linux-x64-gcc-release" },
{ "name": "linux-x64-gcc-release-lto", "configurePreset": "linux-x64-gcc-release-lto" },
{
"name": "linux-x64-gcc-debug",
"configurePreset": "linux-x64-gcc-debug"
},
{
"name": "linux-x64-gcc-asan-ubsan",
"configurePreset": "linux-x64-gcc-asan-ubsan"
},
{
"name": "linux-x64-gcc-tsan",
"configurePreset": "linux-x64-gcc-tsan"
},
{
"name": "linux-x64-gcc-release",
"configurePreset": "linux-x64-gcc-release"
},
{
"name": "linux-x64-gcc-release-lto",
"configurePreset": "linux-x64-gcc-release-lto"
},

{ "name": "linux-x64-clang-debug", "configurePreset": "linux-x64-clang-debug" },
{ "name": "linux-x64-clang-asan-ubsan", "configurePreset": "linux-x64-clang-asan-ubsan" },
{ "name": "linux-x64-clang-tsan", "configurePreset": "linux-x64-clang-tsan" },
{ "name": "linux-x64-clang-release", "configurePreset": "linux-x64-clang-release" },
{ "name": "linux-x64-clang-release-lto", "configurePreset": "linux-x64-clang-release-lto" },
{
"name": "linux-x64-clang-debug",
"configurePreset": "linux-x64-clang-debug"
},
{
"name": "linux-x64-clang-asan-ubsan",
"configurePreset": "linux-x64-clang-asan-ubsan"
},
{
"name": "linux-x64-clang-tsan",
"configurePreset": "linux-x64-clang-tsan"
},
{
"name": "linux-x64-clang-release",
"configurePreset": "linux-x64-clang-release"
},
{
"name": "linux-x64-clang-release-lto",
"configurePreset": "linux-x64-clang-release-lto"
},

{ "name": "windows-x64-msvc-debug", "configurePreset": "windows-x64-msvc-debug" },
{ "name": "windows-x64-msvc-release", "configurePreset": "windows-x64-msvc-release" },
{ "name": "windows-x64-msvc-release-lto", "configurePreset": "windows-x64-msvc-release-lto" }
{
"name": "windows-x64-msvc-debug",
"configurePreset": "windows-x64-msvc-debug"
},
{
"name": "windows-x64-msvc-release",
"configurePreset": "windows-x64-msvc-release"
},
{
"name": "windows-x64-msvc-release-lto",
"configurePreset": "windows-x64-msvc-release-lto"
}
]
}
79 changes: 71 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ endif
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),arm64)
CMAKE_CONFIGURE_PRESET := macos-arm64-$(SUFFIX)
else ifeq ($(UNAME_M),x86_64)
CMAKE_CONFIGURE_PRESET := macos-x64-$(SUFFIX)
else
$(error Unsupported macOS arch '$(UNAME_M)'. Add macos-x64-* presets if needed.)
$(error Unsupported macOS arch '$(UNAME_M)')
endif
BUILD_DIR := build/$(CMAKE_CONFIGURE_PRESET)

Expand Down Expand Up @@ -55,13 +57,71 @@ else
CMAKE_CONFIGURE_PRESET := windows-x64-msvc-$(SUFFIX)
BUILD_DIR := build/$(CMAKE_CONFIGURE_PRESET)
endif

ifeq ($(SUFFIX),asan-ubsan)
$(error CONFIG=asan-ubsan is not supported for windows-x64-msvc presets)
endif
ifeq ($(SUFFIX),tsan)
$(error CONFIG=tsan is not supported for windows-x64-msvc presets)
endif
endif

# Derive the vcpkg triplet from platform to match CMakePresets.json
ifeq ($(UNAME_S),Darwin)
ifeq ($(UNAME_M),arm64)
VCPKG_TRIPLET := arm64-osx
else ifeq ($(UNAME_M),x86_64)
VCPKG_TRIPLET := x64-osx
else
$(error Unsupported macOS arch '$(UNAME_M)')
endif
else ifeq ($(UNAME_S),Linux)
VCPKG_TRIPLET := x64-linux
else
# Windows/MSYS/Git Bash/Cygwin (probably)
VCPKG_TRIPLET := x64-windows
endif

.PHONY: deps configure build run clean
.PHONY: deps vcpkg-install configure build run clean bench-noop bench-touch

### testing this for non-gh actions
deps:
git submodule update --init --recursive
@if [ -f "vcpkg/bootstrap-vcpkg.sh" ]; then \
@set -e; \
if ! command -v ninja >/dev/null 2>&1; then \
echo "ninja not found; attempting to install..."; \
if command -v apt-get >/dev/null 2>&1; then \
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; else SUDO=; fi; \
$$SUDO apt-get update; \
$$SUDO apt-get install -y ninja-build; \
elif command -v dnf >/dev/null 2>&1; then \
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; else SUDO=; fi; \
$$SUDO dnf install -y ninja-build; \
elif command -v pacman >/dev/null 2>&1; then \
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; else SUDO=; fi; \
$$SUDO pacman -S --noconfirm ninja; \
elif command -v zypper >/dev/null 2>&1; then \
if command -v sudo >/dev/null 2>&1; then SUDO=sudo; else SUDO=; fi; \
$$SUDO zypper --non-interactive install ninja; \
elif command -v brew >/dev/null 2>&1; then \
brew install ninja; \
elif command -v winget >/dev/null 2>&1 || command -v winget.exe >/dev/null 2>&1; then \
if command -v winget >/dev/null 2>&1; then WINGET=winget; else WINGET=winget.exe; fi; \
$$WINGET install --id Ninja-build.Ninja --exact --accept-package-agreements --accept-source-agreements; \
else \
echo "error: ninja is missing and no supported package manager was found"; \
exit 1; \
fi; \
else \
echo "ninja already installed"; \
fi; \
if [ ! -f "vcpkg/bootstrap-vcpkg.sh" ] && [ ! -f "vcpkg/bootstrap-vcpkg.bat" ]; then \
echo "vcpkg checkout not found; cloning..."; \
rm -rf vcpkg; \
git clone https://github.com/microsoft/vcpkg.git vcpkg; \
else \
git submodule update --init --recursive; \
fi; \
if [ -f "vcpkg/bootstrap-vcpkg.sh" ]; then \
if [ ! -f "vcpkg/vcpkg" ]; then \
echo "Bootstrapping vcpkg (Unix)..."; \
cd vcpkg && ./bootstrap-vcpkg.sh; \
Expand All @@ -80,16 +140,19 @@ deps:
exit 1; \
fi

vcpkg-install: deps
./vcpkg/vcpkg install --triplet $(VCPKG_TRIPLET)

configure:
cmake --preset $(CMAKE_CONFIGURE_PRESET)
./scripts/sync_compile_commands.sh $(BUILD_DIR)
cmake --preset $(CMAKE_CONFIGURE_PRESET)
./scripts/sync_compile_commands.sh $(BUILD_DIR)

build: configure
cmake --build $(BUILD_DIR)
cmake --build $(BUILD_DIR)

run: build
run: build
cmake --build $(BUILD_DIR) --target run

clean:
rm -rf build

Loading
Loading