Skip to content

Commit

Permalink
Initial project configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
simondevenish committed Nov 19, 2024
1 parent 6a74b82 commit c811e93
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "AllocX Dev Environment",
"build": {
"dockerfile": "../Dockerfile",
"context": ".."
},
"features": {},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"GitHub.vscode-github-actions",
"ms-python.python"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"editor.formatOnSave": true,
"editor.tabSize": 4
}
}
},
"postCreateCommand": "cmake -S . -B build && cmake --build build",
"remoteUser": "root"
}
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: AllocX CI Pipeline

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
gcc-11 \
g++-11 \
cmake \
python3-pip \
clang-format
- name: Configure and Build
run: |
cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Run Tests
run: |
pytest tests --verbose
53 changes: 53 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,56 @@
*.exe
*.out
*.app

# CMake build output
build/
CMakeFiles/
CMakeCache.txt
cmake_install.cmake
Makefile
install_manifest.txt

# Debugging and profiling tools
*.gcda
*.gcno
*.gcov

# IDEs and editors
.vscode/
*.code-workspace
.idea/
*.iml

# Logs and temporary files
*.log
*.tmp
*.bak
*.swp
*.swo
*.DS_Store
Thumbs.db
desktop.ini

# System-specific files
*.out
*.dSYM/
*.stackdump
*.elf

# Python
__pycache__/
*.py[cod]

# Node.js
node_modules/

# Archives
*.tar
*.zip
*.gz
*.rar
*.7z

# Docker
docker-compose.override.yml
.dockerignore
71 changes: 71 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Minimum CMake version required
cmake_minimum_required(VERSION 3.15)

# Project name and description
project(AllocX
VERSION 1.0
DESCRIPTION "A high-performance, cross-platform memory management library designed for low-latency, high-frequency systems."
LANGUAGES C CXX
)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Enable testing
enable_testing()

# Options
option(ALLOCX_BUILD_TESTS "Build unit tests" ON)
option(ALLOCX_BUILD_EXAMPLES "Build examples" ON)

# Define output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Include source directories
add_subdirectory(src)
add_subdirectory(include)

# Add tests if enabled
if(ALLOCX_BUILD_TESTS)
add_subdirectory(tests)
endif()

# Add examples if enabled
if(ALLOCX_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Documentation target
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
else()
message(STATUS "Doxygen not found. Documentation will not be generated.")
endif()

# Installation rules
include(GNUInstallDirs)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS AllocX
EXPORT AllocXTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Export targets for downstream projects
install(EXPORT AllocXTargets
FILE AllocXConfig.cmake
NAMESPACE AllocX::
DESTINATION ${CMAKE_INSTALL_DATADIR}/AllocX
)

# Display configuration summary
message(STATUS "Project: ${PROJECT_NAME}")
message(STATUS "Version: ${PROJECT_VERSION}")
message(STATUS "Description: ${PROJECT_DESCRIPTION}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Use a stable base image
FROM ubuntu:22.04

# Set environment variables to minimise interaction during installation
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8
ENV CC=/usr/bin/gcc
ENV CXX=/usr/bin/g++
ENV VIRTUAL_ENV=/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install core development tools and dependencies
RUN apt-get update && apt-get install -y \
build-essential \
gcc-11 \
g++-11 \
cmake \
python3 \
python3-pip \
python3-venv \
clang-format \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Set GCC/G++ version explicitly
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100

# Create a workspace directory
WORKDIR /workspace

# Copy the entire project into the container
COPY . .

# Create and activate Python virtual environment
RUN python3 -m venv /venv
RUN pip install --no-cache-dir pytest

# Ensure required scripts are executable (if applicable)
RUN chmod +x scripts/* || true

# Build the project using CMake
RUN cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
RUN cmake --build build

# Default command for development
CMD ["/bin/bash"]
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.9"

services:
allocx-dev:
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/workspace:cached
ports:
- 8080:8080 # Example port mapping
environment:
- DEBIAN_FRONTEND=noninteractive
- LANG=C.UTF-8
- LC_ALL=C.UTF-8
command: /bin/bash
Empty file added docs/api_reference.md
Empty file.
Empty file added docs/architecture.md
Empty file.
Empty file added docs/index.md
Empty file.
Empty file added docs/profiling.md
Empty file.
Empty file added include/allocx/allocx.h
Empty file.
Empty file added src/allocx.c
Empty file.
Empty file added src/platform/windows.c
Empty file.
Empty file added tests/CMakeLists.txt
Empty file.

0 comments on commit c811e93

Please sign in to comment.