Diff

Differences From Artifact [bda883498c]:

To Artifact [e99d758cfd]:


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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89


90
91
92
93
94
95
96
97
98
99







-
+


-
+
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
-
+
+
+
+
+



+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+








# Compile everything, all at once
idx=-1
for tryCompilerDir in "$(readlink -f ~/root/cross-compilers)" "$(readlink -f ~/devel/build-cc/TMP)"; do
	setup_cc="${tryCompilerDir}/setup-cc"

	platforms=(
		$("${setup_cc}" | tail -n +2)
		$("${setup_cc}" 2>/dev/null | tail -n +2)
	)

	for platform in "${platforms[@]}"; do
	for platformBase in "${platforms[@]}"; do
		idx=$[$idx + 1]
		(
			workdir="workdir-buildPrecompiled-${idx}-$(openssl rand 20 -hex)-platform-${platform}" || exit 1
			mkdir "${workdir}" || exit 1
			cd "${workdir}" || exit 1

			eval $("${setup_cc}" "${platform}")
		for platformAdditional in "" ".seccomp" ".fakechroot" ".internaldirhandle"; do
			case "${platformAdditional}" in
			make_extra=(
				-f ../Makefile
				srcdir=..
				CC="${CC}"
			)

			case "${platform}" in
				*-musl-*|*-musl)
				*.seccomp|*.seccomp.*)
					# seccomp only works on i386/x86_64 for now
					case "${platformBase}" in
						i?86-*|x86_64-*)
					make_extra=("${make_extra[@]}" FILED_EXTRA_LDFLAGS="-static")
							;;
						*)
							continue
							;;
					esac
					;;
			esac

			platform="${platformBase}${platformAdditional}"
			echo "-- ${platform}"

			idx=$[$idx + 1]
			(
				workdir="workdir-buildPrecompiled-${idx}-$(openssl rand 20 -hex)-platform-${platform}" || exit 1
				mkdir "${workdir}" || exit 1
				cd "${workdir}" || exit 1

				make_extra=(
					-f ../Makefile
					srcdir=..
				)

				extra_cflags=""
				while true; do
					case "${platform}" in
						*.seccomp|*.seccomp.*)
							platform="$(echo "${platform}" | sed 's@\.seccomp@@')"
							make_extra+=(FILED_DO_SECCOMP=1)
							;;
						*.fakechroot|*.fakechroot.*)
							platform="$(echo "${platform}" | sed 's@\.fakechroot@@')"
							extra_cflags="${extra_cflags} -DFILED_FAKE_CHROOT=1"
							;;
						*.internaldirhandle|*.internaldirhandle.*)
							platform="$(echo "${platform}" | sed 's@\.internaldirhandle@@')"
							extra_cflags="${extra_cflags} -DFILED_DONT_REDIRECT_DIRECTORIES=1"
							;;
						*)
							break
							;;
					esac
				done

				case "${platform}" in
					*-musl-*|*-musl)
						make_extra+=(FILED_EXTRA_LDFLAGS="-static")
						;;
				esac

				eval $("${setup_cc}" "${platform}")

				make_extra+=("CC=${CC}")
				if [ -n "${extra_cflags}" ]; then
					make_extra+=(FILED_EXTRA_CFLAGS="${extra_cflags}")
				fi

			make "${make_extra[@]}" > filed.log 2>&1 </dev/null || mv filed.log filed-failed.log
		) &
				make "${make_extra[@]}" > filed.log 2>&1 </dev/null || mv filed.log filed-failed.log
			) &
		done
	done
done

# Wait for that to get done
wait

# Rename the files into place