Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from MGTheTrain/feature/implement-python-bindin…
Browse files Browse the repository at this point in the history
…g-for-core-module

[Feature] - Implement python binding for core module
  • Loading branch information
MGTheTrain committed Apr 15, 2024
2 parents dbe73cb + fc7e97d commit 84a1de0
Show file tree
Hide file tree
Showing 23 changed files with 451 additions and 233 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/dotnet-8.0/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Docker images officially provided by Microsoft that can utilized as base images
// https://hub.docker.com/_/microsoft-vscode-devcontainers
"name": "Tools for C# .Net 8.0 repos",
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:8.0",
// Features to add to the dev container. More info: https://containers.dev/features
"postCreateCommand": "bash .devcontainer/dotnet-8.0/scripts/install-dependencies.sh",
"remoteUser": "root"
}
13 changes: 13 additions & 0 deletions .devcontainer/dotnet-8.0/scripts/install-dependenencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip
pip3 install clang-format cpplint

cd /tmp/
# vcpkg
rm -rf vcpkg
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
9 changes: 9 additions & 0 deletions .devcontainer/go/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Docker images officially provided by Microsoft that can utilized as base images
// https://hub.docker.com/_/microsoft-vscode-devcontainers
"name": "Tools for Go repos",
"image": "mcr.microsoft.com/vscode/devcontainers/go:1.17",
// Features to add to the dev container. More info: https://containers.dev/features
"postCreateCommand": "bash .devcontainer/go/scripts/install-dependencies.sh",
"remoteUser": "root"
}
13 changes: 13 additions & 0 deletions .devcontainer/go/scripts/install-dependenencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip
pip3 install clang-format cpplint

cd /tmp/
# vcpkg
rm -rf vcpkg
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
9 changes: 9 additions & 0 deletions .devcontainer/python/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Docker images officially provided by Microsoft that can utilized as base images
// https://hub.docker.com/_/microsoft-vscode-devcontainers
"name": "Tools for Python repos",
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.9",
// Features to add to the dev container. More info: https://containers.dev/features
"postCreateCommand": "bash .devcontainer/python/scripts/install-dependencies.sh",
"remoteUser": "root"
}
13 changes: 13 additions & 0 deletions .devcontainer/python/scripts/install-dependenencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip
pip3 install clang-format cpplint

cd /tmp/
# vcpkg
rm -rf vcpkg
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
9 changes: 9 additions & 0 deletions .devcontainer/rust/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Docker images officially provided by Microsoft that can utilized as base images
// https://hub.docker.com/_/microsoft-vscode-devcontainers
"name": "Tools for Rust repos",
"image": "mcr.microsoft.com/vscode/devcontainers/rust:bullseye",
// Features to add to the dev container. More info: https://containers.dev/features
"postCreateCommand": "bash .devcontainer/rust/scripts/install-dependencies.sh",
"remoteUser": "root"
}
13 changes: 13 additions & 0 deletions .devcontainer/rust/scripts/install-dependenencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install -y cmake python3 python3-pip
pip3 install clang-format cpplint

cd /tmp/
# vcpkg
rm -rf vcpkg
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
29 changes: 29 additions & 0 deletions .github/workflows/format_and_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Format and lint C++ project with clang-format and commit changes

on: push

jobs:
format-and-lint:
name: Format and lint C++ project
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Apply Auto formatting
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip
sudo pip3 install clang-format cpplint
sudo chmod +x *
./format_and_lint.sh
working-directory: devops/scripts/bash
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email github-actions[bot]@users.noreply.github.com
git pull
git add -A
git diff-index --quiet HEAD || git commit -m "Formatted cpp project with clang-format"
git push
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
69 changes: 69 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and Test

on:
pull_request:
branches:
- main

jobs:
build_and_test_ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install third-party apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential cmake
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
working-directory: /tmp/
- name: Build and Test on Linux
run: |
./compile_source_code.sh -CMakeToolchainFile /tmp/vcpkg/scripts/buildsystems/vcpkg.cmake -RunTests
working-directory: ./devops/scripts/bash/

build_windows:
runs-on: windows-latest
needs: [build_and_test_ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install third-party choco dependencies
run: |
choco install cmake
- name: Install vcpkg
run: |
cd $env:TEMP
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
- name: Build on Windows
shell: pwsh
run: |
.\compile_source_code.ps1 -CMakeToolchainFile $env:TEMP\vcpkg\scripts\buildsystems\vcpkg.cmake
working-directory: .\devops\scripts\ps1\

build_macos:
runs-on: macos-latest
needs: [build_and_test_ubuntu]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install third-party brew dependencies
run: |
brew install pkg-config cmake
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
working-directory: /tmp/
- name: Build on macOS
run: |
./compile_source_code.sh -CMakeToolchainFile /tmp/vcpkg/scripts/buildsystems/vcpkg.cmake
working-directory: ./devops/scripts/bash/
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
branches:
- main

jobs:
build_and_test_ubuntu:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install third-party apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential cmake
- name: Install vcpkg
run: |
git clone https://github.com/Microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.sh
working-directory: /tmp/
- name: Build and Test on Linux
run: |
./compile_source_code.sh -CMakeToolchainFile /tmp/vcpkg/scripts/buildsystems/vcpkg.cmake -RunTests
working-directory: ./devops/scripts/bash/
create_git_tags_from_version_file_job:
runs-on: ubuntu-latest
needs: [build_and_test_ubuntu]
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create git tag from version file
uses: MGTheTrain/public-github-actions/.github/actions/create-git-tag-from-version-file@main
with:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ secrets.cfg
.vscode/
*.deb
*.zip
*.tar
*.tar
*.dll
*.so
__pycache__
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.1.0] - DD-MM-YEAR

TBD
### Added

- [Feature] Initial project setup including `devcontainer.json` files, `C core module` and Python bindings
- [Feature] Modular code base
- [Feature] CI workflows for QA
- [Feature] Sample Python wrappers refering to C++ compiled source code resulting in shared libraries
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
cmake_minimum_required(VERSION 3.10)
set(TARGET cpp-opengl-renderer)
project(${TARGET})
set(CMAKE_CXX_STANDARD 17)

option(BUILD_LIB "Compile module source files for static libraries" ON)
option(BUILD_TEST "Compile source files for test executable and link compiled libraries" ON)
Expand Down
58 changes: 54 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,60 @@ A collection of sample code snippets demonstrating how to create bindings for va

TBD

### Features
## Features

TBD
- [x] Modular code base
- [x] CI workflows for QA
- [x] Sample Python wrappers refering to C++ compiled source code resulting in shared libraries
- [ ] Sample Rust wrappers refering to C++ compiled source code resulting in shared libraries
- [ ] Sample Go wrappers refering to C++ compiled source code resulting in shared libraries
- [ ] Sample C# wrappers refering to C++ compiled source code resulting in shared libraries
- [ ] C++ audio module **(Optional, Experimental)**
- [ ] C++ video module **(Optional, Experimental)**

### Getting started
## Getting started

TBD
### Prerequisite

- Download and install [CMake from the official website](https://cmake.org/download/) or trough a package manager
- Install [vcpkg from the official website](https://vcpkg.io/en/getting-started.html) or trough a package manager

### CMake

#### Unix

In order to compile the source code and link the binaries run in a Unix terminal:

```sh
cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file>
```

In order to additionaly start the test executables in a Unix terminal:

```sh
cd devops/scripts/bash/
./compile_source_code.sh -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests
```

#### Windows

In order to compile the source code and link the binaries run in a PowerShell terminal:

```sh
cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file>
```

In order to additionaly start the test executables in a PowerShell terminal:

```sh
cd devops\scripts\ps1
.\compile_source_code.ps1 -CMakeToolchainFile <path to the vcpkg.cmake file> -RunTests
```

### Bindings

#### Python

Navigate to the [bindings python folder](./bindings/python) after C++ source code compilation and run `python main.py --path <path to libcore_wrapper.so>`
59 changes: 0 additions & 59 deletions bindings/python/core.py

This file was deleted.

Loading

0 comments on commit 84a1de0

Please sign in to comment.