From 9ee32f91b07cabe60d5aefca17b8ee81dc9ac668 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 31 Mar 2020 15:10:17 +0000 Subject: [PATCH] build-sys: Only build schema if source changed Previously we were generating the Go schema source each time `make` is run, which forces the Go compiler to do more work and slows down iteration. `Makefile` rules are designed for this, so use that instead. --- mantle/Makefile | 7 +++++-- mantle/build | 13 ++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mantle/Makefile b/mantle/Makefile index 2a9f044771..c9939de072 100644 --- a/mantle/Makefile +++ b/mantle/Makefile @@ -4,8 +4,11 @@ DESTDIR ?= ARCH:=$(shell uname -m) .PHONY: build test vendor clean -build: - ./build +build: cosa/cosa_v1.go + ./build cmd/* + +cosa/cosa_v1.go: ../src/schema/v1.json Makefile + ./build schema .PHONY: install install: bin/ore bin/kola bin/plume bin/kolet diff --git a/mantle/build b/mantle/build index c2e6a61efd..7192f6cebc 100755 --- a/mantle/build +++ b/mantle/build @@ -7,7 +7,7 @@ cd $(dirname $0) source ./env if [[ $# -eq 0 ]]; then - set -- cmd/* + set -- cmd/* schema fi version=$(git describe --tags --always --dirty) @@ -73,8 +73,11 @@ cross_build() { done } -schema_generate -for cmd in "$@"; do - cmd=$(basename "${cmd}") - host_build "${cmd}" +for arg in "$@"; do + if [ "${arg}" = "schema" ]; then + schema_generate + else + cmd=$(basename "${arg}") + host_build "${cmd}" + fi done