Skip to content

Commit 1ba7020

Browse files
committed
Initial commit
0 parents  commit 1ba7020

26 files changed

+608
-0
lines changed

.github/workflows/ci.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CI build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
- macos-latest
22+
build_type:
23+
- Release
24+
compiler:
25+
- gcc
26+
- clang
27+
include:
28+
- os: macos-latest
29+
compiler: clang
30+
cpp_compiler: clang++
31+
- os: ubuntu-latest
32+
compiler: gcc
33+
cpp_compiler: g++
34+
- os: ubuntu-latest
35+
compiler: clang
36+
cpp_compiler: clang++
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 1
42+
submodules: true
43+
44+
- name: Setup
45+
run: |
46+
echo ${HOME}/.local/bin >> ${GITHUB_PATH}
47+
make setup
48+
49+
- name: Configure
50+
run: make configure
51+
52+
- name: Build
53+
run: make build
54+
55+
- name: Test
56+
run: make test
57+
58+
- name: Run
59+
run: make run

.github/workflows/lint.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Lint
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
6+
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 1
14+
submodules: true
15+
16+
- name: Setup
17+
run: |
18+
echo ${HOME}/.local/bin >> ${GITHUB_PATH}
19+
make setup
20+
21+
- name: Configure
22+
run: make configure
23+
24+
- name: Lint
25+
run: make lint

.github/workflows/mirror.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Mirror
2+
on:
3+
push:
4+
branches: main
5+
workflow_dispatch:
6+
7+
jobs:
8+
mirror:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: jamesaorson/composite-git-mirror@main
13+
with:
14+
target-git-url: [email protected]:~exokomodo/${{ github.event.repository.name }}
15+
ssh-private-key: ${{ secrets.SRHT_SSH_PRIVATE_KEY }}

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Compiled Object files
2+
**/.DS_Store
3+
*.slo
4+
*.lo
5+
*.o
6+
*.obj
7+
8+
# Precompiled Headers
9+
*.gch
10+
*.pch
11+
12+
# Compiled Dynamic libraries
13+
*.so
14+
*.dylib
15+
*.dll
16+
17+
# Fortran module files
18+
*.mod
19+
*.smod
20+
21+
# Compiled Static libraries
22+
*.lai
23+
*.la
24+
*.a
25+
*.lib
26+
27+
# Executables
28+
*.exe
29+
*.out
30+
*.app
31+
32+
# Editors
33+
.idea/*.xml
34+
35+
# Build output
36+
build/*
37+
!**/.gitkeep

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "test/lib/catch2"]
2+
path = test/lib/catch2
3+
url = https://github.com/catchorg/Catch2.git
4+
branch = devel

.vscode/c_cpp_properties.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "default",
5+
"includePath": [
6+
"${workspaceFolder}/include",
7+
"${workspaceFolder}/test/lib/catch2/src",
8+
"${workspaceFolder}/build/test/lib/catch2/generated-includes"
9+
],
10+
"macFrameworkPath": [
11+
"/System/Library/Frameworks",
12+
"/Library/Frameworks"
13+
],
14+
"intelliSenseMode": "macos-clang-x64",
15+
"compilerPath": "/usr/bin/clang",
16+
"cStandard": "c17",
17+
"cppStandard": "c++17"
18+
}
19+
],
20+
"version": 4
21+
}

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"ms-vscode.cpptools-extension-pack",
4+
"ms-vscode.cmake-tools",
5+
"twxs.cmake",
6+
"ms-vscode.makefile-tools"
7+
]
8+
}

CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.31)
2+
3+
project(exosourcing
4+
LANGUAGES CXX C)
5+
6+
set(CMAKE_CXX_STANDARD 17)
7+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8+
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
9+
10+
set(INCLUDE_DIR_exo ${PROJECT_SOURCE_DIR}/include)
11+
12+
add_subdirectory(src)
13+
14+
# Don't even look at tests if we're not top level
15+
if(NOT PROJECT_IS_TOP_LEVEL)
16+
return()
17+
endif()
18+
include(CTest)
19+
add_subdirectory(test)

Makefile

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
SHELL := /bin/bash
2+
.SHELLFLAGS = -e -c
3+
.DEFAULT_GOAL := help
4+
.ONESHELL:
5+
6+
UNAME_S := $(shell uname -s)
7+
8+
NO_GENERATE_TEMPLATES ?= 0
9+
RELEASE_KIND ?= debug
10+
11+
ifeq ($(UNAME_S),Linux)
12+
CC := gcc
13+
endif
14+
ifeq ($(UNAME_S),Darwin)
15+
CC := clang
16+
endif
17+
18+
export PATH := "$(shell pwd)/bin:$(PATH)"
19+
20+
BUILD_DIR := ./build
21+
BINARY := $(shell pwd)/build/src/demo
22+
TEST_BINARY := $(shell pwd)/build/test/tests
23+
24+
.PHONY: configure
25+
configure: ## Configure default candidate
26+
cmake -B$(BUILD_DIR) -S.
27+
28+
.PHONY: configure/debug
29+
configure/debug: ## Configure debug candidate
30+
$(MAKE) configure RELEASE_KIND=debug
31+
32+
.PHONY: configure/release
33+
configure/release: ## Configure release candidate
34+
$(MAKE) configure RELEASE_KIND=release
35+
36+
.PHONY: build
37+
build: configure ## Build default candidate
38+
cmake --build $(BUILD_DIR)
39+
40+
.PHONY: build/debug
41+
build/debug: ## Build debug candidate
42+
$(MAKE) build RELEASE_KIND=debug
43+
44+
.PHONY: build/release
45+
build/release: ## Build release candidate
46+
$(MAKE) build RELEASE_KIND=release
47+
48+
.PHONY: test
49+
test: $(TEST_BINARY) ## Run test binary
50+
$<
51+
52+
.PHONY: run
53+
run: $(BINARY) ## Run binary
54+
$<
55+
56+
.PHONY: run/debug
57+
run/debug: ## Run debug candidate
58+
$(MAKE) build RELEASE_KIND=debug
59+
60+
.PHONY: run/release
61+
run/release: ## Run release candidate
62+
$(MAKE) build RELEASE_KIND=release
63+
64+
.PHONY: setup
65+
setup: ./scripts/setup ## Setup dependencies for system
66+
@$<
67+
68+
SOURCE_FILES := $(shell find ./src -type f -name '*.cpp')
69+
HEADER_FILES := $(shell find ./src -type f -name '*.hpp')
70+
71+
.PHONY: format
72+
format: ## Format the C/C++ code
73+
@echo $(SOURCE_FILES) $(HEADER_FILES) | xargs clang-format -i
74+
75+
.PHONY: lint
76+
lint: ## Lint the C/C++ code
77+
@BAD_FILES=$(shell mktemp)
78+
echo "[clang-format] BEGIN"
79+
echo $(SOURCE_FILES) $(HEADER_FILES) | xargs -I {} $(SHELL) -c 'clang-format --dry-run --Werror {} || echo {}' >> $${BAD_FILES}
80+
if [[ -s $${BAD_FILES} ]]; then
81+
echo "[clang-format] Found formatting errors"
82+
cat $${BAD_FILES}
83+
else
84+
echo "[clang-format] No formatting errors"
85+
fi
86+
echo "[clang-format] END"
87+
echo "[clang-tidy] BEGIN"
88+
$(MAKE) tidy
89+
echo "[clang-tidy] END"
90+
if [[ -s $${BAD_FILES} ]]; then
91+
exit 1
92+
fi
93+
94+
.PHONY: tidy
95+
tidy: ## Tidy the C/C++ code
96+
@clang-tidy $(SOURCE_FILES) $(HEADER_FILES)
97+
98+
.PHONY: version
99+
version: ## Version info
100+
$(MAKE) --version
101+
$(CC) --version
102+
$(MAKE) run/version
103+
104+
.PHONY: help
105+
help: ## Displays help info
106+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Exosourcing

compile_commands.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./build/compile_commands.json

docs/.gitkeep

Whitespace-only changes.

include/exo/event.hpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include <chrono>
4+
5+
namespace exo {
6+
template<typename T>
7+
struct Event {
8+
T data;
9+
10+
bool operator==(const Event<T>& other) const {
11+
return this->data == other.data;
12+
}
13+
};
14+
15+
template<typename T>
16+
Event<T> make_event(T data) {
17+
return {
18+
.data = data,
19+
};
20+
}
21+
}

include/exo/store.hpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
#include <vector>
4+
5+
#include <exo/event.hpp>
6+
7+
namespace exo {
8+
// NOTE: Forward declare all friend types
9+
template<typename T>
10+
struct MemoryStoreInspector;
11+
12+
template<typename T>
13+
struct Store {
14+
bool emplace_back(const exo::Event<T> event);
15+
};
16+
17+
template<typename T>
18+
struct MemoryStore : exo::Store<T> {
19+
friend struct exo::MemoryStoreInspector<T>;
20+
21+
bool emplace_back(const exo::Event<T> event) {
22+
try {
23+
this->events.emplace_back(event);
24+
} catch (const std::exception& e) {
25+
return false;
26+
}
27+
return true;
28+
}
29+
30+
protected:
31+
// NOTE: Using a std::vector, since we always `emplace_back`,
32+
// allowing for guaranteed O(1) insertion
33+
std::vector<Event<T>> events;
34+
};
35+
36+
template<typename T>
37+
exo::MemoryStore<T> make_memory_store() {
38+
return {};
39+
}
40+
}

0 commit comments

Comments
 (0)