Skip to content

Instantly share code, notes, and snippets.

@xfangfang
Last active July 23, 2023 21:01
Show Gist options
  • Save xfangfang/c253580fb036c73549cbd237634c6d52 to your computer and use it in GitHub Desktop.
Save xfangfang/c253580fb036c73549cbd237634c6d52 to your computer and use it in GitHub Desktop.
Build wiliwili on Switchroot Ubuntu

wiliwili is a third-party bilibili client.
Switchroot is a group for open-source development on the Nintendo Switch.

Steps

We use the ffmpeg and mpv from the switchroot team to get hardware decoding support, but you can always switch to the main branches of ffmpeg and mpv to play videos using software decoding

1. Run L4T Megascript for a initial environment

2. Install dependencies

sudo apt install libgnutls28-dev libass-dev libv4l-dev \
  libwebp-dev libboost-filesystem-dev libcurl4-openssl-dev

3. Build ffmpeg

git clone --depth=1 https://gitlab.com/switchroot/switch-l4t-multimedia/FFmpeg.git

cd FFmpeg
./configure \
  --enable-shared --disable-static \
  --extra-cflags='-march=armv8-a+simd+crypto+crc -mtune=cortex-a57 -I/usr/src/jetson_multimedia_api/include' \
  --extra-ldflags='-L/usr/lib/aarch64-linux-gnu/tegra -L/usr/lib/aarch64-linux-gnu/tegra' \
  --extra-libs='-lpthread -lm -lnvbuf_utils -lv4l2' \
  --ld=g++ --enable-gpl --enable-gnutls --enable-libv4l2 \
  --enable-opengl --enable-nvv4l2 --disable-doc --enable-asm \
  --enable-neon --enable-zlib --enable-demuxer=hls --disable-avdevice \
  --disable-protocols --enable-protocol='file,http,tcp,udp,rtmp,hls,https,tls,ftp' \
  --disable-encoders --disable-programs

make -j4

# install to /usr/local/lib
sudo make install

4. Build mpv

git clone --depth=1 https://gitlab.com/switchroot/switch-l4t-multimedia/mpv.git

cd mpv
export LDFLAGS="-L/usr/lib/aarch64-linux-gnu/tegra -L/usr/lib/aarch64-linux-gnu $LDFLAGS"

./bootstrap.py
./waf configure --disable-libmpv-static --enable-libmpv-shared --disable-libavdevice --disable-cplayer
./waf build

# install to /usr/local/lib
sudo ./waf install

5. Build wiliwili

git clone --recursive https://github.com/xfangfang/wiliwili.git

cd wiliwili
mkdir build && cd build
cmake -DPLATFORM_DESKTOP=ON -DCMAKE_BUILD_TYPE=Release -DUSE_BOOST_FILESYSTEM=ON \
  -DCMAKE_CXX_FLAGS="-Wno-error=pedantic" ..
make wiliwili -j4

# test
LD_LIBRARY_PATH=/usr/local/lib ./wiliwili

Bundle AppImage

# build wiliwili with custom resources dir
cd build
cmake -DPLATFORM_DESKTOP=ON -DCMAKE_BUILD_TYPE=Release -DUSE_BOOST_FILESYSTEM=ON \
  -DCMAKE_CXX_FLAGS="-Wno-error=pedantic" -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL=ON \
  -DCUSTOM_RESOURCES_DIR=./share/wiliwili ..
make install DESTDIR=AppDir
# add AppRun/desktop/appIcon
ARCH="$(uname -m)"
wget "https://github.com/AppImage/AppImageKit/releases/download/13/AppRun-${ARCH}" -O ./AppDir/AppRun
chmod 777 ./AppDir/AppRun
cp ./AppDir/usr/share/icons/hicolor/scalable/apps/cn.xfangfang.wiliwili.svg ./AppDir
cp ./AppDir/usr/share/applications/cn.xfangfang.wiliwili.desktop ./AppDir
# copy dependencies
wget 'https://raw.githubusercontent.com/AppImage/pkg2appimage/f2df956789f36204213876c96500c8b05595e43b/excludelist' -O - |
      sed -e 's/[ ]*[#].*//' |
      sed -e 's/[.]/[.]/g' |
      grep -v '^$' |
      sed -e 's/^/.*/' -e 's/$/.*/' > excludelist
    printf -- '.*linux.*vdso.*\n' >> excludelist
    printf 'Excluding the following objects:\n'
    cat excludelist

rsync -L -v -r \
  $(  LD_LIBRARY_PATH=/usr/local/lib ldd ./AppDir/usr/bin/wiliwili | 
     grep '=>' | 
     sed -e 's@.*=> @@' -e 's@ (.*@@' |
     grep -v -f excludelist
  ) \
  ./AppDir/usr/lib/
# test
./AppDir/AppRun
# bundle
wget "https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-${ARCH}.AppImage"
chmod 777 ./appimagetool-${ARCH}.AppImage
./appimagetool-aarch64.AppImage --appimage-extract
./squashfs-root/AppRun -v ./AppDir

Acknowledgement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment