about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh
blob: 44eb453087dbd5c18b136c94920ef83a467b2152 (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
59
60
61
62
63
64
65
66
67
68
69
haredoBuildPhase() {
    runHook preBuild

    local buildTargets jobs
    read -ra buildTargets <<<"${haredoBuildTargets-}"
    echoCmd "haredo build targets" "${buildTargets[@]}"
    if [[ ! -v enableParallelBuilding || -n "${enableParallelBuilding-}" ]]; then
        jobs="${NIX_BUILD_CORES}"
    fi
    haredo ${jobs:+"-j${jobs}"} "${buildTargets[@]}"

    runHook postBuild
}

haredoCheckPhase() {
    runHook preCheck

    local checkTargets jobs

    if [[ -n "${haredoCheckTargets:-}" ]]; then
        read -ra checkTargets <<<"${haredoCheckTargets}"
    else
        for dofile in "check.do" "test.do"; do
            [[ -r "${dofile}" ]] && {
                checkTargets=("${dofile%".do"}")
                break
            }
        done
    fi

    if [[ -z "${checkTargets:-}" ]]; then
        printf -- 'haredoCheckPhase ERROR: no check targets were found' 1>&2
        exit 1
    else
        echoCmd "haredo check targets" "${checkTargets[@]}"
        if [[ ! -v enableParallelChecking || -n "${enableParallelChecking-}" ]]; then
            jobs="${NIX_BUILD_CORES}"
        fi
        haredo ${jobs:+"-j${jobs}"} "${checkTargets[@]}"
    fi

    runHook postCheck
}

haredoInstallPhase() {
    runHook preInstall

    local installTargets jobs
    read -ra installTargets <<<"${haredoInstallTargets:-"install"}"
    echoCmd "haredo install targets" "${installTargets[@]}"
    if [[ ! -v enableParallelInstalling || -n "${enableParallelInstalling-}" ]]; then
        jobs="${NIX_BUILD_CORES}"
    fi
    haredo ${jobs:+"-j${jobs}"} "${installTargets[@]}"

    runHook postInstall
}

if [[ -z "${dontUseHaredoBuild-}" && -z "${buildPhase-}" ]]; then
    buildPhase="haredoBuildPhase"
fi

if [[ -z "${dontUseHaredoCheck-}" && -z "${checkPhase-}" ]]; then
    checkPhase="haredoCheckPhase"
fi

if [[ -z "${dontUseHaredoInstall-}" && -z "${installPhase-}" ]]; then
    installPhase="haredoInstallPhase"
fi