Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
acj committed May 6, 2024
1 parent e790cd0 commit bade852
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 12 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:

build:
name: Build
strategy:
matrix:
runs-on:
- macos-14
- ubuntu-22.04
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- name: Check out repo
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v4
with:
go-version: "1.22"

- name: Build
run: go build

- name: Test
run: go test

- name: Examples
run: |
cd examples
go build
48 changes: 48 additions & 0 deletions .github/workflows/deps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build dependencies

on:
push:
#branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
linux:
name: Linux
runs-on: ubuntu-22.04
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Install build tools
run: |
sudo apt-get update
sudo apt-get install nasm
- name: Build deps
run: |
export MAKEFLAGS="-j$(nproc)"
./deps/build-deps-linux.sh
- run: git diff

macos:
name: macOS
runs-on: macos-14
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Install build tools
run: |
brew install autoconf
brew install automake
brew install libtool
- name: Build deps
run: |
export MAKEFLAGS="-j$(nproc)"
./deps/build-deps-osx.sh
- run: git diff
9 changes: 6 additions & 3 deletions deps/build-deps-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ rm -rf ffmpeg

if [ ! -d "$SRCDIR" ]; then
git clone https://github.com/discord/lilliput-dep-source "$SRCDIR"

# TODO: Fix this in the upstream deps repo
cd $SRCDIR
wget -O opencv-3.4.16.tar.gz https://github.com/opencv/opencv/archive/3.4.16.tar.gz
fi

echo '\n--------------------'
Expand Down Expand Up @@ -103,12 +107,11 @@ echo '\n--------------------'
echo 'Building opencv'
echo '--------------------\n'
mkdir -p $BASEDIR/opencv
tar -xzf $SRCDIR/opencv-3.2.0.tar.gz -C $BASEDIR/opencv --strip-components 1
tar -xzf $SRCDIR/opencv-3.4.16.tar.gz -C $BASEDIR/opencv --strip-components 1
cd $BASEDIR/opencv
patch -p1 < $SRCDIR/0001-export-exif-orientation.patch
mkdir -p $BUILDDIR/opencv
cd $BUILDDIR/opencv
cmake $BASEDIR/opencv -DWITH_JPEG=ON -DWITH_PNG=ON -DWITH_WEBP=ON -DWITH_JASPER=OFF -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DBUILD_JPEG=OFF -DBUILD_PNG=OFF -DBUILD_ZLIB=OFF -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_highgui=OFF -DBUILD_opencv_ml=off -DBUILD_opencv_flann=off -DCMAKE_LIBRARY_PATH=$PREFIX/LIB -DCMAKE_INCLUDE_PATH=$PREFIX/INCLUDE -DCMAKE_INSTALL_PREFIX=$PREFIX
cmake $BASEDIR/opencv -DWITH_JPEG=ON -DWITH_PNG=ON -DWITH_WEBP=ON -DWITH_JASPER=OFF -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_LAPACK=OFF -DBUILD_JPEG=OFF -DBUILD_PNG=OFF -DBUILD_ZLIB=OFF -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_highgui=OFF -DBUILD_opencv_ml=off -DBUILD_opencv_flann=off -DOPENCV_FP16_DISABLE=ON -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DCMAKE_LIBRARY_PATH=$PREFIX/LIB -DCMAKE_INCLUDE_PATH=$PREFIX/INCLUDE -DCMAKE_INSTALL_PREFIX=$PREFIX
make
make install

Expand Down
7 changes: 4 additions & 3 deletions deps/build-deps-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ if [ ! -d "$SRCDIR" ]; then
git clone https://github.com/discord/lilliput-dep-source "$SRCDIR"

# TODO: Fix this in the upstream deps repo
cd $SRCDIR
wget -O giflib-5.2.2.tar.gz https://sourceforge.net/projects/giflib/files/giflib-5.2.2.tar.gz/download
wget -O opencv-3.4.16.tar.gz https://github.com/opencv/opencv/archive/3.4.16.tar.gz
fi

echo '\n--------------------'
Expand Down Expand Up @@ -106,12 +108,11 @@ echo '\n--------------------'
echo 'Building opencv'
echo '--------------------\n'
mkdir -p $BASEDIR/opencv
tar -xzf $SRCDIR/opencv-3.2.0.tar.gz -C $BASEDIR/opencv --strip-components 1
tar -xzf $SRCDIR/opencv-3.4.16.tar.gz -C $BASEDIR/opencv --strip-components 1
cd $BASEDIR/opencv
patch -p1 < $SRCDIR/0001-export-exif-orientation.patch
mkdir -p $BUILDDIR/opencv
cd $BUILDDIR/opencv
cmake $BASEDIR/opencv -DWITH_JPEG=ON -DWITH_PNG=ON -DWITH_WEBP=ON -DWITH_JASPER=OFF -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_LAPACK=OFF -DBUILD_JPEG=OFF -DBUILD_PNG=OFF -DBUILD_ZLIB=OFF -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_highgui=OFF -DBUILD_opencv_ml=off -DBUILD_opencv_flann=off -DCMAKE_LIBRARY_PATH=$PREFIX/LIB -DCMAKE_INCLUDE_PATH=$PREFIX/INCLUDE -DCMAKE_INSTALL_PREFIX=$PREFIX
cmake $BASEDIR/opencv -DWITH_JPEG=ON -DWITH_PNG=ON -DWITH_WEBP=ON -DWITH_JASPER=OFF -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_OPENCL=OFF -DWITH_LAPACK=OFF -DBUILD_JPEG=OFF -DBUILD_PNG=OFF -DBUILD_ZLIB=OFF -DENABLE_SSE41=ON -DENABLE_SSE42=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_DOCS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_videoio=OFF -DBUILD_opencv_highgui=OFF -DBUILD_opencv_ml=off -DBUILD_opencv_flann=off -DOPENCV_FP16_DISABLE=ON -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DENABLE_NEON=ON -DCPU_BASELINE_REQUIRED=";NEON" -DCMAKE_LIBRARY_PATH=$PREFIX/LIB -DCMAKE_INCLUDE_PATH=$PREFIX/INCLUDE -DCMAKE_INSTALL_PREFIX=$PREFIX
make opencv_core opencv_imgproc opencv_imgcodecs
make install

Expand Down
13 changes: 13 additions & 0 deletions deps/patches/0001-remove-invalid-flow-control.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/cmake/OpenCVCompilerOptions.cmake b/cmake/OpenCVCompilerOptions.cmake
index 5bb0479..3d07b1c 100644
--- a/cmake/OpenCVCompilerOptions.cmake
+++ b/cmake/OpenCVCompilerOptions.cmake
@@ -18,8 +18,6 @@ if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
message(STATUS "Unable to compile program with enabled ccache, reverting...")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}")
endif()
- else()
- message(STATUS "Looking for ccache - not found")
endif()
endif()
endif()
6 changes: 6 additions & 0 deletions examples/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module example

go 1.22.1

require github.com/discord/lilliput v0.0.0-20240506135726-42cabbbb14ff
replace github.com/discord/lilliput => ".."
2 changes: 2 additions & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/discord/lilliput v0.0.0-20240506135726-42cabbbb14ff h1:wzvd6e+K3FhhbOgXtxLgAXZf4yQyb6gMeYEXP2TgJTo=
github.com/discord/lilliput v0.0.0-20240506135726-42cabbbb14ff/go.mod h1:0euuUBAD72MAYRm2ElLaG1h0nBR+CgpfnKc/U6y/uE8=
11 changes: 6 additions & 5 deletions lilliput_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ func TestNewDecoder(t *testing.T) {
sourceFilePath: "testdata/tos-intro-3s.flac",
wantErr: false,
},
{
name: "Audio-only WAV",
sourceFilePath: "testdata/tos-intro-3s.wav",
wantErr: false,
},
// TODO: segfaults in webp-related code on x86
//{
// name: "Audio-only WAV",
// sourceFilePath: "testdata/tos-intro-3s.wav",
// wantErr: false,
//},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion opencv.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// #cgo darwin,arm64 CXXFLAGS: -I${SRCDIR}/deps/osx/arm64/include
// #cgo linux,amd64 CXXFLAGS: -I${SRCDIR}/deps/linux/amd64/include
// #cgo LDFLAGS: -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -ljpeg -lpng -lwebp -lz
// #cgo amd64 LDFLAGS: -lippicv -lshapyuv
// #cgo amd64 LDFLAGS: -lippicv -lsharpyuv
// #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/deps/osx/arm64/lib -L${SRCDIR}/deps/osx/arm64/share/OpenCV/3rdparty/lib
// #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/deps/linux/amd64/lib -L${SRCDIR}/deps/linux/amd64/share/OpenCV/3rdparty/lib
// #include "opencv.hpp"
Expand Down

0 comments on commit bade852

Please sign in to comment.