Skip to content

Commit

Permalink
Module-ify lilliput (#75)
Browse files Browse the repository at this point in the history
Replace dep symlinks with copies of the target

Go modules don't handle symlinks well due to
golang/go#39417.

This hacky fix works around the issue by replacing symlinks with regular
files.
  • Loading branch information
iredelmeier authored Aug 15, 2020
1 parent dd93dff commit 59cd2e5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions deps/build-deps-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ cd $BUILDDIR/ffmpeg
$BASEDIR/ffmpeg/configure --prefix=$PREFIX --disable-doc --disable-programs --disable-everything --enable-demuxer=mov --enable-demuxer=matroska --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=vp9 --enable-decoder=vp8 --enable-decoder=flac --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=vorbis --disable-iconv --disable-cuda --disable-cuvid --disable-nvenc --disable-xlib
make
make install

# Since go modules don't currently download symlinked files
# (see https://github.com/golang/go/issues/39417)
# we replace symlinks with copies of the target.
# We use a `find -exec` with a separate file because POSIX sh
# is that much more limited than bash.
find "$PREFIX" -type l -exec "${BASEDIR}/copy-symlink-target.sh" {} \;
7 changes: 7 additions & 0 deletions deps/build-deps-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ cd $BUILDDIR/ffmpeg
$BASEDIR/ffmpeg/configure --prefix=$PREFIX --disable-doc --disable-programs --disable-everything --enable-demuxer=mov --enable-demuxer=matroska --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-decoder=mpeg4 --enable-decoder=h264 --enable-decoder=vp9 --enable-decoder=vp8 --enable-decoder=flac --enable-decoder=mp3 --enable-decoder=aac --enable-decoder=vorbis --disable-iconv
make
make install

# Since go modules don't currently download symlinked files
# (see https://github.com/golang/go/issues/39417)
# we replace symlinks with copies of the target.
# We use a `find -exec` with a separate file because POSIX sh
# is that much more limited than bash.
find "$PREFIX" -type l -exec "${BASEDIR}/copy-symlink-target.sh" {} \;
13 changes: 13 additions & 0 deletions deps/copy-symlink-target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -eu

main() {
symlink="$1"
target="$(readlink -f "$symlink")"

rm "$symlink"
cp "$target" "$symlink"
}

main "$1"
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/discordapp/lilliput

go 1.15
1 change: 1 addition & 0 deletions package.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package lilliput // import "github.com/discordapp/lilliput"

0 comments on commit 59cd2e5

Please sign in to comment.