Skip to content

Commit

Permalink
build script adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilmhansen committed Feb 27, 2012
1 parent 10ec7cc commit 795f4ce
Show file tree
Hide file tree
Showing 8 changed files with 386 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JAVA=/usr/bin/java
CAAT_ROOT_DIR=~/src/git/CAAT

JSDOC_TK_DIR=~/src/jsdoc/jsdoc_toolkit-2.4.0/jsdoc-toolkit
CLOSURE_COMPILER_JAR=~/src/closure/compiler.jar
9 changes: 9 additions & 0 deletions build/scripts/version.compile.doc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /bin/bash
CAAT_SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
CAAT_ROOT_DIR="$( cd "$CAAT_SCRIPT_DIR"/../.. && pwd )"

source $CAAT_SCRIPT_DIR/env.sh
########################################################


$JAVA -jar $JSDOC_TK_DIR/jsrun.jar $JSDOC_TK_DIR/app/run.js -a -v -p -r=4 -t=$JSDOC_TK_DIR/templates/jsdoc $CAAT_ROOT_DIR/src/CAAT.js $CAAT_ROOT_DIR/src/behavior $CAAT_ROOT_DIR/src/box2d $CAAT_ROOT_DIR/src/core $CAAT_ROOT_DIR/src/math $CAAT_ROOT_DIR/src/model/actor.js $CAAT_ROOT_DIR/src/model/audio.js $CAAT_ROOT_DIR/src/model/conpoundimage.js $CAAT_ROOT_DIR/src/model/debug.js $CAAT_ROOT_DIR/src/model/director.js $CAAT_ROOT_DIR/src/model/extraActor.js $CAAT_ROOT_DIR/src/model/imagepreloader.js $CAAT_ROOT_DIR/src/model/mouseevent.js $CAAT_ROOT_DIR/src/model/scene.js $CAAT_ROOT_DIR/src/model/timer.js $CAAT_ROOT_DIR/src/modules $CAAT_ROOT_DIR/src/path $CAAT_ROOT_DIR/src/texture $CAAT_ROOT_DIR/src/webgl -d=$CAAT_ROOT_DIR/documentation/jsdoc
159 changes: 159 additions & 0 deletions build/scripts/version.compile.pack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#! /bin/bash
CAAT_SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
CAAT_ROOT_DIR="$( cd "$CAAT_SCRIPT_DIR"/../.. && pwd )"

source $CAAT_SCRIPT_DIR/env.sh
########################################################

cd $CAAT_SCRIPT_DIR
CAAT_DST=$CAAT_ROOT_DIR/build/caat
LICENSE=$CAAT_ROOT_DIR/LICENSE
CAAT_SRC_DIR=$CAAT_ROOT_DIR/src

#
# execute version procedure.
# version.nfo contains new version value.
#
./version.sh
VERSION=`cat version.nfo`
echo "New generated version: ${VERSION}"


DST_FILE_NAME="${CAAT_DST}";

VERSION=`cat version.nfo`

FILE_CAAT="${DST_FILE_NAME}.js"
FILE_CAAT_CSS="${DST_FILE_NAME}-css.js"
FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d.js"

echo "Packing ${FILE_CAAT}"
echo -e "/*" > "${FILE_CAAT}"
cat $LICENSE >> "${FILE_CAAT}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}"
echo -e "Created on:" >> "${FILE_CAAT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}"
echo -e "*/\n\n" >> "${FILE_CAAT}"

more $CAAT_SRC_DIR/CAAT.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/core/class.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/affinetransform2D.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/color.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/rectangle.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/bezier.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/point.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/math/quadtree.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/path/interpolator.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/behaviour/behaviour.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/behaviour/csskeyframehelper.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/core/browserdetect.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/debug.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/actor.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/audio.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/extraActor.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/director.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/mouseevent.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/conpoundimage.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/imagepreloader.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/timer.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/model/scene.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/modules.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircle.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircleManager.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/LocalStorage/LocalStorage.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/ImageUtil/ImageUtil.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/Layout/layout.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/modules/Font/font.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/path/interpolatoractor.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/path/path.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/path/pathactor.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/texture/plasma.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/webgl/ShaderUtil.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/webgl/glu.js >> "${FILE_CAAT}"
more $CAAT_SRC_DIR/webgl/glTexturePage.js >> "${FILE_CAAT}"


# Distribute resulting compiled files
#
echo -e "\nCopying:"
while read LINE; do
echo -e "\tCopying results to ${LINE}"
cp ${FILE_CAAT} ${LINE}
done < version.distribution


#
# CSS
#
echo "Packing ${FILE_CAAT_CSS}"
echo -e "/*" > "${FILE_CAAT_CSS}"
cat $LICENSE >> "${FILE_CAAT_CSS}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}"
echo -e "Created on:" >> "${FILE_CAAT_CSS}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}"
echo -e "*/\n\n" >> "${FILE_CAAT_CSS}"

more $CAAT_SRC_DIR/CAAT.js >> "${FILE_CAAT_CSS}"
echo -e "CAAT.__CSS__=1;" >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/core/class.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/affinetransform2D.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/color.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/rectangle.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/bezier.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/point.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/math/quadtree.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/path/interpolator.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/behaviour/behaviour.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/behaviour/csskeyframehelper.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/core/browserdetect.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/debug.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/actorCSS.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/audio.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/extraActor.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/director.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/mouseevent.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/conpoundimage.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/imagepreloader.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/timer.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/model/sceneCSS.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/modules.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircle.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/CircleManager/PackedCircleManager.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/LocalStorage/LocalStorage.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/ImageUtil/ImageUtil.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/Layout/layout.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/modules/Font/font.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/path/interpolatoractor.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/path/path.js >> "${FILE_CAAT_CSS}"
more $CAAT_SRC_DIR/path/pathactor.js >> "${FILE_CAAT_CSS}"


#
# Distribute resulting compiled files
#
echo -e "\nCopying css version:"
while read LINE; do
echo -e "\tCopying css ${FILE_CAAT_CSS} results to ${LINE}"
cp ${FILE_CAAT_CSS} "$( dirname "$LINE" )"
done < version.distribution

# box2d

echo "Packing ${FILE_CAAT_BOX2D}"
echo -e "/*" > "${FILE_CAAT_BOX2D}"
cat $LICENSE >> "${FILE_CAAT_BOX2D}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}"
echo -e "Created on:" >> "${FILE_CAAT_BOX2D}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}"
echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}"

more $CAAT_SRC_DIR/box2d/box2Dactor.js >> "${FILE_CAAT_BOX2D}"

#
# Distribute resulting compiled files
#
echo -e "\nCopying:"
while read LINE; do
echo -e "\tCopying results to ${LINE}"
cp ${FILE_CAAT_BOX2D} ${LINE}
done < version.distribution
198 changes: 198 additions & 0 deletions build/scripts/version.compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
#! /bin/bash
CAAT_SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
CAAT_ROOT_DIR="$( cd "$CAAT_SCRIPT_DIR"/../.. && pwd )"

source $CAAT_SCRIPT_DIR/env.sh
########################################################

cd $CAAT_SCRIPT_DIR
CAAT_DST=$CAAT_ROOT_DIR/build/caat
LICENSE=$CAAT_ROOT_DIR/LICENSE

echo -e "\n\nCompilation process\n\n"

#
# define CAAT products files.
#
DST_FILE_NAME="${CAAT_DST}";

FILE_CAAT="${DST_FILE_NAME}-min.js"
FILE_CAAT_CSS="${DST_FILE_NAME}-css-min.js"
FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d-min.js"

#
# DST_FILE is a file name.
# This script will produce different target files as follow:
# + DST_FILE.js
# + DST_FILE-css.js
# + DST_FILE-box2d.js
#
echo "" > "${FILE_CAAT}"
echo "" > "${FILE_CAAT_CSS}"
echo "" > "${FILE_CAAT_BOX2D}"

SOURCE_DIR=$CAAT_ROOT_DIR/src

#
# set compilation level
#
COMPILATION_LEVEL=$1
if [ "${COMPILATION_LEVEL}" ]; then
if [[ "${COMPILATION_LEVEL}" == "simple" ]]; then
echo "Compilation level set to simple"
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
elif [[ "${COMPILATION_LEVEL}" == "advanced" ]]; then
echo "Compilation level set to advanced"
COMPILATION_LECEL="ADVANCED_OPTIMIZATIONS"
elif [[ "${COMPILATION_LEVEL}" == "spaces" ]]; then
echo "Compilation level set to white spaces"
COMPILATION_LEVEL="WHITESPACE_ONLY"
else
echo "Compilation level unknown: '${COMPILATION_LEVEL}'. Change to SIMPLE_OPTIMIZATIONS"
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
fi
else
echo "Compilation level defaults to simple optimizations."
COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS"
fi

#
# execute version procedure.
# version.nfo contains new version value.
#
./version.sh
VERSION=`cat version.nfo`
echo "New generated version: ${VERSION}"
echo "Generated at: ${DST_FILE_NAME}"
echo "From files at: ${SOURCE_DIR}"

#
# create stub files for all CAAT products.
#
echo -e "/*" >> "${FILE_CAAT}"
cat $LICENSE >> "${FILE_CAAT}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}"
echo -e "Created on:" >> "${FILE_CAAT}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}"
echo -e "*/\n\n" >> "${FILE_CAAT}"

echo -e "/*" >> "${FILE_CAAT_CSS}"
cat $LICENSE >> "${FILE_CAAT_CSS}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}"
echo -e "Created on:" >> "${FILE_CAAT_CSS}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}"
echo -e "*/\n\n" >> "${FILE_CAAT_CSS}"

echo -e "/*" >> "${FILE_CAAT_BOX2D}"
cat $LICENSE >> "${FILE_CAAT_BOX2D}"
echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}"
echo -e "Created on:" >> "${FILE_CAAT_BOX2D}"
date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}"
echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}"


#
# Compile canvas/GL
#
echo -e "\nCreating CAAT canvas/webGL"
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/CAAT.js \
--js "${SOURCE_DIR}"/core/browserdetect.js \
--js "${SOURCE_DIR}"/core/class.js \
--js "${SOURCE_DIR}"/math/affinetransform2D.js \
--js "${SOURCE_DIR}"/math/color.js \
--js "${SOURCE_DIR}"/math/rectangle.js \
--js "${SOURCE_DIR}"/math/bezier.js \
--js "${SOURCE_DIR}"/math/point.js \
--js "${SOURCE_DIR}"/math/quadtree.js \
--js "${SOURCE_DIR}"/path/interpolator.js \
--js "${SOURCE_DIR}"/behaviour/behaviour.js \
--js "${SOURCE_DIR}"/model/debug.js \
--js "${SOURCE_DIR}"/model/actor.js \
--js "${SOURCE_DIR}"/model/audio.js \
--js "${SOURCE_DIR}"/model/extraActor.js \
--js "${SOURCE_DIR}"/model/director.js \
--js "${SOURCE_DIR}"/model/mouseevent.js \
--js "${SOURCE_DIR}"/model/conpoundimage.js \
--js "${SOURCE_DIR}"/model/imagepreloader.js \
--js "${SOURCE_DIR}"/model/timer.js \
--js "${SOURCE_DIR}"/model/scene.js \
--js "${SOURCE_DIR}"/modules/modules.js \
--js "${SOURCE_DIR}"/modules/Layout/layout.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircle.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircleManager.js \
--js "${SOURCE_DIR}"/modules/LocalStorage/LocalStorage.js \
--js "${SOURCE_DIR}"/modules/ImageUtil/ImageUtil.js \
--js "${SOURCE_DIR}"/modules/Font/font.js \
--js "${SOURCE_DIR}"/path/interpolatoractor.js \
--js "${SOURCE_DIR}"/path/path.js \
--js "${SOURCE_DIR}"/path/pathactor.js \
--js "${SOURCE_DIR}"/texture/plasma.js \
--js "${SOURCE_DIR}"/webgl/ShaderUtil.js \
--js "${SOURCE_DIR}"/webgl/glu.js \
--js "${SOURCE_DIR}"/webgl/glTexturePage.js \
>> "${FILE_CAAT}"

#
# Compile box2d
#
echo "Creating CAAT Box2d"
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" --js "${SOURCE_DIR}"/box2d/box2Dactor.js >> "${FILE_CAAT_BOX2D}"

#
# Compile css
#
echo "Creating CAAT CSS"
echo -e "CAAT.__CSS__=1;" >> /tmp/__css.js
$JAVA -jar $CLOSURE_COMPILER_JAR --compilation_level "${COMPILATION_LEVEL}" \
--js "${SOURCE_DIR}"/CAAT.js \
--js /tmp/__css.js \
--js "${SOURCE_DIR}"/core/browserdetect.js \
--js "${SOURCE_DIR}"/core/class.js \
--js "${SOURCE_DIR}"/math/affinetransform2D.js \
--js "${SOURCE_DIR}"/math/color.js \
--js "${SOURCE_DIR}"/math/rectangle.js \
--js "${SOURCE_DIR}"/math/bezier.js \
--js "${SOURCE_DIR}"/math/point.js \
--js "${SOURCE_DIR}"/math/quadtree.js \
--js "${SOURCE_DIR}"/path/interpolator.js \
--js "${SOURCE_DIR}"/behaviour/behaviour.js \
--js "${SOURCE_DIR}"/model/debug.js \
--js "${SOURCE_DIR}"/model/actorCSS.js \
--js "${SOURCE_DIR}"/model/audio.js \
--js "${SOURCE_DIR}"/model/extraActor.js \
--js "${SOURCE_DIR}"/model/director.js \
--js "${SOURCE_DIR}"/model/mouseevent.js \
--js "${SOURCE_DIR}"/model/conpoundimage.js \
--js "${SOURCE_DIR}"/model/imagepreloader.js \
--js "${SOURCE_DIR}"/model/timer.js \
--js "${SOURCE_DIR}"/model/sceneCSS.js \
--js "${SOURCE_DIR}"/modules/modules.js \
--js "${SOURCE_DIR}"/modules/Layout/layout.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircle.js \
--js "${SOURCE_DIR}"/modules/CircleManager/PackedCircleManager.js \
--js "${SOURCE_DIR}"/modules/LocalStorage/LocalStorage.js \
--js "${SOURCE_DIR}"/modules/ImageUtil/ImageUtil.js \
--js "${SOURCE_DIR}"/modules/Font/font.js \
--js "${SOURCE_DIR}"/path/interpolatoractor.js \
--js "${SOURCE_DIR}"/path/path.js \
--js "${SOURCE_DIR}"/path/pathactor.js >> "${FILE_CAAT_CSS}"

#
# Distribute resulting compiled files
#
echo -e "\nCopying:"
while read LINE; do
echo -e "\tCopying results to ${LINE}"
cp ${FILE_CAAT} ${LINE}
cp ${FILE_CAAT_CSS} ${LINE}
cp ${FILE_CAAT_BOX2D} ${LINE}
done < version.distribution

./version.compile.pack.sh

#
# Generating JSDoc.
#
echo -e "\nGenerating JSDoc"
./version.compile.doc.sh
1 change: 1 addition & 0 deletions build/scripts/version.distribution
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/home/cyril/src/js/lib
1 change: 1 addition & 0 deletions build/scripts/version.incremental
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
243
1 change: 1 addition & 0 deletions build/scripts/version.nfo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3 build: 243
12 changes: 12 additions & 0 deletions build/scripts/version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FILE="version.nfo"
FILE_INCREMENTAL="version.incremental"

VERSION_INFO=`cat "$FILE"`

VERSION_MAJOR=`echo $VERSION_INFO | cut -d "." -f 1`
VERSION_MINOR=`echo $VERSION_INFO | cut -d "." -f 2 | cut -d " " -f 1`
VERSION_INCREMENTAL=`cat "$FILE_INCREMENTAL"`
let VERSION_INCREMENTAL++;
echo $VERSION_INCREMENTAL > $FILE_INCREMENTAL

echo "$VERSION_MAJOR.$VERSION_MINOR build: $VERSION_INCREMENTAL" > $FILE

0 comments on commit 795f4ce

Please sign in to comment.