view build.sh @ 10:455db4624bce

Check update on build
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Fri, 31 Jan 2014 22:58:46 +0900
parents e0c4a349c94f
children 9dca7035ab93
line wrap: on
line source

#/bin/sh

# source definitions
. `dirname $0`/config/definition.sh

# functions

command_check() {
    if !(which ${build_command} >& /dev/null;) then
        echo ${build_command} not found
        exit
    fi
}

slide_name_from_full_path() {
    echo $1 | sed -e 's/.[^.]*$/.html/'
}


need_build() {
    slide_name=`slide_name_from_full_path $1`

    if [ "${slide_name}" -ot "$1" ]; then
        return 0    # if exist slide and newer than src, not needed.
    fi

    return 1
}

build() {
    ${build_command} build $1 -o `dirname $1` ${build_template_option}
}

build_slides() {
    target_list=`find "$(dirname $0)/${slide_root_dirname}" -name "${build_target_filename}"`
    for target in ${target_list}; do
        if need_build $target; then
            build $target
        fi
    done
}


# main

command_check
build_slides