Skip to content

Commit

Permalink
add initial code
Browse files Browse the repository at this point in the history
Signed-off-by: Inho Oh <webispy@gmail.com>
  • Loading branch information
webispy committed Jul 3, 2024
1 parent 80b64e2 commit e2cee3c
Show file tree
Hide file tree
Showing 34 changed files with 4,507 additions and 1 deletion.
485 changes: 485 additions & 0 deletions .clang-format

Large diffs are not rendered by default.

190 changes: 190 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: CI
on:
push:
branches:
- master
pull_request:

jobs:
clang_format_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt install -y clang-format
- name: lint
run: |
clang-format --dry-run --Werror \
src/*.c tool/*.c tests/*.c \
include/*.h
clang_tidy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install clang-tidy
run: sudo apt install -y clang-tidy libglib2.0-dev
- name: Configure
run: cmake -DCMAKE_INSTALL_PREFIX=/usr -S . -B build_x86
- name: clang-tidy
run: clang-tidy -p build_x86 src/*.c tool/*.c tests/*.c

build:
runs-on: ubuntu-latest
needs: [clang_format_lint, clang_tidy]
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install dependency libraries
run: sudo apt install -y libglib2.0-dev
- name: Configure
run: cmake -DCMAKE_INSTALL_PREFIX=/usr -S . -B build
- name: Build
run: cmake --build build --parallel -v
- name: Test
run: cd build && make test
- name: Install
run: DESTDIR=out cmake --install build
- name: Build artifacts
uses: actions/upload-artifact@v4
with:
name: files
path: out

deb_test:
runs-on: ${{ matrix.os }}
needs: [clang_format_lint, clang_tidy]
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
steps:
- name: Set distribution name
run: |
if [[ "${{ matrix.os }}" == "ubuntu-20.04" ]]; then
echo "DISTRO_NAME=focal" >> $GITHUB_ENV
elif [[ "${{ matrix.os }}" == "ubuntu-22.04" ]]; then
echo "DISTRO_NAME=jammy" >> $GITHUB_ENV
elif [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
echo "DISTRO_NAME=nobble" >> $GITHUB_ENV
fi
- name: Check out the repo
uses: actions/checkout@v4
with:
path: src
- name: Install dependency packages
run: sudo apt install -y libglib2.0-dev doxygen git-buildpackage debhelper cmake
- name: Prepare
run: cd src && cp -a packaging/$DISTRO_NAME debian
- name: Packaging
run: cd src && gbp buildpackage -uc -us

sbuild:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
dist: [jammy, focal]
host: [armhf, arm64, amd64]
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
path: src
- run: cp -a packaging/${{ matrix.dist }} debian
working-directory: src
- run: sudo apt update
- run: sudo apt install -y sbuild ubuntu-dev-tools debhelper
- run: sudo sbuild-adduser $USER
- name: Setup tmpfs overlay
run: |
cat <<EOF > 04tmpfs
#!/bin/sh
set -e
. "\$SETUP_DATA_DIR/common-data"
. "\$SETUP_DATA_DIR/common-functions"
. "\$SETUP_DATA_DIR/common-config"
if [ "\$STAGE" = "setup-start" ]; then
mount -t tmpfs overlay /var/lib/schroot/union/overlay
elif [ "\$STAGE" = "setup-recover" ]; then
mount -t tmpfs overlay /var/lib/schroot/union/overlay
elif [ "\$STAGE" = "setup-stop" ]; then
umount -f /var/lib/schroot/union/overlay
fi
EOF
chmod +x 04tmpfs
sudo mv 04tmpfs /etc/schroot/setup.d/
- name: Make chroot env with cross-compile
if: ${{ matrix.host != 'amd64' }}
run: |
echo "CHROOT=${{ matrix.dist }}-amd64-${{ matrix.host }}" >> $GITHUB_ENV
sg sbuild -c 'mk-sbuild --target ${{ matrix.host }} ${{ matrix.dist }}'
- name: Make chroot env
if: ${{ matrix.host == 'amd64' }}
run: |
echo "CHROOT=${{ matrix.dist }}-${{ matrix.host }}" >> $GITHUB_ENV
sg sbuild -c 'mk-sbuild ${{ matrix.dist }}'
- run: sudo sbuild-update --upgrade $CHROOT
- run: sg sbuild -c 'sbuild --chroot $CHROOT --host ${{ matrix.host }}'
working-directory: src
- run: ls -l
- name: Build artifacts
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.dist }}-${{ matrix.host }}
path: ./*.deb

doxygen:
runs-on: ubuntu-latest
needs: [build, sbuild]
env:
BASEDIR: doc/html
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Install doxygen
run: sudo apt-get install doxygen graphviz
- name: Generate doxygen
run: doxygen
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: debs
pattern: deb-*
merge-multiple: false
- run: ls -lR debs
- name: Prepare deb directories
run: |
mkdir -p ${{ env.BASEDIR }}/ubuntu/dists/focal/pool
mkdir -p ${{ env.BASEDIR }}/ubuntu/dists/focal/main/{binary-amd64,binary-arm64,binary-armhf}
mkdir -p ${{ env.BASEDIR }}/ubuntu/dists/jammy/pool
mkdir -p ${{ env.BASEDIR }}/ubuntu/dists/jammy/main/{binary-amd64,binary-arm64,binary-armhf}
mv debs/deb-focal-amd64/* ${{ env.BASEDIR }}/ubuntu/dists/focal/pool/
mv debs/deb-focal-arm64/* ${{ env.BASEDIR }}/ubuntu/dists/focal/pool/
mv debs/deb-focal-armhf/* ${{ env.BASEDIR }}/ubuntu/dists/focal/pool/
mv debs/deb-jammy-amd64/* ${{ env.BASEDIR }}/ubuntu/dists/jammy/pool/
mv debs/deb-jammy-arm64/* ${{ env.BASEDIR }}/ubuntu/dists/jammy/pool/
mv debs/deb-jammy-armhf/* ${{ env.BASEDIR }}/ubuntu/dists/jammy/pool/
- name: Generate deb repository
working-directory: ${{ env.BASEDIR }}/ubuntu
run: |
dpkg-scanpackages -m -a amd64 dists/focal/pool > dists/focal/main/binary-amd64/Packages
dpkg-scanpackages -m -a arm64 dists/focal/pool > dists/focal/main/binary-arm64/Packages
dpkg-scanpackages -m -a armhf dists/focal/pool > dists/focal/main/binary-armhf/Packages
dpkg-scanpackages -m -a amd64 dists/jammy/pool > dists/jammy/main/binary-amd64/Packages
dpkg-scanpackages -m -a arm64 dists/jammy/pool > dists/jammy/main/binary-arm64/Packages
dpkg-scanpackages -m -a armhf dists/jammy/pool > dists/jammy/main/binary-armhf/Packages
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ env.BASEDIR }}
clean: true
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,30 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

# Temporary directories
build
out
.cache
.DS_Store

# Doxygen
doc/html
doc/latex
doc/man

# Debian package
debian
obj-x86_64-linux-gnu/
obj-arm-linux-gnu/
obj-aarch64-linux-gnu/
packaging/*/*.log
packaging/*/*.substvars
packaging/*/*-stamp
packaging/*/files
packaging/*/.debhelper/
packaging/*/aln/
packaging/*/aln-dbg/
packaging/*/libaln/
packaging/*/libaln-dev/
packaging/*/tmp/
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.9)
project(aln)

include(GNUInstallDirs)
include(FindPkgConfig)

# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# C++ standard: c++11 (not gnu++11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)

# C standard: gnu99 (not c99)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS ON)

# version: 0.1.0
set(VERSION_MAJOR 0)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

pkg_check_modules(glib REQUIRED glib-2.0)

# Global include directories
include_directories(include)

# Public header files
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aln/)

# pkg-config file
configure_file(aln.pc.in ${PROJECT_BINARY_DIR}/aln.pc @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/aln.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/)

if (NOT MSVC)
add_compile_options(-g -Werror -Wall)
endif()

enable_testing()

add_subdirectory(src)
add_subdirectory(tool)
add_subdirectory(tests)
Loading

0 comments on commit e2cee3c

Please sign in to comment.