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 $< $@
|
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
|
$(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
|
||||||
echo "[make-pages]"
|
echo "[make-pages]"
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
|
@ -57,10 +64,7 @@ $(MAKEPAGES): make-pages/*.hs make-pages/make-pages.cabal
|
||||||
|
|
||||||
|
|
||||||
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(YAMLS) $(MAKEPAGES)
|
$(TMPDIR)/index.mk: $(DATADIR)/index.yaml $(YAMLS) $(MAKEPAGES)
|
||||||
echo "[deps] "$@
|
$(call depend-gallery)
|
||||||
mkdir -p $(dir $@)
|
|
||||||
$(MAKEPAGES) $(MPFLAGS) depend-gallery $< -o $@ \
|
|
||||||
-B $(BUILDDIR) -D $(DATADIR) -T $(TMPDIR) -I $(INFONAME)
|
|
||||||
|
|
||||||
ifneq ($(MAKECMDGOALS),clean)
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
ifneq ($(MAKECMDGOALS),distclean)
|
ifneq ($(MAKECMDGOALS),distclean)
|
||||||
|
@ -89,4 +93,82 @@ upload: build
|
||||||
$(BUILDDIR)/ $(HOST):$(REMOTE_DIR)/
|
$(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:
|
.SILENT:
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# 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 Data.Char (isLower, isSpace, isDigit, isAlphaNum)
|
||||||
import Language.Haskell.TH
|
import Language.Haskell.TH
|
||||||
|
@ -179,3 +183,6 @@ pattern c :. t <- (Text.uncons -> Just (c, t))
|
||||||
|
|
||||||
fromChar :: Char -> Builder
|
fromChar :: Char -> Builder
|
||||||
fromChar = singleton
|
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
|
$@index: $@path
|
||||||
|
|
||||||
$@path: $@pages' $@files' $@rss $$(MAKEPAGES)
|
$@path: $@pages' $@files' $@rss $$(MAKEPAGES)
|
||||||
echo "[gallery] "$$@
|
$$(call gallery,$title',$@prefix,$flags)
|
||||||
mkdir -p $$(dir $$@)
|
|
||||||
$$(MAKEPAGES) $$(MPFLAGS) gallery \
|
|
||||||
-p "$@prefix" -t "$*title" $flags -o "$$@" \
|
|
||||||
$$(filter $$(DATADIR)/%/$$(INFONAME),$$^)
|
|
||||||
|
|
||||||
$@rss: $@files' $$(MAKEPAGES)
|
$@rss: $@files' $$(MAKEPAGES)
|
||||||
echo "[rss] "$$@
|
$$(call rss,$title',$description',$@prefix,$@data_)
|
||||||
mkdir -p $$(dir $$@)
|
|
||||||
$$(MAKEPAGES) $$(MPFLAGS) rss -t "$*title" \
|
|
||||||
-d "$*description" \
|
|
||||||
-R "$$(ROOT)" -p "$@prefix" \
|
|
||||||
-o "$$@" -D "$@data_" \
|
|
||||||
$$(filter $$(DATADIR)/%/$$(INFONAME),$$^)
|
|
||||||
|
|
||||||
$rules
|
$rules
|
||||||
|
|
||||||
|
@ -84,6 +74,9 @@ dependGallery' (GalleryInfo {title, description, prefix, filters})
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
flags = filtersToFlags filters
|
flags = filtersToFlags filters
|
||||||
|
title' = substComma title
|
||||||
|
description' = substComma description
|
||||||
|
substComma = textMap \case ',' -> "$(comma)"; c -> fromChar c
|
||||||
|
|
||||||
makeRules :: FilePath -- ^ prefix
|
makeRules :: FilePath -- ^ prefix
|
||||||
-> GalleryFilters
|
-> GalleryFilters
|
||||||
|
@ -93,31 +86,16 @@ makeRules :: FilePath -- ^ prefix
|
||||||
-> Builder
|
-> Builder
|
||||||
makeRules prefix filters build data_ tmp = [b|@0
|
makeRules prefix filters build data_ tmp = [b|@0
|
||||||
$@buildPrefix/%/index.html: $@data_/%/info.yaml $$(MAKEPAGES)
|
$@buildPrefix/%/index.html: $@data_/%/info.yaml $$(MAKEPAGES)
|
||||||
echo "[single] "$$@
|
$$(call single,$@data_,$flags)
|
||||||
mkdir -p $$(dir $$@)
|
|
||||||
$$(MAKEPAGES) $$(MPFLAGS) single -D "$@data_" "$$<" -o "$$@" $flags
|
|
||||||
|
|
||||||
$@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES)
|
$@tmpPrefix/%.mk: $@data_/%/info.yaml $$(MAKEPAGES)
|
||||||
echo "[deps] "$$@
|
$$(call depend-single,$@prefix,$@build,$@data_,$flags)
|
||||||
mkdir -p $$(dir $$@)
|
|
||||||
$$(MAKEPAGES) $$(MPFLAGS) depend-single $flags \
|
$@buildPrefix/%: $@tmp/%
|
||||||
-o "$$@" -p "$@prefix" -B "$@build" -D "$@data_" $$<
|
$$(call copy)
|
||||||
|
|
||||||
$@buildPrefix/%: $@data_/%
|
$@buildPrefix/%: $@data_/%
|
||||||
echo "[copy] "$$@
|
$$(call 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)>' "$$<" "$$@"
|
|
||||||
|]
|
|]
|
||||||
where
|
where
|
||||||
buildPrefix = build </> prefix
|
buildPrefix = build </> prefix
|
||||||
|
|
|
@ -32,6 +32,7 @@ executable make-pages
|
||||||
DerivingStrategies,
|
DerivingStrategies,
|
||||||
DuplicateRecordFields,
|
DuplicateRecordFields,
|
||||||
FlexibleInstances,
|
FlexibleInstances,
|
||||||
|
LambdaCase,
|
||||||
NamedFieldPuns,
|
NamedFieldPuns,
|
||||||
OverloadedLabels,
|
OverloadedLabels,
|
||||||
OverloadedStrings,
|
OverloadedStrings,
|
||||||
|
|
Loading…
Reference in a new issue