luci.mk: add basic support for ucode sources
authorJo-Philipp Wich <jo@mein.io>
Fri, 9 Sep 2022 21:35:30 +0000 (23:35 +0200)
committerJo-Philipp Wich <jo@mein.io>
Mon, 24 Oct 2022 23:03:37 +0000 (01:03 +0200)
Add special handling for ucode/ package subdirs, analogeous to luasrc/.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
luci.mk

diff --git a/luci.mk b/luci.mk
index 9bb51698d90f149e72b32bf54bd7e94714475d9a..fc920f8d3aacfdea3e158b852cf14a85e83ed1af 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -72,6 +72,7 @@ LUCI_LC_ALIAS.zh_Hant=zh-tw
 HTDOCS = /www
 LUA_LIBRARYDIR = /usr/lib/lua
 LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
+UCODE_LIBRARYDIR = /usr/share/ucode/luci
 
 
 # 1: everything expect po subdir or only po subdir
@@ -160,7 +161,7 @@ ifneq ($(LUCI_DESCRIPTION),)
 endif
 
 define Build/Prepare
-       for d in luasrc htdocs root src; do \
+       for d in luasrc ucode htdocs root src; do \
          if [ -d ./$$$$d ]; then \
            mkdir -p $(PKG_BUILD_DIR)/$$$$d; \
                $(CP) ./$$$$d/* $(PKG_BUILD_DIR)/$$$$d/; \
@@ -193,6 +194,11 @@ define Package/$(PKG_NAME)/install
        $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true)
        $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/)
  endif
+ ifneq ($(wildcard ${CURDIR}/ucode),)
+         $(INSTALL_DIR) $(1)$(UCODE_LIBRARYDIR)
+         cp -pR $(PKG_BUILD_DIR)/ucode/* $(1)$(UCODE_LIBRARYDIR)/
+         $(call SubstituteVersion,$(1)$(UCODE_LIBRARYDIR)/)
+ endif
  ifneq ($(wildcard ${CURDIR}/htdocs),)
        $(INSTALL_DIR) $(1)$(HTDOCS)
        cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/
@@ -265,6 +271,11 @@ define SubstituteVersion
                $(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))/g' \
                    -e 's/"\(<%= *\(media\|resource\) *%>[^"]*\.\(js\|css\)\)"/"\1?v=$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))"/g' \
                        "$$$$src"; \
+       done; \
+       $(FIND) $(1) -type f -name '*.ut' | while read src; do \
+               $(SED) 's/{# *\([^ ]*\)PKG_VERSION *#}/\1$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))/g' \
+                   -e 's/"\({{ *\(media\|resource\) *}}[^"]*\.\(js\|css\)\)"/"\1?v=$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))"/g' \
+                       "$$$$src"; \
        done
 endef