clean up the build system
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/*.pdf
|
||||
/pack
|
||||
/result
|
||||
/target
|
||||
|
||||
171
Makefile
171
Makefile
@@ -1,20 +1,7 @@
|
||||
.PHONY: view_documentation
|
||||
view_documentation: documentation.pdf
|
||||
xdg-open $<
|
||||
|
||||
.PHONY: watch_documentation
|
||||
watch_documentation:
|
||||
typst watch --font-path template/fonts documentation.typ & xdg-open documentation.pdf
|
||||
|
||||
.PHONY: watch_%
|
||||
watch_%: %.pdf
|
||||
xdg-open $< & typst watch --root . --font-path template/fonts theses/$*.typ $<
|
||||
|
||||
.PHONY: documentation
|
||||
documentation: documentation.pdf
|
||||
|
||||
PACKDIR := pack/tultemplate2
|
||||
BUNDLEDIR := pack/bundle
|
||||
BUILD_DIR := target
|
||||
PACKS_ROOT := $(BUILD_DIR)/pack
|
||||
PACKDIR := $(PACKS_ROOT)/tultemplate2
|
||||
BUNDLEDIR := $(PACKS_ROOT)/bundle
|
||||
|
||||
TO_PACK := $(shell find template -type f) template/LICENSE
|
||||
BUNDLE_THESES := bp_cs bp_en dp_cs dp_en prj_cs prj_en
|
||||
@@ -23,77 +10,123 @@ BUNDLE_TARGETS := $(TO_PACK:%=$(BUNDLEDIR)/%) $(BUNDLEDIR)/citations.bib $(BUNDL
|
||||
PACK_TARGETS := $(TO_PACK:%=$(PACKDIR)/%) $(PACKDIR)/documentation.typ \
|
||||
$(PACKDIR)/documentation.pdf $(PACKDIR)/citations.bib
|
||||
|
||||
TEMPLATE_SRCS := $(shell find template -type f)
|
||||
|
||||
# == MAIN TARGETS ==
|
||||
|
||||
.PHONY: view_documentation
|
||||
view_documentation: $(BUILD_DIR)/documentation.pdf
|
||||
xdg-open $<
|
||||
|
||||
.PHONY: pack
|
||||
pack: pack/tultemplate2.zip
|
||||
pack: $(PACKDIR)/tultemplate2.zip
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: $(BUNDLE_TARGETS)
|
||||
@echo "!! Bundles are made for tultemplategen and not for direct use !!"
|
||||
|
||||
.PHONY: watch_documentation
|
||||
watch_documentation: $(BUILD_DIR)/documentation.pdf
|
||||
xdg-open $< & typst watch --font-path template/fonts documentation.typ $<
|
||||
|
||||
.PHONY: watch_%
|
||||
watch_%: $(BUILD_DIR)/%.pdf
|
||||
xdg-open $< & typst watch --root . --font-path template/fonts theses/$*.typ $<
|
||||
|
||||
.PHONY: documentation
|
||||
documentation: $(BUILD_DIR)/documentation.pdf
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf pack
|
||||
rm -f ./*.pdf
|
||||
rm -rf target
|
||||
|
||||
pack/tultemplate2.zip: $(PACK_TARGETS)
|
||||
@mkdir -p $(@D)
|
||||
rm -f $@
|
||||
cd pack && zip -r tultemplate2.zip tultemplate2
|
||||
# == ROOTS ==
|
||||
|
||||
$(PACKDIR)/%: %
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
$(BUILD_DIR):
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR)/citations.bib: citations.bib
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
$(PACKS_ROOT): | $(BUILD_DIR)
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR)/%.typ: theses/%.typ
|
||||
@mkdir -p $(@D)
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' $< | sed 's/\.\.\/template\//template\//' > $@
|
||||
$(PACKDIR): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR)/Makefile: templategen.mk
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
$(BUNDLEDIR): | $(PACKS_ROOT)
|
||||
mkdir $@
|
||||
|
||||
$(PACKDIR)/template/LICENSE: LICENSE
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
# == UTILS ==
|
||||
|
||||
$(BUNDLEDIR)/template/LICENSE: LICENSE
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
define minify_csl
|
||||
cat $(1) | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $(2)
|
||||
endef
|
||||
|
||||
$(PACKDIR)/template/tul_citace.csl: template/tul_citace.csl
|
||||
@mkdir -p $(@D)
|
||||
cat $< | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $@
|
||||
define minify_json
|
||||
cat $(1) | jq -c > $(2)
|
||||
endef
|
||||
|
||||
$(BUNDLEDIR)/template/tul_citace.csl: template/tul_citace.csl
|
||||
@mkdir -p $(@D)
|
||||
cat $< | sed 's/^\s*\(.*\)$$/\1/' | tr -d '\n' > $@
|
||||
# == DIRECT BUILDS ==
|
||||
|
||||
$(PACKDIR)/template/lang.json: template/lang.json
|
||||
@mkdir -p $(@D)
|
||||
cat $< | jq -c > $@
|
||||
$(BUILD_DIR)/documentation.pdf: documentation.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
typst compile --font-path template/fonts $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/lang.json: template/lang.json
|
||||
@mkdir -p $(@D)
|
||||
cat $< | jq -c > $@
|
||||
|
||||
$(PACKDIR)/template/%: template/%
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/%: template/%
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
TEMPLATE_SRCS := $(shell find template -type f)
|
||||
|
||||
documentation.pdf: documentation.typ $(TEMPLATE_SRCS)
|
||||
typst compile --font-path template/fonts $<
|
||||
|
||||
%.pdf: theses/%.typ
|
||||
$(BUILD_DIR)/%.pdf: theses/%.typ $(TEMPLATE_SRCS) | $(BUILD_DIR)
|
||||
typst compile --font-path template/fonts --root . $< $@
|
||||
|
||||
# == PACKS - clean builds for direct use ==
|
||||
|
||||
$(PACKDIR)/%: % | $(PACKDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template: | $(PACKDIR)
|
||||
mkdir $@
|
||||
|
||||
$(PACKDIR)/template/LICENSE: LICENSE | $(PACKDIR)/template
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/template/tul_citace.csl: template/tul_citace.csl | $(PACKDIR)/template
|
||||
$(call minify_csl,$<,$@)
|
||||
|
||||
$(PACKDIR)/template/lang.json: template/lang.json | $(PACKDIR)/template
|
||||
$(call minify_json,$<,$@)
|
||||
|
||||
$(PACKDIR)/template/%: template/% | $(PACKDIR)/template
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/%.pdf: $(BUILD_DIR)/%.pdf | $(PACKDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(PACKDIR)/tultemplate2.zip: $(PACK_TARGETS) | $(PACKDIR)
|
||||
rm -f $@
|
||||
cd $(PACKS_ROOT) && zip -r tultemplate2.zip tultemplate2
|
||||
|
||||
# == BUNDLES - packs for tultemplategen ==
|
||||
|
||||
$(BUNDLEDIR)/template: | $(BUNDLEDIR)
|
||||
mkdir $@
|
||||
|
||||
$(BUNDLEDIR)/template/LICENSE: LICENSE | $(BUNDLEDIR)/template
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/Makefile: templategen.mk | $(BUNDLEDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/tul_citace.csl: template/tul_citace.csl | $(BUNDLEDIR)/template
|
||||
$(call minify_csl,$<,$@)
|
||||
|
||||
$(BUNDLEDIR)/template/lang.json: template/lang.json | $(BUNDLEDIR)/template
|
||||
$(call minify_json,$<,$@)
|
||||
|
||||
$(BUNDLEDIR)/citations.bib: citations.bib | $(BUNDLEDIR)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/template/%: template/% | $(BUNDLEDIR)/template
|
||||
@mkdir -p $(@D)
|
||||
ln -f $< $@
|
||||
|
||||
$(BUNDLEDIR)/%.typ: theses/%.typ | $(BUNDLEDIR)
|
||||
awk 'BEGIN{RS=""; ORS="\n\n"} NR>2{print}' $< | sed 's/\.\.\/template\//template\//' > $@
|
||||
|
||||
# == TESTS ==
|
||||
|
||||
include tests/make.mk
|
||||
|
||||
16
flake.nix
16
flake.nix
@@ -11,22 +11,6 @@
|
||||
dependencies = with pkgs; [ typst gnumake jq xdg-utils zip ];
|
||||
in
|
||||
{
|
||||
packages.documentation = pkgs.stdenv.mkDerivation {
|
||||
pname = "documentation";
|
||||
version = "1.2";
|
||||
src = ./.;
|
||||
buildInputs = dependencies;
|
||||
buildPhase = ''
|
||||
make documentation.pdf
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r documentation.pdf $out/ || true
|
||||
'';
|
||||
};
|
||||
|
||||
packages.default = self.packages.${system}.documentation;
|
||||
|
||||
devShell = with pkgs; mkShell {
|
||||
buildInputs = dependencies;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// | TULTemplate 2 |
|
||||
// +---------------+
|
||||
//
|
||||
// Unofficial TUL template for all kinds of documents.
|
||||
// Typst TUL template for all kinds of documents.
|
||||
//
|
||||
// Git: https://git.zumepro.cz/tul/tultemplate2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user