Adding management of deleted .sbs files, deleted graphs and deleted presets

This commit is contained in:
yannk 2021-12-27 18:11:50 +01:00
parent ac063d1c82
commit c664a3ed93

View file

@ -12,9 +12,12 @@ export SBSFILES = $(wildcard $(SBS_DIR)/*.sbs)
export SBSARDESTINATION = $(subst $(SBS_DIR)/, $(SBSAR_DIR)/, $(SBSFILES)) export SBSARDESTINATION = $(subst $(SBS_DIR)/, $(SBSAR_DIR)/, $(SBSFILES))
export SBSARFILES = $(SBSARDESTINATION:.sbs=.sbsar) export SBSARFILES = $(SBSARDESTINATION:.sbs=.sbsar)
# existing texturesets list
export TEXTURES := $(wildcard $(TEXTURESET_FOLDER)/*)
### RECIPE PART ### ### RECIPE PART ###
all : previews subformats all : previews subformats del_obsolete
previews: $(SBSARFILES) previews: $(SBSARFILES)
$(MAKE) -f Makefile_previews all $(MAKE) -f Makefile_previews all
@ -22,12 +25,32 @@ previews: $(SBSARFILES)
subformats: $(SBSARFILES) subformats: $(SBSARFILES)
$(MAKE) -f Makefile_subformats all $(MAKE) -f Makefile_subformats all
del_obsolete: $(SBS_DIR)
@ for material in $(TEXTURES); do \
rootname=$$(echo $$material | sed -r 's|$(TEXTURESET_FOLDER)/(.*)_.*|\1|');\
sbs_name=$(SBS_DIR)/$$rootname.sbs ;\
if [ ! -f $$sbs_name ] ;\
then echo "CLEANUP : The corresponding $$sbs_name doesnt exist any more, deleting the corresponding obsolete files :" ;\
rm -Rf $(SBSAR_DIR)/$$rootname.sbsar ;\
echo " -"$(SBSAR_DIR)/$$rootname.sbsar ;\
rm -Rf $(PNG1024_DIR)/$$(basename $$material)* ;\
echo " -"$(PNG1024_DIR)/$$(basename $$material)* ;\
rm -Rf $(PNG512_DIR)/$$(basename $$material)* ;\
echo " -"$(PNG512_DIR)/$$(basename $$material)* ;\
rm -Rf $(PNG256_DIR)/$$(basename $$material)* ;\
echo " -"$(PNG256_DIR)/$$(basename $$material)* ;\
rm -Rf $(TEXTURESET_FOLDER)/$$(basename $$material) ;\
echo " -"$(TEXTURESET_FOLDER)/$$(basename $$material) ;\
rm -Rf $(PREVIEW_FOLDER)/$$(basename $$material)* ;\
echo " -"$(PREVIEW_FOLDER)/$$(basename $$material)* ;\
fi ;\
done
export: $(SBSARFILES) export: $(SBSARFILES)
$(MAKE) -f Makefile_export all $(MAKE) -f Makefile_export all
# Recipe to make sbsar, its main PNG files and its preset textureset file # Recipe to make sbsar, its main PNG files and its preset textureset file
$(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
@ echo $$(basename $@ ".sbsar")
@ echo "Processing" $< "->" $@ @ echo "Processing" $< "->" $@
@ mkdir -p $(SBSAR_DIR) @ mkdir -p $(SBSAR_DIR)
@ $(MAKESBSAR) --output-path $(SBSAR_DIR) $< @ $(MAKESBSAR) --output-path $(SBSAR_DIR) $<
@ -35,9 +58,9 @@ $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
# There is a png imageset for each preset of a base texture # There is a png imageset for each preset of a base texture
# All png are stored in a png_1024 folder # All png are stored in a png_1024 folder
@ mkdir -p $(PNG1024_DIR) @ mkdir -p $(PNG1024_DIR)
@ echo "Building 1024 png imageset(s) from presets of" $@ # Get all presets for the graph
# Get all presets from this base material
@ $(eval PRESETLIST=`$(GETPRESET) --input $< | grep PRESET | sed -r 's/PRESET "(.*)"/\1/g'`) @ $(eval PRESETLIST=`$(GETPRESET) --input $< | grep PRESET | sed -r 's/PRESET "(.*)"/\1/g'`)
# Get graph outputs list
@ declare -i graphcount=0 ;\ @ declare -i graphcount=0 ;\
output_list="" ;\ output_list="" ;\
for line in $$($(GETOUTPUT) $<) ; do \ for line in $$($(GETOUTPUT) $<) ; do \
@ -51,16 +74,18 @@ $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
else : ;\ else : ;\
fi ;\ fi ;\
done;\ done;\
echo "output_list :"$$output_list;\ echo " - Graph output_list :"$$output_list;\
echo "Building 1024 png imageset(s) from presets of" $@ ;\
pngfiles="";\ pngfiles="";\
material=$$(basename $@ ".sbsar");\
echo "material :"$$material;\
echo "Cleaning old entries from the material :"$$material;\
rm -Rf $(PNG1024_DIR)/$${material}*;\
rm -Rf $(PNG512_DIR)/$${material}*;\
rm -Rf $(PNG256_DIR)/$${material}*;\
for preset in $(PRESETLIST) ; do \ for preset in $(PRESETLIST) ; do \
echo "- Preset" $$preset; \ echo "- Preset" $$preset; \
material=$$(basename -s .sbsar $@);\
echo "material :"$$material;\
obsolete="$${material}_$${preset}" ;\
echo "Cleaning old entries from the material : $$obsolete" ;\
rm -Rf $(PNG1024_DIR)/$$obsolete* ;\
rm -Rf $(PNG512_DIR)/$$obsolete* ;\
rm -Rf $(PNG256_DIR)/$$obsolete* ;\
listitem="";\ listitem="";\
for item in $$output_list;\ for item in $$output_list;\
do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\ do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\
@ -68,7 +93,7 @@ $(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
done;\ done;\
echo "listitem :"$$listitem;\ echo "listitem :"$$listitem;\
mkdir --parents $(TEXTURESET_FOLDER);\ mkdir --parents $(TEXTURESET_FOLDER);\
echo $$listitem > $(TEXTURESET_FOLDER)/$$(basename $@ ".sbsar")_$$preset;\ echo $$listitem > $(TEXTURESET_FOLDER)/$$(basename -s .sbsar $@)_$$preset;\
$(SBSRENDER) render $@ --use-preset $$preset --output-name {inputGraphUrl}\_$$preset\_{outputNodeName} --set-value \$$outputsize@10,10# --output-path $(PNG1024_DIR); \ $(SBSRENDER) render $@ --use-preset $$preset --output-name {inputGraphUrl}\_$$preset\_{outputNodeName} --set-value \$$outputsize@10,10# --output-path $(PNG1024_DIR); \
done;\ done;\