ref: master
plugins/social_share_privacy/public/socialshareprivacy/build.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
#!/bin/bash modules=all autoload=on css=on img=on pathprefix= stylefile=stylesheets/jquery.socialshareprivacy.min.css langs=all builddir=build allmodules=`ls javascripts/modules/*.js|sed 's/javascripts\/modules\/\(.*\)\.js/\1/'` alllangs=`ls -d javascripts/locale/??|xargs -n 1 basename` while getopts ":m:a:s:p:c:i:l:o:h" opt; do case $opt in m) modules="$OPTARG" ;; a) autoload="$OPTARG" ;; c) css="$OPTARG" ;; i) img="$OPTARG" ;; p) pathprefix="$OPTARG" ;; s) stylefile="$OPTARG" ;; l) langs="`echo "$OPTARG"|tr ',' ' '`" ;; o) builddir="$OPTARG" ;; h) echo "Usage:" echo " ./build.sh [options]" echo echo "Options:" echo " -h Print this help message." echo " -m <modules> Comma separated list of JavaScript modules to pack. Possible values:" echo all none $allmodules|sed 's/ /, /g'|fmt -60|xargs -n 1 -d '\n' echo " " echo " default: all" echo echo " -l <languages> Comma separated list of languages to pack. Possible values:" echo all none $alllangs|sed 's/ /, /g'|fmt -60|xargs -n 1 -d '\n' echo " " echo " default: all" echo echo " -a <enabled> Autoload. Possible values: on, off (default: on)" echo " -c <enabled> Pack stylesheets. Possible values: on, off (default: on)" echo " -i <enabled> Pack images. Possible values: on, off (default: on)" echo " -p <path> Prefix to stylesheet and dummy image paths. (empty per default)" echo " -s <path> Stylesheet path in the generated JavaScript file." echo " default: stylesheets/jquery.socialshareprivacy.min.css" echo " -o <directory> Output directory. (default: build)" echo exit ;; \?) echo "Invalid option: -$OPTARG" >&2 echo "See -h for a list of available options." >&2 exit 1 ;; esac done if [ "$modules" = "all" ]; then modules=`echo -n $allmodules|tr ' ' ','` elif [ "$modules" = "" ]; then modules="none" fi if [ "$langs" = "all" ]; then langs="$alllangs" elif [ "$langs" = "" ]; then langs="none" fi mkdir -p "$builddir/javascripts" || exit 1 files="javascripts/socialshareprivacy.js" if [ "$modules" != "none" ]; then files="$files `eval echo javascripts/modules/{$modules}.js`" fi files="$files javascripts/settings.js" uglifyjs $files \ --compress=warnings=false \ | sed -e "s|path_prefix:\"\"|path_prefix:\"$pathprefix\"|g" \ | sed -e "s|stylesheets/socialshareprivacy.css|$stylefile|g" \ > "$builddir/javascripts/jquery.socialshareprivacy.min.js" || exit 1 echo "created $builddir/javascripts/jquery.socialshareprivacy.min.js" if [ "$autoload" = "on" ]; then uglifyjs $files javascripts/autoload.js \ --compress=warnings=false \ | sed -e "s|path_prefix:\"\"|path_prefix:\"$pathprefix\"|g" \ | sed -e "s|stylesheets/socialshareprivacy.css|$stylefile|g" \ > "$builddir/javascripts/jquery.socialshareprivacy.min.autoload.js" || exit 1 echo "created $builddir/javascripts/jquery.socialshareprivacy.min.autoload.js" fi if [ "$langs" != "none" ]; then for lang in $langs; do files="javascripts/locale/$lang/socialshareprivacy.js" if [ "$modules" != "none" ]; then files="$files `eval ls javascripts/locale/$lang/modules/{$modules}.js 2>/dev/null`" fi node join-trans.js $files | uglifyjs \ --compress=warnings=false \ --output="$builddir/javascripts/jquery.socialshareprivacy.min.$lang.js" || exit 1 echo "created $builddir/javascripts/jquery.socialshareprivacy.min.$lang.js" done fi if [ "$img" = "on" ]; then mkdir -p "$builddir/images" || exit 1 files="`eval ls images/socialshareprivacy_* images/settings.png images/{dummy_,}{box_,}{$modules}.* 2>/dev/null`" if [ "$files" != "" ]; then cp $files "$builddir/images" || exit 1 echo "copied images to $builddir/images" fi if [ "$langs" != "none" ]; then for lang in $langs; do if [ -d "images/$lang" ]; then mkdir -p "$builddir/images/$lang" || exit 1 files="`eval ls images/$lang/{dummy_,}{box_,}{$modules}.* 2>/dev/null`" if [ "$files" != "" ]; then cp $files "$builddir/images/$lang" || exit 1 echo "copied images to $builddir/images/$lang" fi fi done fi fi if [ "$css" = "on" ]; then styledir="`dirname "$builddir/$stylefile"`" mkdir -p "$styledir" || exit 1 files="stylesheets/common.css" if [ "$modules" != "none" ]; then files="$files `eval ls stylesheets/modules/{$modules}.css 2>/dev/null`" fi uglifycss $files > "$builddir/$stylefile" || exit 1 echo "created $builddir/$stylefile" fi |