From 90d8054990828fdffda2f83af844592f5287af42 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Tue, 10 Mar 2015 07:20:11 -0700 Subject: [PATCH] Fetch only the cores we can build with --cores option --- libretro-fetch.sh | 54 ++++++++++++++++++++++++++------------- script-modules/modules.sh | 54 +++++++++++++++++++++++++++++++++++---- 2 files changed, 85 insertions(+), 23 deletions(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index 916ca50d..4e0c3a44 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -25,7 +25,6 @@ fi . "$BASE_DIR/rules.d/devkit-rules.sh" # TODO: Read these programmatically - # libretro_fetch: Download the given core using its fetch rules # # $1 Name of the core to fetch @@ -97,30 +96,49 @@ libretro_fetch() { fi } +libretro_players="retroarch" +libretro_devkits="devkit" + if [ -n "$1" ]; then + fetch_devel="" no_more_args="" while [ -n "$1" ]; do - if [ -z "$no_more_args" ]; then + if [[ "$1" = -* && -z "$no_more_args" ]]; then case "$1" in - --) - no_more_args="1" - ;; - - *) - # New style (just cores for now) - libretro_fetch $1 - ;; + --) no_more_args=1 ;; + --devel) fetch_devel=1 ;; + --cores) fetch_cores="$libretro_cores" ;; + --devkit) fetch_devkits="$libretro_devkits" ;; + --players) fetch_players="$libretro_players" ;; + --retroarch) fetch_players="retroarch" ;; + *) ;; esac - else - libretro_fetch $1 + shift + continue fi + + fetch_cores="$fetch_cores $1" + # Handle non-commands shift done else - libretro_fetch retroarch - libretro_fetch devkit - - for a in $libretro_cores; do - libretro_fetch "${a%%:*}" - done + # Make libretro-fetch.sh with no args behave traditionally by default + fetch_devel=1 + fetch_cores="$libretro_cores" + fetch_players="retroarch" + fetch_devkit="devkit" fi + +for a in $fetch_players; do + libretro_fetch $a +done + +for a in $fetch_devkits; do + libretro_fetch $a +done + +for a in $fetch_cores; do + if [ -n "$fetch_devel" ] || can_build_module "$a"; then + libretro_fetch "${a%%:*}" + fi +done diff --git a/script-modules/modules.sh b/script-modules/modules.sh index 3cf26f43..e251bc9d 100644 --- a/script-modules/modules.sh +++ b/script-modules/modules.sh @@ -1,17 +1,35 @@ # vim: set ts=3 sw=3 noet ft=sh : bash register_module() { - case "$1" in + mod_type="$1" + mod_name="$2" + shift 2 + + case "$mod_type" in core|devkit|player) - if [ -n "$2" ]; then - eval "libretro_${1}s=\"\$libretro_${1}s $2::\"" + 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\"" else - echo "register_module:Trying to register a $1 without a name" + echo "register_module:Trying to register a $mod_type without a name" exit 1 fi ;; *) - echo "register_module:Unknown module type \"$1\"" + echo "register_module:Unknown module type \"$mod_type\"" exit 1 ;; esac @@ -20,3 +38,29 @@ register_module() { register_core() { register_module core $@ } + +can_build_module() { + if [[ "$1" != *:*:* ]]; then + # Not in :: format, assume developer mode + return 0 + 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 +}