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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
#!/bin/bash
OUT_BASE=$STORM_ROOT/release/storm
arch="$1"
command="$2"
version="$3"
date="$4"
notes="$5"
# Launchers to include in build: An @ indicates envvars to set on Linux.
# Note ~ is used as replacement for space. Versions can contain + for unnamed git versions.
launchers=(
"progvis:progvis.main~--noconsole" #@STORM_RENDER_BACKEND=gtk"
"trees:trees.main~--noconsole"
"generate_html_doc:markdown.doc.generateStormDoc~--~--clear~html~--version=${version}~--date=${date}"
)
function join_array { local IFS=" "; echo "$*"; }
launchers=$(join_array "${launchers[@]}")
if [[ $arch == *_win* ]]
then
OUT_EXT=.zip
add="7z a"
exe=".exe"
lib=".dll"
scr=".bat"
else
OUT_EXT=.tar
add="tar -rf"
exe=""
lib=".so"
scr=".sh"
fi
OUT=$OUT_BASE$OUT_EXT
# We only need the build command to know where to look for compiled files.
namesuffix=""
if [[ $command == *64* ]]
then
namesuffix="64"
fi
# Figure out the GC used, we need it to find the executable.
if [[ $command == *mps* ]]
then
gc=_mps
elif [[ $command == *smm* ]]
then
gc=_smm
fi
function fix_name_case {
if [[ $arch == *_win* ]]
then
echo ${1^}
else
echo ${1,}
fi
}
function launcher {
args=${1%%@*}
envvars=$(expr match "$1" '.*@\(.*\)')
if [[ "$2" =~ \.bat$ ]]
then
# If the args don't have --, add -- %* to the end to allow passing parameters.
if [[ "$args" != *~--~* ]]
then
args="${args}~--~%*"
fi
if [[ "$args" == *~--noconsole* ]]
then
echo '@start "Storm" "%~dp0Storm.exe" -f '"${args//'~'/ }" > "$2"
else
echo '@"%~dp0Storm.exe" -f '"${args//'~'/ }" > "$2"
fi
else
(
echo '#!/bin/bash'
echo 'DIR=$(dirname "$0")'
echo 'chmod +x "$DIR"/storm 2> /dev/null'
while [ ! "x$envvars" == "x" ]
do
echo "export ${envvars%%@*}"
envvars=$(expr match "$envvars" '.*@\(.*\)')
done
# If args don't have --, add -- $@ to the end to allow passing parameters.
if [[ "$args" != *~--~* ]]
then
args="${args}~--~\"\$@\""
fi
echo "exec \"\$DIR\"/storm -f ${args//'~'/ }"
) > "$2"
chmod +x "$2"
fi
}
function add_rename {
cp $1 $2
eval $add $OUT $2 > /dev/null
rm $2
}
function add_rename_custom {
cp $2 $3
eval $add $1 $3 > /dev/null
rm $3
}
if [[ -e $OUT ]]
then
rm $OUT
fi
cd $STORM_ROOT
echo "Packing release..."
# Documentation.
find doc/ -type f | xargs --delimiter='\n' $add $OUT > /dev/null
# Release notes.
if [[ -f $notes ]]
then
cp "$notes" doc/release_notes.txt
else
release-notes > doc/release_notes.txt
fi
$add $OUT doc/release_notes.txt > /dev/null
rm doc/release_notes.txt
# Source code from root/
find root/ -type f -not -name "*$lib" | grep -v "server-tests/" | xargs --delimiter='\n' $add $OUT > /dev/null
# Rename and add dynamic libraries
IFS=$'\n'
for j in $(find root/ -name "Release${namesuffix}*${lib}")
do
name=$(echo $j | sed "s/Release${namesuffix}//")
# Otherwise Release64X.dll matches as 64X.dll when it should not.
if [[ $name != */64* ]]
then
add_rename $j $name
fi
done
# Mariadb library:
plainsuffix=32
if [[ $namesuffix != "" ]]
then
plainsuffix=$namesuffix
fi
for j in $(find root/ -name "*_${plainsuffix}${lib}")
do
name=${j%_${plainsuffix}${lib}}${lib}
add_rename $j $name
done
# Add the Emacs plugin.
add_rename Plugin/emacs.el storm-mode.el
# Add any launchers.
IFS=" "
for l in $launchers
do
name=${l%%:*}$scr
name=$(fix_name_case $name)
launcher "${l#*:}" "$name"
eval $add $OUT "$name" > /dev/null
rm "$name"
done
# Add the main executable
add_rename_custom ${OUT} release${namesuffix}/Storm${gc}$exe $(fix_name_case Storm$exe)
# Make it the proper name.
mv ${OUT} ${OUT_BASE}_${arch}${OUT_EXT}
if [[ $OUT_EXT == .tar ]]
then
if [[ -e ${OUT_BASE}_$arch.tar.gz ]]
then
rm ${OUT_BASE}_$arch.tar.gz
fi
gzip ${OUT_BASE}_$arch.tar
fi
echo "Done!"
|