aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/compile-db
blob: acd3a07770fc4601b117d8792920d29e980c4394 (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
#!@shebangdir@/execlineb -WS2

# ISC license.

multisubstitute {
	define CONFIGDIR ${1}
	define LIVEDIR ${2}
}

backtick -ED" " OLDDB { realpath ${CONFIGDIR}/compiled }
backtick -E DATE { date +%s }
elglob SOURCES ${CONFIGDIR}/src/*

if { s6-rc-compile -v2 ${CONFIGDIR}/compiled-${DATE} ${SOURCES} }

if {
	if -x0 { eltest -d ${LIVEDIR} }
	if -n -x0 { s6-rc-update -v2 -l ${LIVEDIR} ${CONFIGDIR}/compiled-${DATE} }
		if { s6-rc-update -v2 -l ${LIVEDIR} ${CONFIGDIR}/compiled }
		if { rm -Rf ${CONFIGDIR}/compiled-${DATE} }
		exit 1
}

if { ln -sf compiled-${DATE} ${CONFIGDIR}/../compiled }
if { mv -f ${CONFIGDIR}/../compiled ${CONFIGDIR}/ }

if -x0 { eltest ${CONFIGDIR}/compiled != ${CONFIGDIR}/compiled }
rm -Rf ${OLDDB}