From af1b5d3f7a059d8e553ca291811d4d7365d2ec21 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 29 Apr 2012 19:18:47 -0400 Subject: [PATCH] CC-3740: Use jsmin on javascript code before releasing -Done --- dev_tools/release/jsmin/jsmin | Bin 0 -> 9966 bytes dev_tools/release/jsmin/jsmin.c | 299 ++++++++++++++++++++++++++++++++ dev_tools/release/release.sh | 52 ++++++ 3 files changed, 351 insertions(+) create mode 100755 dev_tools/release/jsmin/jsmin create mode 100644 dev_tools/release/jsmin/jsmin.c create mode 100755 dev_tools/release/release.sh diff --git a/dev_tools/release/jsmin/jsmin b/dev_tools/release/jsmin/jsmin new file mode 100755 index 0000000000000000000000000000000000000000..27364aa7b9b017b7c37030c406b2f93999fa0892 GIT binary patch literal 9966 zcmcIq4RBP~b-vo=N#b`U@ngUuY_KR`TPrX>BMj6}2;mi3Fc?VU8vE@ct$xf(tJ!^< z2*O{x$YJ}yRTH;m>^9MK8jq*xv`jJ+t1-3tNs38bSE)U=re#vq!Bfe?fuxDOaj>`F zIq%-p+ox6A=}fO??>XnY=bU@az4zVsbl*GC6x!}7DG{o8#BU3hN_B?pT8QC!N<#=; z)QfV|OGULP1+3wx^mNH7dQrMov|PIJf=(meBLRL?So>vre`T0)Memn!gjGD!jzqE>ly-yCPSF8!jH0N@k8-15we(l*(IJtn z6A|0Eo}fGyz;?f9wi2K9*$P>o&Wxh_Y*;9&?DoKp;{4wh6=z+n^WcVcb+OjkSZ8;t zx3;%_L+yrjfn+@J0LNbehm_*OyY{ndH6B%vsBc;pG?&yq^XZL^BW-WS-}-6n9}oV1 z&+dPEUazONnfR6ANAan6!E#ZXCVRg_R_tOhl#9F2_!h%IHwC_V3cPU&eCZT;0C=TXEQaQW!P({>2v8h!F}wdtFq5=~ z=tm{BxD(Un5pA|8z9{3SxurQ$Mde9rLCrI@sXPg%HKU3eFT&N@rnX+`pVpsRYlNS4 z;Izh6IqkrmYqj5jQy;3FbKtx_Wy632r@mDQrf-&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% zMB1x;l7fSn|C`C!t z_$l~BFiv}Q{;tmD>DkFy-2HzKjZXXB6*{Z$mWghrMn`e?e-Uk@qVA*WJ%xII;T|uy z{Z*Geov2Y6knb`6CwqE^a`sQhX;jWjdv||s`Az83RIB*aeNeqe8IbwY^+QG3tGKQM zbM~*!iN83P)${tcG-0p&{JYCuJ%@y)eNY)ns_Ybf-(~;e+%RjtDDBmAt~8$%&uui2 zFO~mAX@5c5uU3YVR=DI}L8koOddhyP`;Qz}yepXK+v$2(_W!991h4EAOtQLm6h`!% z?D(9VxX%Eq$4`x$+E?iER=I=Cm(?{k`-;oCyZ^jF5ynf=dh|&xUPN476!(hFMe%94 zAL_zgyts1?cyu?6d`iVoQM^p3`;*hii&0VcokD!N2v5_U5c6Ifx|}SE&lDp?@mWIc z>rQ80+!54%U5I1XRQs@_!7F@1?XM0P`Bn(EZx-T}ct5E-A?CfJN~nF#+2|E>@!mD; zgrxpF>_^4$`PgTQ;S2B{witd_{yh>qmX#O(9jNQR5MLzJ^<0Qgyk9HC>1nXA*w@D# zaldOk>AIUHex857qO9n$DJe1z_cA_t9O#-V5tGNE3Ajhh5xZUeKF<1!#qiuPxQXle zDdrc85s9nov==z}x#;pURs5&e&s=fNHU59dc$GL^se_v+-vnDM{%-@Peuw7h6UyK& z;a6d(TlB|1@c3-=7wXn=brK)?XwBUHAxa>i34scaQWlF7fqcIwSPlNaYrO zr2ln^%WY5mQsRFjaf*Y=ukj=OW92%Dg3lO;p{)w|$V{Ci!DkDgrNB!(lhR?T# z-e+EzLjQ-rD;@ifn)kP+(0?CzMUi|zVm}ktwOao(ka(qMkvK2ciHi6x#^(uoY3VFA zz-ip*wJ4Pg*FvlVUV-cVg3FIC@!KxEiTqg zfzRi|=RSsk!x@znjf?%ANufLYqmx3+i1OKv{1BzE4L BNM-;4 literal 0 HcmV?d00001 diff --git a/dev_tools/release/jsmin/jsmin.c b/dev_tools/release/jsmin/jsmin.c new file mode 100644 index 000000000..74ba9233f --- /dev/null +++ b/dev_tools/release/jsmin/jsmin.c @@ -0,0 +1,299 @@ +/* jsmin.c + 2012-04-15 + +Copyright (c) 2002 Douglas Crockford (www.crockford.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include +#include + +static int theA; +static int theB; +static int theLookahead = EOF; + + +/* isAlphanum -- return true if the character is a letter, digit, underscore, + dollar sign, or non-ASCII character. +*/ + +static int +isAlphanum(int c) +{ + return ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || + (c >= 'A' && c <= 'Z') || c == '_' || c == '$' || c == '\\' || + c > 126); +} + + +/* get -- return the next character from stdin. Watch out for lookahead. If + the character is a control character, translate it to a space or + linefeed. +*/ + +static int +get() +{ + int c = theLookahead; + theLookahead = EOF; + if (c == EOF) { + c = getc(stdin); + } + if (c >= ' ' || c == '\n' || c == EOF) { + return c; + } + if (c == '\r') { + return '\n'; + } + return ' '; +} + + +/* peek -- get the next character without getting it. +*/ + +static int +peek() +{ + theLookahead = get(); + return theLookahead; +} + + +/* next -- get the next character, excluding comments. peek() is used to see + if a '/' is followed by a '/' or '*'. +*/ + +static int +next() +{ + int c = get(); + if (c == '/') { + switch (peek()) { + case '/': + for (;;) { + c = get(); + if (c <= '\n') { + return c; + } + } + case '*': + get(); + for (;;) { + switch (get()) { + case '*': + if (peek() == '/') { + get(); + return ' '; + } + break; + case EOF: + fprintf(stderr, "Error: JSMIN Unterminated comment.\n"); + exit(1); + } + } + default: + return c; + } + } + return c; +} + + +/* action -- do something! What you do is determined by the argument: + 1 Output A. Copy B to A. Get the next B. + 2 Copy B to A. Get the next B. (Delete A). + 3 Get the next B. (Delete B). + action treats a string as a single character. Wow! + action recognizes a regular expression if it is preceded by ( or , or =. +*/ + +static void +action(int d) +{ + switch (d) { + case 1: + putc(theA, stdout); + case 2: + theA = theB; + if (theA == '\'' || theA == '"' || theA == '`') { + for (;;) { + putc(theA, stdout); + theA = get(); + if (theA == theB) { + break; + } + if (theA == '\\') { + putc(theA, stdout); + theA = get(); + } + if (theA == EOF) { + fprintf(stderr, "Error: JSMIN unterminated string literal."); + exit(1); + } + } + } + case 3: + theB = next(); + if (theB == '/' && (theA == '(' || theA == ',' || theA == '=' || + theA == ':' || theA == '[' || theA == '!' || + theA == '&' || theA == '|' || theA == '?' || + theA == '{' || theA == '}' || theA == ';' || + theA == '\n')) { + putc(theA, stdout); + putc(theB, stdout); + for (;;) { + theA = get(); + if (theA == '[') { + for (;;) { + putc(theA, stdout); + theA = get(); + if (theA == ']') { + break; + } + if (theA == '\\') { + putc(theA, stdout); + theA = get(); + } + if (theA == EOF) { + fprintf(stderr, + "Error: JSMIN unterminated set in Regular Expression literal.\n"); + exit(1); + } + } + } else if (theA == '/') { + break; + } else if (theA =='\\') { + putc(theA, stdout); + theA = get(); + } + if (theA == EOF) { + fprintf(stderr, + "Error: JSMIN unterminated Regular Expression literal.\n"); + exit(1); + } + putc(theA, stdout); + } + theB = next(); + } + } +} + + +/* jsmin -- Copy the input to the output, deleting the characters which are + insignificant to JavaScript. Comments will be removed. Tabs will be + replaced with spaces. Carriage returns will be replaced with linefeeds. + Most spaces and linefeeds will be removed. +*/ + +static void +jsmin() +{ + if (peek() == 0xEF) { + get(); + get(); + get(); + } + theA = '\n'; + action(3); + while (theA != EOF) { + switch (theA) { + case ' ': + if (isAlphanum(theB)) { + action(1); + } else { + action(2); + } + break; + case '\n': + switch (theB) { + case '{': + case '[': + case '(': + case '+': + case '-': + case '!': + case '~': + action(1); + break; + case ' ': + action(3); + break; + default: + if (isAlphanum(theB)) { + action(1); + } else { + action(2); + } + } + break; + default: + switch (theB) { + case ' ': + if (isAlphanum(theA)) { + action(1); + break; + } + action(3); + break; + case '\n': + switch (theA) { + case '}': + case ']': + case ')': + case '+': + case '-': + case '"': + case '\'': + case '`': + action(1); + break; + default: + if (isAlphanum(theA)) { + action(1); + } else { + action(3); + } + } + break; + default: + action(1); + break; + } + } + } +} + + +/* main -- Output any command line arguments as comments + and then minify the input. +*/ +extern int +main(int argc, char* argv[]) +{ + int i; + for (i = 1; i < argc; i += 1) { + fprintf(stdout, "// %s\n", argv[i]); + } + jsmin(); + return 0; +} diff --git a/dev_tools/release/release.sh b/dev_tools/release/release.sh new file mode 100755 index 000000000..6543a31c9 --- /dev/null +++ b/dev_tools/release/release.sh @@ -0,0 +1,52 @@ +#!/bin/bash -e + +#release.sh 1.8.2 +#creates an airtime folder with a "1.8.2" suffix +#creates tarballs with a "1.8.2" suffix + +#release.sh 1.8.2 RC +#creates an airtime folder with a "1.8.2" suffix +#creates tarballs with a "1.8.2-RC" suffix + +if [ $# == 0 ]; then + echo "Zero arguments" + exit +elif [ $# == 1 ]; then + suffix=$1 + version=$1 +else + suffix=$1-$2 + version=$1 +fi + +dir=$(dirname $(readlink -f $0)) +gitrepo=$(readlink -f ./../../) + +echo "Creating tarballs with ${suffix} suffix" + +target=/tmp/airtime-${version} +target_file=/tmp/airtime-${suffix}.tar.gz + +rm -rf $target +rm -f $target_file +git clone file://$gitrepo $target + +cd $target + +echo "Checking out tag airtime-${suffix}" +git checkout airtime-${suffix} +git submodule init +git submodule update +rm -rf .git .gitignore .gitmodules .zfproject.xml dev_tools/ audio_samples/ python_apps/pypo/liquidsoap_bin/.git + +echo "Minimizing Airtime Javascript files..." +cd $dir +find $target/airtime_mvc/public/js/airtime/ -iname "*.js" -exec bash -c 'echo {}; jsmin/jsmin < {} > {}.min' \; +find $target/airtime_mvc/public/js/airtime/ -iname "*.js" -exec mv {}.min {} \; +echo "Done" + + +#zip -r airtime-${suffix}.zip airtime-${version} +tar -czf $target_file $target + +echo "Output file available at $target_file"