Using variable source folder for scripts, used by default in global-config.mk, and replaced in production by proper content folder
This commit is contained in:
parent
c338370d7c
commit
eb12212546
4 changed files with 30 additions and 25 deletions
3
Makefile
3
Makefile
|
@ -2,7 +2,8 @@
|
|||
SHELL=/bin/bash
|
||||
|
||||
# Get Configuration informations from global or local config file
|
||||
CONFIG_FILES=global-config.mk local-config.mk
|
||||
LOCAL_CONFIG = $(wildcard local-config.mk)
|
||||
CONFIG_FILES = global-config.mk $(LOCAL_CONFIG)
|
||||
include $(CONFIG_FILES)
|
||||
|
||||
# sbsar files generation part
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TEXTURESETS := $(foreach file, $(TEXTURESET_FOLDER), $(basename $(notdir $(wildcard $(TEXTURESET_FOLDER)/*))))
|
||||
BLENDFILES := $(foreach file, $(BLENDFILES_FOLDER), $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/*.blend))))
|
||||
BLENDFILES := $(foreach file, $(BLENDFILES_FOLDER)/master, $(basename $(notdir $(wildcard $(BLENDFILES_FOLDER)/master/*.blend))))
|
||||
BLENDFILES_SUFFIX := $(foreach file, $(BLENDFILES), $(addsuffix $(file), _))
|
||||
TARGET := $(foreach file, $(TEXTURESETS), $(addprefix $(file), $(BLENDFILES_SUFFIX)))
|
||||
TARGET := $(foreach file, $(TARGET), $(addsuffix .png, $(file)))
|
||||
|
@ -9,6 +9,9 @@ RENDERS := $(foreach file, $(BLENDFILES_SUFFIX), $(addprefix %, $(file)))
|
|||
RENDERS := $(foreach file, $(RENDERS), $(addsuffix .png, $(file)))
|
||||
RENDERS := $(foreach file, $(RENDERS), $(addprefix $(PREVIEW_FOLDER)/, $(file)))
|
||||
|
||||
test:
|
||||
echo "TARGET: $(TARGET)"
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(RENDERS): $(TEXTURESET_FOLDER)/%
|
||||
|
@ -20,29 +23,30 @@ $(RENDERS): $(TEXTURESET_FOLDER)/%
|
|||
for file in $$pngset ;\
|
||||
do basename=$$(basename "$$file");\
|
||||
newname=$$(echo $$basename | sed -r 's/.*($(TEXTURES_NAMES))/\\\1/' | sed -r 's/\\//');\
|
||||
mkdir --parents blenderfiles/textures;\
|
||||
mkdir --parents $(BLENDFILES_FOLDER)/textures;\
|
||||
echo "Copying "$$file ;\
|
||||
cp $$file blenderfiles/textures/$$newname ; done ;\
|
||||
cp $$file $(BLENDFILES_FOLDER)/textures/$$newname ; done ;\
|
||||
presetname=$$(echo $$(basename $< ".png") | sed -r 's/(.*_[0-9]{2})_.*/\\\1/' | sed -r 's/\\//');\
|
||||
echo "presetname :"$$presetname;\
|
||||
echo "MATERIALLIST :"$(MATERIALLIST);\
|
||||
rendertype=$$(cat $(MATERIALLIST) | jq -r --arg folder "$$presetname" '.[] | select(.name==$$folder) | .type');\
|
||||
echo "foldername :" $$rendertype;\
|
||||
blender_render_files=$$(ls blenderfiles/$$rendertype/*.blend | sed -r 's/blenderfiles\/.*\///' | sed -r 's/\.blend//' | tr '\n' ' ') ;\
|
||||
blender_render_files=$$(ls $(BLENDFILES_FOLDER)/$$rendertype/*.blend | sed -r 's|$(BLENDFILES_FOLDER)/.*/||' | sed -r 's/\.blend//' | tr '\n' ' ') ;\
|
||||
echo "blender_render_files :"$$blender_render_files;\
|
||||
for blendname in $$blender_render_files;\
|
||||
do echo "blendname :" $$blendname;\
|
||||
destination=$$(echo $$presetname"_"$$blendname.png);\
|
||||
echo "destination :"$(PREVIEW_FOLDER)"/"$$destination;\
|
||||
blendfile=$$(echo "blenderfiles/"$$rendertype"/"$$blendname".blend");\
|
||||
blendfile=$$(echo "$(BLENDFILES_FOLDER)/"$$rendertype"/"$$blendname".blend");\
|
||||
echo "blendfile :" $$blendfile;\
|
||||
mkdir --parents render;\
|
||||
mkdir --parents $(BLENDFILES_FOLDER)/render;\
|
||||
temp_render_dir=$$(realpath $(BLENDFILES_FOLDER)/render);\
|
||||
echo "Rendering "$(PREVIEW_FOLDER)/$$destination;\
|
||||
$(BLENDEREXEC) -b $$blendfile --render-output //../../render/render##.png -f 1 --addons > /dev/null 2>&1;\
|
||||
$(BLENDEREXEC) -b $$blendfile --render-output $$temp_render_dir/render##.png -f 1 --addons > /dev/null 2>&1;\
|
||||
mkdir --parents $(PREVIEW_FOLDER);\
|
||||
composite -compose atop -gravity southeast -dissolve 90% $(LOGO) render/render01.png $(PREVIEW_FOLDER)/$$destination;\
|
||||
composite -compose atop -gravity southeast -dissolve 90% $(LOGO) $(BLENDFILES_FOLDER)/render/render01.png $(PREVIEW_FOLDER)/$$destination;\
|
||||
done
|
||||
# Clean the subfolder with temp textures
|
||||
@ rm -Rf blenderfiles/textures
|
||||
@ rm -Rf $(BLENDFILES_FOLDER)/textures
|
||||
# Clean the temp render folder
|
||||
@ rm -Rf render
|
||||
@ rm -Rf $(BLENDFILES_FOLDER)/render
|
||||
|
|
10
README.md
10
README.md
|
@ -6,20 +6,20 @@ This repository use [Git LFS](https://git-lfs.github.com/).
|
|||
|
||||
### Configuration of the Makefile
|
||||
|
||||
The file `global-config.mk` contain configuration informations about paths to sources, executables and to the building destinations. It details all the variables which can be set but shouldn’t be modified, as it can receive new variables in the future needed for the script to work. Moreover is handled by git for new versions and any changes you make would be erased by new pull of the script. If you want to specify a dedicated value to any variable, you should copy its line definition to a new file inf the same folder, called `local-config.mk`. Like this, you will keep your local configuration files in the future with new versions of the script.
|
||||
The file `global-config.mk` contain configuration informations about paths to sources, executables and to the building destinations. It details all the variables which can be set but shouldn’t be modified, as it can receive new variables in the future needed for the script to work and concerns only example files included with the script. Moreover is handled by git for new versions and any changes you make would be erased by new pull of the script. To specify dedicated values to any variable, you should copy its line definition to a new file inf the same folder, called `local-config.mk`. Like this, you will keep your local configuration files in the future with new versions of the script. You will have to do it at least to take in charge your persnal data and not the `example` content given.
|
||||
|
||||
Simply write either the absolute or the relative path from your Makefile script situation for any information needed.
|
||||
|
||||
## Executables used
|
||||
|
||||
These are the adress of the substance automation toolkit binaries.
|
||||
|
||||
## Sbsar files generation part
|
||||
|
||||
You need to define a sbs source folder where the script will check for new content in the `SBS_DIR` variables content.
|
||||
|
||||
You must write down also the place where the script will write the generated sbsar.
|
||||
|
||||
## Executables used
|
||||
|
||||
These are the adress of the substance automation toolkit binaries. Note you can use former variables defined sooner in the file, like it is done in the `--includes` section of MAKESBSAR.
|
||||
|
||||
## Texturesets files
|
||||
|
||||
This files will be used only internally by the script to check the texturesets it handles.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# sbsar files generation part
|
||||
export SBS_DIR=example/sbs
|
||||
export SBSAR_DIR=build/sbsar
|
||||
|
||||
# executables used
|
||||
export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "sbs/utilities/"
|
||||
export MAKESBSAR=sbscooker --quiet --output-name {inputName} --includes "/opt/Allegorithmic/Substance_Automation_Toolkit/resources/packages/" --includes "$(SBS_DIR)/utilities/"
|
||||
export GETPRESET=sbsmutator info --print-presets
|
||||
export GETOUTPUT=sbsmutator info --print-outputs
|
||||
export SBSRENDER=sbsrender
|
||||
|
||||
# sbsar files generation part
|
||||
export SBS_DIR=sbs
|
||||
export SBSAR_DIR=build/sbsar
|
||||
|
||||
# texturesets files
|
||||
export TEXTURESET_FOLDER := build/texturesets
|
||||
|
||||
|
@ -20,14 +20,14 @@ export PNG512_DIR := build/png_512
|
|||
export PNG256_DIR := build/png_256
|
||||
|
||||
# Blender related
|
||||
export BLENDFILES_FOLDER := blenderfiles/master
|
||||
export BLENDEREXEC := blender
|
||||
export BLENDFILES_FOLDER := example/blenderfiles
|
||||
export BLENDEREXEC := /opt/blender/blender
|
||||
|
||||
# Logo file
|
||||
export LOGO := logo/YKtextures.png
|
||||
export LOGO := example/logo/YKtextures.png
|
||||
|
||||
# Destination preview folder
|
||||
export PREVIEW_FOLDER := build/previews
|
||||
|
||||
# Material list
|
||||
export MATERIALLIST := material_list.json
|
||||
export MATERIALLIST := example/material_list.json
|
||||
|
|
Loading…
Reference in a new issue