Blame view

buildAll.sh 4 KB
Michał Lenart authored
1
2
3
4
#!/bin/bash

set -e -o pipefail
Michał Lenart authored
5
if [ "$#" -ne 4 ]; then
Michał Lenart authored
6
    echo "Must provide exactly 4 arguments: <CROSSMORFEUSZ_ROOT> <INPUT_DICTIONARIES> <DEFAULT_DICT_NAME> <DICT_VERSION>"
Michał Lenart authored
7
8
9
    exit 1
fi
Michał Lenart authored
10
11
export CROSSMORFEUSZ_ROOT="$1"
export INPUT_DICTIONARIES="$2"
Michał Lenart authored
12
export DEFAULT_DICT_NAME="$3"
Michał Lenart authored
13
export DICT_VERSION="$4"
Michał Lenart authored
14
15
export ANALYZER_DICTIONARY_CPP=`mktemp`.cpp
export GENERATOR_DICTIONARY_CPP=`mktemp`.cpp
Michał Lenart authored
16
export DICT_DIR=`mktemp -d`
Michał Lenart authored
17
18

function buildDictionaries {
Michał Lenart authored
19
Michał Lenart authored
20
    INPUT_TAGSET=input/morfeusz-sgjp.tagset
Michał Lenart authored
21
22
23
24
25
26
    SEGMENT_RULES_FILE=input/segmenty.dat

    python fsabuilder/morfeusz_builder \
        --input-files="$INPUT_DICTIONARIES" \
        --tagset-file="$INPUT_TAGSET" \
        --segments-file="$SEGMENT_RULES_FILE" \
Michał Lenart authored
27
28
29
30
        --analyzer-cpp="$ANALYZER_DICTIONARY_CPP" \
        --generator-cpp="$GENERATOR_DICTIONARY_CPP" \
        --dict="$DEFAULT_DICT_NAME" \
        --dict-dir="$DICT_DIR"
Michał Lenart authored
31
Michał Lenart authored
32
    echo "DONE building dictionaries" >&2
Michał Lenart authored
33
}
Michał Lenart authored
34
Michał Lenart authored
35
function build {
Michał Lenart authored
36
    set -e -o pipefail
Michał Lenart authored
37
38
    os=$1
    arch=$2
Michał Lenart authored
39
40
    embedded=$3
    shift
Michał Lenart authored
41
42
43
    shift
    shift
    targets=$@
Michał Lenart authored
44
Michał Lenart authored
45
    srcDir=`pwd`
Michał Lenart authored
46
    buildDir=buildall/$os-$arch-$embedded
Michał Lenart authored
47
    targetDir=$srcDir/target
Michał Lenart authored
48
    toolchain=$srcDir/toolchains/Toolchain-$os-$arch.cmake
Michał Lenart authored
49
Michał Lenart authored
50
    echo "Will use $toolchain toolchain"
Michał Lenart authored
51
Michał Lenart authored
52
    rm -rf $buildDir
Michał Lenart authored
53
    #~ rm -rf $targetDir
Michał Lenart authored
54
55
56
    mkdir -p $buildDir
    mkdir -p $targetDir
    cd $buildDir
Michał Lenart authored
57
58
59
60
61
62
63

    if [ "$embedded" = true ]
    then
        if [ "$os" == "Linux" ]
        then
            CPACK_GENERATOR=TGZ
        fi
Michał Lenart authored
64
        CMAKE_ARGS="-D CROSSMORFEUSZ_ROOT=$CROSSMORFEUSZ_ROOT \
Michał Lenart authored
65
66
67
68
69
70
            -D CMAKE_TOOLCHAIN_FILE=$toolchain \
            -D TARGET_DIR=$targetDir \
            -D ANALYZER_DICTIONARY_CPP=$ANALYZER_DICTIONARY_CPP \
            -D GENERATOR_DICTIONARY_CPP=$GENERATOR_DICTIONARY_CPP \
            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
            -D SKIP_DICTIONARY_BUILDING=1 \
Michał Lenart authored
71
72
            -D EMBEDDED_DEFAULT_DICT=1 \
            -D DICT_VERSION=$DICT_VERSION"
Michał Lenart authored
73
74
        if [ "$CPACK_GENERATOR" != "" ]
        then
Michał Lenart authored
75
            CMAKE_ARGS="$CMAKE_ARGS -D CPACK_GENERATOR=$CPACK_GENERATOR"
Michał Lenart authored
76
        fi
Michał Lenart authored
77
78
    else
        echo "setting default ACL to prevent control-file-has-bad-permissions lintian error"
Michał Lenart authored
79
        setfacl -R -d -m o::rx -m g::rx -m u::rwx .
Michał Lenart authored
80
Michał Lenart authored
81
        CMAKE_ARGS="-D CROSSMORFEUSZ_ROOT=$CROSSMORFEUSZ_ROOT \
Michał Lenart authored
82
83
84
85
86
            -D CMAKE_TOOLCHAIN_FILE=$toolchain \
            -D TARGET_DIR=$targetDir \
            -D DEFAULT_DICT_DIR=$DICT_DIR \
            -D DEFAULT_DICT_NAME=$DEFAULT_DICT_NAME \
            -D SKIP_DICTIONARY_BUILDING=1 \
Michał Lenart authored
87
88
            -D CPACK_GENERATOR=DEB \
            -D DICT_VERSION=$DICT_VERSION"
Michał Lenart authored
89
    fi
Michał Lenart authored
90
    cmake $CMAKE_ARGS $srcDir 2>&1
Michał Lenart authored
91
    echo "building $toolchain" >&2
Michał Lenart authored
92
    make
Michał Lenart authored
93
    make $targets
Michał Lenart authored
94
Michał Lenart authored
95
    for f in `find "$targetDir" -name "*-Linux-*.deb"`
Michał Lenart authored
96
    do 
Michał Lenart authored
97
98
        mv "$f" "`echo $f | sed -r 's/Linux-amd64.deb$/amd64.deb/' | sed -r 's/Linux-i386.deb/i386.deb/'`"
    done
Michał Lenart authored
99
Jan Szejko authored
100
101
102
103
    if [ "$os" = Linux -a "$embedded" = false ]; then
        "$srcDir/createDictionaryDeb.sh" "$DICT_DIR" "${DEFAULT_DICT_NAME}" "${DICT_VERSION}" "${targetDir}"
    fi
Michał Lenart authored
104
105
106
    cd "$srcDir"
}
Michał Lenart authored
107
108
109
110
111
112
function log {
    os=$1
    arch=$2
    stdbuf -oL sed -e $"s/^/$os-$arch:\t/" | tee "log/$os-$arch.out"
}
Michał Lenart authored
113
export -f build
Michał Lenart authored
114
export -f log
Michał Lenart authored
115
Michał Lenart authored
116
rm -rf log target
Michał Lenart authored
117
mkdir -p log
Michał Lenart authored
118
Michał Lenart authored
119
120
121
buildDictionaries 2>&1 | log All all

{
Michał Lenart authored
122
    echo "build Linux amd64 true package package-java package-python package-builder 2>&1 | log Linux-tgz amd64"
Jan Szejko authored
123
    echo "build Linux amd64 false lib-deb bin-deb dev-deb dictionary-deb java-deb 2>&1 | log Linux-deb amd64"
Michał Lenart authored
124
    echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 true package package-java 2>&1 | log Linux-tgz i386"
Jan Szejko authored
125
    echo "LDFLAGS=-m32;CFLAGS=-m32;CXXFLAGS=-m32 build Linux i386 false lib-deb bin-deb java-deb 2>&1 | log Linux-deb i386"
Michał Lenart authored
126
127
128
    echo "build Windows amd64 true package package-java 2>&1 | log Windows amd64"
    echo "build Windows i386 true package package-java 2>&1 | log Windows i386"
    echo "build Darwin amd64 true package package-java 2>&1 | log Darwin amd64"
Michał Lenart authored
129
} | xargs -n1 -P2 -d$'\n' bash -c
Michał Lenart authored
130
Michał Lenart authored
131