From 67e1b43859879e981eac2c684e37959ca3f65f7b Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sun, 10 Nov 2019 13:23:47 +0100 Subject: [PATCH] Adds WIP SASS and LiveScript backends. --- Makefile | 42 +++++++++++++++++++++++++++++---- build/livescript.zsh | 56 ++++++++++++++++++++++++++++++++++++++++++++ build/sass.zsh | 29 +++++++++++++++++++++++ 3 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 build/livescript.zsh create mode 100644 build/sass.zsh diff --git a/Makefile b/Makefile index e84e559..eb6d7d0 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ LDFLAGS := Q := @ -all: build.zsh build/binary.zsh build/crystal.zsh build/header.zsh build/library.zsh build/man.zsh build/moon.zsh build/ofile.zsh build/scdocman.zsh build/script.zsh build/sharedlib.zsh build/staticlib.zsh +all: build.zsh build/binary.zsh build/crystal.zsh build/header.zsh build/library.zsh build/livescript.zsh build/man.zsh build/moon.zsh build/ofile.zsh build/sass.zsh build/scdocman.zsh build/script.zsh build/sharedlib.zsh build/staticlib.zsh @: build.zsh: build.zsh.in @@ -90,6 +90,19 @@ build/library.zsh.uninstall: @echo ' RM > $(SHAREDIR)/build.zsh/library.zsh' $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/library.zsh' +build/livescript.zsh: + +build/livescript.zsh.install: build/livescript.zsh + @echo ' IN > $(SHAREDIR)/build.zsh/livescript.zsh' + $(Q)mkdir -p '$(DESTDIR)$(SHAREDIR)/build.zsh' + $(Q)install -m0755 build/livescript.zsh $(DESTDIR)$(SHAREDIR)/build.zsh/livescript.zsh + +build/livescript.zsh.clean: + +build/livescript.zsh.uninstall: + @echo ' RM > $(SHAREDIR)/build.zsh/livescript.zsh' + $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/livescript.zsh' + build/man.zsh: build/man.zsh.install: build/man.zsh @@ -129,6 +142,19 @@ build/ofile.zsh.uninstall: @echo ' RM > $(SHAREDIR)/build.zsh/ofile.zsh' $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/ofile.zsh' +build/sass.zsh: + +build/sass.zsh.install: build/sass.zsh + @echo ' IN > $(SHAREDIR)/build.zsh/sass.zsh' + $(Q)mkdir -p '$(DESTDIR)$(SHAREDIR)/build.zsh' + $(Q)install -m0755 build/sass.zsh $(DESTDIR)$(SHAREDIR)/build.zsh/sass.zsh + +build/sass.zsh.clean: + +build/sass.zsh.uninstall: + @echo ' RM > $(SHAREDIR)/build.zsh/sass.zsh' + $(Q)rm -f '$(DESTDIR)$(SHAREDIR)/build.zsh/sass.zsh' + build/scdocman.zsh: build/scdocman.zsh.install: build/scdocman.zsh @@ -201,12 +227,12 @@ $(DESTDIR)$(INCLUDEDIR): $(DESTDIR)$(MANDIR): @echo ' DIR > $(MANDIR)' $(Q)mkdir -p $(DESTDIR)$(MANDIR) -install: subdirs.install build.zsh.install build/binary.zsh.install build/crystal.zsh.install build/header.zsh.install build/library.zsh.install build/man.zsh.install build/moon.zsh.install build/ofile.zsh.install build/scdocman.zsh.install build/script.zsh.install build/sharedlib.zsh.install build/staticlib.zsh.install +install: subdirs.install build.zsh.install build/binary.zsh.install build/crystal.zsh.install build/header.zsh.install build/library.zsh.install build/livescript.zsh.install build/man.zsh.install build/moon.zsh.install build/ofile.zsh.install build/sass.zsh.install build/scdocman.zsh.install build/script.zsh.install build/sharedlib.zsh.install build/staticlib.zsh.install @: subdirs.install: -uninstall: subdirs.uninstall build.zsh.uninstall build/binary.zsh.uninstall build/crystal.zsh.uninstall build/header.zsh.uninstall build/library.zsh.uninstall build/man.zsh.uninstall build/moon.zsh.uninstall build/ofile.zsh.uninstall build/scdocman.zsh.uninstall build/script.zsh.uninstall build/sharedlib.zsh.uninstall build/staticlib.zsh.uninstall +uninstall: subdirs.uninstall build.zsh.uninstall build/binary.zsh.uninstall build/crystal.zsh.uninstall build/header.zsh.uninstall build/library.zsh.uninstall build/livescript.zsh.uninstall build/man.zsh.uninstall build/moon.zsh.uninstall build/ofile.zsh.uninstall build/sass.zsh.uninstall build/scdocman.zsh.uninstall build/script.zsh.uninstall build/sharedlib.zsh.uninstall build/staticlib.zsh.uninstall @: subdirs.uninstall: @@ -216,7 +242,7 @@ test: all subdirs subdirs.test subdirs.test: -clean: build.zsh.clean build/binary.zsh.clean build/crystal.zsh.clean build/header.zsh.clean build/library.zsh.clean build/man.zsh.clean build/moon.zsh.clean build/ofile.zsh.clean build/scdocman.zsh.clean build/script.zsh.clean build/sharedlib.zsh.clean build/staticlib.zsh.clean +clean: build.zsh.clean build/binary.zsh.clean build/crystal.zsh.clean build/header.zsh.clean build/library.zsh.clean build/livescript.zsh.clean build/man.zsh.clean build/moon.zsh.clean build/ofile.zsh.clean build/sass.zsh.clean build/scdocman.zsh.clean build/script.zsh.clean build/sharedlib.zsh.clean build/staticlib.zsh.clean distclean: clean @@ -235,9 +261,11 @@ $(PACKAGE)-$(VERSION).tar.gz: distdir $(PACKAGE)-$(VERSION)/build/crystal.zsh \ $(PACKAGE)-$(VERSION)/build/header.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/livescript.zsh \ $(PACKAGE)-$(VERSION)/build/man.zsh \ $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ + $(PACKAGE)-$(VERSION)/build/sass.zsh \ $(PACKAGE)-$(VERSION)/build/scdocman.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ @@ -254,9 +282,11 @@ $(PACKAGE)-$(VERSION).tar.xz: distdir $(PACKAGE)-$(VERSION)/build/crystal.zsh \ $(PACKAGE)-$(VERSION)/build/header.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/livescript.zsh \ $(PACKAGE)-$(VERSION)/build/man.zsh \ $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ + $(PACKAGE)-$(VERSION)/build/sass.zsh \ $(PACKAGE)-$(VERSION)/build/scdocman.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ @@ -273,9 +303,11 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir $(PACKAGE)-$(VERSION)/build/crystal.zsh \ $(PACKAGE)-$(VERSION)/build/header.zsh \ $(PACKAGE)-$(VERSION)/build/library.zsh \ + $(PACKAGE)-$(VERSION)/build/livescript.zsh \ $(PACKAGE)-$(VERSION)/build/man.zsh \ $(PACKAGE)-$(VERSION)/build/moon.zsh \ $(PACKAGE)-$(VERSION)/build/ofile.zsh \ + $(PACKAGE)-$(VERSION)/build/sass.zsh \ $(PACKAGE)-$(VERSION)/build/scdocman.zsh \ $(PACKAGE)-$(VERSION)/build/script.zsh \ $(PACKAGE)-$(VERSION)/build/sharedlib.zsh \ @@ -313,9 +345,11 @@ help: @echo ' - build/crystal.zsh script' @echo ' - build/header.zsh script' @echo ' - build/library.zsh script' + @echo ' - build/livescript.zsh script' @echo ' - build/man.zsh script' @echo ' - build/moon.zsh script' @echo ' - build/ofile.zsh script' + @echo ' - build/sass.zsh script' @echo ' - build/scdocman.zsh script' @echo ' - build/script.zsh script' @echo ' - build/sharedlib.zsh script' diff --git a/build/livescript.zsh b/build/livescript.zsh new file mode 100644 index 0000000..9ba03d6 --- /dev/null +++ b/build/livescript.zsh @@ -0,0 +1,56 @@ + +## +# The livescript backend makes a lot of assumptions about a *lot* of things. +# For example, it assumes you’ll build using browserify, that you’ll want +# to minify using babel, and so on. +# +# You’ll probably want to override or redefine some of those functions in +# your project.zsh, which kinda sucks but is also difficult to avoid with… +# well… you know, JavaScript. +## + +function LSC { + echo "${fg_bold[blue]} LSC > ${fg_bold[white]}$@${reset_color}" +} + +function BUN { + echo "${fg_bold[green]} BUN > ${fg_bold[white]}$@${reset_color}" +} + +function MIN { + echo "${fg_bold[red]} MIN > ${fg_bold[white]}$@${reset_color}" +} + +function livescript.prelude { + : ${install[$target]:=\$(SHAREDIR)/$package} + : ${chmod[$target]:=644} +} + +function livescript.build { + write "${target}: ${target%.js}.bundle.js $(dirdep $target)" + write "\t@echo '$(MIN ${target%.js}.js)'" + write "\t${Q}npx babel --minified ${target%.js}.bundle.js -o ${target}" + write "\n" + + write "${target%.js}.bundle.js: ${sources[$target]} ${depends[$target]} $(dirdep $target)" + write "\t@echo '$(BUN ${target%.js}.bundle.js)'" + write "\t${Q}npx browserify -t browserify-livescript ${sources[$target]} -o ${target%.js}.bundle.js" + write "\n" +} + +function livescript.clean { + write "${target}.clean:" + for file in ${target} ${target%.js}.bundle.js; do + write "\t@echo '$(RM ${file})'" + write "\t${Q}rm -f ${file}" + done + write "\n" +} + +function livescript.install { + binary.install "$@" +} + +function livescript.uninstall { + binary.uninstall "$@" +} diff --git a/build/sass.zsh b/build/sass.zsh new file mode 100644 index 0000000..d68fe92 --- /dev/null +++ b/build/sass.zsh @@ -0,0 +1,29 @@ + +function CSS { + echo "${fg_bold[yellow]} CSS > ${fg_bold[white]}$@${reset_color}" +} + +function sass.prelude { + : ${install[$target]:=\$(SHAREDIR)/$package} + : ${chmod[$target]:=644} +} + +function sass.build { + write "${target}: ${sources[$target]} $(dirdep $target)" + write "\t@echo '$(CSS ${target})'" + write "\t${Q}sassc ${sources[$target]} > ${target}" + write "\n" +} + +function sass.clean { + script.clean "$@" +} + +function sass.install { + binary.install "$@" +} + +function sass.uninstall { + binary.uninstall "$@" +} +