Textures_factory/Makefile

105 lines
3.8 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Variables definitions
SHELL=/bin/bash
# Get Configuration informations from global or local config file
LOCAL_CONFIG = $(wildcard local-config.mk)
CONFIG_FILES = global-config.mk $(LOCAL_CONFIG)
include $(CONFIG_FILES)
# sbsar files generation part
export SBSFILES = $(wildcard $(SBS_DIR)/*.sbs)
export SBSARDESTINATION = $(subst $(SBS_DIR)/, $(SBSAR_DIR)/, $(SBSFILES))
export SBSARFILES = $(SBSARDESTINATION:.sbs=.sbsar)
# existing texturesets list
export TEXTURES := $(wildcard $(TEXTURESET_FOLDER)/*)
### RECIPE PART ###
all : previews del_obsolete export
previews: $(SBSARFILES)
$(MAKE) -f Makefile_previews all
subformats: $(SBSARFILES)
$(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) | subformats
$(MAKE) -f Makefile_export all
# Recipe to make sbsar, its main PNG files and its preset textureset file
$(SBSAR_DIR)/%.sbsar: $(SBS_DIR)/%.sbs
@ echo "Processing" $< "->" $@
@ mkdir -p $(SBSAR_DIR)
@ $(MAKESBSAR) --output-path $(SBSAR_DIR) $<
# Then build png imageset from sbsar
# There is a png imageset for each preset of a base texture
# All png are stored in a png_1024 folder
@ mkdir -p $(PNG1024_DIR)
# Get all presets for the graph
@ $(eval PRESETLIST=`$(GETPRESET) --input $< | grep PRESET | sed -r 's/PRESET "(.*)"/\1/g'`)
# Get graph outputs list
@ declare -i graphcount=0 ;\
output_list="" ;\
for line in $$($(GETOUTPUT) $<) ; do \
if [ "$$line" = "GRAPH-URL" ] ;\
then ((graphcount++)) ;\
fi ;\
if [ $$graphcount -le 1 ] ;\
then if [ "$$line" != "OUTPUT" ] && [ "$$line" != "GRAPH-URL" ] && [ "$${line:0:4}" != "pkg:" ] ;\
then output_list+=" $${line}" ;\
fi ;\
else : ;\
fi ;\
done;\
echo " - Graph output_list :"$$output_list;\
echo "Building 1024 png imageset(s) from presets of" $@ ;\
pngfiles="";\
for preset in $(PRESETLIST) ; do \
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="";\
for item in $$output_list;\
do itemfull="$(PNG1024_DIR)/$${material}_$${preset}_$${item}.png";\
listitem="$$listitem $$itemfull";\
done;\
echo "listitem :"$$listitem;\
mkdir --parents $(TEXTURESET_FOLDER);\
echo $$listitem > $(TEXTURESET_FOLDER)/$$(basename -s .sbsar $@)_$$preset;\
rendersize=$$(cat $(MATERIALLIST) | jq -r --arg folder "$${material}_$${preset}" '.[] | select(.name==$$folder) | .format') ;\
echo "DEBUG : MATERIALLIST : $(MATERIALLIST)" ;\
echo "DEBUG : material : "$$material ;\
echo "DEBUG : preset : "$$preset ;\
echo "DEBUG : material_preset : $${material}_$${preset}" ;\
echo "DEBUG : rendersize : "$$rendersize ;\
$(SBSRENDER) render $@ --use-preset $$preset --output-name {inputGraphUrl}\_$$preset\_{outputNodeName} --set-value \$$outputsize@$$rendersize# --output-path $(PNG1024_DIR); \
done;\