summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--contrib/package/csstidy/Makefile39
-rw-r--r--luci.mk16
2 files changed, 53 insertions, 2 deletions
diff --git a/contrib/package/csstidy/Makefile b/contrib/package/csstidy/Makefile
new file mode 100644
index 0000000000..bcf435e1e5
--- /dev/null
+++ b/contrib/package/csstidy/Makefile
@@ -0,0 +1,39 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=csstidy
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=https://github.com/jow-/csstidy-cpp.git
+PKG_SOURCE_DATE:=2018-12-12
+PKG_SOURCE_VERSION:=e1b50469604d77778ec34b20824cb2aae7510f1d
+PKG_MIRROR_HASH:=3c30b668ed54571c5ae81accf031423e93eacb81e6c96825f0e09c5012ac3cb0
+
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE_FILES:=COPYING
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/csstidy
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=CSSTidy parser and optimiser
+ DEPENDS:=+libstdcpp
+endef
+
+define Package/csstidy/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/csstidy/csstidy $(1)/usr/bin/
+endef
+
+
+define Host/Install
+ $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/csstidy/csstidy $(1)/bin/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,csstidy))
diff --git a/luci.mk b/luci.mk
index aa2e195e27..2dab144caa 100644
--- a/luci.mk
+++ b/luci.mk
@@ -83,8 +83,8 @@ PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
PKG_RELEASE?=1
PKG_INSTALL:=$(if $(realpath src/Makefile),1)
-PKG_BUILD_DEPENDS += lua/host luci-base/host $(LUCI_BUILD_DEPENDS)
-PKG_CONFIG_DEPENDS += CONFIG_LUCI_SRCDIET CONFIG_LUCI_JSMIN
+PKG_BUILD_DEPENDS += lua/host luci-base/host LUCI_CSSTIDY:csstidy/host $(LUCI_BUILD_DEPENDS)
+PKG_CONFIG_DEPENDS += CONFIG_LUCI_SRCDIET CONFIG_LUCI_JSMIN CONFIG_LUCI_CSSTIDY
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
@@ -117,6 +117,10 @@ ifeq ($(PKG_NAME),luci-base)
bool "Minify JavaScript sources"
default y
+ config LUCI_CSSTIDY
+ bool "Minify CSS files"
+ default y
+
menu "Translations"$(foreach lang,$(LUCI_LANGUAGES),
config LUCI_LANG_$(lang)
@@ -169,6 +173,13 @@ define JsMin
done
endef
+define CssTidy
+ $(FIND) $(1) -type f -name '*.css' | while read src; do \
+ if csstidy "$$$$src" --template=highest --remove_last_semicolon=true "$$$$src.o"; \
+ then mv "$$$$src.o" "$$$$src"; fi; \
+ done
+endef
+
define SubstituteVersion
$(FIND) $(1) -type f -name '*.htm' | while read src; do \
$(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(PKG_VERSION)/g' \
@@ -189,6 +200,7 @@ define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)$(HTDOCS); \
cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/; \
$(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true); \
+ $(if $(CONFIG_LUCI_CSSTIDY),$(call CssTidy,$(1)$(HTDOCS)/),true); \
else true; fi
if [ -d $(PKG_BUILD_DIR)/root ]; then \
$(INSTALL_DIR) $(1)/; \