blob: ba3f1e1680af44434dc548fac9063953b60e3445 (
plain)
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
|
#!/bin/bash
#
# Copyright (C) 2015 by Michael Olbrich <mol@pengutronix.de>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#
ptxd_make_serialize_take() {
local readptr="ptxd_make_serialize_${pkg_stage}_readfd"
local tmp
if [ -n "${!readptr}" ]; then
read -n 1 -u "${!readptr}" tmp
fi
}
export -f ptxd_make_serialize_take
ptxd_make_serialize_put() {
local ret=$?
local fifo="${PTXDIST_TEMPDIR}/${pkg_stage}-fifo"
if [ -e "${fifo}" ]; then
echo -n '+' > "${fifo}"
fi
return "${ret}"
}
export -f ptxd_make_serialize_put
ptxd_make_serialize_setup() {
local name="${1}"
local count="${2}"
local fifo="${PTXDIST_TEMPDIR}/${name}-fifo"
local writeptr="ptxd_make_serialize_${name}_writefd"
local readptr="ptxd_make_serialize_${name}_readfd"
local writefd readfd
mkfifo "${fifo}" || return
echo -n "$(seq -s "+" 0 ${count} | sed 's/[^+]//g')" > "${fifo}" &
exec {readfd}< "${fifo}" &&
exec {writefd}> "${fifo}" &&
eval "${readptr}"="${readfd}" &&
eval "${writeptr}"="${writefd}" &&
export "${readptr}" "${writeptr}"
}
export -f ptxd_make_serialize_setup
ptxd_make_serialize_init() {
local num="${PTXDIST_PARALLELMFLAGS#-j}"
local sync mflags
if [ -n "${num}" ]; then
ptxd_make_serialize_setup global "${num}" || return
sync="${PTXDIST_OUTPUT_SYNC:+${PTXDIST_OUTPUT_SYNC}recurse}"
mflags="${sync} -j --jobserver-fds=${ptxd_make_serialize_global_readfd},${ptxd_make_serialize_global_writefd}"
PTXDIST_PARALLELMFLAGS_INTERN="${mflags}"
PTXDIST_PARALLELMFLAGS_EXTERN="${mflags}"
else
case "${PTXDIST_PARALLELMFLAGS_INTERN}" in
-j1) ;;
*)
sync="${PTXDIST_OUTPUT_SYNC:+${PTXDIST_OUTPUT_SYNC}target --no-print-directory}"
PTXDIST_PARALLELMFLAGS_INTERN="${PTXDIST_PARALLELMFLAGS_INTERN} ${sync}" ;;
esac
fi
ptxd_make_serialize_setup get 4 &&
ptxd_make_serialize_setup extract 2
}
ptxd_make_serialize_init
|