Tuesday, April 17, 2018

Shell script to set up Ready-To-Use Blender Git Checkouts on Linux

Recently, I've been setting up quite a few copies/checkouts of Blender Git repositories (approximately 3-4 per machine I'm using - including twice on the same machine after the hard drive failed). Doing this has made me all too aware of all the steps needed to get these things into a nicely working state for development (including how you need to copy out a whole bunch of commands each time).

Today, I can announce that for Linux users, the wait is over! I've successfully put together a script that basically automates the entire procedure listed on the wiki, making it possible to relatively painlessly grab the Blender sources, and then proceed to compile and run them.


It's actually part of a larger repo of automated configuration-setup scripts/tools I've been putting together over the past few weeks to make it easier to get my computing setup deployed onto new machines faster. For the time being, I'm not quite prepared to release the actual repo where all these are housed publicly, as I still haven't managed to fully vet that no private details have managed to leak/leech into the config files contained. Unfortunately, the final release of that may have to wait until I'm back in NZ (as it seems that I ultimately ended up forgetting to transfer some critical files for a few of the programs).


Usage Instructions
To use this script:
1) Install the script by putting in in the "bin" folder of your $HOME (or user profile) folder. Make sure that this is on the PATH  (i.e. on the latest XUbuntu, you'll have to copy the relevant code from .bash_profile to .bash_rc to get this working)

2) Navigate to the folder where you want to store the Blender repos (e.g. ~/src or ~/blenderdev are common choices).

3) Assuming this is the first time you're trying to compile Blender, in a terminal, run the following command:
$ brepo_init.sh --install_deps

4) When prompted to install dependencies, type y

5) Wait for everything to get downloaded and compile

6) When the script completes, copy the path it gives you, and "cd" to it.  e.g.,
$ cd /home/aligorith/blenderdev/master/blender

7) Compile Blender by doing,
$ make

8) Run Blender by doing,
$ ../install/blender

9) To update sources, do:
$ make update
(in the "/home/aligorith/blenderdev/master/blender" folder)


Notes:
* This script still assumes that you've already installed git and build-essentials
(i.e. sudo apt-get install git && cmake && build_essentials)

* I personally recommend that people install and use git gui (i.e. the git-gui package on Linux). Especially when combined with custom defined tools (more of which are contained in my full automated-setup repos), this is a very powerful and nice workflow compared to many others out there.


Advanced Usage Instructions
NOTE: The instructions here go into a bit more details about the different options.

There are basically several ways to use this script:
1) $ brepo_init.sh      - This just downloads the master branch, into a folder named "master"

2) $ brepo_init.sh mainline - This just downloads the master branch into a folder named "mainline"

3) $brepo_init.sh b28 blender2.8 - This downloads Blender 2.8 into a folder called "b28"


In addition to these command line parameters, you can also tune the behaviour of the script by modifying a few of the parameters (located at the top of the file).
* AS_DEV - Set this option to "true" if you have push access to Blender's main repository. (It's unlikely that you do though... if you're a developer, you probably are already managing stuff in your own way, and are unlikely to want to use this, unless you're me ;)

* OPTIMISE_REBUILDS - (on by default) This basically controls the use of the hack (recommended on the wiki page) of symlinking the scripts folder in the source tree into the build output directory, such that the binaries get written into there. The end result is that this reduces the time spent copying changed changed Python scripts after each rebuild.


(TODO: I just realised that we'll have to still manually patch the git-exclude file to ignore the generated files)

Closing Notes
This script is still largely experimental, though I've successfully used it a few times this afternoon to set up a bunch of new repos. Caution is still advised when using it, as there may be some pitfalls (e.g. OPTIMISE_REBUILDS related bugs) that I haven't fully solved yet.

Support for an equivalent script for Windows is also still in the works. I've been running into a few technical challenges with that one (notably, the different file paths now used by MSVC 2017), so more work will still be needed in future to get it working.

No comments:

Post a Comment