| 1 |
#!/bin/bash |
|---|
| 2 |
|
|---|
| 3 |
if [[ $1 != [0-9].[0-9][0-9][0-9] ]]; then |
|---|
| 4 |
echo Wrong version format. Expected: d.ddd |
|---|
| 5 |
exit; |
|---|
| 6 |
fi |
|---|
| 7 |
|
|---|
| 8 |
BUILD="./build" |
|---|
| 9 |
DIR="dil.$1" |
|---|
| 10 |
DEST="$BUILD/$DIR" |
|---|
| 11 |
FRESH_REPOS="$BUILD/fresh_repos" |
|---|
| 12 |
|
|---|
| 13 |
# Create build directory if it doesn't exist. |
|---|
| 14 |
[ ! -e $BUILD ] && mkdir $BUILD |
|---|
| 15 |
|
|---|
| 16 |
# Convert Unix newlines to Windows newlines |
|---|
| 17 |
# function unix2win |
|---|
| 18 |
# { |
|---|
| 19 |
# sed {s/$/\\r/} $* |
|---|
| 20 |
# } |
|---|
| 21 |
|
|---|
| 22 |
# We need dil to get a list of all modules to be compiled. |
|---|
| 23 |
if [ ! -s ./dil ]; then |
|---|
| 24 |
dsss build -full &> /dev/null |
|---|
| 25 |
fi |
|---|
| 26 |
|
|---|
| 27 |
if [ ! -s ./dil ]; then |
|---|
| 28 |
echo "Couldn't build DIL. Can't get list of modules to be built." |
|---|
| 29 |
exit; |
|---|
| 30 |
fi |
|---|
| 31 |
|
|---|
| 32 |
# Used by doc generation and winbuild function. |
|---|
| 33 |
SRC_FILES=`./dil igraph src/main.d --paths` |
|---|
| 34 |
|
|---|
| 35 |
# Recreate destination directory. |
|---|
| 36 |
rm -rf $DEST |
|---|
| 37 |
mkdir -p $DEST/{bin,doc/htmlsrc,src} |
|---|
| 38 |
|
|---|
| 39 |
# Create documentation. |
|---|
| 40 |
./dil ddoc $DEST/doc/ -v src/macros_dil.ddoc -version=DDoc src/config.d $SRC_FILES |
|---|
| 41 |
# Generate syntax highlighted HTML files. |
|---|
| 42 |
HTMLSRC="$DEST/doc/htmlsrc" |
|---|
| 43 |
for filepath in $SRC_FILES; |
|---|
| 44 |
do |
|---|
| 45 |
htmlfile=`echo $filepath | sed -e 's@^src/@@' -e 's@/@.@g' -e 's@.d$@@'`.html |
|---|
| 46 |
echo "FILE: $filepath > $HTMLSRC/$htmlfile"; |
|---|
| 47 |
./dil hl --lines --syntax --html $filepath > "$HTMLSRC/$htmlfile"; |
|---|
| 48 |
done |
|---|
| 49 |
|
|---|
| 50 |
# Linux Debug Binaries |
|---|
| 51 |
echo "***** Building Linux binaries *****" |
|---|
| 52 |
dsss build -clean -full -version=D2 |
|---|
| 53 |
cp dil $DEST/bin/dil2_d |
|---|
| 54 |
dsss build -clean -full |
|---|
| 55 |
cp dil $DEST/bin/dil_d |
|---|
| 56 |
# Linux Release Binaries |
|---|
| 57 |
# N.B.: the -inline switch makes the binaries significantly larger. |
|---|
| 58 |
dsss build -clean -full -release -O -inline -version=D2 |
|---|
| 59 |
cp dil $DEST/bin/dil2 |
|---|
| 60 |
dsss build -clean -full -release -O -inline |
|---|
| 61 |
cp dil $DEST/bin/dil |
|---|
| 62 |
|
|---|
| 63 |
if [ -s ~/bin/dmd.exe ]; then |
|---|
| 64 |
echo "***** Building Windows binaries *****" |
|---|
| 65 |
function winbuild |
|---|
| 66 |
{ # obj dir is winobj. -op = don't strip paths from obj files. |
|---|
| 67 |
wine ~/bin/dmd.exe -odwinobj -op -ofdil $* $SRC_FILES |
|---|
| 68 |
} |
|---|
| 69 |
# Windows Debug Binaries |
|---|
| 70 |
winbuild -version=D2 |
|---|
| 71 |
cp dil.exe $DEST/bin/dil2_d.exe |
|---|
| 72 |
winbuild |
|---|
| 73 |
cp dil.exe $DEST/bin/dil_d.exe |
|---|
| 74 |
# Windows Release Binaries |
|---|
| 75 |
winbuild -release -O -inline -version=D2 |
|---|
| 76 |
cp dil.exe $DEST/bin/dil2.exe |
|---|
| 77 |
winbuild -release -O -inline |
|---|
| 78 |
cp dil.exe $DEST/bin/dil.exe |
|---|
| 79 |
fi |
|---|
| 80 |
|
|---|
| 81 |
# Copy source and other files. |
|---|
| 82 |
rm -rf $FRESH_REPOS |
|---|
| 83 |
hg archive -r tip -t files $FRESH_REPOS |
|---|
| 84 |
cp -r $FRESH_REPOS/* $DEST |
|---|
| 85 |
|
|---|
| 86 |
cp $FRESH_REPOS/src/config.d $DEST/bin/ |
|---|
| 87 |
cp $FRESH_REPOS/src/lang_*.d $DEST/bin/ |
|---|
| 88 |
cp $FRESH_REPOS/src/*_map.d $DEST/bin/ |
|---|
| 89 |
cp $FRESH_REPOS/src/*.css $DEST/bin/ |
|---|
| 90 |
cp $FRESH_REPOS/src/predefined.ddoc $DEST/bin/ |
|---|
| 91 |
cp $FRESH_REPOS/src/html.css $HTMLSRC |
|---|
| 92 |
|
|---|
| 93 |
# Build archives |
|---|
| 94 |
# tar.gz doesn't compress well |
|---|
| 95 |
tar --owner root --group root -czf $DEST.tar.gz $DEST |
|---|
| 96 |
tar --owner root --group root --bzip2 -cf $DEST.tar.bz2 $DEST |
|---|
| 97 |
zip -q -9 -r $DEST.zip $DEST |
|---|