Toggle Blender's Build Options

A little script I use to speed up compiling Blender

My work on Blender mostly involves the Animation & Rigging module. For this, I can do without Cycles, USD, Alembic, Collada, and some other modules. Disabling those modules allows me to build Blender faster. It would be even faster to disable everything you can disable, but that would disable way too much. Also, it’s hard to change it back, because you can’t just enable everything either.

So, as usual, I wrote a little script to do this for me. Save the script below to your build directory, and name it enable-stuff.sh. Then create a symlink ln -s enable-stuff.sh disable-stuff.sh.

#!/bin/bash

MY_BASE=$(basename "$0")
MY_DIR=$(dirname $(readlink -f $0))

case $MY_BASE in
    enable-stuff.sh)
        WITH=ON
        ;;
    disable-stuff.sh)
        WITH=OFF
        ;;
    *)
        echo "Unknown name $MY_BASE" >&2
        exit 47
        ;;
esac

set -ex
cd $MY_DIR
cmake \
    -DWITH_ALEMBIC=${WITH} \
    -DWITH_OPENCOLLADA=${WITH} \
    -DWITH_USD=${WITH} \
    -DWITH_CODEC_AVI=${WITH} \
    -DWITH_CYCLES=${WITH} \
    -DWITH_LIBMV=${WITH} \
    -DWITH_MOD_FLUID=${WITH} \
    -DWITH_MOD_OCEANSIM=${WITH} \
    -DWITH_MOD_REMESH=${WITH} \
    .
nice -n 20 ninja -C $MY_DIR

I made a similar script for enabling and disabling tests, which only sets the WITH_GTESTS build option. I’ll leave that as an exercise for the reader.

This post was made possible by the Blender Development Fund.

dr. Sybren A. Stüvel
dr. Sybren A. Stüvel
Open Source software developer, photographer, drummer

Related