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

Commit

Permalink
[merge] add: Ci Build (#2)
Browse files Browse the repository at this point in the history
Add: Ci Build
  • Loading branch information
qingyiwebt authored Sep 17, 2023
2 parents b8f18a4 + 7cc9213 commit e5b62d3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 81 deletions.
35 changes: 13 additions & 22 deletions .github/workflows/ci-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,24 @@ env:
jobs:
build-android:
runs-on: ubuntu-latest

env:
ANDROID_NDK: "/usr/local/lib/android/sdk/ndk/24.0.8215888"
ANDROID_NDK_HOME: "/usr/local/lib/android/sdk/ndk/24.0.8215888"
ANDROID_NDK_LATEST_HOME: "/usr/local/lib/android/sdk/ndk/24.0.8215888"
ANDROID_NDK_ROOT: "/usr/local/lib/android/sdk/ndk/24.0.8215888"
steps:
- uses: actions/checkout@v3

- name: Configure environment
run: |
sudo apt install -y git build-essential
- name: Install NDK
uses: nttld/setup-ndk@v1
id: ndk-install
with:
ndk-version: r24
local-cache: true
sudo apt install -y git build-essential ninja-build
- name: Install vcpkg and dependencies
run: |
export ANDROID_NDK_HOME="${{ steps.ndk-install.outputs.ndk-path }}"
git clone https://github.com/microsoft/vcpkg
pushd vcpkg
# Install vcpkg
echo "Install vcpkg"
./bootstrap-vcpkg.sh
# Install dependencies
TRIPLETS="arm-android arm64-android x86-android x64-android"
TRIPLETS="arm-neon-android arm64-android x86-android x64-android"
pushd $VCPKG_INSTALLATION_ROOT
for TRIPLET in $TRIPLETS
do
Expand All @@ -48,9 +39,9 @@ jobs:
- name: Build (Android)
run: |
CFG_FLAGS=('-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}' '-DVCPKG_CMAKE_SYSTEM_NAME=Android' '-DCMAKE_SYSTEM_NAME=Android' '-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake' '-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${{ steps.ndk-install.outputs.ndk-path }}/build/cmake/android.toolchain.cmake' '-DCMAKE_MAKE_PROGRAM=${{ steps.ndk-install.outputs.ndk-path }}/prebuilt/linux-x86_64/bin/make' '-G' 'Unix Makefiles')
CFG_FLAGS=('-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}' '-DVCPKG_CMAKE_SYSTEM_NAME=Android' '-DCMAKE_SYSTEM_NAME=Android' "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake")
TRIPLET='arm-android'
TRIPLET='arm-neon-android'
ABI='armeabi-v7a'
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET -DANDROID_ABI=$ABI "${CFG_FLAGS[@]}"
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
Expand All @@ -73,8 +64,8 @@ jobs:
- name: Upload Artifact (arm-android)
uses: actions/upload-artifact@v3.1.2
with:
name: libUnimage-arm-android.so
path: ${{github.workspace}}/build-arm-android/libUnimage.so
name: libUnimage-arm-neon-android.so
path: ${{github.workspace}}/build-arm-neon-android/libUnimage.so

- name: Upload Artifact (arm64-android)
uses: actions/upload-artifact@v3.1.2
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/ci-darwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ jobs:
- uses: actions/checkout@v3
- name: Install vcpkg and dependencies
run: |
git clone https://github.com/microsoft/vcpkg
pushd vcpkg
# Install vcpkg
echo "Install vcpkg"
./bootstrap-vcpkg.sh
cp ${{github.workspace}}/scripts/arm64-ios-bitcode.cmake ${{github.workspace}}/vcpkg/triplets/community/
cp ${{github.workspace}}/scripts/arm64-ios-bitcode.cmake $VCPKG_INSTALLATION_ROOT/triplets/community/
# Install dependencies
TRIPLETS="x64-osx arm64-ios-bitcode"
pushd $VCPKG_INSTALLATION_ROOT
for TRIPLET in $TRIPLETS
do
./vcpkg install "libjpeg-turbo:$TRIPLET"
Expand All @@ -36,11 +32,11 @@ jobs:
- name: Configure and build
run: |
TRIPLET='x64-osx'
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
TRIPLET='arm64-ios-bitcode'
cmake -B ${{github.workspace}}/build-$TRIPLET -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64
cmake -B ${{github.workspace}}/build-$TRIPLET -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
- name: Upload Artifact (x64-osx)
Expand Down
28 changes: 12 additions & 16 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@ jobs:
- name: Install vcpkg and dependencies
run: |
git clone https://github.com/microsoft/vcpkg
pushd vcpkg
# Install vcpkg
echo "Install vcpkg"
./bootstrap-vcpkg.sh
# Install dependencies
TRIPLET="x64-linux"
./vcpkg install "libjpeg-turbo:$TRIPLET"
./vcpkg install "stb:$TRIPLET"
./vcpkg install "libwebp:$TRIPLET"
TRIPLETS="x64-linux"
popd
pushd $VCPKG_INSTALLATION_ROOT
- name: Configure CMake
run: |
TRIPLET="x64-linux"
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake
for TRIPLET in $TRIPLETS
do
echo "Install dependencies for $TRIPLET"
./vcpkg install "libjpeg-turbo:$TRIPLET"
./vcpkg install "stb:$TRIPLET"
./vcpkg install "libwebp:$TRIPLET"
done
popd
- name: Build
- name: Configure and build
run: |
TRIPLET="x64-linux"
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
- name: Upload Artifact (x64-linux)
Expand Down
32 changes: 14 additions & 18 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: ci-win
on: workflow_dispatch


env:
BUILD_TYPE: Release

jobs:
build-win:
runs-on: windows-latest
Expand All @@ -11,35 +14,28 @@ jobs:
- uses: actions/checkout@v3
- name: Install vcpkg and dependencies, then configure and build it
run: |
git clone https://github.com/microsoft/vcpkg
pushd vcpkg
# Install vcpkg
echo "Install vcpkg"
./bootstrap-vcpkg.bat
# Install dependencies
$TRIPLETS='x64-windows','x86-windows';
$VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT;
# Install dependencies and build
$TRIPLETS='x64-windows';
foreach ($TRIPLET in $TRIPLETS) {
echo "Install dependencies for $TRIPLET"
pushd $VCPKG_ROOT
./vcpkg install "libjpeg-turbo:$TRIPLET"
./vcpkg install "stb:$TRIPLET"
./vcpkg install "libwebp:$TRIPLET"
}
./vcpkg integrate install
popd
popd
$TRIPLET="x64-windows";
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET "-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}\vcpkg\scripts\buildsystems\vcpkg.cmake"
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
$TRIPLET="x86-windows";
cmake -B ${{github.workspace}}/build-$TRIPLET -DVCPKG_TARGET_TRIPLET=$TRIPLET "-DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}\vcpkg\scripts\buildsystems\vcpkg.cmake"
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
echo "Build for $TRIPLET"
cmake -B ${{github.workspace}}/build-$TRIPLET "-DVCPKG_TARGET_TRIPLET=$TRIPLET" "-DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build ${{github.workspace}}/build-$TRIPLET --config ${{env.BUILD_TYPE}}
}
- name: Upload Artifact (x64-windows)
uses: actions/upload-artifact@v3.1.2
with:
name: libUnimage-x64-windows.dll
path: ${{github.workspace}}/build-x86-android/libUnimage.dll
path: ${{github.workspace}}/build-x64-windows/libUnimage.dll

- name: Upload Artifact (x86-windows)
uses: actions/upload-artifact@v3.1.2
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Unimage Native
[![ci-win](https://github.com/Klrohias/unimage-native/actions/workflows/ci-windows.yml/badge.svg)](https://github.com/Klrohias/unimage-native/actions/workflows/ci-windows.yml)
[![ci-linux](https://github.com/Klrohias/unimage-native/actions/workflows/ci-linux.yml/badge.svg)](https://github.com/Klrohias/unimage-native/actions/workflows/ci-linux.yml)
[![ci-android](https://github.com/Klrohias/unimage-native/actions/workflows/ci-android.yml/badge.svg)](https://github.com/Klrohias/unimage-native/actions/workflows/ci-android.yml)
[![ci-darwin](https://github.com/Klrohias/unimage-native/actions/workflows/ci-darwin.yml/badge.svg)](https://github.com/Klrohias/unimage-native/actions/workflows/ci-darwin.yml)
Used by [Unimage Unity](https://github.com/Klrohias/unimage-unity).
It can load `png`/`jpeg`/`webp`/`bmp`/`tga`/`gif` in to memory, and provides some simple operations.

Expand Down
26 changes: 13 additions & 13 deletions scripts/export-symbols.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
_unimage_clip
_unimage_copy_from
_unimage_copy_to_memory
_unimage_create
_unimage_free
_unimage_get_buffer
_unimage_get_error_message
_unimage_get_format
_unimage_get_height
_unimage_get_width
_unimage_load
_unimage_load_raw
_unimage_resize
_unimage_processor_create
_unimage_processor_free
_unimage_processor_load_raw
_unimage_processor_load
_unimage_processor_get_width
_unimage_processor_get_height
_unimage_processor_get_format
_unimage_processor_copy_to_memory
_unimage_processor_resize
_unimage_processor_get_error_message
_unimage_processor_get_buffer
_unimage_processor_copy_from
_unimage_processor_clip
17 changes: 14 additions & 3 deletions scripts/ios-link.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/zsh
echo "[iOS-build] vcpkg root path: $1"

VCPKG_DIR=$1
OUTPUT_DIR=$(pwd)
Expand All @@ -8,18 +7,30 @@ PACKAGES_DIR=$VCPKG_DIR/packages

TRIPLET=arm64-ios-bitcode

echo "[iOS-build] ===== Unimage iOS Post-build Script ====="
echo "[iOS-build] VCPKG_DIR: $VCPKG_DIR"
echo "[iOS-build] OUTPUT_DIR: $OUTPUT_DIR"
echo "[iOS-build] SCRIPT_DIR: $SCRIPT_DIR"
echo "[iOS-build] PACKAGES_DIR: $PACKAGES_DIR"
echo "[iOS-build] TRIPLET: $TRIPLET"

echo "[iOS-build] List Of $OUTPUT_DIR"
ls -al $OUTPUT_DIR

function ExtractVcpkgArchive {
ar x $PACKAGES_DIR/$1_$TRIPLET/lib/$2
}

function ExtractArchive {
echo "[iOS-build] extract library: $1"
echo "[iOS-build] Extract library: $1"
ar x $1
}

mkdir _ARCHIVE
pushd _ARCHIVE

echo "[iOS-build] Extract libraries"

# Extract all archives
ExtractArchive $OUTPUT_DIR/libUnimage.a
ExtractVcpkgArchive libjpeg-turbo libturbojpeg.a
Expand All @@ -28,7 +39,7 @@ ExtractVcpkgArchive libwebp libwebpdecoder.a
ExtractVcpkgArchive libwebp libwebpdemux.a

# Link all objects
echo "[iOS-build] link objects"
echo "[iOS-build] Link objects"
ld -r *.o -o $OUTPUT_DIR/libUnimage.o -bitcode_bundle -exported_symbols_list $SCRIPT_DIR/export-symbols.txt
rm $OUTPUT_DIR/libUnimage.a
ar -q $OUTPUT_DIR/libUnimage.a $OUTPUT_DIR/libUnimage.o
Expand Down

0 comments on commit e5b62d3

Please sign in to comment.