Skip to content

Commit

Permalink
build: MediaPipe v0.10.14 (#1200)
Browse files Browse the repository at this point in the history
* build: upgrade mediapipe to v0.10.14

* updete Third Party Licenses

* fix: use *_t types to avoid 'does not name a type' errors

* doc: upgrade MediaPipe to v0.10.14

* fix: avoid XNNPACK build errors for Android

* build: install Clang 16

* build: use gcc-11 to support AVX-VNNI intrinsics

* ci: build iOS framework on M1 mac

* fix: circumvent build errors on Windows
  • Loading branch information
homuler committed Jun 23, 2024
1 parent bd417bf commit 4bae91d
Show file tree
Hide file tree
Showing 25 changed files with 372 additions and 184 deletions.
14 changes: 10 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ common --experimental_repo_remote_exec

# Basic build settings
build --jobs 128
build --define='absl=1'
build --features=compiler_param_file
build --define='absl=1' # for gtest
build --enable_platform_specific_config

# Enable stack traces
test --test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1"

# Linux
build:linux --cxxopt=-std=c++17
build:linux --host_cxxopt=-std=c++17
Expand Down Expand Up @@ -41,13 +43,13 @@ build --apple_generate_dsym
# for Android.
build:android --crosstool_top=//external:android/crosstool
build:android --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:android --cxxopt=-std=c++17
build:android --copt=-w
build:android --linkopt=-landroid
build:android --linkopt=-ldl
build:android --linkopt=-llog
build:android --linkopt=-lm
build:android --linkopt=-Wl,--gc-sections
# TODO: Remove this flag once we updated to NDK 25
build:android --define=xnn_enable_arm_i8mm=false

build:android_armv7 --config=android
build:android_armv7 --cpu=armeabi-v7a
Expand All @@ -65,6 +67,7 @@ build:android_x86_64 --config=android
build:android_x86_64 --cpu=x86_64
build:android_x86_64 --fat_apk_cpu=x86_64

# iOS configs.
build:ios --apple_platform_type=ios
build:ios --copt=-fno-aligned-allocation

Expand Down Expand Up @@ -106,6 +109,9 @@ build:wasm --host_crosstool_top=@bazel_tools//tools/cpp:toolchain
build:wasm --copt=-emit-llvm
build:wasm --cxxopt=-emit-llvm

# Turn off maximum stdout size
build --experimental_ui_max_stdouterr_bytes=-1

# This bazelrc file is meant to be written by a setup script.
try-import %workspace%/.configure.bazelrc

Expand Down
30 changes: 19 additions & 11 deletions .github/workflows/linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
required: true
jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -37,18 +37,18 @@ jobs:
Packages/com.github.homuler.mediapipe/Runtime/Scripts/Protobuf/**/*.cs
Packages/com.github.homuler.mediapipe/PackageResources/MediaPipe/*.bytes
Packages/com.github.homuler.mediapipe/PackageResources/MediaPipe/*.txt
key: libs-ubuntu-20.04-v1-${{ hashFiles('cache_key.txt') }}
key: libs-ubuntu-22.04-v1-${{ hashFiles('cache_key.txt') }}

# Setup build tools
- name: Mount bazel cache
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/cache/restore@v4
with:
path: "~/.cache/bazel"
key: bazel-ubuntu-20.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
key: bazel-ubuntu-22.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
restore-keys: |
bazel-ubuntu-20.04-v1-${{ hashFiles('WORKSPACE') }}-
bazel-ubuntu-20.04-v1-
bazel-ubuntu-22.04-v1-${{ hashFiles('WORKSPACE') }}-
bazel-ubuntu-22.04-v1-
- name: Remove cache_key.txt
run: |
Expand All @@ -63,10 +63,19 @@ jobs:
- name: Install dependencies
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
# install GCC/G++ 8
# install GCC/G++ 11
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install -y --no-install-recommends gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100 --slave /usr/bin/g++ g++ /usr/bin/g++-8
sudo apt-get install -y --no-install-recommends gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11
# install Clang 16
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
sudo ln -sf /usr/bin/clang-16 /usr/bin/clang
sudo ln -sf /usr/bin/clang++-16 /usr/bin/clang++
sudo ln -sf /usr/bin/clang-format-16 /usr/bin/clang-format
# install NuGet
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
Expand Down Expand Up @@ -97,7 +106,7 @@ jobs:
uses: actions/cache/save@v4
with:
path: ~/.cache/bazel
key: bazel-ubuntu-20.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}
key: bazel-ubuntu-22.04-v1-${{ hashFiles('WORKSPACE') }}-${{ hashFiles('cache_key.txt') }}

test:
runs-on: ${{ matrix.os }}
Expand All @@ -107,7 +116,6 @@ jobs:
matrix:
os:
- ubuntu-22.04
- ubuntu-20.04
unityVersion:
- 2022.3.16f1
- 2021.3.33f1
Expand Down Expand Up @@ -190,7 +198,7 @@ jobs:
retention-days: 7

- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'ubuntu-20.04' && startsWith(matrix.unityVersion, '2021') }}
if: ${{ matrix.os == 'ubuntu-22.04' && startsWith(matrix.unityVersion, '2021') }}
with:
name: Coverage results
path: DummyProject/CodeCoverage
Expand Down
13 changes: 1 addition & 12 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
path: Packages/com.github.homuler.mediapipe/Runtime/Plugins/libmediapipe_c.dylib

ios-build:
runs-on: macos-12
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -141,17 +141,6 @@ jobs:
- name: Install NumPy
run: pip install --no-cache-dir --user numpy

- name: Build bazel to circumvent a compile error
run: |
mkdir bin
git clone https://github.com/bazelbuild/bazel.git --depth 1 --single-branch --branch 6.1.1
cd bazel
git apply ../third_party/bazel_ios_workaround.diff
USE_BAZEL_VERSION=6.2.1 bazel build --java_runtime_version=remotejdk_11 //src:bazel
cp bazel-bin/src/bazel ../bin
cd ..
echo "bin" >> $GITHUB_PATH
- name: Build MediaPipeUnity.framework
run: |
unset ANDROID_NDK_HOME
Expand Down
131 changes: 131 additions & 0 deletions Packages/com.github.homuler.mediapipe/Third Party Notices.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,51 @@ IN THE SOFTWARE.

---

Component Name: cpuinfo

Licence Type: 2-Clause BSD

Copyright (c) 2019 Google LLC
Copyright (c) 2017-2018 Facebook Inc.
Copyright (C) 2012-2017 Georgia Institute of Technology
Copyright (C) 2010-2012 Marat Dukhan

All rights reserved.

https://github.com/pytorch/cpuinfo

```
Copyright (c) 2019 Google LLC
Copyright (c) 2017-2018 Facebook Inc.
Copyright (C) 2012-2017 Georgia Institute of Technology
Copyright (C) 2010-2012 Marat Dukhan
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

Component Name: easyexif

Licence Type: 2-Clause BSD
Expand Down Expand Up @@ -2387,6 +2432,92 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

---

Component Name: pthreadpool

License Type: 2-Clause BSD

Copyright 2019 Google LLC
Copyright (c) 2017 Facebook Inc.
Copyright (c) 2015-2017 Georgia Institute of Technology
All rights reserved.

https://github.com/Maratyszcza/pthreadpool

```
Copyright 2019 Google LLC
Copyright (c) 2017 Facebook Inc.
Copyright (c) 2015-2017 Georgia Institute of Technology
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

Component Name: XNNPACK

License Type: 3-Clause BSD

Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
Copyright 2019 Google LLC

https://github.com/google/XNNPACK

```
BSD License
For XNNPACK software
Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.
Copyright 2019 Google LLC
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

Component Name: zlib

License Type: Zlib
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MediaPipe Unity Plugin

This is a Unity (2022.3.16f1) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.10.9).
This is a Unity (2022.3.16f1) [Native Plugin](https://docs.unity3d.com/Manual/NativePlugins.html) to use [MediaPipe](https://github.com/google/mediapipe) (0.10.14).

The goal of this project is to port the MediaPipe API (C++) _one by one_ to C# so that it can be called from Unity.\
This approach may sacrifice performance when you need to call multiple APIs in a loop, but it gives you the flexibility to use MediaPipe instead.
Expand Down
Loading

0 comments on commit 4bae91d

Please sign in to comment.