Page MenuHomePhorge

action.yml
No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None

action.yml

name: Build Native Dependencies
description: Build libsodium, mbedtls, zlib as needed
inputs:
deps:
description: Space-separated list of deps to build (libsodium mbedtls zlib)
required: true
prefix:
description: Install prefix
required: true
cc:
description: C compiler
required: true
cxx:
description: C++ compiler
required: false
default: ''
ar:
description: AR tool
required: false
default: ar
ranlib:
description: RANLIB tool
required: false
default: ranlib
cmake_generator:
description: CMake generator (Ninja, MinGW Makefiles, etc)
required: false
default: ''
libsodium_version:
required: true
mbedtls_version:
required: true
zlib_version:
required: true
runs:
using: composite
steps:
- name: Compute deps hash
id: deps-hash
shell: bash
run: echo "hash=$(echo '${{ inputs.deps }}' | tr ' ' '-')" >> $GITHUB_OUTPUT
- name: Cache native deps
id: cache
uses: actions/cache@v4
with:
path: ${{ inputs.prefix }}
key: deps-${{ runner.os }}-${{ runner.arch }}-${{ steps.deps-hash.outputs.hash }}-${{ hashFiles('.github/versions.json') }}-v1
- name: Prepare build environment
id: prep
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
PREFIX=$(cygpath -m "${{ inputs.prefix }}")
else
PREFIX="${{ inputs.prefix }}"
fi
echo "prefix=$PREFIX" >> $GITHUB_OUTPUT
mkdir -p "$PREFIX"
- name: Build libsodium
if: steps.cache.outputs.cache-hit != 'true' && contains(inputs.deps, 'libsodium')
shell: bash
run: |
git clone --depth 1 --branch ${{ inputs.libsodium_version }}-RELEASE https://github.com/jedisct1/libsodium.git /tmp/libsodium
cd /tmp/libsodium
./configure CC=${{ inputs.cc }} --prefix=${{ steps.prep.outputs.prefix }} --disable-shared --enable-static
make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
make install
- name: Build mbedtls
if: steps.cache.outputs.cache-hit != 'true' && contains(inputs.deps, 'mbedtls')
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$(cygpath "$RUNNER_TEMP/msys64/clang64/bin"):$PATH"
fi
git clone --depth 1 --branch mbedtls-${{ inputs.mbedtls_version }} --recurse-submodules https://github.com/Mbed-TLS/mbedtls.git /tmp/mbedtls
cd /tmp/mbedtls
CMAKE_GENERATOR="${{ inputs.cmake_generator }}"
CMAKE_ARGS="-DCMAKE_C_COMPILER=${{ inputs.cc }}"
if [[ "$RUNNER_OS" == "Windows" ]]; then
AR_PATH="$(which ${{ inputs.ar }})"
RANLIB_PATH="$(which ${{ inputs.ranlib }})"
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_AR=$AR_PATH -DCMAKE_RANLIB=$RANLIB_PATH"
fi
if [[ -n "${{ inputs.cxx }}" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=${{ inputs.cxx }}"
fi
cmake -B build \
${CMAKE_GENERATOR:+-G "$CMAKE_GENERATOR"} \
$CMAKE_ARGS \
-DCMAKE_INSTALL_PREFIX=${{ steps.prep.outputs.prefix }} \
-DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_STATIC_MBEDTLS_LIBRARY=ON -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
cmake --build build -j$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
cmake --install build
- name: Build zlib
if: steps.cache.outputs.cache-hit != 'true' && contains(inputs.deps, 'zlib')
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
export PATH="$(cygpath "$RUNNER_TEMP/msys64/clang64/bin"):$PATH"
fi
git clone --depth 1 --branch v${{ inputs.zlib_version }} https://github.com/madler/zlib.git /tmp/zlib
cd /tmp/zlib
CMAKE_GENERATOR="${{ inputs.cmake_generator }}"
if [[ "$RUNNER_OS" != "macOS" ]]; then
export AR="${{ inputs.ar }}"
export RANLIB="${{ inputs.ranlib }}"
fi
CMAKE_ARGS="-DCMAKE_C_COMPILER=${{ inputs.cc }}"
if [[ "$RUNNER_OS" == "Windows" ]]; then
AR_PATH="$(which ${{ inputs.ar }})"
RANLIB_PATH="$(which ${{ inputs.ranlib }})"
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_AR=$AR_PATH -DCMAKE_RANLIB=$RANLIB_PATH"
fi
if [[ -n "${{ inputs.cxx }}" ]]; then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=${{ inputs.cxx }}"
fi
cmake -B build \
${CMAKE_GENERATOR:+-G "$CMAKE_GENERATOR"} \
$CMAKE_ARGS \
-DCMAKE_INSTALL_PREFIX=${{ steps.prep.outputs.prefix }} \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=MinSizeRel
cmake --build build
cmake --install build
rm -f ${{ steps.prep.outputs.prefix }}/lib/libz.so* 2>/dev/null || true

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 1, 2:09 PM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
587709
Default Alt Text
action.yml (4 KB)

Event Timeline