diff --git a/.github/workflows/test-addon.yml b/.github/workflows/test-addon.yml new file mode 100644 index 0000000..291c98b --- /dev/null +++ b/.github/workflows/test-addon.yml @@ -0,0 +1,66 @@ +name: test-addon + +# Tests the addon against a tagged openFrameworks release (see OF_TAG below). +on: + push: + pull_request: + workflow_dispatch: + inputs: + of_tag: + description: "openFrameworks tag to test against (blank = OF_TAG below)" + +env: + # TODO: change to test another OF version, e.g. nightly/master checkout + OF_TAG: ${{ inputs.of_tag || '0.12.1' }} + # TODO: rename to your addon (must match addon_config.mk ADDON_NAME) + ADDON_NAME: ofxMyAddon + +jobs: + linux64: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + with: + path: addon + - name: Clone openFrameworks at tag + run: git clone --depth 1 --branch "$OF_TAG" https://github.com/openframeworks/openFrameworks ~/openFrameworks + - name: Install OF dependencies + run: | + cd ~/openFrameworks + sudo ./scripts/ci/linux64/install.sh + ./scripts/linux/download_libs.sh + - name: Install addon + run: | + mv "$GITHUB_WORKSPACE/addon" ~/openFrameworks/addons/$ADDON_NAME + cd ~/openFrameworks/addons/$ADDON_NAME + ./scripts/download_libs.sh linux64 || echo "no libs release yet, continuing with sources only" + - name: Build examples + run: | + export OF_ROOT=~/openFrameworks + for ex in ~/openFrameworks/addons/$ADDON_NAME/example_*; do + [ -d "$ex" ] || continue + echo "== building $ex" + make -C "$ex" -j"$(nproc)" + done + + osx: + runs-on: macos-15 + steps: + - uses: actions/checkout@v6 + with: + path: addon + - name: Clone openFrameworks at tag + run: git clone --depth 1 --branch "$OF_TAG" https://github.com/openframeworks/openFrameworks ~/openFrameworks + - name: Install addon + run: | + mv "$GITHUB_WORKSPACE/addon" ~/openFrameworks/addons/$ADDON_NAME + cd ~/openFrameworks/addons/$ADDON_NAME + ./scripts/download_libs.sh osx || echo "no libs release yet, continuing with sources only" + - name: Build examples + run: | + export OF_ROOT=~/openFrameworks + for ex in ~/openFrameworks/addons/$ADDON_NAME/example_*; do + [ -d "$ex" ] || continue + echo "== building $ex" + make -C "$ex" -j"$(sysctl -n hw.ncpu)" + done diff --git a/.gitignore b/.gitignore index 593962f..6308b5a 100644 --- a/.gitignore +++ b/.gitignore @@ -105,3 +105,19 @@ Desktop.ini *.log *.sql *.sqlite + +######################### +# addon prebuilt binaries +######################### + +# Binaries are fetched with scripts/download_libs.sh, not committed. +# (Folder skeleton is kept via .gitkeep files.) +libs/*/lib/**/*.[ao] +libs/*/lib/**/*.lib +libs/*/lib/**/*.so +libs/*/lib/**/*.dylib +libs/*/lib/**/*.dll +libs/*/lib/**/*.framework +libs/*/lib/**/*.xcframework +*.tar.bz2 +/releases/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..975a6fc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,92 @@ +# CMakeLists.txt - TEMPLATE for building an openFrameworks addon + example with CMake. +# +# Usage: +# cmake -S . -B build -DOF_ROOT=/path/to/openFrameworks -DOF_TARGET=linux64 +# cmake --build build +# +# OF_TARGET must be one of the projectGenerator platform tokens, matching a +# folder under libs//lib/ (see addon_config.mk sections): +# osx | ios | tvos | vs | msys2 | linux64 | linuxarmv6l | linuxarmv7l | +# linuxaarch64 | android | emscripten +# +cmake_minimum_required(VERSION 3.16) + +# TODO: rename to your addon (must match addon_config.mk ADDON_NAME) +set(ADDON_NAME ofxMyAddon) +project(${ADDON_NAME} LANGUAGES C CXX) + +set(OF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "openFrameworks root") +set(OF_TARGET "linux64" CACHE STRING "OF platform token (see above)") + +# Same language standards as apothecary (scripts/apothecary/apothecary/apothecary): +# C 17, C++ 23, honoring apothecary's C_STANDARD / CPP_STANDARD env overrides. +if("$ENV{C_STANDARD}" STREQUAL "") + set(C_STANDARD 17) +else() + set(C_STANDARD "$ENV{C_STANDARD}") +endif() +if("$ENV{CPP_STANDARD}" STREQUAL "") + set(CPP_STANDARD 23) +else() + set(CPP_STANDARD "$ENV{CPP_STANDARD}") +endif() +set(CMAKE_C_STANDARD ${C_STANDARD}) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD ${CPP_STANDARD}) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# --- addon sources: mirrors what PG auto-discovers (src/ + libs/*/src|include). +# PG walks both trees recursively, so this recurses too: sources nested at any +# depth (e.g. libs//src/vendor/sub/file.cpp) are picked up. Binaries under +# libs/*/lib/ are ignored by extension. To drop files per-platform, prune the +# lists (the equivalent of addon_config.mk ADDON_SOURCES_EXCLUDE), e.g.: +# list(FILTER ADDON_SOURCES EXCLUDE REGEX ".*port/AndroidJNI.*") +file(GLOB_RECURSE ADDON_SOURCES CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cxx" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.c" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.cc" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.cxx") +file(GLOB_RECURSE ADDON_HEADERS CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/libs/*.hpp") + +add_library(${ADDON_NAME} STATIC ${ADDON_SOURCES} ${ADDON_HEADERS}) +target_include_directories(${ADDON_NAME} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/src") + +# Every lib folder becomes an include path, like the PG does. +file(GLOB LIB_INCLUDE_DIRS LIST_DIRECTORIES true "${CMAKE_CURRENT_SOURCE_DIR}/libs/*") +foreach(d IN LISTS LIB_INCLUDE_DIRS) + if(IS_DIRECTORY "${d}") + target_include_directories(${ADDON_NAME} PUBLIC "${d}/include" "${d}/src") + endif() +endforeach() + +# --- prebuilt binaries for this platform (download with scripts/download_libs.sh) +set(OF_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs") +file(GLOB PREBUILT_LIBS + "${OF_LIB_DIR}/*/lib/${OF_TARGET}/*.a" + "${OF_LIB_DIR}/*/lib/${OF_TARGET}/*.so" + "${OF_LIB_DIR}/*/lib/${OF_TARGET}/*.dylib" + "${OF_LIB_DIR}/*/lib/${OF_TARGET}/*.lib") +if(APPLE) + # PG treats osx/macos as aliases; accept either folder. + file(GLOB PREBUILT_LIBS_MACOS "${OF_LIB_DIR}/*/lib/macos/*") + list(APPEND PREBUILT_LIBS ${PREBUILT_LIBS_MACOS}) +endif() +if(PREBUILT_LIBS) + target_link_libraries(${ADDON_NAME} PUBLIC ${PREBUILT_LIBS}) +else() + message(WARNING "No prebuilt libs for OF_TARGET=${OF_TARGET}; run scripts/download_libs.sh ${OF_TARGET}") +endif() + +# --- OF core headers (compile against a tagged OF checkout, e.g. 0.12.1) +if(IS_DIRECTORY "${OF_ROOT}/libs/openFrameworks") + target_include_directories(${ADDON_NAME} PUBLIC "${OF_ROOT}/libs/openFrameworks") +endif() diff --git a/README_DEPLOY.md b/README_DEPLOY.md index 3c52a1f..dbda10e 100644 --- a/README_DEPLOY.md +++ b/README_DEPLOY.md @@ -15,7 +15,16 @@ State which license you offer your addon under. openFrameworks is distributed un Installation ------------ -Any steps necessary to install your addon. Optimally, this means just dropping the folder into the `openFrameworks/addons/` folder. +Drop the folder into the `openFrameworks/addons/` folder, then fetch the +prebuilt binaries for your platform: + + ./scripts/download_libs.sh # auto-detects: osx, linux64, msys2, ... + ./scripts/download_libs.sh ios # a specific platform, or `all` + +(On Windows run it from git-bash, or use `scripts\download_libs.cmd`.) +If your platform has no prebuilt release yet, the addon still builds from the +sources under `libs/*/src/` - see `scripts/build_libs.sh` to build and publish +binaries. Dependencies ------------ diff --git a/addon_config.mk b/addon_config.mk index 1a0a893..f1461bc 100644 --- a/addon_config.mk +++ b/addon_config.mk @@ -94,9 +94,15 @@ vs: linuxarmv6l: linuxarmv7l: -android/armeabi: -android/armeabi-v7a: +linuxaarch64: +msys2: +emscripten: +android/armeabi-v7a: +android/arm64-v8a: +android/x86: +android/x86_64: osx: +macos: # osx/iOS only, any framework that should be included in the project # ADDON_FRAMEWORKS = ios: diff --git a/libs/README.md b/libs/README.md new file mode 100644 index 0000000..588dec5 --- /dev/null +++ b/libs/README.md @@ -0,0 +1,28 @@ +# libs/ + +Prebuilt binaries live here, one folder per openFrameworks platform token: + + libs//lib/osx/ macOS (also matches the `macos` alias) + libs//lib/ios/ iOS + libs//lib/tvos/ tvOS + libs//lib/vs/ Windows Visual Studio (.lib) + libs//lib/msys2/ Windows MSYS2/MinGW + libs//lib/linux64/ Linux x86_64 + libs//lib/linuxarmv6l/ Linux ARMv6 (Raspberry Pi 1/Zero) + libs//lib/linuxarmv7l/ Linux ARMv7 (Raspberry Pi 2/3) + libs//lib/linuxaarch64/ Linux ARM64 + libs//lib/android// armeabi-v7a, arm64-v8a, x86, x86_64 + libs//lib/emscripten/ Emscripten (WebAssembly) + +The names are load-bearing: the projectGenerator links a binary only if its +path contains the platform token, and `scripts/download_libs.sh` resolves the +same names to GitHub release assets. + +Binaries are NOT committed (see `.gitignore`). Fetch them with: + + ./scripts/download_libs.sh # auto-detect host platform + ./scripts/download_libs.sh linux64 # or: all, osx, ios, vs, ... + +Sources under `libs//src/` and headers under `libs//include/` are +compiled automatically by the projectGenerator and the CMakeLists template - +no `addon_config.mk` entries needed. diff --git a/libs/necessaryLib/lib/android/armeabi-v7a/static_necessaryLib1.a b/libs/necessaryLib/lib/android/arm64-v8a/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/android/armeabi-v7a/static_necessaryLib1.a rename to libs/necessaryLib/lib/android/arm64-v8a/.gitkeep diff --git a/libs/necessaryLib/lib/android/armeabi-v7a/static_necessaryLib2.a b/libs/necessaryLib/lib/android/armeabi-v7a/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/android/armeabi-v7a/static_necessaryLib2.a rename to libs/necessaryLib/lib/android/armeabi-v7a/.gitkeep diff --git a/libs/necessaryLib/lib/android/armeabi/static_necessaryLib1.a b/libs/necessaryLib/lib/android/x86/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/android/armeabi/static_necessaryLib1.a rename to libs/necessaryLib/lib/android/x86/.gitkeep diff --git a/libs/necessaryLib/lib/android/armeabi/static_necessaryLib2.a b/libs/necessaryLib/lib/android/x86_64/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/android/armeabi/static_necessaryLib2.a rename to libs/necessaryLib/lib/android/x86_64/.gitkeep diff --git a/libs/necessaryLib/lib/ios/static_necessaryLib1.a b/libs/necessaryLib/lib/emscripten/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/ios/static_necessaryLib1.a rename to libs/necessaryLib/lib/emscripten/.gitkeep diff --git a/libs/necessaryLib/lib/ios/static_necessaryLib2.a b/libs/necessaryLib/lib/ios/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/ios/static_necessaryLib2.a rename to libs/necessaryLib/lib/ios/.gitkeep diff --git a/libs/necessaryLib/lib/linux/static_necessaryLib1.a b/libs/necessaryLib/lib/linux64/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/linux/static_necessaryLib1.a rename to libs/necessaryLib/lib/linux64/.gitkeep diff --git a/libs/necessaryLib/lib/linux/static_necessaryLib2.a b/libs/necessaryLib/lib/linuxaarch64/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/linux/static_necessaryLib2.a rename to libs/necessaryLib/lib/linuxaarch64/.gitkeep diff --git a/libs/necessaryLib/lib/linux64/static_necessaryLib1.a b/libs/necessaryLib/lib/linuxarmv6l/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/linux64/static_necessaryLib1.a rename to libs/necessaryLib/lib/linuxarmv6l/.gitkeep diff --git a/libs/necessaryLib/lib/linux64/static_necessaryLib2.a b/libs/necessaryLib/lib/linuxarmv7l/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/linux64/static_necessaryLib2.a rename to libs/necessaryLib/lib/linuxarmv7l/.gitkeep diff --git a/libs/necessaryLib/lib/osx/static_necessaryLib1.a b/libs/necessaryLib/lib/msys2/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/osx/static_necessaryLib1.a rename to libs/necessaryLib/lib/msys2/.gitkeep diff --git a/libs/necessaryLib/lib/osx/static_necessaryLib2.a b/libs/necessaryLib/lib/osx/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/osx/static_necessaryLib2.a rename to libs/necessaryLib/lib/osx/.gitkeep diff --git a/libs/necessaryLib/lib/vs/static_necessaryLib1.lib b/libs/necessaryLib/lib/tvos/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/vs/static_necessaryLib1.lib rename to libs/necessaryLib/lib/tvos/.gitkeep diff --git a/libs/necessaryLib/lib/vs/static_necessaryLib2.lib b/libs/necessaryLib/lib/vs/.gitkeep similarity index 100% rename from libs/necessaryLib/lib/vs/static_necessaryLib2.lib rename to libs/necessaryLib/lib/vs/.gitkeep diff --git a/libs/necessaryLib/lib/win_cb/static_necessaryLib1.a b/libs/necessaryLib/lib/win_cb/static_necessaryLib1.a deleted file mode 100644 index e69de29..0000000 diff --git a/libs/necessaryLib/lib/win_cb/static_necessaryLib2.a b/libs/necessaryLib/lib/win_cb/static_necessaryLib2.a deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/build_libs.sh b/scripts/build_libs.sh new file mode 100755 index 0000000..aad6012 --- /dev/null +++ b/scripts/build_libs.sh @@ -0,0 +1,90 @@ +#!/usr/bin/env bash +# +# build_libs.sh - TEMPLATE for building addon libs and packaging them as +# GitHub release assets with the naming convention expected by +# scripts/download_libs.sh: +# +# -libs--.tar.bz2 +# +# Usage: +# scripts/build_libs.sh [platform] [-v ] +# scripts/build_libs.sh --upload [platform] [-v ] (needs `gh`) +# +# Steps for the addon author: +# 1. Set LIB_NAME / LIB_SRC / BUILD_CMDS below to build your lib. +# 2. Run this on each platform (or in CI), producing one archive per platform. +# 3. Create a GitHub release named and upload the archives: +# gh release create 1.0.0 releases/*.tar.bz2 +# 4. Point scripts/download_libs.sh at your repo (GITHUB_REPO) and version. +# +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ADDON_DIR="$(dirname "$SCRIPT_DIR")" +ADDON_NAME="$(basename "$ADDON_DIR")" + +# ---------------------------------------------------------------- TODO: edit +LIB_NAME="necessaryLib" # folder under libs/ holding include/ src/ lib/ +LIBS_VERSION="1.0.0" # GitHub release tag the archives are uploaded to +RELEASE_DIR="$ADDON_DIR/releases" +# ---------------------------------------------------------------------------- + +PLATFORM="" +UPLOAD=0 +while [ $# -gt 0 ]; do + case "$1" in + -v|--version) LIBS_VERSION="$2"; shift 2 ;; + --upload) UPLOAD=1; shift ;; + -h|--help) sed -n '2,/^$/p' "$0"; exit 0 ;; + *) PLATFORM="$1"; shift ;; + esac +done + +if [ -z "$PLATFORM" ]; then + # Same detection as download_libs.sh + case "$(uname -s)" in + Darwin) PLATFORM="osx" ;; + MINGW*|MSYS*|CYGWIN*) PLATFORM="msys2" ;; + Linux) + case "$(uname -m)" in + x86_64) PLATFORM="linux64" ;; + armv6l) PLATFORM="linuxarmv6l" ;; + armv7l) PLATFORM="linuxarmv7l" ;; + aarch64) PLATFORM="linuxaarch64" ;; + *) PLATFORM="linux64" ;; + esac ;; + *) PLATFORM="linux64" ;; + esac +fi +if [ "$PLATFORM" = "macos" ]; then PLATFORM="osx"; fi + +LIB_DIR="$ADDON_DIR/libs/$LIB_NAME" +OUT_DIR="$LIB_DIR/lib/$PLATFORM" + +echo "==> TODO: build your lib here and install the binaries into:" +echo " $OUT_DIR" +echo " (edit the BUILD section of $0)" +# Example: build from libs/$LIB_NAME/src with cmake/make, then copy: +# cmake -S "$LIB_DIR/src" -B "/tmp/${LIB_NAME}-build" -DCMAKE_BUILD_TYPE=Release +# cmake --build "/tmp/${LIB_NAME}-build" --config Release +# mkdir -p "$OUT_DIR" +# cp "/tmp/${LIB_NAME}-build/libnecessaryLib.a" "$OUT_DIR/" + +if [ ! -d "$OUT_DIR" ]; then + echo "ERROR: $OUT_DIR does not exist. Build the lib for $PLATFORM first." >&2 + exit 1 +fi + +ASSET="${ADDON_NAME}-libs-${PLATFORM}-${LIBS_VERSION}.tar.bz2" +mkdir -p "$RELEASE_DIR" +# Archive paths relative to libs/$LIB_NAME so they extract to lib//... +tar -cjf "$RELEASE_DIR/$ASSET" -C "$LIB_DIR" "lib/$PLATFORM" "include" +echo "==> wrote $RELEASE_DIR/$ASSET" +tar -tjf "$RELEASE_DIR/$ASSET" | head -n 20 + +if [ "$UPLOAD" = "1" ]; then + gh release upload "$LIBS_VERSION" "$RELEASE_DIR/$ASSET" --clobber +fi + +echo "Upload all platform archives with:" +echo " gh release create $LIBS_VERSION $RELEASE_DIR/*.tar.bz2" diff --git a/scripts/download_libs.cmd b/scripts/download_libs.cmd new file mode 100644 index 0000000..2df359a --- /dev/null +++ b/scripts/download_libs.cmd @@ -0,0 +1,18 @@ +@echo off +REM download_libs.cmd - Windows shim: VS uses the bash script via git-bash. +REM Requires git-bash (ships with Git for Windows). Usage: +REM scripts\download_libs.cmd [platform] [-v ] [-u ] +REM With no arguments it downloads the `vs` libs (a bare run under git-bash +REM would otherwise auto-detect `msys2`). +setlocal +where bash >nul 2>&1 +if errorlevel 1 ( + echo bash not found. Install Git for Windows and run this from git-bash: + echo ./scripts/download_libs.sh vs + exit /b 1 +) +if "%~1"=="" ( + bash "%~dp0download_libs.sh" vs +) else ( + bash "%~dp0download_libs.sh" %* +) diff --git a/scripts/download_libs.sh b/scripts/download_libs.sh new file mode 100755 index 0000000..dca866e --- /dev/null +++ b/scripts/download_libs.sh @@ -0,0 +1,111 @@ +#!/usr/bin/env bash +# +# download_libs.sh - download prebuilt addon binaries from GitHub releases. +# +# Usage: +# scripts/download_libs.sh [platform] [-v ] [-u ] +# +# platform: osx | macos | ios | tvos | vs | msys2 | linux64 | +# linuxarmv6l | linuxarmv7l | linuxaarch64 | +# android | emscripten | all +# (default: auto-detected from the host machine) +# +# The platform names MUST match the folder names under libs//lib/, +# because the projectGenerator links a binary only if its path contains +# the platform token (see ofAddon::getLibsRecursively). +# +# Release asset naming convention (created with scripts/build_libs.sh): +# -libs--.tar.bz2 +# e.g. ofxMyAddon-libs-osx-1.0.0.tar.bz2 +# Each archive unpacks to libs//lib//... +# +# On Windows run this from git-bash (ships with Git for Windows). +# +set -e + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ADDON_DIR="$(dirname "$SCRIPT_DIR")" +ADDON_NAME="$(basename "$ADDON_DIR")" + +# ---------------------------------------------------------------- TODO: edit +# GitHub repo hosting the releases, and the libs version to download. +# (Flag names mirror OF's scripts/dev/download_libs.sh: -v/--version.) +# Override from the command line with -u / -v, or via a scripts/libs_version.txt file. +GITHUB_REPO="yournamehere/${ADDON_NAME}" +LIBS_VERSION="1.0.0" +# Name of the lib folder under libs/ (must contain lib//...). +LIB_NAME="necessaryLib" +# ---------------------------------------------------------------------------- + +if [ -f "$SCRIPT_DIR/libs_version.txt" ]; then + LIBS_VERSION="$(tr -d ' \t\r\n' < "$SCRIPT_DIR/libs_version.txt")" +fi + +PLATFORM="" +while [ $# -gt 0 ]; do + case "$1" in + -v|--version) LIBS_VERSION="$2"; shift 2 ;; + -u|--repo) GITHUB_REPO="$2"; shift 2 ;; + -h|--help) + sed -n '2,/^$/p' "$0"; echo "Usage: $0 [platform] [-v ] [-u ]" + exit 0 ;; + *) PLATFORM="$1"; shift ;; + esac +done + +detect_platform() { + local os arch + os="$(uname -s)" + arch="$(uname -m)" + case "$os" in + Darwin) echo "osx" ;; + MINGW*|MSYS*|CYGWIN*) echo "msys2" ;; + Linux) + case "$arch" in + x86_64) echo "linux64" ;; + armv6l) echo "linuxarmv6l" ;; + armv7l) echo "linuxarmv7l" ;; + aarch64) echo "linuxaarch64" ;; + *) echo "linux64" ;; + esac ;; + *) echo "linux64" ;; + esac +} + +if [ -z "$PLATFORM" ]; then + PLATFORM="$(detect_platform)" +fi + +ALL_PLATFORMS="osx ios tvos vs msys2 linux64 linuxarmv6l linuxarmv7l linuxaarch64 android emscripten" +if [ "$PLATFORM" = "macos" ]; then + PLATFORM="osx" # PG treats them as aliases; releases use "osx" +fi + +download_one() { + local platform="$1" + local asset="${ADDON_NAME}-libs-${platform}-${LIBS_VERSION}.tar.bz2" + local url="https://github.com/${GITHUB_REPO}/releases/download/${LIBS_VERSION}/${asset}" + echo "==> ${platform}: downloading ${url}" + mkdir -p "$ADDON_DIR/libs/$LIB_NAME" + if command -v curl >/dev/null 2>&1; then + curl -fL -o "/tmp/${asset}" "$url" + else + wget -O "/tmp/${asset}" "$url" + fi + tar -xjf "/tmp/${asset}" -C "$ADDON_DIR/libs/$LIB_NAME" + rm -f "/tmp/${asset}" + if [ ! -d "$ADDON_DIR/libs/$LIB_NAME/lib/$platform" ] && [ "$platform" != "android" ]; then + echo "WARNING: archive did not contain libs/$LIB_NAME/lib/$platform/" >&2 + fi + echo "==> ${platform}: done" +} + +if [ "$PLATFORM" = "all" ]; then + for p in $ALL_PLATFORMS; do + download_one "$p" + done +else + download_one "$PLATFORM" +fi + +echo "Libs ${LIBS_VERSION} installed for: ${PLATFORM}" diff --git a/scripts/libs_version.txt b/scripts/libs_version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/scripts/libs_version.txt @@ -0,0 +1 @@ +1.0.0