aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: 561123856a2085cbc2afb402040e5d9573bc0d53 (plain) (blame)
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
#!/bin/bash
set -x
prog=dm
extern=.extern
DFLAGS="-w -g -O"

build_tinyendian() {
    pushd ${extern}
        [ ! -d "tinyendian" ] && git clone --recursive https://github.com/dlang-community/tinyendian
        pushd tinyendian
            if [[ $(find . -name '*.a') ]]; then
                popd
                popd
                return
            fi
            git checkout v0.2.0
            dmd ${DFLAGS} -lib -oflibtinyendian.a \
                $(find source -type f -name '*.d')
        popd
    popd
}

build_dyaml() {
    pushd ${extern}
        [ ! -d "D-YAML" ] && git clone --recursive https://github.com/dlang-community/D-YAML
        pushd D-YAML
            if [[ $(find . -name '*.a') ]]; then
                popd
                popd
                return
            fi
            git checkout v0.7.1
            dmd ${DFLAGS} -lib -oflibdyaml.a \
                -I../tinyendian/source \
                ../tinyendian/libtinyendian.a \
                $(find source -type f -name '*.d')
        popd
    popd
}

clean() {
    rm -rf ${extern}
    rm -rf *.o
}

if [ "$1" == "clean" ]; then
    clean
    exit 0
fi

mkdir -p ${extern}
build_tinyendian
build_dyaml
dmd ${DFLAGS} -of${prog} \
    -I${extern}/tinyendian/source \
    -I${extern}/D-YAML/source \
    ${extern}/D-YAML/libdyaml.a \
    $(find source -type f -name '*.d')