forked from mod-audio/mod-plugin-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·158 lines (123 loc) · 4.84 KB
/
build
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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
source .common
#######################################################################################################################
# initial plugin setup
action=$1
if [[ "${build}" == "plugins-dep" ]]; then
if [[ "${action}" == "" ]]; then
echo "Usage: $0 <package-name>"
exit 1
fi
if [[ "${action}" == "cleanup" ]]; then
# cleanup previous
rm -rf ${WORKDIR}/tmp-lv2-spec
# make sure plugins dir exists and it's clean
mkdir -p ${WORKDIR}/plugins
rm -rf ${WORKDIR}/plugins/*
# move lv2 spec to a temp dir so we can delete everything else
mkdir ${WORKDIR}/tmp-lv2-spec
mv ${WORKDIR}/${build}/target/usr/lib/lv2/{atom,buf-size,data-access,dynmanifest,event,instance-access,log,lv2core,midi,morph,options,parameters,patch,port-groups,port-props,presets,resize-port,schemas,state,time,ui,units,urid,uri-map,worker}.lv2 ${WORKDIR}/tmp-lv2-spec/
rm -rf ${WORKDIR}/${build}/target/usr/lib/lv2/*
mv ${WORKDIR}/tmp-lv2-spec/* ${WORKDIR}/${build}/target/usr/lib/lv2/
rmdir ${WORKDIR}/tmp-lv2-spec
# just in case
rm -rf ${WORKDIR}/${build}/target/usr/local/lib/lv2
# all done!
exit 0
fi
if [[ "${action}" != *"-dirclean" ]] && [[ "${action}" != *"-rebuild" ]] && [[ "${action}" != "menuconfig" ]]; then
action=$(basename ${action} | sed "s|\.mk||")
pkgname=$(echo ${action} | tr a-z- A-Z_)
if [ ! -d ${SOURCE_DIR}/plugins/package/${action} ]; then
error "Package name '${action}' does not exist"
exit 1
fi
if [ ! -f ${SOURCE_DIR}/plugins/package/${action}/${action}.mk ]; then
error "Requested package has no 'mk' file"
exit 1
fi
bundles=($(cat plugins/package/${action}/${action}.mk | awk 'sub("'${pkgname}'_BUNDLES = ","")'))
if [[ "${bundles}" == "" ]]; then
error "Requested package has no bundles"
exit 1
fi
fi
fi
#######################################################################################################################
# buildroot setup
export DOWNLOAD_PATH=${DOWNLOAD_DIR}
export TOOLCHAIN_PATH=${TOOLCHAIN_DIR}
mkdir -p /tmp/skeleton
#######################################################################################################################
# now building...
cd ${BUILD_DIR}/${BUILDROOT_VERSION}
make O=${WORKDIR}/${build} BR2_EXTERNAL=${SOURCE_DIR}/${build} ${platform}_defconfig &>/dev/null
make O=${WORKDIR}/${build} BR2_EXTERNAL=${SOURCE_DIR}/${build} ${action}
#######################################################################################################################
# if cleaning, stop here
if [[ "${action}" == *"-dirclean" ]]; then
# run host-*-dirclean
make O=${WORKDIR}/${build} BR2_EXTERNAL=${SOURCE_DIR}/${build} host-${action} &>/dev/null
exit 0
fi
#######################################################################################################################
# copy the requested plugin bundles
function bundle_has_binaries
{
for f in "$1"/*.so; do
if [ -e "$f" ]; then
return 1;
fi
done
return 0
}
function try_copy_plugin_bundles
{
path="$1"
for bundle in ${bundles[@]}; do
if [ ! -d ${path}/${bundle} ]; then
return
fi
done
ls ${WORKDIR}/plugins
if [ -z "`ls ${WORKDIR}/plugins`" ]; then
was_empty="1"
else
was_empty="0"
fi
for bundle in ${bundles[@]}; do
rm -rf ${WORKDIR}/plugins/${bundle}
cp -rL ${path}/${bundle} ${WORKDIR}/plugins/${bundle}
info "Finished copying ${bundle}"
done
if [ ${was_empty} == "1" ]; then
for bundle in `ls ${path}`; do
if ( bundle_has_binaries ${path}/${bundle} ); then
continue
fi
if [[ " ${bundles[@]} " =~ " ${bundle} " ]]; then true; else
echo "NOTE: Bundle '$bundle' possibly missing from _BUNDLES definition"
fi
done
fi
exit 0
}
if [[ "${build}" == "plugins-dep" ]] && [[ "${action}" != "menuconfig" ]]; then
mkdir -p ${WORKDIR}/plugins
try_copy_plugin_bundles ${WORKDIR}/${build}/target/usr/lib/lv2
try_copy_plugin_bundles ${WORKDIR}/${build}/target/usr/local/lib/lv2
error "Failed to find plugin installed bundles"
exit 1
fi
#######################################################################################################################
# check for a menuconfig action to automatically save config
if [[ "${action}" == *"menuconfig"* ]]; then
PREFIX=$(echo ${action} | sed 's/menuconfig//g')
if [[ "$PREFIX" == "" ]]; then
make O=${WORKDIR}/${build} BR2_EXTERNAL=${SOURCE_DIR}/${build} savedefconfig
else
make O=${WORKDIR}/${build} BR2_EXTERNAL=${SOURCE_DIR}/${build} "$PREFIX"update-config
fi
info "Changes of ${action} saved to correspondent configuration file"
fi
#######################################################################################################################