build: make GluonSrcDiet simpler and more robust (#2033)
- If luasrcdiet fails for a Lua script, this is a bug that should be noticed rather than including the unminified script - Use .tmp suffix for temporary file rather than .o - Replace chmod + stat + mv with simpler cp + rm to overwrite file while preserving file mode
This commit is contained in:
		
							parent
							
								
									1956696da5
								
							
						
					
					
						commit
						50adb097fa
					
				@ -62,11 +62,11 @@ define GluonSrcDiet
 | 
			
		||||
	rm -rf $(2)
 | 
			
		||||
	$(CP) $(1) $(2)
 | 
			
		||||
  ifdef CONFIG_GLUON_MINIFY
 | 
			
		||||
	$(FIND) $(2) -type f | while read src; do \
 | 
			
		||||
		if luasrcdiet --noopt-binequiv -o "$$$$src.o" "$$$$src"; then \
 | 
			
		||||
			chmod $$$$(stat -c%a "$$$$src") "$$$$src.o"; \
 | 
			
		||||
			mv "$$$$src.o" "$$$$src"; \
 | 
			
		||||
		fi; \
 | 
			
		||||
	# Use cp + rm instead of mv to preserve destination permissions
 | 
			
		||||
	set -e; $(FIND) $(2) -type f | while read src; do \
 | 
			
		||||
		luasrcdiet --noopt-binequiv -o "$$$$src.tmp" "$$$$src"; \
 | 
			
		||||
		cp "$$$$src.tmp" "$$$$src"; \
 | 
			
		||||
		rm "$$$$src.tmp"; \
 | 
			
		||||
	done
 | 
			
		||||
  endif
 | 
			
		||||
endef
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user