From 42d3cef11bd9a84d11eb48a4ff9686d2e0ce5436 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Fri, 18 Jan 2019 20:36:11 +0000 Subject: Sanity check to run the Make with proper group permissions If the `./for-group' script is not used properly, it can lead to the whole pipeline being re-run. Therefore it is important to do a sanity check immediately at the start of Make's processing and inform the user if there is a problem. With this commit, `./for-group' exports the `reproducible_paper_for_group' variable which is used by both the initial `./configure' script, and later in each call to Make. The `./configure' script will use it to write a value in `reproduce/config/pipeline/LOCAL.mk' and Make will use it to compare with the value in `reproduce/config/pipeline/LOCAL.mk'. If there is an inconsistency, Make will not even attempt to build anything and will just print a message and abort. --- reproduce/config/pipeline/LOCAL.mk.in | 24 ++++++++++++ reproduce/src/make/top.mk | 72 +++++++++++++++++++++++++++++------ 2 files changed, 84 insertions(+), 12 deletions(-) (limited to 'reproduce') diff --git a/reproduce/config/pipeline/LOCAL.mk.in b/reproduce/config/pipeline/LOCAL.mk.in index 89e3e23..846a5b8 100644 --- a/reproduce/config/pipeline/LOCAL.mk.in +++ b/reproduce/config/pipeline/LOCAL.mk.in @@ -6,3 +6,27 @@ BDIR = @bdir@ INDIR = @indir@ DEPENDENCIES-DIR = @ddir@ DOWNLOADER = @downloader@ +FOR-GROUP = @forgroup@ + + + + + +# In the top Makefile (which is created after running `./configure' and is +# actually a symbolic link to `reproduce/src/make/top.mk'), we need to +# start by checking if there is no conflict with the running and configured +# group configuration of the pipeline. +good-group-configuration := $(shell \ + if [ "x$(FOR-GROUP)" = xyes ]; then \ + if [ "x$(reproducible_paper_for_group)" = xyes ]; then \ + echo "yes"; \ + else \ + echo "no"; \ + fi; \ + else \ + if [ "x$(reproducible_paper_for_group)" = xyes ]; then \ + echo "no"; \ + else \ + echo "yes"; \ + fi; \ + fi) diff --git a/reproduce/src/make/top.mk b/reproduce/src/make/top.mk index 5d4c210..25c4f0b 100644 --- a/reproduce/src/make/top.mk +++ b/reproduce/src/make/top.mk @@ -23,17 +23,59 @@ +# Load the local configuration (created after running `./configure'). +include reproduce/config/pipeline/LOCAL.mk + + + + + # Ultimate target of this pipeline # -------------------------------- # -# The final paper (in PDF format) is the main target of this whole -# reproduction pipeline. So as defined in the Make paradigm, we are -# defining it here. +# The final paper/report (`paper.pdf') is the main target of this whole +# reproduction pipeline. So as defined in the Make paradigm, it is the +# first target that we define (immediately after loading the local +# configuration settings, necessary for a group building scenario mentioned +# next). +# +# Group build +# ----------- # -# Note that if you don't have LaTeX to build the PDF, or generally are just -# interested in the processing, you can skip create the final PDF creation -# with `pdf-build-final' of `reproduce/config/pipeline/pdf-build.mk'. +# This pipeline can also be configured to have a shared build directory +# between multiple users. In this scenario, many users (on a server) can +# have their own/separate version controlled pipeline source of the +# pipeline, but share the same build outputs (in a common directory). This +# will allow a group to work separately, on parallel parts of the analysis. +# It is thus very useful in cases were special storage requirements or CPU +# power is necessary and its not possible/efficient for each user to have a +# fully separate copy of the build directory. +# +# `FOR-GROUP': from `LOCAL.mk' (which was built by `./configure'). +# `reproducible_paper_for_group': from the `./for-group' script. +# +# The final paper is only built when both have a value of `yes', or when +# `FOR-GROUP' is no and `./for-group' wasn't called (if `./for-group' is +# called before `make', then `reproducible_paper_for_group==yes'). +# +# Only processing, no LaTeX PDF +# ----------------------------- +# +# If you are just interested in the processing and don't want to build the +# PDF, you can skip the creatation of the final PDF by removing the value +# of `pdf-build-final' in `reproduce/config/pipeline/pdf-build.mk'. +ifeq ($(good-group-configuration),yes) all: paper.pdf +else +all: + @if [ "x$(reproducible_paper_for_group)" = xyes ]; then \ + echo "Pipeline is NOT configured for groups, please run"; \ + echo " $$ .local/bin/make"; \ + else \ + echo "Pipeline is configured for groups, please run"; \ + echo " $$ ./for-group make"; \ + fi +endif @@ -77,11 +119,17 @@ makesrc = initialize \ -# Include necessary Makefiles -# --------------------------- +# Include all Makefiles +# --------------------- +# +# We have two classes of Makefiles, separated by context and their location: +# +# 1) First, we'll include all the configuration-Makefiles. These +# Makefiles only define variables with no rules or order. We just +# won't include `LOCAL.mk' because it has already been included +# above. # -# First, we'll include all the configuration-Makefiles (only defining -# variables with no rules or order), then the workhorse Makefiles which -# contain rules and order matters for them. -include reproduce/config/pipeline/*.mk +# 2) Then, we'll import the workhorse-Makefiles which contain rules to +# actually do the processing of this pipeline. +include $(filter-out %LOCAL.mk, reproduce/config/pipeline/*.mk) include $(foreach s,$(makesrc), reproduce/src/make/$(s).mk) -- cgit v1.2.1