2013-05-30 15:47:47 -07:00
|
|
|
#!/bin/bash
|
2011-06-25 22:34:59 +02:00
|
|
|
|
2013-01-28 18:03:27 -08:00
|
|
|
# Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
# http://paperjs.org/
|
2011-03-07 00:50:44 +00:00
|
|
|
#
|
2014-01-04 01:47:16 +01:00
|
|
|
# Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
|
|
|
|
# http://scratchdisk.com/ & http://jonathanpuckey.com/
|
2011-03-07 00:50:44 +00:00
|
|
|
#
|
2011-07-01 12:17:45 +02:00
|
|
|
# Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
#
|
|
|
|
# All rights reserved.
|
2011-03-07 00:50:44 +00:00
|
|
|
|
2011-03-03 13:45:21 +00:00
|
|
|
# preprocess.sh
|
|
|
|
#
|
|
|
|
# A simple code preprocessing wrapper that uses a combination of cpp, jssrip.py
|
|
|
|
# and sed to preprocess JavaScript files containing C-style preprocess macros
|
2013-08-08 15:21:35 -07:00
|
|
|
# (#include, #ifdef, etc.). Three options offer control over whether comments
|
2011-03-03 13:45:21 +00:00
|
|
|
# are preserved or stripped and whitespaces are compressed.
|
|
|
|
#
|
|
|
|
# Usage:
|
2013-02-28 17:41:02 -08:00
|
|
|
# preprocess.sh MODE SOURCE ARGUMENTS DESTINATION
|
2011-03-03 13:45:21 +00:00
|
|
|
#
|
|
|
|
# MODE:
|
2012-12-24 16:44:13 +01:00
|
|
|
# commented Preprocessed, still formated and commented
|
|
|
|
# stripped Preprocessed, formated but without comments
|
2011-03-03 13:45:21 +00:00
|
|
|
|
2013-05-27 15:11:32 -07:00
|
|
|
# Get the date from the git log:
|
2011-07-24 19:41:13 +01:00
|
|
|
DATE=$(git log -1 --pretty=format:%ad)
|
2014-04-06 14:47:45 +02:00
|
|
|
# Load __options from options.js and convert it to escaped JSON, to be passed on
|
|
|
|
# to prepro:
|
2013-05-27 15:11:32 -07:00
|
|
|
OPTIONS=$(printf '%q' $(node -e "
|
|
|
|
eval(require('fs').readFileSync('../src/options.js', 'utf8'));
|
2013-11-29 23:06:51 +01:00
|
|
|
process.stdout.write(JSON.stringify(__options));
|
2013-05-27 15:11:32 -07:00
|
|
|
"))
|
|
|
|
# Build the prepo.js command out of it, passing on version and date as defines:
|
2014-08-16 18:49:35 +02:00
|
|
|
COMMAND="../node_modules/.bin/prepro -o $OPTIONS -o '{ \"date\": \"$DATE\" }' $3 $2"
|
2011-03-03 13:45:21 +00:00
|
|
|
|
2011-07-13 13:27:14 +01:00
|
|
|
case $1 in
|
2011-03-03 13:45:21 +00:00
|
|
|
commented)
|
2013-02-28 17:41:02 -08:00
|
|
|
eval $COMMAND > $4
|
2011-03-03 13:45:21 +00:00
|
|
|
;;
|
2012-12-24 16:44:13 +01:00
|
|
|
stripped)
|
2013-02-28 17:41:02 -08:00
|
|
|
eval "$COMMAND -c" > $4
|
2011-03-03 13:45:21 +00:00
|
|
|
;;
|
|
|
|
esac
|