|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +buildCyanrip() { |
| 4 | + cyan_prepare |
| 5 | + build_curl |
| 6 | + build_neon |
| 7 | + build_libmusicbrainz |
| 8 | + # build_libcoverart |
| 9 | + build_ffmpeg |
| 10 | + build_cyanrip |
| 11 | +} |
| 12 | + |
| 13 | +cyan_prepare() { |
| 14 | + local rootdir="$(pwd)" |
| 15 | + CYANRIPREPODIR="${GITHUB_WORKSPACE:-$(realpath "$rootdir/..")}" |
| 16 | + CYANRIPINSTALLDIR="$(realpath "$rootdir/_install")" |
| 17 | + CYANRIPBUILDDIR="$(realpath "$rootdir/_build")" |
| 18 | + PKG_CONFIG_PATH=$CYANRIPINSTALLDIR/lib/pkgconfig:$PKG_CONFIG_PATH |
| 19 | + CPATH="$(cygpath -pm $CYANRIPINSTALLDIR/include:$MINGW_PREFIX/include)" |
| 20 | + LIBRARY_PATH="$(cygpath -pm $CYANRIPINSTALLDIR/lib:$MINGW_PREFIX/lib)" |
| 21 | + CPPFLAGS="-D_FORTIFY_SOURCE=0 -D__USE_MINGW_ANSI_STDIO=1" |
| 22 | + CFLAGS="-mthreads -mtune=generic -O2 -pipe" |
| 23 | + CXXFLAGS="${CFLAGS}" |
| 24 | + LDFLAGS="-pipe -static-libgcc -static-libstdc++" |
| 25 | + export CYANRIPREPODIR CYANRIPBUILDDIR CYANRIPINSTALLDIR PKG_CONFIG_PATH CPATH LIBRARY_PATH CPPFLAGS CFLAGS CXXFLAGS LDFLAGS |
| 26 | + mkdir -p "$CYANRIPBUILDDIR" "$CYANRIPINSTALLDIR" |
| 27 | + |
| 28 | + cyan_do_hide_all_sharedlibs |
| 29 | +} |
| 30 | + |
| 31 | +cyan_do_vcs() { |
| 32 | + local vcsURL=${1#*::} vcsFolder=$2 |
| 33 | + local vcsBranch=${vcsURL#*#} ref=origin/HEAD |
| 34 | + : "${vcsFolder:=$(basename "$vcsURL" .git)}" |
| 35 | + |
| 36 | + cd "$CYANRIPBUILDDIR" |
| 37 | + git clone --depth 1 "$vcsURL" "$vcsFolder" |
| 38 | + cd "$vcsFolder" |
| 39 | +} |
| 40 | + |
| 41 | +cyan_do_hide_all_sharedlibs() { |
| 42 | + local files |
| 43 | + files="$(find /mingw{32,64}/lib /mingw{32/i686,64/x86_64}-w64-mingw32/lib -name "*.dll.a" 2> /dev/null)" |
| 44 | + local tomove=() |
| 45 | + for file in $files; do |
| 46 | + [[ -f ${file%*.dll.a}.a ]] && tomove+=("$file") |
| 47 | + done |
| 48 | + printf '%s\0' "${tomove[@]}" | xargs -0ri mv -f '{}' '{}.dyn' |
| 49 | +} |
| 50 | + |
| 51 | +cyan_hide_files() { |
| 52 | + for opt; do [[ -f $opt ]] && mv -f "$opt" "$opt.bak"; done |
| 53 | +} |
| 54 | +cyan_hide_conflicting_libs() { |
| 55 | + local -a installed |
| 56 | + mapfile -t installed < <(find "$CYANRIPINSTALLDIR/lib" -maxdepth 1 -name "*.a") |
| 57 | + cyan_hide_files "${installed[@]//$CYANRIPINSTALLDIR/$MINGW_PREFIX}" |
| 58 | +} |
| 59 | + |
| 60 | +cyan_do_separate_confmakeinstall() { |
| 61 | + rm -rf ./_build && |
| 62 | + mkdir _build && cd _build && |
| 63 | + ../configure --disable-shared --enable-static --prefix="$CYANRIPINSTALLDIR" "$@" && |
| 64 | + make && make install |
| 65 | +} |
| 66 | + |
| 67 | +cyan_do_cmakeinstall() { |
| 68 | + PKG_CONFIG=pkg-config cmake -B _build -G Ninja -DBUILD_SHARED_LIBS=off \ |
| 69 | + -DCMAKE_INSTALL_PREFIX="$CYANRIPINSTALLDIR" -DUNIX=on \ |
| 70 | + -DCMAKE_FIND_ROOT_PATH="$(cygpath -pm "$CYANRIPINSTALLDIR:$MINGW_PREFIX:$MINGW_PREFIX/$MINGW_CHOST")" \ |
| 71 | + -DCMAKE_PREFIX_PATH="$(cygpath -pm "$CYANRIPINSTALLDIR:$MINGW_PREFIX:$MINGW_PREFIX/$MINGW_CHOST")" \ |
| 72 | + -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ |
| 73 | + -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ |
| 74 | + -DCMAKE_BUILD_TYPE=Release "$@" && |
| 75 | + ninja -C _build && ninja -C _build install |
| 76 | +} |
| 77 | + |
| 78 | +build_curl() { |
| 79 | + cyan_do_vcs "https://github.com/curl/curl.git" && |
| 80 | + autoreconf -fi && |
| 81 | + sed -ri "s;(^SUBDIRS = lib) src (include) scripts;\1 \2;" Makefile.in && |
| 82 | + CPPFLAGS+=" -DNGHTTP2_STATICLIB" \ |
| 83 | + cyan_do_separate_confmakeinstall --with-{winssl,winidn,nghttp2} \ |
| 84 | + --without-{ssl,gnutls,mbedtls,libssh2,random,ca-bundle,ca-path,librtmp,brotli,debug,libpsl} |
| 85 | +} |
| 86 | + |
| 87 | +build_neon() { |
| 88 | + cyan_do_vcs "https://github.com/notroj/neon.git" && |
| 89 | + ./autogen.sh && |
| 90 | + cyan_do_separate_confmakeinstall --disable-{nls,debug,webdav} |
| 91 | +} |
| 92 | + |
| 93 | +build_libmusicbrainz() { |
| 94 | + cyan_do_vcs "https://github.com/wiiaboo/libmusicbrainz.git" && |
| 95 | + cyan_do_cmakeinstall |
| 96 | +} |
| 97 | + |
| 98 | +build_libcoverart() { |
| 99 | + cyan_do_vcs "https://github.com/wiiaboo/libcoverart.git" && |
| 100 | + cyan_do_cmakeinstall |
| 101 | +} |
| 102 | + |
| 103 | +build_ffmpeg() { |
| 104 | + cyan_do_vcs "https://git.ffmpeg.org/ffmpeg.git" |
| 105 | + cyan_do_separate_confmakeinstall --pkg-config-flags=--static \ |
| 106 | + --disable-{programs,devices,filters,decoders,hwaccels,encoders,muxers} \ |
| 107 | + --disable-{debug,protocols,demuxers,parsers,doc,swscale,postproc,network} \ |
| 108 | + --disable-{avdevice,autodetect} \ |
| 109 | + --disable-bsfs --enable-protocol=file \ |
| 110 | + --enable-encoder=flac,tta,aac,wavpack,alac,pcm_s16le,pcm_s32le \ |
| 111 | + --enable-muxer=flac,tta,ipod,wv,mp3,opus,ogg,wav,pcm_s16le,pcm_s32le \ |
| 112 | + --enable-parser=png,mjpeg --enable-decoder=mjpeg,png \ |
| 113 | + --enable-demuxer=image2,png_pipe,bmp_pipe \ |
| 114 | + --enable-{bzlib,zlib,lzma,iconv} \ |
| 115 | + --enable-filter=hdcd \ |
| 116 | + --enable-lib{mp3lame,vorbis,opus} \ |
| 117 | + --enable-encoder={libmp3lame,libvorbis,libopus} |
| 118 | +} |
| 119 | + |
| 120 | +build_cyanrip() { |
| 121 | + cd "$CYANRIPREPODIR" |
| 122 | + cyan_hide_conflicting_libs |
| 123 | + PKG_CONFIG=pkg-config \ |
| 124 | + CFLAGS+=" -DLIBXML_STATIC -DCURL_STATICLIB $(printf ' -I%s' "$(cygpath -m "$CYANRIPINSTALLDIR/include")")" \ |
| 125 | + LDFLAGS+="$(printf ' -L%s' "$(cygpath -m "$CYANRIPINSTALLDIR/lib")")" \ |
| 126 | + meson build --default-library=static --buildtype=release --prefix="$CYANRIPINSTALLDIR" --backend=ninja && |
| 127 | + ninja -C build && strip --strip-all build/src/cyanrip.exe -o cyanrip.exe |
| 128 | +} |
| 129 | + |
| 130 | +cd "$(dirname "$0")" |
| 131 | +buildCyanrip |
0 commit comments