reorganise make stuff
This commit is contained in:
parent
0f0073ba77
commit
59c226111e
4 changed files with 106 additions and 38 deletions
90
Makefile
90
Makefile
|
@ -48,6 +48,13 @@ $(BUILDDIR)/%: $(TMPDIR)/%
|
|||
cp $< $@
|
||||
|
||||
|
||||
$(TMPDIR)/%_small.png: $(DATADIR)/%.png
|
||||
$(call resize,$(SMALL),$(SMALL),^,-gravity center -crop 1:1+0)
|
||||
|
||||
$(TMPDIR)/%_med.png: $(DATADIR)/%.png
|
||||
$(call resize,$(MEDW),$(MEDH),>)
|
||||
|
||||
|
||||
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
|
||||
echo "[make-pages]"
|
||||
mkdir -p $(dir $@)
|
||||
|
@ -57,10 +64,7 @@ $(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
|
|||
|
||||
|
||||
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(YAMLS) $(MAKEPAGES)
|
||||
echo "[deps] "$@
|
||||
mkdir -p $(dir $@)
|
||||
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o $@ \
|
||||
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
|
||||
$(call depend-gallery)
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(MAKECMDGOALS),distclean)
|
||||
|
@ -89,4 +93,82 @@ upload: build
|
|||
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
|
||||
|
||||
|
||||
# no args
|
||||
define copy
|
||||
echo "[copy] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
cp -Ll "$^" "$@"
|
||||
endef
|
||||
|
||||
# args:
|
||||
# 1. width
|
||||
# 2. height
|
||||
# 3. imagemagick resize hint (^, <, !, etc)
|
||||
# 4. other flags (e.g. cropping)
|
||||
define resize
|
||||
echo "[resize] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
convert -resize "$(1)x$(2)$(3)" $(4) "$^" "$@"
|
||||
endef
|
||||
|
||||
# no args
|
||||
define depend-gallery
|
||||
echo "[deps] "$@
|
||||
mkdir -p $(dir $@)
|
||||
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o "$@" \
|
||||
-B "$(BUILDDIR)" -D "$(DATADIR)" -T "$(TMPDIR)" -I "$(INFONAME)"
|
||||
endef
|
||||
|
||||
# args:
|
||||
# 1. gallery prefix
|
||||
# 2. build dir
|
||||
# 3. data dir
|
||||
# 4. other flags
|
||||
define depend-single
|
||||
echo "[deps] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
$(MAKEPAGES) $(MPFLAGS) depend-single \
|
||||
$(4) -o "$@" -p "$(1)" -B "$(2)" -D "$(3)" $<
|
||||
endef
|
||||
|
||||
# args
|
||||
# 1. title
|
||||
# 2. gallery prefix
|
||||
# 3. other flags
|
||||
define gallery
|
||||
echo "[gallery] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
$(MAKEPAGES) $(MPFLAGS) gallery -t "$(1)" -p "$(2)" $(3) -o "$@" \
|
||||
$(filter $(DATADIR)/%/$(INFONAME),$^)
|
||||
endef
|
||||
|
||||
# args:
|
||||
# 1. data dir
|
||||
# 2. other flags
|
||||
define single
|
||||
echo "[single] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
$(MAKEPAGES) $(MPFLAGS) single -D "$(1)" $< -o "$@" $(2)
|
||||
endef
|
||||
|
||||
# args:
|
||||
# 1. title with commas replaced with $(comma)
|
||||
# 2. description with commas replaced
|
||||
# 3. gallery prefix
|
||||
# 4. data dir
|
||||
# 5. other flags
|
||||
define rss
|
||||
echo "[rss] "$@
|
||||
mkdir -p "$(dir $@)"
|
||||
$(MAKEPAGES) $(MPFLAGS) rss -t "$(1)" -d "$(2)" \
|
||||
-R "$(ROOT)" -p "$(3)" -D "$(4)" -o "$@" $(5) \
|
||||
$(filter $(DATADIR)/%/$(INFONAME),$^)
|
||||
endef
|
||||
|
||||
comma := ,
|
||||
|
||||
|
||||
# never delete intermediate files
|
||||
.SECONDARY:
|
||||
|
||||
.SILENT:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module BuilderQQ (b, Builder, toLazyText, fromText, fromString, fromChar) where
|
||||
module BuilderQQ
|
||||
(b,
|
||||
Builder, toLazyText, fromText, fromString, fromChar,
|
||||
textMap)
|
||||
where
|
||||
|
||||
import Data.Char (isLower, isSpace, isDigit, isAlphaNum)
|
||||
import Language.Haskell.TH
|
||||
|
@ -179,3 +183,6 @@ pattern c :. t <- (Text.uncons -> Just (c, t))
|
|||
|
||||
fromChar :: Char -> Builder
|
||||
fromChar = singleton
|
||||
|
||||
textMap :: (Char -> Builder) -> Text -> Builder
|
||||
textMap f = Text.foldl' (\buf c -> buf <> f c) mempty
|
||||
|
|
|
@ -63,20 +63,10 @@ dependGallery' (GalleryInfo {title, description, prefix, filters})
|
|||
$@index: $@path
|
||||
|
||||
$@path: $@pages' $@files' $@rss $$(MAKEPAGES)
|
||||
echo "[gallery] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) $$(MPFLAGS) gallery \
|
||||
-p "$@prefix" -t "$*title" $flags -o "$$@" \
|
||||
$$(filter $$(DATADIR)/%/$$(INFONAME),$$^)
|
||||
$$(call gallery,$title',$@prefix,$flags)
|
||||
|
||||
$@rss: $@files' $$(MAKEPAGES)
|
||||
echo "[rss] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) $$(MPFLAGS) rss -t "$*title" \
|
||||
-d "$*description" \
|
||||
-R "$$(ROOT)" -p "$@prefix" \
|
||||
-o "$$@" -D "$@data_" \
|
||||
$$(filter $$(DATADIR)/%/$$(INFONAME),$$^)
|
||||
$$(call rss,$title',$description',$@prefix,$@data_)
|
||||
|
||||
$rules
|
||||
|
||||
|
@ -84,6 +74,9 @@ dependGallery' (GalleryInfo {title, description, prefix, filters})
|
|||
|]
|
||||
where
|
||||
flags = filtersToFlags filters
|
||||
title' = substComma title
|
||||
description' = substComma description
|
||||
substComma = textMap \case ',' -> "$(comma)"; c -> fromChar c
|
||||
|
||||
makeRules :: FilePath -- ^ prefix
|
||||
-> GalleryFilters
|
||||
|
@ -93,31 +86,16 @@ makeRules :: FilePath -- ^ prefix
|
|||
-> Builder
|
||||
makeRules prefix filters build data_ tmp = [b|@0
|
||||
$@buildPrefix/%/index.html: $@data_/%/info.yaml $$(MAKEPAGES)
|
||||
echo "[single] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) $$(MPFLAGS) single -D "$@data_" "$$<" -o "$$@" $flags
|
||||
$$(call single,$@data_,$flags)
|
||||
|
||||
$@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES)
|
||||
echo "[deps] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$$(MAKEPAGES) $$(MPFLAGS) depend-single $flags \
|
||||
-o "$$@" -p "$@prefix" -B "$@build" -D "$@data_" $$<
|
||||
$$(call depend-single,$@prefix,$@build,$@data_,$flags)
|
||||
|
||||
$@buildPrefix/%: $@tmp/%
|
||||
$$(call copy)
|
||||
|
||||
$@buildPrefix/%: $@data_/%
|
||||
echo "[copy] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
cp "$$<" "$$@"
|
||||
|
||||
$@buildPrefix/%_small.png: $@data_/%.png
|
||||
echo "[resize] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
convert -resize '$$(SMALL)x$$(SMALL)^' \
|
||||
-gravity center -crop 1:1+0 "$$<" "$$@"
|
||||
|
||||
$@buildPrefix/%_med.png: $@data_/%.png
|
||||
echo "[resize] "$$@
|
||||
mkdir -p $$(dir $$@)
|
||||
convert -resize '$$(MEDW)x$$(MEDH)>' "$$<" "$$@"
|
||||
$$(call copy)
|
||||
|]
|
||||
where
|
||||
buildPrefix = build </> prefix
|
||||
|
|
|
@ -32,6 +32,7 @@ executable make-pages
|
|||
DerivingStrategies,
|
||||
DuplicateRecordFields,
|
||||
FlexibleInstances,
|
||||
LambdaCase,
|
||||
NamedFieldPuns,
|
||||
OverloadedLabels,
|
||||
OverloadedStrings,
|
||||
|
|
Loading…
Reference in a new issue