OpenSCAD dependency management

Working with OpenSCAD for a few weeks, I quickly wished there was an easy dependency manager. None of the options appealed to me, so I made my own. It could actually be used with most any language, really, and is basically just a script that invokes Git to clone dependencies into a folder in your home directory, then creates a link to said folder. Behold get_deps.sh:


#!/bin/sh

# OpenSCAD dependency management through Git.
# Probably works for other things, too.
# Edit dependencies, run, then in your scads do e.g.:
# use <deps.link/BOSL/joiners.scad>
# MIT License; do what you want. -Erhannis

LOCAL=deps.link
REMOTE=~/.scad_deps/
while getopts hl:r: option
do
case "${option}"
in
h) echo $'./get_deps.sh [-h] [-l LOCAL=deps.link] [-r REMOTE=~/.scad_deps]';;
l) LOCAL=${OPTARG};;
r) REMOTE=${OPTARG};;
esac
done

# Setup
if [ ! -e "$LOCAL" ]; then
mkdir -p "$REMOTE"
ln -s "$REMOTE" "$LOCAL"
fi

#TODO Should recursively fetch dependencies
#TODO Should MAYBE update dependencies

# Dependencies
cd "$REMOTE"
git clone https://github.com/revarbat/BOSL

Just add any other dependencies at the bottom, and in your scad files, do e.g.

use <deps.link/BOSL/nema_steppers.scad>

It’s worked quite well for me, so far, (aside from usually having to convert Thingiverse libraries into Github repos), though I expect a larger, longer term, or more complicated project would need features the script doesn’t currently offer. Better than a poke in the eye, at least, and I’m pleased with its simplicity.

Oh, do note that it’s a Linux script. You could make an equivalent Windows batch file. I haven’t.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.