summaryrefslogtreecommitdiff
path: root/prepare_debug_dir.sh
blob: d26671640a9c5ba00e9af1b9db33a9f992ebffc0 (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
#!/bin/bash

function make_symlink {
	local src="$1"
	local target="$2"
	if [ -L "$target/$(basename "$src")" ]; then
		# Overwrite existing symlinks
		ln -sf "$src" "$target"
	else
		# But nothing else
		ln -s "$src" "$target"
	fi
}

function make_symlinks {
	local target="${@:$#}"
	while [ $# -gt 1 ]; do
		local src="$1"
		shift
		if [[ "$src" == *\** ]]; then
			continue
		fi
		make_symlink "$src" "$target"
	done
}

SCRIPT_PATH=$(readlink -f "$0")
SOWATCH_ROOT=$(dirname "$SCRIPT_PATH")
BUILD_ROOT=$(pwd)

rm -r drivers notifications watchlets com
mkdir -p drivers notifications watchlets
mkdir -p com/javispedro/sowatch

make_symlinks $BUILD_ROOT/*/lib*driver.so drivers
make_symlinks $BUILD_ROOT/*/lib*notification.so notifications
make_symlinks $BUILD_ROOT/*/lib*watchlet{s,}.so watchlets

for i in $SOWATCH_ROOT/*; do
	b="$BUILD_ROOT/$(basename $i)"
	if [ -d "$i" -a -d "$b" ]; then
		make_symlinks $i/*.png $i/*.qml "$b"
		if [ -d "$i/res" ]; then
			make_symlinks $i/res/* "$b"
		fi
		if [ -d "$i/qml" ]; then
			make_symlinks $i/qml/* "$b"
		fi
		if [ -d "$i/qml/com/javispedro/sowatch" ]; then
			make_symlinks $i/qml/com/javispedro/sowatch/* com/javispedro/sowatch
		fi
	fi
	
done