Skip to content

Commit

Permalink
Merge pull request #174 from EmixamPP/remove-py
Browse files Browse the repository at this point in the history
Migrate all Python code to C++ and remove boot command
  • Loading branch information
EmixamPP committed Apr 18, 2024
2 parents c84bf36 + 71fb789 commit 3e10e23
Show file tree
Hide file tree
Showing 51 changed files with 516 additions and 921 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/does-not-work-at-boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ assignees: ''
<!--- Please look at the docs before open an issue -->
<!--- https://github.com/EmixamPP/linux-enable-ir-emitter/blob/master/docs/README.md -->

**Output of `linux-enable-ir-emitter boot status`**
**Output of `systemctl status linux-enable-ir-emitter`**
```
paste here
```
Expand Down
92 changes: 30 additions & 62 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ name: "Build"
on:
workflow_dispatch:
workflow_call:
push:

env:
OPENCV_VERSION: "4.9.0"
YAML_VERSION: "0.8.0"

jobs:
build:
Expand All @@ -16,79 +11,52 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
- name: Load dependencies versions
uses: cardinalby/export-env-action@v2
with:
python-version: "3.10"
envFile: '.github/workflows/deps/version.env'

- name: Install dependencies
- name: Install build dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y python3-setuptools python3-wheel ninja-build g++ pkg-config libgtk-3-dev cmake curl
python -m pip install --upgrade pip
sudo apt-get install -y python3-setuptools python3-wheel ninja-build g++ pkg-config libgtk-3-dev cmake
python -m pip install meson
- name: Cache OpenCV
id: opencv-cache
uses: actions/cache@v4
with:
path: opencv
key: opencv-${{ env.OPENCV_VERSION }}
- name: Build tiny static OpenCV
if: ${{ steps.opencv-cache.outputs.cache-hit != 'true' }}
run: |
mkdir -p opencv/build
curl -L https://github.com/opencv/opencv/archive/refs/tags/${{ env.OPENCV_VERSION }}.tar.gz | tar -xz -C opencv
cmake -B opencv/build -S opencv/opencv-${{ env.OPENCV_VERSION }} -GNinja \
-DBUILD_SHARED_LIBS=OFF -DOPENCV_GENERATE_PKGCONFIG=YES \
-DBUILD_LIST=videoio,highgui \
-DWITH_V4L=ON -DWITH_GTK=ON -DZLIB_FOUND=OFF -DBUILD_ZLIB=ON \
-DWITH_JPEG=OFF -DWITH_PNG=OFF -DWITH_TIFF=OFF -DWITH_WEBP=OFF -DWITH_OPENJPEG=OFF -DWITH_JASPER=OFF -DWITH_OPENEXR=OFF -DWITH_IMGCODEC_HDR=OFF -DWITH_IMGCODEC_SUNRASTER=OFF -DWITH_IMGCODEC_PXM=OFF -DWITH_IMGCODEC_PFM=OFF \
-DWITH_FFMPEG=FALSE -DWITH_GSTREAMER=OFF -DWITH_1394=OFF -DDVIDEOIO_ENABLE_PLUGINS=OFF -DWITH_ANDROID_MEDIANDK=OFF \
-DHIGHGUI_ENABLE_PLUGINS=OFF -DWITH_VTK=OFF \
-DWITH_PROTOBUF=OFF -DOPENCV_DNN_OPENCL=OFF \
-DWITH_VA_INTEL=OFF -DWITH_OPENCL=OFF -DWITH_OPENCL_SVM=OFF -DWITH_OPENCLAMDFFT=OFF -DWITH_OPENCLAMDBLAS=OFF -DWITH_OPENCL_D3D11_NV=OFF \
-DWITH_CAROTENE=OFF -DWITH_CPUFEATURES=OFF -DWITH_EIGEN=OFF -DWITH_OPENVX=OFF -DWITH_DIRECTX=OFF -DWITH_VA=OFF -DWITH_LAPACK=OFF -DWITH_QUIRC=OFF -DBUILD_ITT=OFF -DWITH_IPP=OFF -DBUILD_IPP_IW=OFF
ninja -C opencv/build
- name: Cache YAML
id: yaml-cache
- name: Cache lib dependencies
id: deps-cache
uses: actions/cache@v4
with:
path: yaml
key: yaml-${{ env.YAML_VERSION }}

- name: Build minimal static YAML
if: ${{ steps.yaml-cache.outputs.cache-hit != 'true' }}
run: |
mkdir -p yaml/build
curl -L https://github.com/jbeder/yaml-cpp/archive/refs/tags/${{ env.YAML_VERSION }}.tar.gz | tar -xz -C yaml
cmake -B yaml/build -S yaml/yaml-cpp-${{ env.YAML_VERSION }} -GNinja \
-DYAML_BUILD_SHARED_LIBS=OFF -DYAML_CPP_BUILD_CONTRIB=OFF -DYAML_CPP_BUILD_TOOLS=OFF
ninja -C yaml/build
- name: Install OpenCV and YAML
path: .github/workflows/deps/install_dir
key: ${{ env.OPENCV_GIT_TAG }}-${{ env.YAML_GIT_TAG }}-${{ env.ARGPARSE_GIT_TAG }}

- name: Build lib dependencis
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
run: |
sudo ninja install -C opencv/build
sudo ninja install -C yaml/build
cd .github/workflows/deps
cmake . -B build -GNinja \
-DOPENCV_GIT_TAG=${{ env.OPENCV_GIT_TAG }} -DYAML_GIT_TAG=${{ env.YAML_GIT_TAG }} -DARGPARSE_GIT_TAG=${{ env.ARGPARSE_GIT_TAG }}
ninja -C build
cd -
- name: Setup build
run: |
meson setup build --libdir=lib --prefer-static
meson setup build --libdir=lib --prefer-static --pkg-config-path=$(find .github -name "pkgconfig")
- name: Compile
run: |
meson compile -C build
- name: Retrieve version
run: |
VERSION=$(meson introspect --projectinfo build | jq -r '.version')
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Create tarball
run: |
DESTDIR=install_dir_systemd meson install -C build
tar -czvf build/linux-enable-ir-emitter.systemd.x86-64.tar.gz -C build/install_dir_systemd .
DESTDIR=install_dir meson install -C build
tar -czvf build/linux-enable-ir-emitter-${VERSION}.systemd.x86-64.tar.gz -C build/install_dir .
- name: Upload tarball
uses: actions/upload-artifact@v4
with:
name: linux-enable-ir-emitter.systemd.x86-64.tar.gz
path: build/linux-enable-ir-emitter.systemd.x86-64.tar.gz

name: linux-enable-ir-emitter-${{ env.VERSION }}.systemd.x86-64.tar.gz
path: build/linux-enable-ir-emitter-${{ env.VERSION }}.systemd.x86-64.tar.gz
19 changes: 14 additions & 5 deletions .github/workflows/cpp-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,27 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Load dependencies versions
uses: cardinalby/export-env-action@v2
with:
envFile: '.github/workflows/deps/version.env'

- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y python3-setuptools python3-wheel ninja-build g++ pkg-config clang-tidy libgtk-3-dev libopencv-dev libyaml-cpp-dev
python -m pip install --upgrade pip
sudo apt-get install -y python3-setuptools python3-wheel ninja-build g++ pkg-config libgtk-3-dev
python -m pip install meson
- name: Cache lib dependencies
uses: actions/cache@v4
with:
path: .github/workflows/deps/install_dir
key: ${{ env.OPENCV_GIT_TAG }}-${{ env.YAML_GIT_TAG }}-${{ env.ARGPARSE_GIT_TAG }}
fail-on-cache-miss: true

- name: Setup
run: |
meson setup build
meson setup build --prefer-static --pkg-config-path=$(find .github -name "pkgconfig")
- name: Lint
run: |
ninja clang-tidy -C build
41 changes: 41 additions & 0 deletions .github/workflows/depend-argparse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Update YAML
on:
workflow_dispatch:
schedule:
- cron: '0 7 * * *'

jobs:
update-yaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Fetch release version
env:
GITHUB_TOKEN: ${{ github.token }}
OWNER: p-ranav
REPO: argparse
run: |
VERSION=$(gh api "/repos/$OWNER/$REPO/releases/latest" --jq ".tag_name")
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Modify file if new version
run: |
sed -E -i "s@(ARGPARSE_GIT_TAG=\s+\")(v[0-9]+\.[0-9]+\.[0-9]+)(\")@\1$VERSION\3@" .github/workflows/deps/version.env
- name: Create PR if new version
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
title: "chore(ci): update argparse to ${{ env.VERSION }}"
branch: "argparse-${{ env.VERSION }}"
commit-message: "chore(ci): update argparse to ${{ env.VERSION }}"
body: |
Update YAML to ${{ env.VERSION }}.
This PR has been created automatically.
committer: github-actions[bot] <noreply@github.com>
author: github-actions[bot] <noreply@github.com>
assignees: "EmixamPP"
labels: dependencies
delete-branch: true
6 changes: 3 additions & 3 deletions .github/workflows/depend-opencv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- name: Modify file if new version
run: |
sed -E -i "s@(OPENCV_VERSION:\s+\")([0-9]+\.[0-9]+\.[0-9]+)(\")@\1$VERSION\3@" .github/workflows/build.yml
sed -E -i "s@(OPENCV_GIT_TAG=\s+\")([0-9]+\.[0-9]+\.[0-9]+)(\")@\1$VERSION\3@" .github/workflows/deps/version.env
- name: Create PR if new version
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
title: "chore(workflow): update opencv to ${{ env.VERSION }}"
title: "chore(ci): update opencv to ${{ env.VERSION }}"
branch: "opencv-${{ env.VERSION }}"
commit-message: "chore(workflow): update opencv to ${{ env.VERSION }}"
commit-message: "chore(ci): update opencv to ${{ env.VERSION }}"
body: |
Update OpenCV to ${{ env.VERSION }}.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/depend-yaml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
- name: Modify file if new version
run: |
sed -E -i "s@(YAML_VERSION:\s+\")([0-9]+\.[0-9]+\.[0-9]+)(\")@\1$VERSION\3@" .github/workflows/build.yml
sed -E -i "s@(YAML_GIT_TAG=\s+\")([0-9]+\.[0-9]+\.[0-9]+)(\")@\1$VERSION\3@" .github/workflows/deps/version.env
- name: Create PR if new version
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.PAT }}
title: "chore(workflow): update yaml to ${{ env.VERSION }}"
title: "chore(ci): update yaml to ${{ env.VERSION }}"
branch: "yaml-${{ env.VERSION }}"
commit-message: "chore(workflow): update yaml to ${{ env.VERSION }}"
commit-message: "chore(ci): update yaml to ${{ env.VERSION }}"
body: |
Update YAML to ${{ env.VERSION }}.
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/deps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
cmake_minimum_required(VERSION 3.10)
project("linux-enable-ir-emitter dependencies")

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install_dir" CACHE PATH "Default install prefix" FORCE)
endif()

option(OPENCV_GIT_TAG "Tag or branch used to checkout when cloning opencv" "master")
option(YAML_GIT_TAG "Tag or branch used to checkout when cloning yaml-cpp" "master")
option(ARGPARSE_GIT_TAG "Tag or branch used to checkout when cloning argparse" "master")

include(ExternalProject)

ExternalProject_Add(opencv
GIT_REPOSITORY https://github.com/opencv/opencv.git
GIT_TAG ${OPENCV_GIT_TAG}
PREFIX ${CMAKE_BINARY_DIR}/opencv
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS
-DLIBRARY_OUTPUT_DIRECTORY=lib
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DBUILD_SHARED_LIBS=OFF
-DOPENCV_GENERATE_PKGCONFIG=YES
-DBUILD_LIST=videoio,highgui
-DWITH_V4L=ON
-DWITH_GTK=ON
-DZLIB_FOUND=OFF
-DBUILD_ZLIB=ON
-DWITH_JPEG=OFF
-DWITH_PNG=OFF
-DWITH_TIFF=OFF
-DWITH_WEBP=OFF
-DWITH_OPENJPEG=OFF
-DWITH_JASPER=OFF
-DWITH_OPENEXR=OFF
-DWITH_IMGCODEC_HDR=OFF
-DWITH_IMGCODEC_SUNRASTER=OFF
-DWITH_IMGCODEC_PXM=OFF
-DWITH_IMGCODEC_PFM=OFF
-DWITH_FFMPEG=FALSE
-DWITH_GSTREAMER=OFF
-DWITH_1394=OFF
-DDVIDEOIO_ENABLE_PLUGINS=OFF
-DWITH_ANDROID_MEDIANDK=OFF
-DHIGHGUI_ENABLE_PLUGINS=OFF
-DWITH_VTK=OFF
-DWITH_PROTOBUF=OFF
-DOPENCV_DNN_OPENCL=OFF
-DWITH_VA_INTEL=OFF
-DWITH_OPENCL=OFF
-DWITH_OPENCL_SVM=OFF
-DWITH_OPENCLAMDFFT=OFF
-DWITH_OPENCLAMDBLAS=OFF
-DWITH_OPENCL_D3D11_NV=OFF
-DWITH_CAROTENE=OFF
-DWITH_CPUFEATURES=OFF
-DWITH_EIGEN=OFF
-DWITH_OPENVX=OFF
-DWITH_DIRECTX=OFF
-DWITH_VA=OFF
-DWITH_LAPACK=OFF
-DWITH_QUIRC=OFF
-DBUILD_ITT=OFF
-DWITH_IPP=OFF
-DBUILD_IPP_IW=OFF
)

ExternalProject_Add(yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG ${YAML_GIT_TAG}
PREFIX ${CMAKE_BINARY_DIR}/yaml-cpp
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DYAML_BUILD_SHARED_LIBS=OFF
-DYAML_CPP_BUILD_CONTRIB=OFF
-DYAML_CPP_BUILD_TOOLS=OFF
)

ExternalProject_Add(argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
GIT_TAG ${ARGPARSE_GIT_TAG}
PREFIX ${CMAKE_BINARY_DIR}/argparse
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DARGPARSE_BUILD_TESTS=OFF
)
3 changes: 3 additions & 0 deletions .github/workflows/deps/version.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENCV_GIT_TAG="4.9.0"
YAML_GIT_TAG="0.8.0"
ARGPARSE_GIT_TAG="v3.0"
38 changes: 17 additions & 21 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ name: "Pull Request"

on:
pull_request:
types: [opened, reopened]


jobs:
py-lint:
uses: ./.github/workflows/py-lint.yml
build:
uses: ./.github/workflows/build.yml

cpp-lint:
needs:
- build
uses: ./.github/workflows/cpp-lint.yml

build:
uses: ./.github/workflows/build.yml

comment:
name: Bot comment
needs:
- py-lint
- cpp-lint
needs:
- build
- cpp-lint
runs-on: ubuntu-latest
if: always()
steps:
Expand All @@ -32,15 +29,14 @@ jobs:
## :clipboard: [Logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
## :mag: Linting results:
${{ needs.py-lint.result == 'success' && ':heavy_check_mark:' || ':x:' }} Python Linting
${{ needs.cpp-lint.result == 'success' && ':heavy_check_mark:' || ':x:' }} C++ Linting
## :hammer_and_wrench: Building result:
${{ needs.build.result == 'success' && ':heavy_check_mark:' || ':x:' }} Building
## :mag: Linting results: ${{ needs.cpp-lint.result == 'success' && ':heavy_check_mark:' || ':x:' }}
## :hammer_and_wrench: Building result: ${{ needs.build.result == 'success' && ':heavy_check_mark:' || ':x:' }}
## :package: Artifacts:
If the building step was successfull, you can download the appropriate tarball in the artifacts section [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
Uninstall the previous version, unzip and then execute `sudo tar -C / --no-same-owner -h -vxzf linux-enable-ir-emitter*.tar.gz`.
If the building step was successfull:
1. Download the tarball in the artifacts section [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
2. [Uninstall the previous version](docs/uninstallation.md) if you have one
3. Unzip: `unzip linux-enable-ir-emitter*.tar.gz.zip`
4. Install: `sudo tar -C / --no-same-owner -h -vxzf linux-enable-ir-emitter*.tar.gz`
5. Enable the boot service: `sudo systemctl enable --now linux-enable-ir-emitter`

0 comments on commit 3e10e23

Please sign in to comment.