Skip to content

Commit

Permalink
Merge pull request #22 from HyperInspire/feature/ci
Browse files Browse the repository at this point in the history
AdD auto-build ci
  • Loading branch information
tunmx authored May 6, 2024
2 parents 43de275 + 88f0b7e commit 0935c4e
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 27 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/built_release_from_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Release SDKs

on:
push:
tags:
- "v*" # 当推送符合 "v*" 模式的标签时触发

jobs:
build:
name: Compile and Package SDKs
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Step 2: Update Git submodules recursively
- name: Update submodules
run: |
git submodule sync --recursive # Ensure submodule paths are up-to-date
git submodule update --init --recursive # Initialize and update all submodules
# 使用 Docker Compose 构建项目
- name: Build SDKs with Docker Compose
run: docker-compose up

# 压缩每个 SDK 目录
- name: Zip SDK Files
run: |
zip -r linux_armv7_armhf.zip build/linux_armv7_armhf/
zip -r linux_rv1109rv1126_armhf.zip build/linux_rv1109rv1126_armhf/
zip -r linux_ubuntu18.zip build/linux_ubuntu18/
# 上传打包文件以供发布任务使用
- name: Upload SDK Artifacts
uses: actions/upload-artifact@v2
with:
name: sdk_files
path: |
linux_armv7_armhf.zip
linux_rv1109rv1126_armhf.zip
linux_ubuntu18.zip
release:
name: Release SDKs to GitHub
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

# 下载上一个步骤上传的 SDK 文件
- name: Download SDK Artifacts
uses: actions/download-artifact@v2
with:
name: sdk_files

# 创建 GitHub Release 并上传 SDK 文件
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
linux_armv7_armhf.zip
linux_rv1109rv1126_armhf.zip
linux_ubuntu18.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ else()
endif ()
if(ISF_BUILD_LINUX_ARM7)
set(PLAT linux-arm7)
message("The OpenCV that builds the gnueabihf version depends on is specialized!")
set(OpenCV_DIR ${ISF_THIRD_PARTY_DIR}/inspireface-precompile/opencv/3.4.5/opencv-linux-armhf/share/OpenCV)
set(OpenCV_STATIC_INCLUDE_DIR ${PATH_3RDPARTY}/inspireface-precompile/opencv/3.4.5/opencv-linux-armhf/include/)
elseif(ISF_BUILD_LINUX_AARCH64)
Expand Down
82 changes: 76 additions & 6 deletions command/build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,84 @@
mkdir -p build/local
# shellcheck disable=SC2164
cd build/local
# export cross_compile_toolchain=/home/s4129/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
#!/bin/bash

# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"

# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi

# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +

# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null

# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"

echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}

# Detect the operating system
OS_NAME=$(uname)
BUILD_DIR="build"
SCRIPT_DIR=$(pwd) # Project dir



# Determine the appropriate build directory based on the OS
case "$OS_NAME" in
Darwin)
# macOS system
BUILD_DIR="${BUILD_DIR}/macos"
;;
Linux)
# Linux system, further identify the distribution if necessary
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu)
BUILD_DIR="${BUILD_DIR}/linux_ubuntu"
;;
centos)
BUILD_DIR="${BUILD_DIR}/linux_centos"
;;
*)
# If an unknown Linux distribution, default to generic 'linux'
BUILD_DIR="${BUILD_DIR}/linux"
;;
esac
else
# If unable to detect Linux distribution, default to 'linux'
BUILD_DIR="${BUILD_DIR}/linux"
fi
;;
*)
# If OS is not recognized, default to 'generic'
BUILD_DIR="${BUILD_DIR}/generic"
;;
esac

# Create the build directory and navigate into it
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" || exit 1

# Run CMake configuration (adjust the options as needed)
cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ../../
-DISF_BUILD_SHARED_LIBS=ON "$SCRIPT_DIR"

# Compile and install
make -j4
make install
make install

# Move 'install' files to the build root directory using an absolute path
move_install_files "$(pwd)"
51 changes: 51 additions & 0 deletions command/build_cross_armv7_armhf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"

# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi

# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +

# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null

# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"

echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}

SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_armv7_armhf
# shellcheck disable=SC2164
cd build/linux_armv7_armhf
# export cross_compile_toolchain=/home/jingyuyan/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_VERSION=1 \
-DCMAKE_SYSTEM_PROCESSOR=armv7 \
-DCMAKE_C_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/arm-linux-gnueabihf-gcc \
-DCMAKE_CXX_COMPILER=$ARM_CROSS_COMPILE_TOOLCHAIN/bin/arm-linux-gnueabihf-g++ \
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -flax-vector-conversions" \
-DTARGET_PLATFORM=armlinux \
-DISF_BUILD_LINUX_ARM7=ON \
-DISF_BUILD_WITH_SAMPLE=OFF \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}

make -j4
make install

move_install_files "$(pwd)"
36 changes: 32 additions & 4 deletions command/build_cross_rv1109rv1126_armhf.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
mkdir -p build/rv1109rv1126_armhf
#!/bin/bash

# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"

# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi

# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +

# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null

# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"

echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}

SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_rv1109rv1126_armhf
# shellcheck disable=SC2164
cd build/rv1109rv1126_armhf
# export cross_compile_toolchain=/home/s4129/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cd build/linux_rv1109rv1126_armhf
# export cross_compile_toolchain=/home/jingyuyan/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_VERSION=1 \
Expand All @@ -18,8 +45,9 @@ cmake -DCMAKE_SYSTEM_NAME=Linux \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_BUILD_SHARED_LIBS=ON ../..
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}

make -j4
make install

move_install_files "$(pwd)"
34 changes: 32 additions & 2 deletions command/build_linux_cuda.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
#!/bin/bash

# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"

# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi

# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +

# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null

# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"

echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}


SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_cuda
# shellcheck disable=SC2164
cd build/linux_cuda
# export cross_compile_toolchain=/home/s4129/software/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf

cmake -DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=OFF \
Expand All @@ -11,6 +39,8 @@ cmake -DCMAKE_SYSTEM_NAME=Linux \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DISF_GLOBAL_INFERENCE_BACKEND_USE_MNN_CUDA=ON \
-DISF_LINUX_MNN_CUDA=/home/tunm/software/MNN-2.7.0/build_cuda/install \
-DISF_BUILD_SHARED_LIBS=ON ../..
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}

make -j4

move_install_files "$(pwd)"
44 changes: 44 additions & 0 deletions command/build_linux_ubuntu18.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Reusable function to handle 'install' directory operations
move_install_files() {
local root_dir="$1"
local install_dir="$root_dir/install"

# Step 1: Check if the 'install' directory exists
if [ ! -d "$install_dir" ]; then
echo "Error: 'install' directory does not exist in $root_dir"
exit 1
fi

# Step 2: Delete all other files/folders except 'install'
find "$root_dir" -mindepth 1 -maxdepth 1 -not -name "install" -exec rm -rf {} +

# Step 3: Move all files from 'install' to the root directory
mv "$install_dir"/* "$root_dir" 2>/dev/null

# Step 4: Remove the empty 'install' directory
rmdir "$install_dir"

echo "Files from 'install' moved to $root_dir, and 'install' directory deleted."
}

SCRIPT_DIR=$(pwd) # Project dir

mkdir -p build/linux_ubuntu18/
# shellcheck disable=SC2164
cd build/linux_ubuntu18/

cmake -DCMAKE_BUILD_TYPE=Release \
-DISF_BUILD_WITH_SAMPLE=ON \
-DISF_BUILD_WITH_TEST=OFF \
-DISF_ENABLE_BENCHMARK=OFF \
-DISF_ENABLE_USE_LFW_DATA=OFF \
-DISF_ENABLE_TEST_EVALUATION=OFF \
-DOpenCV_DIR=3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 \
-DISF_BUILD_SHARED_LIBS=ON ${SCRIPT_DIR}

make -j4
make install

move_install_files "$(pwd)"
15 changes: 0 additions & 15 deletions command/build_linux_ubuntu18_opencv.sh

This file was deleted.

1 change: 1 addition & 0 deletions cpp/inspireface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if (ISF_ENABLE_RKNN)
set(NEED_INCLUDE ${NEED_INCLUDE} ${ISF_RKNN_API_INCLUDE_DIRS})
endif ()
if (ISF_BUILD_LINUX_ARM7)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
set(NEED_INCLUDE ${NEED_INCLUDE} ${OpenCV_STATIC_INCLUDE_DIR})
endif ()

Expand Down
Loading

0 comments on commit 0935c4e

Please sign in to comment.