summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/Makefile20
-rwxr-xr-xhttp/bin/prune_out32
2 files changed, 16 insertions, 36 deletions
diff --git a/http/Makefile b/http/Makefile
index bf5abd3..e789c8f 100644
--- a/http/Makefile
+++ b/http/Makefile
@@ -18,6 +18,8 @@ out_deps := $(addprefix out/,$(src_files:src/%=%))
remove_layout_from_out_deps = out_deps := $$(subst $(1).upp,.,$$(out_deps))
$(foreach layout,$(layouts),$(eval $(call remove_layout_from_out_deps,.$(layout))))
$(eval $(call remove_layout_from_out_deps,))
+out_deps_without_src := $(filter-out $(out_deps),$(shell find -L out -type f))
+out_deps += $(out_deps_without_src)
blogs := $(subst blogs/,,$(wildcard blogs/*))
@@ -61,6 +63,18 @@ $(blog_post_target): $(blog_post_src) $(let ext,html,$(layout_file) $(component_
-f $$*.$(BLOG_EXT_$(blog))
endef
+define prune_out_file_rule =
+$(let orig_ext,$(patsubst .%,%,$(suffix $(file))),
+$(let ext,$(patsubst upp%,%,$(orig_ext)),
+$(let rel_basename,$(patsubst out/%.$(orig_ext),%,$(file)),
+$(let src_file,src/$(rel_basename).upp$(ext),
+$(let src_files_with_layouts,$(foreach layout,$(layouts),src/$(rel_basename).$(layout).upp$(ext)),
+$(let public_file,public/$(rel_basename).$(orig_ext),
+$(src_file) $(src_files_with_layouts) $(public_file):
+ rm $(file)
+))))))
+endef
+
define prune_blog_rule =
.PHONY: prune_$(blog)
prune_$(blog):
@@ -106,11 +120,9 @@ out/%: public/%
mkdir -p $(dir $@) && cp $< $@
.PHONY: prune
-prune: $(addprefix prune_,$(blogs)) prune_out
+prune: $(addprefix prune_,$(blogs))
-.PHONY: prune_out
-prune_out:
- ./bin/prune_out
+$(foreach file,$(out_deps_without_src),$(eval $(prune_out_file_rule)))
$(foreach blog,$(blogs),$(eval $(prune_blog_rule)))
diff --git a/http/bin/prune_out b/http/bin/prune_out
deleted file mode 100755
index f8bbcab..0000000
--- a/http/bin/prune_out
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh -e
-
-for out in $(find out -type f)
-do
- out_basename="$(basename "$out")"
- out_ext="${out_basename##*\.}"
- rel_path="$(echo "${out}" | cut -c5-)"
-
- if [ -f "public/${rel_path}" ]; then
- continue
- fi
-
- base_rel_path="${rel_path%%.${out_ext}}"
- src_path="src/${base_rel_path}.upp${out_ext}"
- if [ -f "$src_path" ]; then
- continue
- fi
-
- for layout in $(find share/layouts -name "*.layout.upp${out_ext}"); do
- layout="$(basename "$layout")"
- layout="$(echo ${layout} | cut -c1-$(( ${#layout} - 15 )) )"
- rel_path="$(echo "${out}" | cut -c5-)"
- base_rel_path="${rel_path%%.${out_ext}}"
- src_path="src/${base_rel_path}.${layout}.upp${out_ext}"
- if [ -f "$src_path" ]; then
- continue 2
- fi
- done
-
- echo "No source file found to match ${out}: removing it"
- rm "$out"
-done