fix: remove flatbuffers-compile #87
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: linux-precompile | |
on: | |
push: | |
tags: | |
- 'v*' | |
- 'precompile-test' | |
- 'precompile-test-linux' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
precompile: | |
runs-on: ubuntu-20.04 | |
env: | |
TFLITE_BEAM_PREFER_PRECOMPILED: "false" | |
ARMV6_TOOLCHAIN_NAME: "nerves_toolchain_armv6_nerves_linux_gnueabihf-linux_x86_64" | |
ARMV6_TOOLCHAIN_VERSION: "14.2.0" | |
ARMV6_TOOLCHAIN_HASH: "11156D8" | |
RISCV64_TOOLCHAIN_NAME: "nerves_toolchain_riscv64_nerves_linux_gnu-linux_x86_64" | |
RISCV64_TOOLCHAIN_VERSION: "14.2.0" | |
RISCV64_TOOLCHAIN_HASH: "D43CCBE" | |
name: ${{ matrix.pair.target_arch }}-${{ matrix.pair.target_os }}-${{ matrix.pair.target_abi }} - OTP ${{ matrix.pair.otp }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# remember to change the `get_precompiled_nif_version/0` function in the `tflite_beam_precompiled` file | |
# if upgrade the Erlang/OTP version to 26.x or later | |
# 2.16 for OTP 24.x and 25.x | |
# 2.17 for OTP 26.x | |
- pair: | |
otp: "25.x" | |
arch_name: x86_64 | |
cmake_toolchain_file: "" | |
c_compiler: gcc | |
cpp_compiler: g++ | |
libedgetpu_library: "x86_64" | |
target_arch: "x86_64" | |
target_os: "linux" | |
target_abi: "gnu" | |
- pair: | |
otp: "25.x" | |
arch_name: aarch64 | |
cmake_toolchain_file: cc_toolchain/aarch64-linux-gnu.cmake | |
c_compiler: gcc-aarch64-linux-gnu | |
cpp_compiler: g++-aarch64-linux-gnu | |
libedgetpu_library: "aarch64" | |
target_arch: "aarch64" | |
target_os: "linux" | |
target_abi: "gnu" | |
cc: "/usr/bin/aarch64-linux-gnu-gcc" | |
cxx: "/usr/bin/aarch64-linux-gnu-g++" | |
- pair: | |
otp: "25.x" | |
arch_name: armv7l | |
cmake_toolchain_file: cc_toolchain/armv7l-linux-gnueabihf.cmake | |
c_compiler: gcc-arm-linux-gnueabihf | |
cpp_compiler: g++-arm-linux-gnueabihf | |
libedgetpu_library: "armv7l" | |
target_arch: "armv7l" | |
target_os: "linux" | |
target_abi: "gnueabihf" | |
cc: "/usr/bin/arm-linux-gnueabihf-gcc" | |
cxx: "/usr/bin/arm-linux-gnueabihf-g++" | |
- pair: | |
otp: "25.x" | |
arch_name: armv6 | |
cmake_toolchain_file: cc_toolchain/armv6-nerves-linux-gnueabihf.cmake | |
c_compiler: armv6-nerves-linux-gnueabihf-gcc | |
cpp_compiler: armv6-nerves-linux-gnueabihf-g++ | |
libedgetpu_library: "armv6" | |
target_arch: "armv6" | |
target_os: "linux" | |
target_abi: "gnueabihf" | |
cc: "/usr/local/bin/nerves_toolchain_armv6_nerves_linux_gnueabihf-linux_x86_64-14.2.0/bin/armv6-nerves-linux-gnueabihf-gcc" | |
cxx: "/usr/local/bin/nerves_toolchain_armv6_nerves_linux_gnueabihf-linux_x86_64-14.2.0/bin/armv6-nerves-linux-gnueabihf-g++" | |
- pair: | |
otp: "25.x" | |
arch_name: riscv64 | |
cmake_toolchain_file: cc_toolchain/riscv64-nerves-linux-gnu.cmake | |
c_compiler: riscv64-nerves-linux-gnu-gcc | |
cpp_compiler: riscv64-nerves-linux-gnu-g++ | |
libedgetpu_library: "riscv64" | |
target_arch: "riscv64" | |
target_os: "linux" | |
target_abi: "gnu" | |
cc: "/usr/local/bin/nerves_toolchain_riscv64_nerves_linux_gnu-linux_x86_64-14.2.0/bin/riscv64-nerves-linux-gnu-gcc" | |
cxx: "/usr/local/bin/nerves_toolchain_riscv64_nerves_linux_gnu-linux_x86_64-14.2.0/bin/riscv64-nerves-linux-gnu-g++" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: erlef/setup-beam@v1 | |
with: | |
otp-version: ${{ matrix.pair.otp }} | |
- name: Install system dependecies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip curl git libssl-dev gzip libncurses5-dev ca-certificates | |
if [ "${{ matrix.pair.arch_name }}" = "aarch64" ]; then | |
sudo sed -i 's/focal/jammy/g' /etc/apt/sources.list | |
sudo apt-get update | |
fi | |
if [ "${{ matrix.pair.arch_name }}" = "armv6" ]; then | |
curl -fSL https://github.com/nerves-project/toolchains/releases/download/v${ARMV6_TOOLCHAIN_VERSION}/${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION}-11156D8.tar.xz -o ${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION}-${ARMV6_TOOLCHAIN_HASH}.tar.xz | |
tar -xf ${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION}-${ARMV6_TOOLCHAIN_HASH}.tar.xz | |
sudo mv ${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION} /usr/local/bin/${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION} | |
elif [ "${{ matrix.pair.arch_name }}" = "riscv64" ]; then | |
curl -fSL https://github.com/nerves-project/toolchains/releases/download/v14.2.0/${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION}-${RISCV64_TOOLCHAIN_HASH}.tar.xz -o ${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION}-${RISCV64_TOOLCHAIN_HASH}.tar.xz | |
tar -xf ${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION}-${RISCV64_TOOLCHAIN_HASH}.tar.xz | |
sudo mv ${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION} /usr/local/bin/${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION} | |
else | |
sudo apt-get install -y ${{ matrix.pair.c_compiler }} ${{ matrix.pair.cpp_compiler }} | |
fi | |
git clone https://github.com/google/flatbuffers.git | |
cd flatbuffers/ | |
git checkout e6463926479bd6b330cbcf673f7e917803fd5831 | |
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release | |
make | |
sudo make install | |
- name: Create precompiled library | |
run: | | |
export NIF_VERSION="$(erl -noshell -eval "io:format('~ts', [erlang:system_info(nif_version)])." -s erlang halt)" | |
if [ "${{ matrix.pair.cmake_toolchain_file }}" != "" ]; then | |
export CMAKE_TOOLCHAIN_FILE="$(pwd)/${{ matrix.pair.cmake_toolchain_file }}" | |
export CC="${{ matrix.pair.cc }}" | |
export CXX="${{ matrix.pair.cxx }}" | |
export TARGET_ARCH="${{ matrix.pair.target_arch }}" | |
export TARGET_OS="${{ matrix.pair.target_os }}" | |
export TARGET_ABI="${{ matrix.pair.target_abi }}" | |
export TFLITE_BEAM_CORAL_LIBEDGETPU_LIBRARIES="${{ matrix.pair.libedgetpu_library }}" | |
fi | |
if [ "${{ matrix.pair.arch_name }}" = "armv6" ]; then | |
export TARGET_GCC_FLAGS="-mabi=aapcs-linux -mfpu=vfp -marm -fstack-protector-strong -mfloat-abi=hard -mcpu=arm1176jzf-s -fPIE -pie -Wl,-z,now -Wl,-z,relro" | |
export PATH="/usr/local/bin/${ARMV6_TOOLCHAIN_NAME}-${ARMV6_TOOLCHAIN_VERSION}/bin/:${PATH}" | |
elif [ "${{ matrix.pair.arch_name }}" = "riscv64" ]; then | |
export PATH="/usr/local/bin/${RISCV64_TOOLCHAIN_NAME}-${RISCV64_TOOLCHAIN_VERSION}/bin/:${PATH}" | |
fi | |
echo "CMAKE_TOOLCHAIN_FILE: ${CMAKE_TOOLCHAIN_FILE}" | |
echo "TFLITE_BEAM_CORAL_LIBEDGETPU_LIBRARIES: ${TFLITE_BEAM_CORAL_LIBEDGETPU_LIBRARIES}" | |
echo "TFLITE_BEAM_PREFER_PRECOMPILED: ${TFLITE_BEAM_PREFER_PRECOMPILED}" | |
echo "CC: ${CC}" | |
echo "CXX: ${CXX}" | |
echo "TARGET_ARCH: ${TARGET_ARCH}" | |
echo "TARGET_OS: ${TARGET_OS}" | |
echo "TARGET_ABI: ${TARGET_ABI}" | |
echo "TARGET_GCC_FLAGS: ${TARGET_GCC_FLAGS}" | |
rebar3 deps | |
rebar3 compile | |
export PKG_NAME=tflite_beam-nif-${NIF_VERSION}-${{ matrix.pair.arch_name }}-${{ matrix.pair.target_os }}-${{ matrix.pair.target_abi }}-${GITHUB_REF##*/} | |
mkdir -p "${PKG_NAME}" | |
cp -a ./priv "${PKG_NAME}" | |
tar -czf "${PKG_NAME}.tar.gz" "${PKG_NAME}" | |
rm -rf "${PKG_NAME}" | |
ls -lah "${PKG_NAME}.tar.gz" | |
mkdir -p artifacts | |
mv "${PKG_NAME}.tar.gz" artifacts | |
- uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: artifacts/tflite_beam-*.tar.gz |