Overhaul input/output sync to hopefully work the same both directions

parent addd8e92
......@@ -67,7 +67,7 @@ endif
ALLTAGS := $(strip $(shell git tag --points-at HEAD | xargs echo) $(and $(findstring /,$(BRANCH)),$(BRANCH)))
ifneq ($(ALLTAGS),)
# If we are on a tagged release, don't do pre-sync
# If we are on a tagged release cut pre-sync off at the knees and always build fresh
undefine INPUTDIR
DIFF = false
......@@ -99,11 +99,11 @@ endif
# End non-tagged
endif
# Assume OUTPATHS is always used in a foreach loop with TARGET variable set
# Assume OUTPATH is always used in a foreach loop with TARGET variable set
ifeq ($(BRANCH),master)
OUTPATHS = $(TARGET) $(and $(TARGET),$(TAGNAME),$(TARGET)/$(TAGNAME))
OUTPATH = $(TARGET)$(and $(TAGNAME),/$(TAGNAME))
else
OUTPATHS = $(BRANCH)
OUTPATH = $(BRANCH)
endif
# If there is a layout associated with a tag, only build that layout
......@@ -120,8 +120,6 @@ endif
ifeq ($(MAKECMDGOALS),ci)
sync_pre: init debug
pdfs renderings promotionals: sync_pre
sync_post: pdfs renderings promotionals
ci: sync_pre sync_post
endif
debug: debug_avadanlik
......@@ -131,8 +129,10 @@ debug: debug_avadanlik
debug_avadanlik:
@echo AVADANLIKDIR: $(AVADANLIKDIR)
@echo BRANCH: $(BRANCH)
@echo INPUTDIR: $(INPUTDIR)
@echo OUTPATH: $(OUTPATH)
@echo OUTPUTDIR: $(OUTPUTDIR)
@echo TAGNAME: $(TAGNAME)
@echo OUTPATHS: $(OUTPATHS)
check_dependencies: check_dependencies_avadanlik
......@@ -162,7 +162,7 @@ $(UPDATATAGTARGETS): update_%_tags:
init: init_avadanlik
.PHONY: init_avadanlik
init_avadanlik: time_warp_avadanlik $(AVADANLIKDIR)/yarn.lock
init_avadanlik: time_warp_avadanlik $(AVADANLIKDIR)/yarn.lock $(OUTPUTDIR)
$(AVADANLIKDIR)/yarn.lock: $(AVADANLIKDIR)/package.json
cd $(AVADANLIKDIR) && yarn install
......@@ -181,27 +181,43 @@ time_warp: time_warp_avadanlik
time_warp_avadanlik:
$(call time_warp,$(AVADANLIKDIR))
$(OUTPUTDIR):
mkdir -p $@
# Create per book jobs in the CI config
define ci_setup ?=
yq -M -s -y -e --arg sources "$(strip $(SOURCES))" \
'. + ($$sources | [splits(" ") as $$target | { ($$target + ".pdfs") : { "extends": ".pdfs", "only": [ "master", ("/^"+$$target+"\\/.*/") ], "artifacts": { "paths": [($$target+"*")] } }}]) | add'
endef
require_inputdir := $(or $(strip $(INPUTDIR)),fail)
.PHONY: sync_pre
sync_pre: | $(require_pubdir) $(require_outputdir)
$(and $(INPUTDIR),rsync -utv $(INPUTDIR)/* $(PROJECTDIR)/ ||:)
$(and $(INPUTDIR),$(foreach TARGET,$(TARGETS),rsync -utv $(INPUTDIR)/$(TARGET)/* $(PROJECTDIR)/ ||:;))
sync_pre: | $(require_inputdir)
$(foreach TARGET,$(TARGETS),
find $(INPUTDIR)/$(OUTPATH)/ -maxdepth 1 -type f \( \
-name "$(TARGET)*" \
$(and $(call printisbn,$(TARGET)),-or -name "$(call printisbn,$(TARGET))*") \
$(and $(call ebookisbn,$(TARGET)),-or -name "$(call ebookisbn,$(TARGET))*") \
\) -execdir rsync -utv {} $(PROJECTDIR)/ \;;)
ifneq ($(strip $(TARGETS)),$(strip $(PROJECT)))
find $(INPUTDIR)/ -maxdepth 1 -type f \
-name "$(PROJECT)*" \
-execdir rsync -utv {} $(PROJECTDIR)/ \;
endif
require_outputdir := $(or $(strip $(OUTPUTDIR)),fail)
.PHONY: sync_post
sync_post: | $(require_pubdir) $(require_outputdir)
$(foreach TARGET,$(TARGETS),$(foreach OUTPATH,$(OUTPATHS),mkdir -p $(OUTPUTDIR)/$(OUTPATH);)
find $(PUBDIR) -type f \( \
-name "$(TARGET)*" \
$(and $(call printisbn,$(TARGET)),-or -name "$(call printisbn,$(TARGET))*") \
$(and $(call ebookisbn,$(TARGET)),-or -name "$(call ebookisbn,$(TARGET))*") \
\)$(foreach OUTPATH,$(OUTPATHS), -execdir rsync -ct {} $(OUTPUTDIR)/$(OUTPATH)/ \;);)
$(foreach TARGET,$(TARGETS),mkdir -p $(OUTPUTDIR)/$(OUTPATH);
find $(PUBDIR)/ -maxdepth 1 -type f \( \
-name "$(TARGET)*" \
$(and $(call printisbn,$(TARGET)),-or -name "$(call printisbn,$(TARGET))*") \
$(and $(call ebookisbn,$(TARGET)),-or -name "$(call ebookisbn,$(TARGET))*") \
\) -execdir rsync -ct {} $(OUTPUTDIR)/$(OUTPATH)/ \;;)
ifneq ($(strip $(TARGETS)),$(strip $(PROJECT)))
find $(PUBDIR) -type f \
find $(PUBDIR)/-maxdepth 1 -type f \
-name "$(PROJECT)*" \
-execdir rsync -ct {} $(OUTPUTDIR)/ \;
endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment