From 14480732a8194c8e1fe54ef83e67c3838be276bd Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Wed, 13 May 2020 00:17:33 -0400 Subject: [PATCH] make: Add proper dependency logic to build/release As mentioned in the top comment, building webpack take both over a minute on my development laptop and gets my fans spinning real good. So for cutting a release where no public content has changed, it's reallllly painful to have to sit through that! (ok, I exaggerate, but my hobby time is precious!) Thankfully, this is exactly what make was built for -- only building that which has changed. Throw in a couple `find`'s and some dependency magic with timestamp files and boom, we don't have to rebuild webpack anymore! --- .gitignore | 1 + Makefile | 23 ++++++++++++++++++++--- build.sh | 9 --------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 8366403..3ddb444 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ public/asset tags /build/ /build.*/ +.public.ts diff --git a/Makefile b/Makefile index cc6bc2b..538a5b3 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,8 @@ +# Rebuilding the webpack for a server-only release is a painful +# few minutes on my poor old thinkpad. We can do better +PUBLIC_FILES := $(shell find public -type f) +LIB_FILES := $(shell find lib -type f) + .PHONY: all all: test tags @@ -10,12 +15,24 @@ test: perl -c gloat.pl perl t/Rules.t -.PHONY: release -release: test +# If no public files have changed, don't rebuild the webpack! +# We make this timestamp file the dependency for build to +# ensure we don't do it too often... +.public.ts: $(PUBLIC_FILES) ./build.sh + touch .public.ts + +# Only rebuild if any of public/ or the Perl stuff has changed +build: .public.ts $(LIB_FILES) gloat.pl + mkdir -p build + cp -a gloat.pl public lib build + @echo ">>> Build Success! <<<" + +.PHONY: release +release: build test scp -r build/* www@euchre.live:/var/www/euchre-live ssh www@euchre.live sh /var/www/deploy.sh .PHONY: clean clean: - rm -rf build build.1* + rm -rf build diff --git a/build.sh b/build.sh index 64310f8..529d909 100755 --- a/build.sh +++ b/build.sh @@ -15,12 +15,3 @@ export MOJO_WEBPACK_BUILD=1 # Run an effectively no-op (non daemonizing) command to kick it off ./gloat.pl routes - -# Make the build directory -[ -d "build" ] && mv build build.`date +%s` -mkdir build -cp -a public lib gloat.pl build - -echo "---------------------------------------------------------------" -echo " Build Success!" -echo "---------------------------------------------------------------" -- libgit2 1.1.1