My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
#!/bin/sh
# This script compresses the parser and embeds it into
# the Makefile, using Makefile.in template
#
# Trick to hide the silly warnings caused by windows line ends
file $0 | grep -q CRLF && sed -i 's/\r//' $0 && exec $SHELL $0;

echo Updating Makefile

# output file can be overriden by MAKEFILE_OUT variable
[ "$MAKEFILE_OUT" ] || MAKEFILE_OUT="/tmp/Makefile"

{
cat Makefile.in

echo '### PARSER CODE (gzipped and base64 encoded) ###'
{
#we perform the '#include' first
sed '/#include PROCESS/,$d' Parser.cpp
cat Make.hpp
sed '1,/#include PROCESS/d' Parser.cpp
} | gzip -9 | base64 -w74 | sed 's/.*/#:&/;'

echo '### BRC parser (gzipped and base64 encoded) ###'
cat brc.sh | gzip -9 | base64 -w74 | sed 's/.*/#~&/;'

echo '### Colorizer (gzipped and base64 encoded) ###'
cat color.sh | gzip -9 | base64 -w74 | sed 's/.*/#%&/;'
} > "$MAKEFILE_OUT"

# fix line endings
sed -i 's/\r//;' "$MAKEFILE_OUT"

# little trick to ensure Makefile is always "rebuild"
sh -c 'sleep 2 && touch Makefile.in'&

exit 0 # comment this line out to see some compression statistics

stat() {
printf "%s %5i -> %5i %3i -> %3i\n" "$1"\
`cat $2 | wc -c` `grep $3 "$MAKEFILE_OUT" | wc -c` \
`cat $2 | wc -l` `grep $3 "$MAKEFILE_OUT" | wc -l`
}

echo "Compression info:"
printf "%s%12s%14s\n" "File " bytes lines
stat "Parser " Parser.cpp '^#:'
stat "Brc parser" brc.sh '^#~'
stat "Colorizer " color.sh '^#%'
stat "Total " "Parser.cpp brc.sh color.sh" '^#[%~:]'
stat "Makefile " Makefile.in '^'

Change log

r4598 by dolik on Feb 15, 2012   Diff
.lpbuild2, .UppBuilder: various fixes
Go to: 
Project members, sign in to write a code review

Older revisions

r4581 by dolik on Feb 13, 2012   Diff
.lpbuild2: packaging improvements (RM
#244)
r4562 by dolik on Feb 8, 2012   Diff
+UppBuilder: upp file parser and
makefile generator
All revisions of this file

File info

Size: 1518 bytes, 51 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting