http: replaces prune_out script with make rules
This commit is contained in:
+16
-4
@@ -18,6 +18,8 @@ out_deps := $(addprefix out/,$(src_files:src/%=%))
|
|||||||
remove_layout_from_out_deps = out_deps := $$(subst $(1).upp,.,$$(out_deps))
|
remove_layout_from_out_deps = out_deps := $$(subst $(1).upp,.,$$(out_deps))
|
||||||
$(foreach layout,$(layouts),$(eval $(call remove_layout_from_out_deps,.$(layout))))
|
$(foreach layout,$(layouts),$(eval $(call remove_layout_from_out_deps,.$(layout))))
|
||||||
$(eval $(call remove_layout_from_out_deps,))
|
$(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/*))
|
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))
|
-f $$*.$(BLOG_EXT_$(blog))
|
||||||
endef
|
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 =
|
define prune_blog_rule =
|
||||||
.PHONY: prune_$(blog)
|
.PHONY: prune_$(blog)
|
||||||
prune_$(blog):
|
prune_$(blog):
|
||||||
@@ -106,11 +120,9 @@ out/%: public/%
|
|||||||
mkdir -p $(dir $@) && cp $< $@
|
mkdir -p $(dir $@) && cp $< $@
|
||||||
|
|
||||||
.PHONY: prune
|
.PHONY: prune
|
||||||
prune: $(addprefix prune_,$(blogs)) prune_out
|
prune: $(addprefix prune_,$(blogs))
|
||||||
|
|
||||||
.PHONY: prune_out
|
$(foreach file,$(out_deps_without_src),$(eval $(prune_out_file_rule)))
|
||||||
prune_out:
|
|
||||||
./bin/prune_out
|
|
||||||
|
|
||||||
$(foreach blog,$(blogs),$(eval $(prune_blog_rule)))
|
$(foreach blog,$(blogs),$(eval $(prune_blog_rule)))
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user