File: module_base.sh

package info (click to toggle)
libretro-core-info 1.3.6%2Bgit20160816-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, stretch
  • size: 1,292 kB
  • ctags: 129
  • sloc: sh: 5,078; makefile: 15
file content (76 lines) | stat: -rw-r--r-- 1,496 bytes parent folder | download
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
# vim: set ts=3 sw=3 noet ft=sh : bash

register_module() {
	mod_type="$1"
	mod_name="$2"
	shift 2

	case "$mod_type" in
		core|devkit|player)
			if [ -n "$mod_name" ]; then
				build_plats=""
				skip_plats=""
				while [ -n "$1" ]; do
					if [[ "$1" = -* ]]; then
						skip_plats="$skip_plats,$1"
					else
						build_plats="$build_plats,$1"
					fi
					shift
				done

				build_plats="${build_plats#,}"
				skip_plats="${skip_plats#,}"

				eval "libretro_${mod_type}s=\"\$libretro_${mod_type}s $mod_name:${build_plats:=any}:$skip_plats\""
				libretro_modules="$libretro_modules $mod_name:$build_plats:$skip_plats"
			else
				echo "register_module:Trying to register a $mod_type without a name"
				exit 1
			fi
			;;
		*)
			echo "register_module:Unknown module type \"$mod_type\""
			exit 1
			;;
	esac
}

can_build_module() {
	[ -n "$force" ] && return 0

	if [[ "$1" != *:*:* ]]; then
		# Not in <name>:<build>:<skip> format, assume error
		return 1
	fi

	build_plats="${1#*:}"
	build_plats="${build_plats%:*}"
	skip_plats="${1##*:}"

	if [ "$build_plats" != "any" ]; then
		# Module is exclusive to certain platforms
		if [[ "$platform" != *${build_plats}* ]]; then
			# And this isn't one of them.
			return 1
		fi
	fi

	if [[ "$skip_plats" = *${platform}* ]]; then
		# Module is disabled on this particular platform
		return 1
	fi

	return 0
}

find_module() {
	needle="$1"
	shift

	for haystack in $@; do
		if [[ "$needle" == $haystack:* ]]; then
			echo "$needle"
		fi
	done
}