On the off chance that anyone is interested, I've attached a small, very simple, Bash script I've made that takes care of building, installing and uninstalling small and simple D libraries. Just put it somewhere in your path, mark it as executable, and off you go. :) Note that it only works with DMD.

It assumes a straightforward library structure. As an example, say you have a library "foo" consisting of, say, the modules foo.bar and foo.baz. These should then be located in the files foo/bar.d and foo/baz.d.

Then, from foo/'s parent directory, type the following commands.

To build the library (it will be located in .dlib/libfoo.a afterwards):
    dlib build foo

To install the library and sources to /usr/local:
    sudo dlib install foo

To remove the library and sources again:
    sudo dlib remove foo

To remove dlib's hidden working dir:
    dlib clean


I made the script for my own, personal use. Though it ain't exactly DSSS, I hope that someone else will find it useful as well. :)

-Lars


The usual disclaimer follows:
You use this script at your own risk. Under no circumstances shall the author be held responsible for any consequences of your use of the script.
#!/bin/bash

# Simple library build script.
#
# Author:     Lars T. Kyllingstad, [email protected]
# Licence:    WTFPL
# Disclaimer: You use this script at your own risk. Under no
#             circumstances shall the author be held responsible
#             for any consequences of your use of the script.

ME=`basename "$0"`


# Change to suit your preferences
PREFIX="/usr/local"
WRKDIR=".$ME"


# Read arguments
CMD="$1"
shift
SRCDIR="$1"
shift
DMDOPTS="$@"


# Locate source files and directories
LIBFILE="lib$SRCDIR.a"
LIBPATH="$WRKDIR/$LIBFILE"
HDRDIR="$WRKDIR/$SRCDIR"

# Locate target directories
SYSLIBDIR="$PREFIX/lib"
SYSINCDIR="$PREFIX/include/d"


# If no arguments are given, show help
if [ -z "$CMD" ]; then
    echo "Usage:"
    echo "  $ME build <library> [DMD options]   --  Build a library"
    echo "  $ME install <library>               --  Install a library"
    echo "  $ME remove <library>                --  Uninstall a library"
    echo "  $ME clean                           --  Clean up after build 
process"
    exit
fi


# Operation: Remove temporary directory
if [ "$CMD" == "clean" ]; then
    rm -r "$WRKDIR"
    exit
fi


# Check if a library name is given.
if [ -z "$SRCDIR" ]; then
    echo "$ME: $CMD which library?"
    exit
fi


# Operation: Remove installed library.
if [ "$CMD" == remove ]; then
    rm "$SYSLIBDIR/$LIBFILE"
    rm -r "$SYSINCDIR/$SRCDIR"
    exit
fi



# Find source files.
if [ ! -d "$SRCDIR" ]; then
    echo "$ME: source directory '$SRCDIR' not found."
    exit 1
fi
SOURCES=`find $SRCDIR | grep '\.d$' | grep -v '\.svn'`



# Operation: Install library and include files.
if [ "$CMD" == "install" ]; then
    if [ ! -f "$LIBPATH" ]; then
        echo "$ME: library file '$LIBFILE' not found."
        exit 1
    fi

    mkdir -p -m 0755 "$SYSLIBDIR" "$SYSINCDIR"
    install -p -m 0644 "$LIBPATH" "$SYSLIBDIR"
    cp -r $HDRDIR "$SYSINCDIR"

    exit
fi



# Operation: Build library.
if [ "$CMD" == "build" ]; then
    dmd $SOURCES -lib -od$WRKDIR -of$LIBFILE $DMDOPTS
    cp -r --parents $SOURCES "$WRKDIR/"
    exit
fi


echo "$ME: invalid command: $CMD"
exit 2

Reply via email to