From 59cb21e3b6b4e7be3104152eb990a54bb2fced88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 22 Jul 2022 16:36:23 +0200 Subject: [PATCH] Makefile: add `tools` targets to download FFmpeg Four Makefile targets have been added: - `tools`, which evokes the other three - `tools-linux`, `tools-darwin`, `tools-windows`, download FFmpeg and put the `ffmpeg` executables into `./tools/ffmpeg-{OS}-{ARCH}`. Downloaded tarball/ZIP files are stored in `tools/download`, and won't be re-downloaded if they already exist. --- .gitignore | 1 + Makefile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/.gitignore b/.gitignore index a6e60789..9cfa4e14 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,7 @@ web/manager-api/dist/ web/static/ web/flamenco-io-site/public/ /dist/ +/tools/ # IDE related stuff *.DS_Store diff --git a/Makefile b/Makefile index cac3ba70..b88bab09 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,11 @@ WEB_STATIC=web/static # Prevent any dependency that requires a C compiler, i.e. only work with pure-Go libraries. export CGO_ENABLED=0 +# FFmpeg version to bundle. +FFMPEG_VERSION=5.0.1 +TOOLS=./tools +TOOLS_DOWNLOAD=./tools/download + all: application # Install generators and build the software. @@ -191,6 +196,50 @@ site: --exclude .htaccess \ --delete-after +# Download & install FFmpeg in the 'tools' directory for supported platforms. +.PHONY: tools +tools: + $(MAKE) -s tools-linux + $(MAKE) -s tools-darwin + $(MAKE) -s tools-windows + +FFMPEG_PACKAGE_LINUX=$(TOOLS_DOWNLOAD)/ffmpeg-$(FFMPEG_VERSION)-linux-amd64-static.tar.xz +FFMPEG_PACKAGE_DARWIN=$(TOOLS_DOWNLOAD)/ffmpeg-$(FFMPEG_VERSION)-darwin-amd64.zip +FFMPEG_PACKAGE_WINDOWS=$(TOOLS_DOWNLOAD)/ffmpeg-$(FFMPEG_VERSION)-windows-amd64.zip + +.PHONY: tools-linux +tools-linux: + [ -e $(FFMPEG_PACKAGE_LINUX) ] || curl \ + --create-dirs -o $(FFMPEG_PACKAGE_LINUX) \ + https://johnvansickle.com/ffmpeg/releases/ffmpeg-$(FFMPEG_VERSION)-amd64-static.tar.xz + tar xvf \ + $(FFMPEG_PACKAGE_LINUX) \ + ffmpeg-$(FFMPEG_VERSION)-amd64-static/ffmpeg \ + --strip-components=1 + mv ffmpeg $(TOOLS)/ffmpeg-linux-amd64 + +.PHONY: tools-darwin +tools-darwin: + [ -e $(FFMPEG_PACKAGE_DARWIN) ] || curl \ + --create-dirs -o $(FFMPEG_PACKAGE_DARWIN) \ + https://evermeet.cx/ffmpeg/ffmpeg-$(FFMPEG_VERSION).zip + unzip $(FFMPEG_PACKAGE_DARWIN) + mv ffmpeg $(TOOLS)/ffmpeg-darwin-amd64 + +.PHONY: tools-windows +tools-windows: + [ -e $(FFMPEG_PACKAGE_WINDOWS) ] || curl \ + --create-dirs -o $(FFMPEG_PACKAGE_WINDOWS) \ + https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-$(FFMPEG_VERSION)-essentials_build.zip + unzip -j $(FFMPEG_PACKAGE_WINDOWS) ffmpeg-5.0.1-essentials_build/bin/ffmpeg.exe -d . + mv ffmpeg.exe $(TOOLS)/ffmpeg-windows-amd64.exe + +# https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-$(FFMPEG_VERSION)-essentials_build.zip +# +# cd tools-download; + + + package: flamenco-manager flamenco-worker addon-packer rm -rf dist-build mkdir -p dist-build