From 0e94fea288d7f29dfbd5bef38ccae12c3f050d73 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:17:32 -0700 Subject: [PATCH 01/20] nproc is Linux-specific, but you can do the same with sysctl on a Mac --- libretro-config.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libretro-config.sh b/libretro-config.sh index c573e251..f28ea640 100755 --- a/libretro-config.sh +++ b/libretro-config.sh @@ -171,8 +171,11 @@ case "$platform" in config_log_build_host if [ -z "$JOBS" ]; then + # nproc is generally Linux-specific. if command -v nproc >/dev/null; then JOBS="$(nproc)" + elif [ "$pltaform" = "osx" ] && command -v sysctl >/dev/null; then + JOBS="$(sysctl -n hw.physicalcpu)" else JOBS=1 fi From 094be73b66ed935c287df84400c14aadf448a024 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:21:28 -0700 Subject: [PATCH 02/20] Logging changes --- script-modules/log.sh | 62 +++++++++++++++++++++++++++++++++++++----- script-modules/util.sh | 6 ---- 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/script-modules/log.sh b/script-modules/log.sh index acec92dd..07a57477 100644 --- a/script-modules/log.sh +++ b/script-modules/log.sh @@ -4,19 +4,33 @@ color() { [ -n "$use_color" ] && echo -n "[0;${1:-0}m" } -lecho() { - if [ -n "$LIBRETRO_LOG_SUPER" ]; then - echo "$@" >> $log_super - fi +secho() { + echo "$@" + [ -n "$log_file_only" ] && echo "$@" >&6 } +lecho() { + [ -n "$LIBRETRO_LOG_SUPER" ] && echo "$@" >> $log_super +} + +lsecho() { + echo "$@" + [ -n "$log_file_only" ] && echo "$@" >&6 + [ -n "$LIBRETRO_LOG_SUPER" ] && echo "$@" >> $log_super +} + +echo_cmd() { + eval 'echo "$@"' + eval "$@" + return $? +} LIBRETRO_LOG_DIR="${LIBRETRO_LOG_DIR:-$WORKDIR/log}" -LIBRETRO_LOG_CORE="${LIBRETRO_LOG_CORE:-%s.log}" +LIBRETRO_LOG_MODULE="${LIBRETRO_LOG_MODULE:-%s.log}" LIBRETRO_LOG_SUPER="${LIBRETRO_LOG_SUPER:-libretro-super.log}" libretro_log_init() { - if [ -z "$LIBRETRO_LOG_SUPER" -a -z "$LIBRETRO_LOG_CORE" ]; then + if [ -z "$LIBRETRO_LOG_SUPER" -a -z "$LIBRETRO_LOG_MODULE" ]; then return fi @@ -24,9 +38,43 @@ libretro_log_init() { if [ -n "$LIBRETRO_LOG_SUPER" ]; then log_super="$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_SUPER" + # Redirecting : avoids dependency on trunc(1) [ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_super fi - # Core log can't be truncated here + # Module logs are truncated as they're opened in log_module_start +} + +log_module_start() { + if [ -n "$LIBRETRO_LOG_MODULE" ]; then + printf -v log_module "$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_MODULE" "$1" + + # Save stdout and stderr to fds 6 and 7 + exec 6>&1 7>&2 + + # Redirecting : avoids dependency on trunc(1) + [ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_module + + # Output to screen and logfile in developer mode (if possible) + if [[ -n "$LIBRETRO_DEVELOPER" && -n "${log_tee:=$(find_tool "tee")}" ]]; then + exec > >($log_tee -a $log_module) 2>&1 + else + exec >> $log_module 2>&1 + log_file_only=1 + fi + fi +} + +log_module_stop() { + if [ -n "$1" ]; then + # There's a reason we're stopping + lsecho "$@" + fi + if [ -n "$LIBRETRO_LOG_MODULE" ]; then + # Restore stdout/stderr and close our copies + exec 1>&6 2>&7 6>&- 7>&- + log_file_only="" + fi + lsecho "" } # TODO: Move this into libretro_log_init once libretro-fetch is fixed diff --git a/script-modules/util.sh b/script-modules/util.sh index 8305a1af..86de28a6 100644 --- a/script-modules/util.sh +++ b/script-modules/util.sh @@ -1,11 +1,5 @@ # vim: set ts=3 sw=3 noet ft=sh : bash -echo_cmd() { - eval 'echo "$@"' - eval "$@" - return $? -} - # Lets us avoid use of wc numwords() { echo "$#" From 0a1f95a0895765456d9654683df7000449c55c16 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:24:57 -0700 Subject: [PATCH 03/20] Add a do_nothing function --- script-modules/util.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script-modules/util.sh b/script-modules/util.sh index 86de28a6..95c9402e 100644 --- a/script-modules/util.sh +++ b/script-modules/util.sh @@ -14,3 +14,7 @@ find_tool() { shift done } + +do_nothing() { + : +} From 81a44fdfa99533b863f07dabe00cb40b0fa1ca30 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:43:15 -0700 Subject: [PATCH 04/20] Remove conditional fetching from libretro-fetch.sh The partially-finished use of can_build_module() had to be pulled from libretro-fetch because how it works has changed a little bit. Don't worry too much though because libretro-super.sh already fetches using the new setup. It's just not quite ready yet. --- libretro-fetch.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index 1bbed1e8..8a51812f 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -101,13 +101,11 @@ libretro_players="retroarch" libretro_devkits="devkit" if [ -n "$1" ]; then - fetch_devel="" no_more_args="" while [ -n "$1" ]; do if [[ "$1" = -* && -z "$no_more_args" ]]; then case "$1" in --) no_more_args=1 ;; - --devel) fetch_devel=1 ;; --cores) fetch_cores="$libretro_cores" ;; --devkit) fetch_devkits="$libretro_devkits" ;; --players) fetch_players="$libretro_players" ;; @@ -124,7 +122,6 @@ if [ -n "$1" ]; then done else # Make libretro-fetch.sh with no args behave traditionally by default - fetch_devel=1 fetch_cores="$libretro_cores" fetch_players="retroarch" fetch_devkit="devkit" @@ -139,7 +136,5 @@ for a in $fetch_devkits; do done for a in $fetch_cores; do - if [ -n "$fetch_devel" ] || can_build_module "$a"; then - libretro_fetch "${a%%:*}" - fi + libretro_fetch "${a%%:*}" done From afb0bab33c37d99fb0227bf365e089f00084d803 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:47:49 -0700 Subject: [PATCH 05/20] The stuff that would've broken libretro-fetch.sh --- script-modules/modules.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/script-modules/modules.sh b/script-modules/modules.sh index e251bc9d..9c947da4 100644 --- a/script-modules/modules.sh +++ b/script-modules/modules.sh @@ -22,7 +22,8 @@ register_module() { build_plats="${build_plats#,}" skip_plats="${skip_plats#,}" - eval "libretro_${mod_type}s=\"\$libretro_${mod_type}s $mod_name:${build_plats:-any}:$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 @@ -40,9 +41,11 @@ register_core() { } can_build_module() { + [ -n "$force" ] && return 0 + if [[ "$1" != *:*:* ]]; then - # Not in :: format, assume developer mode - return 0 + # Not in :: format, assume error + return 1 fi build_plats="${1#*:}" @@ -64,3 +67,14 @@ can_build_module() { return 0 } + +find_module() { + needle="$1" + shift + + for haystack in $@; do + if [[ "$needle" == $haystack:* ]]; then + echo "$needle" + fi + done +} From f92c7cde4e47bfaa7980b5b0097160520dc920fb Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:53:51 -0700 Subject: [PATCH 06/20] New bits for libretro-super.sh --- script-modules/fetch-rules.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/script-modules/fetch-rules.sh b/script-modules/fetch-rules.sh index d469ee27..53584a0c 100644 --- a/script-modules/fetch-rules.sh +++ b/script-modules/fetch-rules.sh @@ -36,6 +36,10 @@ fetch_revision_git() { git log -n 1 --pretty=format:%H } +local_files_git() { + git diff-files --quiet --ignore-submodules + return $? +} # fetch_revision: Output SCM-dependent revision string of a module # (currently just calls fetch_revision_git) @@ -44,3 +48,18 @@ fetch_revision_git() { fetch_revision() { fetch_revision_git $1 } + +module_get_revision() { + if [ -d "$WORKDIR/$module_dir" ]; then + cd "$WORKDIR/$module_dir" + case "$module_fetch_rule" in + git) + if [ -n "$1" ]; then + git diff-files --quiet --ignore-submodules || echo -n "changed from " + fi + git log -n 1 --pretty=format:%H + ;; + *) ;; + esac + fi +} From 84b949f791104f5e31f534a455feda4971a4412f Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:55:22 -0700 Subject: [PATCH 07/20] Fix libretro-build.sh to work with recent changes --- libretro-build-common.sh | 70 ++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/libretro-build-common.sh b/libretro-build-common.sh index f96080ed..d6b79688 100755 --- a/libretro-build-common.sh +++ b/libretro-build-common.sh @@ -243,9 +243,9 @@ build_makefile() { libretro_build_core() { local opengl_type - if [ -n "${LIBRETRO_LOG_CORE}" ]; then - printf -v log_core "$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_CORE" "$1" - [ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_core + if [ -n "${LIBRETRO_LOG_MODULE}" ]; then + printf -v log_module "$LIBRETRO_LOG_DIR/$LIBRETRO_LOG_MODULE" "$1" + [ -z "$LIBRETRO_LOG_APPEND" ] && : > $log_module fi eval "core_name=\${libretro_${1}_name:-$1}" @@ -278,27 +278,26 @@ libretro_build_core() { echo "Building ${1}..." lecho "Building ${1}..." - if [ -n "$log_core" ]; then + if [ -n "$log_module" ]; then exec 6>&1 - echo "Building ${1}..." >> $log_core + echo "Building ${1}..." >> $log_module # TODO: Possibly a shell function for tee? if [[ -n "$LIBRETRO_DEVELOPER" && -n "${cmd_tee:=$(find_tool "tee")}" ]]; then - exec > >($cmd_tee -a $log_core) + exec > >($cmd_tee -a $log_module) else - exec > $log_core + exec > $log_module fi fi case "$core_build_rule" in generic_makefile) - for a in configure preclean prebuild prepkg; do - if [ "$(type -t libretro_${1}_build_$a 2> /dev/null)" = "function" ]; then - eval "core_build_$a=libretro_${1}_build_$a" - else - eval "core_build_$a=" - fi - done + # As of right now, only configure is used for now... + if [ "$(type -t libretro_${1}_configure 2> /dev/null)" = "function" ]; then + eval "core_configure=libretro_${1}_configure" + else + eval "core_configure=do_nothing" + fi eval "core_build_makefile=\$libretro_${1}_build_makefile" eval "core_build_subdir=\$libretro_${1}_build_subdir" eval "core_build_args=\$libretro_${1}_build_args" @@ -327,7 +326,7 @@ libretro_build_core() { exit 1 ;; esac - if [ -n "$log_core" ]; then + if [ -n "$log_module" ]; then exec 1>&6 6>&- fi } @@ -365,33 +364,21 @@ summary() { local num_fail="$(numwords $build_fail)" local fmt_fail="${fmt_output:+$(echo " $build_fail" | $fmt_output)}" - for output in "" ${LIBRETRO_LOG_SUPER:+$log_super}; do - if [ -n "$output" ]; then - exec 6>&1 - exec >> $output - use_color="" - fi - { - echo "" - if [[ -z "$build_success" && -z "$build_fail" ]]; then - echo "No build actions performed." - continue - fi + if [[ -z "$build_success" && -z "$build_fail" ]]; then + lsecho "No build actions performed." + return + fi - if [ -n "$build_success" ]; then - echo "$(color 32)$num_success core(s)$(color) successfully processed:" - echo "$fmt_success" - fi - if [ -n "$build_fail" ]; then - echo "$(color 31)$num_fail core(s)$(color) failed:" - echo "$fmt_fail" - fi - } - if [ -n "$output" ]; then - exec 1>&6 6>&- - use_color="$want_color" - fi - done + if [ -n "$build_success" ]; then + secho "$(color 32)$num_success core(s)$(color) successfully processed:" + lecho "$num_success core(s) successfully processed:" + lsecho "$fmt_success" + fi + if [ -n "$build_fail" ]; then + secho "$(color 31)$num_fail core(s)$(color) failed:" + lecho "$num_fail core(s) failed:" + lsecho "$fmt_fail" + fi } create_dist_dir() { @@ -445,7 +432,6 @@ build_libretro_mame_prerule() { [ "$MAME_GIT_TINY" -eq 1 ] && mame_targets="mame mess" for target in $mame_targets; do - echo_cmd "$MAKE -f Makefile.libretro $extra_args platform=\"$FORMAT_COMPILER_TARGET\" \"-j$JOBS\" clean-osd" || die 'Failed to clean MAME OSD' echo_cmd "$MAKE -f Makefile.libretro $extra_args \"TARGET=$target\" platform=\"$FORMAT_COMPILER_TARGET\" $MAME_COMPILER \"-j$JOBS\"" || die "Failed to build $target" copy_core_to_dist "$target" ret=$? From 6a9f434636d1c656e6c4ca3eb14aa3dd6904fd25 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 22:57:13 -0700 Subject: [PATCH 08/20] Remove the mgit fetch rule --- libretro-fetch.sh | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index 8a51812f..e4aa939c 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -62,28 +62,6 @@ libretro_fetch() { fetch_git "$git_url" "$module_dir" "$git_submodules" ;; - multi_git) - local num_git_urls - local git_url - local git_subdir - local git_submodules - local i - - eval "num_git_urls=\${libretro_${1}_mgit_urls:-0}" - if [ "$num_git_urls" -lt 1 ]; then - echo "Cannot fetch \"$num_git_urls\" multiple git URLs" - return 1 - fi - - [ "$module_dir" != "." ] && echo_cmd "mkdir -p \"$WORKDIR/$module_dir\"" - for (( i=0; i < $num_git_urls; ++i )); do - eval "git_url=\$libretro_${1}_mgit_url_$i" - eval "git_subdir=\$libretro_${1}_mgit_dir_$i" - eval "git_submodules=\$libretro_${1}_mgit_submodules_$i" - fetch_git "$git_url" "$module_dir/$git_subdir" "$git_submodules" - done - ;; - *) echo "libretro_fetch:Unknown fetch rule for $1: \"$fetch_rule\"." exit 1 From 803f23ee3aede368973ff1fbc5fd3c468bec3e34 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 23:23:06 -0700 Subject: [PATCH 09/20] Fully fix libretro-fetch.sh (mostly --devkit) --- libretro-fetch.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libretro-fetch.sh b/libretro-fetch.sh index e4aa939c..dcc05074 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -76,7 +76,6 @@ libretro_fetch() { } libretro_players="retroarch" -libretro_devkits="devkit" if [ -n "$1" ]; then no_more_args="" @@ -101,16 +100,16 @@ if [ -n "$1" ]; then else # Make libretro-fetch.sh with no args behave traditionally by default fetch_cores="$libretro_cores" - fetch_players="retroarch" - fetch_devkit="devkit" + fetch_players="$libretro_players" + fetch_devkit="$libretro_devkits" fi for a in $fetch_players; do - libretro_fetch $a + libretro_fetch "${a%%:*}" done for a in $fetch_devkits; do - libretro_fetch $a + libretro_fetch "${a%%:*}" done for a in $fetch_cores; do From 1e478fd4c64eb05f7c4f555593fac5f74983797d Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 23:24:21 -0700 Subject: [PATCH 10/20] Missed with last commit --- script-modules/modules.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script-modules/modules.sh b/script-modules/modules.sh index 9c947da4..b4db0f3f 100644 --- a/script-modules/modules.sh +++ b/script-modules/modules.sh @@ -40,6 +40,14 @@ register_core() { register_module core $@ } +register_devkit() { + register_module devkit $@ +} + +register_player() { + register_module player $@ +} + can_build_module() { [ -n "$force" ] && return 0 From b626d15b2d4f7b827c30d307bf0cb3a1f7e10ef0 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 23:25:11 -0700 Subject: [PATCH 11/20] Update devkit rules for new libretro-fetch.sh --- rules.d/devkit-rules.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/rules.d/devkit-rules.sh b/rules.d/devkit-rules.sh index cc798854..985bd295 100644 --- a/rules.d/devkit-rules.sh +++ b/rules.d/devkit-rules.sh @@ -1,13 +1,22 @@ # vim: set ts=3 sw=3 noet ft=sh : bash -libretro_devkit_name="libretro Developer's Kit" -libretro_devkit_fetch_rule=multi_git -libretro_devkit_mgit_urls=4 -libretro_devkit_mgit_dir_0="libretro-manifest" -libretro_devkit_mgit_url_0="https://github.com/libretro/libretro-manifest.git" -libretro_devkit_mgit_dir_1="libretrodb" -libretro_devkit_mgit_url_1="https://github.com/libretro/libretrodb.git" -libretro_devkit_mgit_dir_2="libretro-dat-pull" -libretro_devkit_mgit_url_2="https://github.com/libretro/libretro-dat-pull.git" -libretro_devkit_mgit_dir_3="libretro-common" -libretro_devkit_mgit_url_3="https://github.com/libretro/libretro-common.git" +register_devkit "manifest" any +libretro_manifest_name="Devkit: libretro-manifest" +libretro_manifest_dir="libretro-devkit/libretro-manifest" +libretro_manifest_git_url="https://github.com/libretro/libretro-manifest.git" + +register_devkit "libretrodb" any +libretro_libretrodb_name="Devkit: libretrodb" +libretro_libretrodb_dir="libretro-devkit/libretrodb" +libretro_libretrodb_git_url="https://github.com/libretro/libretrodb.git" + +register_devkit "dat_pull" any +libretro_dat_pull_name="Devkit: libretro-dat-pull" +libretro_dat_pull_dir="libretro-devkit/libretro-dat-pull" +libretro_dat_pull_git_url="https://github.com/libretro/libretro-dat-pull.git" + +register_devkit "common" any +libretro_common_name="Devkit: libretro-common" +libretro_common_dir="libretro-devkit/libretro-common" +libretro_common_git_url="https://github.com/libretro/libretro-common.git" + From d447f635670bc416f86295cdc4565bd0388975ce Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 5 Apr 2015 23:25:51 -0700 Subject: [PATCH 12/20] Update core rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is mostly for libretro-super.sh, but libretro-build-common.sh has already been updated to work with them. Getting very close to ready to commit libretro-super.sh now—it just needs to learn to do something with the devkits and players. --- rules.d/core-rules.sh | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/rules.d/core-rules.sh b/rules.d/core-rules.sh index 09a3a72e..b691c37e 100644 --- a/rules.d/core-rules.sh +++ b/rules.d/core-rules.sh @@ -121,7 +121,7 @@ register_core "pcsx_rearmed" -theos_ios -ngc -ps3 -psp1 -wii libretro_pcsx_rearmed_name="PCSX ReARMed" libretro_pcsx_rearmed_git_url="https://github.com/libretro/pcsx_rearmed.git" libretro_pcsx_rearmed_build_makefile="Makefile.libretro" -libretro_pcsx_rearmed_build_configure() { +libretro_pcsx_rearmed_configure() { if [ "$platform" = "ios" ]; then core_build_cores="pcsx_rearmed_interpreter pcsx_rearmed" fi @@ -235,7 +235,7 @@ register_core "mupen64plus" -theos_ios -ngc -ps3 -psp1 -wii libretro_mupen64plus_name="Mupen64Plus" libretro_mupen64plus_git_url="https://github.com/libretro/mupen64plus-libretro.git" libretro_mupen64plus_build_platform="$FORMAT_COMPILER_TARGET_ALT" -libretro_mupen64Plus_build_configure() { +libretro_mupen64Plus_configure() { if iscpu_x86_64 $ARCH; then core_build_args="WITH_DYNAREC=x86_64" elif iscpu_x86 $ARCH; then @@ -352,29 +352,35 @@ libretro_lutro_build_makefile="Makefile" ## TODO: The lutro modules here aren't really "cores", they're assets ## Figure out where to put them and what to do with them. -register_core "lutro_platformer" none +register_core "lutro_platformer" any libretro_lutro_platformer_name="Lutro-Platformer" libretro_lutro_platformer_git_url="https://github.com/libretro/lutro-platformer.git" +libretro_lutro_platformer_build_rule=none -register_core "lutro_pong" none +register_core "lutro_pong" any libretro_lutro_pong_name="Lutro-Pong" libretro_lutro_pong_git_url="https://github.com/libretro/lutro-pong.git" +libretro_lutro_pong_build_rule=none -register_core "lutro_tetris" none +register_core "lutro_tetris" any libretro_lutro_tetris_name="Lutro-tetris" libretro_lutro_tetris_git_url="https://github.com/libretro/lutro-tetris.git" +libretro_lutro_tetris_build_rule=none -register_core "lutro_snake" none +register_core "lutro_snake" any libretro_lutro_snake_name="Lutro-snake" libretro_lutro_snake_git_url="https://github.com/libretro/lutro-snake.git" +libretro_lutro_snake_build_rule=none -register_core "lutro_iyfct" none +register_core "lutro_iyfct" any libretro_lutro_iyfct_name="Lutro-iyfct" libretro_lutro_iyfct_git_url="https://github.com/libretro/lutro-iyfct.git" +libretro_lutro_iyfct_build_rule=none -register_core "lutro_game_of_life" none +register_core "lutro_game_of_life" any libretro_lutro_game_of_life_name="Lutro-Game-of-Life" libretro_lutro_game_of_life_git_url="https://github.com/libretro/lutro-game-of-life.git" +libretro_lutro_game_of_life_build_rule=none # CORE RULE VARIABLES # @@ -403,16 +409,6 @@ libretro_lutro_game_of_life_git_url="https://github.com/libretro/lutro-game-of-l # build_subdir Subdir containing the libretro makefile # Leave unset if in top level of core # -# For the "multi_git" fetch rule: -# -# mgit_urls Number of URLs to fetch -# -# mgit_url_ th URL to fetch, start with 0 -# If you have 4 mgit_urls, will be 0, 1, 2, or 3 -# -# mgit_dir_ th directory to fetch into -# You must set this for each URL -# # For the generic makefile build rule: # # build_makefile Name of makefile From 557a82576c66cd42381580c9d5c34c41f6bb5777 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Mon, 6 Apr 2015 01:29:39 -0700 Subject: [PATCH 13/20] Multi-make for bsnes! (Only in libretro-super.sh) --- rules.d/core-rules.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rules.d/core-rules.sh b/rules.d/core-rules.sh index b691c37e..ce5c5e73 100644 --- a/rules.d/core-rules.sh +++ b/rules.d/core-rules.sh @@ -3,6 +3,7 @@ register_core "bsnes" -theos_ios -ngc -ps3 -psp1 -qnx -wii libretro_bsnes_name="bsnes/higan" libretro_bsnes_git_url="https://github.com/libretro/bsnes-libretro.git" +libretro_bsnes_build_makefile_targets="profile=\"accuracy\" profile=\"balanced\" profile=\"performance\"" libretro_bsnes_build_args="compiler=\"${CXX11}\"" libretro_bsnes_build_products="out" libretro_bsnes_build_cores="bsnes_accuracy bsnes_balanced bsnes_performance" @@ -217,6 +218,7 @@ libretro_bsnes_cplusplus98_build_products="out" register_core "bsnes_mercury" -theos_ios -ngc -ps3 -psp1 -qnx -wii libretro_bsnes_mercury_name="bsnes-mercury" libretro_bsnes_mercury_git_url="https://github.com/libretro/bsnes-mercury.git" +libretro_bsnes_mercury_build_makefile_targets="profile=\"accuracy\" profile=\"balanced\" profile=\"performance\"" libretro_bsnes_mercury_build_args="compiler=\"${CXX11}\"" libretro_bsnes_mercury_build_products="out" libretro_bsnes_mercury_build_cores="bsnes_mercury_accuracy bsnes_mercury_balanced bsnes_mercury_performance" From c26d473061274b752c5cac74c80c3ea6853a7d2e Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Mon, 6 Apr 2015 01:30:40 -0700 Subject: [PATCH 14/20] New script libretro-super.sh This script will replace libretro-build.sh and libretro-fetch.sh (and probably others), but it's not quite ready yet. It's also completely undocumented outside of the source code. _I_ know what it does, but you shouldn't use it just yet. ;) --- libretro-super.sh | 535 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 535 insertions(+) create mode 100755 libretro-super.sh diff --git a/libretro-super.sh b/libretro-super.sh new file mode 100755 index 00000000..de893557 --- /dev/null +++ b/libretro-super.sh @@ -0,0 +1,535 @@ +#! /usr/bin/env bash +# vim: set ts=3 sw=3 noet ft=sh : bash + +libretro_version="1.1" +default_actions="fetch clean compile" + +SCRIPT="${0#./}" +BASE_DIR="${SCRIPT%/*}" +WORKDIR="$PWD" + +if [ "$BASE_DIR" = "$SCRIPT" ]; then + BASE_DIR="$WORKDIR" +else + if [[ "$0" != /* ]]; then + # Make the path absolute + BASE_DIR="$WORKDIR/$BASE_DIR" + fi +fi + +shopt -q nullglob || reset_nullglob=1 + +. "$BASE_DIR/libretro-config.sh" + +. "$BASE_DIR/script-modules/log.sh" +. "$BASE_DIR/script-modules/util.sh" +. "$BASE_DIR/script-modules/fetch-rules.sh" +. "$BASE_DIR/script-modules/modules.sh" + +# Read all of the rules file +shopt -s nullglob +cd "$BASE_DIR" # Cope with whitespace in $BASE_DIR +for rules_file in rules.d/*; do + . $rules_file +done +[ -n "$reset_noglob" ] && shopt -u nullglob + +skip_unchanged="" +libretro_log_init +if [ -n "$1" ]; then + opt_terminator="" + actions="" + types="" + process="" + + while [ -n "$1" ]; do + if [[ "$1" = -* && -z "$opt_terminator" ]]; then + case "$1" in + + # + # Informational + # + + # TODO + --help) ;; + + --license|--licence) + show_license=1 + LIBRETRO_LOG_SUPER="" + LIBRETRO_LOG_MODULE="" + ;; + + --nologs) + LIBRETRO_LOG_SUPER="" + LIBRETRO_LOG_MODULE="" + ;; + + # + # Scope controls + # + + --devel) LIBRETRO_DEVELOPER=1 ;; + --no-devel) LIBRETRO_DEVELOPER="" ;; + + --force) force=1 ;; + --skip-unchanged) skip_unchanged=1 ;; + --no-skip-unchanged) skip_unchanged=0 ;; + + # + # Action controls + # + + --default) + actions="$default_actions" + ;; + + --fetch) + actions="$actions fetch" + ;; + + --clean) + actions="$actions clean" + ;; + + --compile) + actions="$actions compile" + ;; + + --build) + actions="$actions clean compile" + ;; + + --package) + actions="$actions package" + ;; + + # + # Module type controls + # + + --cores) modtypes="$modtypes cores" ;; + --devkit) modtypes="$modtypes devkits" ;; + --players) modtypes="$modtypes players" ;; + + # + # Script plumbing + # + + # In case there's ever a need for an option terminator + --) opt_terminator=1 ;; + + # Something starting with - that we don't recognize + *) + echo "Unknown command \"$1\"" + exit 1 + ;; + esac + shift + continue + fi + + # Non-commands are operating targets + process="$process $1" + shift + done +fi + +lsecho "libretro-super v$libretro_version +Script Copyright (C) 2015 by The Libretro Team" +if [ -n "$show_license" ]; then + lsecho " +This script ant its components are a work that is licensed under the +Creative Commons Attribution 4.0 International License. To view a copy of +this license, visit http://creativecommons.org/licenses/by/4.0/ or send a +letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA." + exit 0 +fi +lsecho "Licensed under CC-BY-4.0 (--license for details)" + + +# Configure some defaults +[ -z "$actions" ] && actions="$default_actions" +[ -z "$modtypes" ] && modtypes="cores players ${LIBRETRO_DEVELOPER:+devkits}" +[ -n "$process" ] && force=1 + +# If user didn't ask for anything, they want "everything" (new, at least) +if [ -z "$process" ]; then + [ -z "$skip_unchanged" ] && skip_unchanged=1 + if [[ "$modtypes" = *cores* ]]; then + for target in $libretro_cores; do + if [ -n "$LIBRETRO_DEVELOPER" ] || can_build_module $target; then + process="$process $target" + fi + done + fi + + # TODO: players and devkits +else + # If user has asked for something specific, don't skip it + [ -z "$skip_unchanged" ] && skip_unchanged=0 +fi + +################################################################### +# +# MODULE PROCESSING +# +################################################################### + +module_set_vars() { + module_varname="$1" + eval "module_name=\${libretro_${1}_name:-$1}" + eval "module_dir=\${libretro_${1}_dir:-libretro-$1}" + + for func in configure preclean prepackage; do + if [ "$(type -t libretro_${1}_$func 2> /dev/null)" = "function" ]; then + eval "module_$func=libretro_${1}_$func" + else + eval "module_$func=do_nothing" + fi + done + + eval "module_fetch_rule=\${libretro_${1}_fetch_rule:-git}" + case "$module_fetch_rule" in + git) + eval "git_url=\$libretro_${1}_git_url" + eval "git_submodules=\$libretro_${1}_git_submodules" + ;; + + none) ;; + + *) + echo "Unknown fetch rule for $1: \"$module_fetch_rule\"." + ;; + esac + + eval "module_build_rule=\${libretro_${1}_build_rule:-generic_makefile}" + + # TODO: Do OpenGL better + eval "module_build_opengl=\$libretro_${1}_build_opengl" + module_opengl_type="" + if [ -n "$module_build_opengl" ]; then + if [ -n "$ENABLE_GLES" ]; then + module_opengl_type="-gles" + else + module_opengl_type="-opengl" + fi + fi + + module_build_subdir="" + case "$module_build_rule" in + generic_makefile) + eval "module_build_makefile=\$libretro_${1}_build_makefile" + eval "module_build_subdir=\$libretro_${1}_build_subdir" + eval "module_build_makefile_targets=\"\$libretro_${1}_build_makefile_targets\"" + eval "module_build_args=\$libretro_${1}_build_args" + + # TODO: change how $platform is done + eval "module_build_platform=\${libretro_${1}_build_platform:-$FORMAT_COMPILER_TARGET}$opengl_type" + + eval "module_build_cores=\${libretro_${1}_build_cores:-$1}" + eval "module_build_products=\$libretro_${1}_build_products" + ;; + + legacy) + eval "module_build_legacy=\$libretro_${1}_build_legacy" + ;; + + none) ;; + + *) + echo "Unknown build rule for $1: \"$module_build_rule\"." + ;; + esac + + module_build_dir="$WORKDIR/$module_dir${module_build_subdir:+/$module_build_subdir}" +} + +module_fetch() { + lsecho "Fetching ${module_varname}..." + + case "$module_fetch_rule" in + git) + if [ -z "$git_url" ]; then + echo "module_fetch: No URL set to fetch $1 via git." + exit 1 + fi + fetch_git "$git_url" "$module_dir" "$git_submodules" + ;; + + none) + # This module doesn't get fetched + ;; + + *) + secho "module_fetch: Unknown fetch rule for $module_varname: \"$module_fetch_rule\"." + return 1 + ;; + esac +} + +module_clean() { + if [ -z "$force" ] && ! can_build_module $1; then + lsecho "Skipping clean, $module_varname is disabled on ${platform}..." + return 0 + fi + + case "$module_build_rule" in + generic_makefile) + lsecho "Cleaning ${module_varname}..." + echo_cmd "cd \"$module_build_dir\"" + + make_cmdline="$MAKE" + if [ -n "$module_build_makefile" ]; then + make_cmdline="$make_cmdline -f $module_build_makefile" + fi + + # TODO: Do $platform type stuff better (requires modding each core) + make_cmdline="$make_cmdline platform=\"$module_build_platform\"" + + [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" + echo_cmd "$make_cmdline $module_build_args clean" + return $? + ;; + + legacy) + lsecho "Legacy rules cannot be cleaned separately, skipping..." + ;; + + none) + lsecho "No rule to clean ${module_varname}." + ;; + + *) ;; + esac +} + +module_compile() { + if [ -z "$force" ] && ! can_build_module $1; then + lsecho "Skipping compile, $module_varname is disabled on ${platform}..." + return 0 + fi + + case "$module_build_rule" in + generic_makefile) + lsecho "Compiling ${module_varname}..." + echo_cmd "cd \"$module_build_dir\"" + + make_cmdline="$MAKE" + if [ -n "$module_build_makefile" ]; then + make_cmdline="$make_cmdline -f $module_build_makefile" + fi + + # TODO: Do $platform type stuff better (requires modding each core) + make_cmdline="$make_cmdline platform=\"$module_build_platform\"" + + [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" + + make_cmdline="$make_cmdline $COMPILER" + if [ -n "$module_build_makefile_targets" ]; then + for target in $module_build_makefile_targets; do + echo_cmd "$make_cmdline $module_build_args $target" + done + else + echo_cmd "$make_cmdline $module_build_args" + fi + if [ $? -gt 0 ]; then + for core in $module_build_cores; do + build_summary_log 1 $core + done + return 1 + fi + + modules_copied="" + for module in $module_build_cores; do + module_src="${module_build_products:+$module_build_products/}$module$CORE_SUFFIX" + module_dest="$module$CORE_SUFFIX" + if [ -f "$module_src" ]; then + build_summary_log 0 $module + echo_cmd "cp \"$module_src\" \"$RARCH_DIST_DIR/$module_dest\"" + modules_copied="$modules_copied $module_dest" + else + build_summary_log 1 $module + fi + done + return 0 + ;; + + legacy) + if [ -n "$module_build_legacy" ]; then + lsecho "Warning: $module_varname hasn't been ported to a modern build rule yet." + lsecho "Compiling $module_varname using legacy \"$module_build_legacy\"..." + $module_build_legacy + return $? + else + lsecho "module_compile: No legacy build rule for ${module_varname}." + return 1 + fi + ;; + + none) + lsecho "No rule to compile ${module_varname}." + ;; + + *) ;; + esac +} + +module_package() { + if [ -n "$modules_copied" ]; then + lsecho "Packaging ${module_varname}..." + cd "$RARCH_DIST_DIR" + for module in $modules_copied; do + # TODO: Support more than zip here + zip -m9 "${module}.zip" $module + done + fi +} + +module_process() { + local module_changed + + if [[ "$libretro_modules" != *$1* ]]; then + secho "$(color 34)=== $(color 1)$1 $(color 31)not found$(color)" + lecho "=== $1 not found" + lsecho "" + return 1 + fi + if module_set_vars ${1%%:*}; then + secho "$(color 34)=== $(color 1)$module_name$(color)" + lecho "=== $module_name" + else + secho "$(color 34)=== $color 1)$1 $(color 31)rule error$(color)" + lecho "=== $1 rule error" + return 1 + fi + + log_module_start $module_varname + + module_revision_old="$(module_get_revision)" + if [[ "$actions" = *fetch* ]]; then + if ! module_fetch $1; then + log_module_stop "module_process: Unable to fetch ${module_varname}." + return 1 + fi + fi + module_revision="$(module_get_revision 1)" + if [ "0$skip_unchanged" -eq 1 ]; then + if [ "$module_revision_old" != "$module_revision" ]; then + module_changed=1 + else + module_changed="" + fi + else + module_changed=1 + fi + + if [[ -n "$module_changed" && "$actions" = *clean* ]]; then + if ! $module_preclean; then + log_module_stop "module_process: module_preclean for $module_varname failed." + return 1 + fi + if ! module_clean $1; then + log_module_stop "module_process: Unable to clean ${module_varname}." + return 1 + fi + fi + + if [[ -n "$module_changed" && "$actions" = *compile* ]]; then + if ! $module_configure; then + log_module_stop "module_process: module_configure for $module_varname failed." + return 1 + fi + if ! module_compile $1; then + log_module_stop "module_process: Unable to compile ${module_varname}." + return 1 + fi + fi + + if [[ -n "$module_changed" && "$actions" = *package* ]]; then + if ! $module_prepackage; then + log_module_stop "module_process: module_prepackage for $module_varname failed." + return 1 + fi + if ! module_package $1; then + log_module_stop "module_process: Unable to package ${module_varname}." + return 1 + fi + fi + + log_module_stop +} + +################################# +# Borrowed from original libretro-build +# TODO: Replace this code using find_tool + +if [ -z "$RARCH_DIST_DIR" ]; then + RARCH_DIR="$WORKDIR/dist" + RARCH_DIST_DIR="$RARCH_DIR/$DIST_DIR" +fi + +if [ -z "$JOBS" ]; then + JOBS=7 +fi + +if [ "$HOST_CC" ]; then + CC="${HOST_CC}-gcc" + CXX="${HOST_CC}-g++" + CXX11="${HOST_CC}-g++" + STRIP="${HOST_CC}-strip" +fi + + +if [ -z "$MAKE" ]; then + if uname -s | grep -i MINGW > /dev/null 2>&1; then + MAKE=mingw32-make + else + if type gmake > /dev/null 2>&1; then + MAKE=gmake + else + MAKE=make + fi + fi +fi + +if [ -z "$CC" ]; then + if [ $FORMAT_COMPILER_TARGET = "osx" ]; then + CC=cc + elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then + CC=mingw32-gcc + else + CC=gcc + fi +fi + +if [ -z "$CXX" ]; then + if [ $FORMAT_COMPILER_TARGET = "osx" ]; then + CXX=c++ + CXX11="clang++ -std=c++11 -stdlib=libc++" + # FIXME: Do this right later. + if [ "$ARCH" = "i386" ]; then + CC="cc -arch i386" + CXX="c++ -arch i386" + CXX11="clang++ -arch i386 -std=c++11 -stdlib=libc++" + fi + elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then + CXX=mingw32-g++ + CXX11=mingw32-g++ + else + CXX=g++ + CXX11=g++ + fi +fi + +FORMAT_COMPILER_TARGET_ALT=$FORMAT_COMPILER_TARGET + +. "$BASE_DIR/libretro-build-common.sh" + +# End of borrowed code +################################# + +for target in $process; do + module_process $target +done + +summary From 0e0f20338a4ae2373824437f7be85d10464063ac Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Mon, 6 Apr 2015 02:07:15 -0700 Subject: [PATCH 15/20] MAME's legacy rule is _gone_. libretro-super.sh now has multi-target, so this isn't needed anymore. --- libretro-build-common.sh | 60 ---------------------------------------- 1 file changed, 60 deletions(-) diff --git a/libretro-build-common.sh b/libretro-build-common.sh index d6b79688..ac0299cb 100755 --- a/libretro-build-common.sh +++ b/libretro-build-common.sh @@ -386,63 +386,3 @@ create_dist_dir() { } create_dist_dir - - -########## LEGACY RULES -# TODO: Port these to modern rules - -build_libretro_mame_prerule() { - build_dir="$WORKDIR/libretro-mame" - - if build_should_skip mame "$build_dir"; then - echo "Core mame is already built, skipping..." - return - fi - - ret=0 - if [ -d "$build_dir" ]; then - echo '' - echo "=== Building MAME ===" - echo_cmd "cd \"$build_dir\"" - - local extra_args - [ "${MAME_GIT_TINY:=0}" -eq 1 ] && extra_args="$extra_args SUBTARGET=tiny" - - if [ -z "$NOCLEAN" ]; then - echo_cmd "$MAKE -f Makefile.libretro $extra_args platform=\"$FORMAT_COMPILER_TARGET\" \"-j$JOBS\" clean" - ret=$? - - if [ "$ret" != 0 ]; then - die 'Failed to clean MAME' - return $ret - fi - fi - - # For mame platforms that are CROSS_BUILD's (iOS/Android), we must make buildtools natively - if [ "$platform" = "ios" ]; then - echo_cmd "$MAKE -f Makefile.libretro platform=\"\" buildtools" || die 'Failed to build MAME buildtools' - fi - - # This hack is because mame uses $(CC) to comiple C++ code because "historical reasons" - # It can/should be removed when upstream MAME fixes it on their end. - MAME_COMPILER="REALCC=\"${CC:-cc}\" CC=\"${CXX:-c++}\"" - - # mame's tiny subtarget doesn't support UME - mame_targets="mame mess ume" - [ "$MAME_GIT_TINY" -eq 1 ] && mame_targets="mame mess" - - for target in $mame_targets; do - echo_cmd "$MAKE -f Makefile.libretro $extra_args \"TARGET=$target\" platform=\"$FORMAT_COMPILER_TARGET\" $MAME_COMPILER \"-j$JOBS\"" || die "Failed to build $target" - copy_core_to_dist "$target" - ret=$? - - # If a target fails, stop here... - [ $ret -eq 0 ] || break - done - - else - echo 'MAME not fetched, skipping ...' - fi - - build_save_revision $ret mame -} From 7a58a77f0d2e213225368505b440744c574a2748 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Thu, 9 Apr 2015 18:18:27 -0700 Subject: [PATCH 16/20] Kind of an early POC on new --platform libretro-super.sh works, but you currently need to set platform and ARCH in your environment before running it as you do with libretro-build.sh now (see libretro-build-ios.sh wrapper for what I mean). The major work left here is the --platform argument and a bunch of little things that will mostly fall into place when that's done. Also need to settle on a license for this. My habit for scripts is public domain, but it could be argued that libretro-super is no longer "a script". Still, I want people to use this if it's useful to them, so I'd prefer a totally unencumbered license in the vein of MIT/BSD/CC-BY. I've tentatively selected CC-BY as a RFC on it vs. MIT, mostly because it tries to explain things in plain language and unlike MIT/BSD is reviewed in the context of (d)evolving international laws to ensure that it still does what is intended. --- libretro-super.sh | 632 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 553 insertions(+), 79 deletions(-) diff --git a/libretro-super.sh b/libretro-super.sh index de893557..6be42495 100755 --- a/libretro-super.sh +++ b/libretro-super.sh @@ -17,14 +17,524 @@ else fi fi -shopt -q nullglob || reset_nullglob=1 +################################################################### +# +# NEW PLATFORM STUFF +# Move to rules files like cores are done +# +################################################################### -. "$BASE_DIR/libretro-config.sh" +#register_toolchain OSX x86 x86_64 +toolchain_OSX_CC="cc" +toolchain_OSX_CXX="c++" +toolchain_OSX_CXX11="clang++" +toolchain_OSX_CXX11_args="-std=c++11 -stdlib=libc++" +toolchain_OSX_x86_suffix=" -arch i386" +toolchain_OSX_x86_64_suffix=" -arch x86_64" +toolchain_OSX_platform="osx" + +#register_toolchain iOS armv7 # x86? +toolchain_iOS_CC="cc" +toolchain_iOS_CXX="c++" +toolchain_iOS_CXX11="clang++" +toolchain_iOS_CXX11_args="-std=c++11 -stdlib=libc++" +toolchain_iOS_armv7_suffix="-arch armv7 -marm -miphoneos-version-min=5.0 -isysroot \$IOSSDK" +toolchain_iOS_platform="ios" +toolchain_iOS_configure() { + if [ -z "$IOSSDK" ]; then + if [ -z "${xcodebuild:-$(find_tool xcodebuild)}" ]; then + lsecho "You must set IOSSDK or have xcodebuild in your path for iOS" + return 1 + fi + export IOSSDK=$(xcodebuild -version -sdk iphoneos Path) + fi + + if [ ! -d "$IOSSDK/usr" ]; then + lsecho "\"$IOSSDK\" does not appear to be a valid iOS SDK." + return 1 + fi +} + + +################################################################### +# +# LIBRETRO-CONFIG +# Replace with args, rules-based --platform selection, and config +# file to save user preferences +# +# Config file generation will ultimately be something like Linux +# kernel menuconfig if you have dialog/whiptail, but those won't +# be required. +# +################################################################### + +# The platform variable is normally not set at the time libretro-config is +# included by libretro-build.sh. Other platform scripts may begin to include +# libretro-config as well if they define their platform-specific code in the +# case block below. This is a band-aid fix that we will address after 1.1 is +# released. + +case "$platform" in + ## + ## Configs that did not use libretro-config originally + ## TODO: Integrate this with everything else (post-1.1) + ## + + ios) + # NOTE: This config requires a Mac with an Xcode installation. These + # scripts will work at least as far as 10.5 that we're sure of, but + # we build with clang targeting iOS >= 5. We'll accept patches for + # older versions of iOS. + + DIST_DIR="ios" + FORMAT_EXT=dylib + IOS=1 + ARCH=armv7 + FORMAT=_ios + FORMAT_COMPILER_TARGET=ios + FORMAT_COMPILER_TARGET_ALT=ios + export IOSSDK=$(xcodebuild -version -sdk iphoneos Path) + iosver=$(xcodebuild -version -sdk iphoneos ProductVersion) + IOSVER_MAJOR=${iosver%.*} + IOSVER_MINOR=${iosver#*.} + IOSVER=${IOSVER_MAJOR}${IOSVER_MINOR} + MIN_IOS5="-miphoneos-version-min=5.0" + MIN_IOS7="-miphoneos-version-min=7.0" + + # Use generic names rather than gcc/clang to better support both + CC="cc -arch armv7 -marm -miphoneos-version-min=5.0 -isysroot $IOSSDK" + CXX="c++ -arch armv7 -marm -miphoneos-version-min=5.0 -isysroot $IOSSDK" + CXX11="clang++ -std=c++11 -stdlib=libc++ -arch armv7 -marm -miphoneos-version-min=5.0 -isysroot $IOSSDK" + ;; + + theos_ios) + DIST_DIR="theos_ios" + BUILD_PRODUCT_PREFIX="objs/obj" + FORMAT_EXT=dylib + IOS=1 + ARCH=armv7 + FORMAT=_ios + FORMAT_COMPILER_TARGET=theos_ios + FORMAT_COMPILER_TARGET_ALT=theos_ios + + # Make sure that the cross bins you need are first in your path + CXX11="clang++ -std=c++11 -stdlib=libc++ -miphoneos-version-min=5.0" + + ;; + + ## + ## Original libretro-config path + ## + *) + + # Architecture Assignment + config_cpu() { + [ -n "$2" ] && ARCH="$1" + [ -z "$ARCH" ] && ARCH="$(uname -m)" + case "$ARCH" in + x86_64) + X86=true + X86_64=true + ;; + i386|i686) + X86=true + ;; + armv*) + ARM=true + export FORMAT_COMPILER_TARGET=armv + export RARCHCFLAGS="$RARCHCFLAGS -marm" + case "${ARCH}" in + armv5tel) ARMV5=true ;; + armv6l) ARMV6=true ;; + armv7l) ARMV7=true ;; + esac + ;; + esac + if [ -n "$PROCESSOR_ARCHITEW6432" -a "$PROCESSOR_ARCHITEW6432" = "AMD64" ]; then + ARCH=x86_64 + X86=true && X86_64=true + fi + } + + # Platform Assignment + config_platform() { + [ -n "$1" ] && platform="$1" + [ -z "$platform" ] && platform="$(uname)" + case "$platform" in + *BSD*) + platform=bsd + FORMAT_EXT="so" + FORMAT_COMPILER_TARGET="unix" + DIST_DIR="bsd" + ;; + osx|*Darwin*) + platform=osx + FORMAT_EXT="dylib" + FORMAT_COMPILER_TARGET="osx" + DIST_DIR="osx" + ;; + win|*mingw32*|*MINGW32*|*MSYS_NT*) + platform=win + FORMAT_EXT="dll" + FORMAT_COMPILER_TARGET="win" + DIST_DIR="win_x86" + ;; + win64|*mingw64*|*MINGW64*) + platform=win + FORMAT_EXT="dll" + FORMAT_COMPILER_TARGET="win" + DIST_DIR="win_x64" + ;; + *psp1*) + platform=psp1 + FORMAT_EXT="a" + FORMAT_COMPILER_TARGET="psp1" + DIST_DIR="psp1" + ;; + *wii*) + platform=wii + FORMAT_EXT="a" + FORMAT_COMPILER_TARGET="wii" + DIST_DIR="wii" + ;; + *ngc*) + platform=ngc + FORMAT_EXT="a" + FORMAT_COMPILER_TARGET="ngc" + DIST_DIR="ngc" + ;; + theos_ios*) + platform=theos_ios + FORMAT_EXT="dylib" + FORMAT_COMPILER_TARGET="theos_ios" + DIST_DIR="theos_ios" + ;; + android) + FORMAT_EXT="so" + FORMAT_COMPILER_TARGET="android" + DIST_DIR="android" + ;; + android-armv7) + FORMAT_EXT="so" + FORMAT_COMPILER_TARGET="android-armv7" + DIST_DIR="android/armeabi-v7a" + ;; + *) + FORMAT_EXT="so" + FORMAT_COMPILER_TARGET="unix" + DIST_DIR="unix" + ;; + esac + export FORMAT_COMPILER_TARGET_ALT="$FORMAT_COMPILER_TARGET" + } + + config_log_build_host() { + echo "PLATFORM: $platform" + echo "ARCHITECTURE: $ARCH" + echo "TARGET: $FORMAT_COMPILER_TARGET" + } + + config_cpu + config_platform + config_log_build_host + + if [ -z "$JOBS" ]; then + # nproc is generally Linux-specific. + if command -v nproc >/dev/null; then + JOBS="$(nproc)" + elif [ "$pltaform" = "osx" ] && command -v sysctl >/dev/null; then + JOBS="$(sysctl -n hw.physicalcpu)" + else + JOBS=1 + fi + fi + ;; +esac + +# Taken from LIBRETRO-BUILD-COMMON.SH +[[ "${ARM_NEON}" ]] && echo '=== ARM NEON opts enabled... ===' && export FORMAT_COMPILER_TARGET="$FORMAT_COMPILER_TARGET-neon" +[[ "${CORTEX_A8}" ]] && echo '=== Cortex A8 opts enabled... ===' && export FORMAT_COMPILER_TARGET="$FORMAT_COMPILER_TARGET-cortexa8" +[[ "${CORTEX_A9}" ]] && echo '=== Cortex A9 opts enabled... ===' && export FORMAT_COMPILER_TARGET="$FORMAT_COMPILER_TARGET-cortexa9" +[[ "${ARM_HARDFLOAT}" ]] && echo '=== ARM hardfloat ABI enabled... ===' && export FORMAT_COMPILER_TARGET="$FORMAT_COMPILER_TARGET-hardfloat" +[[ "${ARM_SOFTFLOAT}" ]] && echo '=== ARM softfloat ABI enabled... ===' && export FORMAT_COMPILER_TARGET="$FORMAT_COMPILER_TARGET-softfloat" +[[ "$X86" ]] && echo '=== x86 CPU detected... ===' +[[ "$X86" ]] && [[ "$X86_64" ]] && echo '=== x86_64 CPU detected... ===' + +#if uncommented, will build experimental cores as well which are not yet fit for release. +#export BUILD_EXPERIMENTAL=1 + +#ARM DEFINES +#=========== + +#if uncommented, will build cores with Cortex A8 compiler optimizations +#export CORTEX_A8=1 + +#if uncommented, will build cores with Cortex A9 compiler optimizations +#export CORTEX_A9=1 + +#if uncommented, will build cores with ARM hardfloat ABI +#export ARM_HARDFLOAT=1 + +#if uncommented, will build cores with ARM softfloat ABI +#export ARM_SOFTFLOAT=1 + +#if uncommented, will build cores with ARM NEON support (ARMv7+ only) +#export ARM_NEON=1 + +#OPENGL DEFINES +#============== + +#if uncommented, will build libretro GL cores. Ignored for mobile platforms - GL cores will always be built there. +export BUILD_LIBRETRO_GL=1 + +#if uncommented, will build cores with OpenGL ES 2 support. Not needed +#for platform-specific cores - only for generic core builds (ie. libretro-build.sh) +#export ENABLE_GLES=1 + +#ANDROID DEFINES +#================ + +export TARGET_ABIS="armeabi armeabi-v7a x86" + +#uncomment to define NDK standalone toolchain for ARM +#export NDK_ROOT_DIR_ARM = + +#uncomment to define NDK standalone toolchain for MIPS +#export NDK_ROOT_DIR_MIPS = + +#uncomment to define NDK standalone toolchain for x86 +#export NDK_ROOT_DIR_X86 = + +# android version target if GLES is in use +export NDK_GL_HEADER_VER=android-18 + +# android version target if GLES is not in use +export NDK_NO_GL_HEADER_VER=android-9 + +# Retroarch target android API level +export RA_ANDROID_API=android-18 + +# Retroarch minimum API level (defines low end android version compatability) +export RA_ANDROID_MIN_API=android-9 + +#OSX DEFINES +#=========== + +# Define this to skip the universal build +# export NOUNIVERSAL=1 + +# ARCHFLAGS is a very convenient way of doing this for simple/obvious cores +# that don't need anything defined on the command line for 32 vs 64 bit +# systems, however it won't work for anything that does. For that, you need +# to do two separate builds, one for each arch, and then do something like: +# lipo -create core_i386.dylib core_x86_64.dylib -output core_ub.dylib +# +# If building on 10.5/10.6, it's possible that you could actually build a UB +# for Intel/PowerPC, but please don't. ;) Consider this a proof of concept +# for now just to test a few cores. + +if [[ "$FORMAT_COMPILER_TARGET" = "osx" && -z "$NOUNIVERSAL" ]]; then + case "$ARCH" in + i386|x86_64) + export ARCHFLAGS="-arch i386 -arch x86_64" + ;; + ppc|ppc64) + export ARCHFLAGS="-arch ppc -arch ppc64" + ;; + *) + echo "Will not build universal binaries for unknown ARCH=\"$ARCH\"" + ;; + esac +fi + +# OUTPUT AND LOGGING +# ================== +# +# This is kind of an inline design document that'll be changed for basic user +# instructions when the logging system is finished and tested. +# +# libretro-super has two kinds of output, the basic kind showing what the +# script is doing in a big-picture sense, and the commands and output from +# individual commands. End-users don't necessarily need to see this more +# detailed output, except when we're talking about huge cores like mame. +# +# If each can be directed to null, to the screen, to a log file, or to both +# the screen and a log file, you end up with a matrix os 16 possibilities. Of +# those, only a few are truly useful: +# +# Basic Detailed Useful to +# screen screen developer/end-user w/ space issues +# screen both developer +# both both developer +# screen log end-user +# log log buildbot +# +# What this tells me is that we need to log by default, as long as we kill +# old logfiles to avoid filling your HD with gigabytes of mame build logs. +# Output should go to both screen and log for developers, but users don't need +# to see the make commands, etc. Being able to disable both would be useful, +# but that a near-term TODO item. That just leaves being able to squelch the +# screen output for buildbot usage, and that's just > /dev/null on the command +# line, so not our problem here. +# +# Again, the ability to turn OFF these logs will be wanted very soon. + +# Uncomment this to avoid clobbering logs +#LIBRETRO_LOG_APPEND=1 + +# Change this to adjust where logs are written +#LIBRETRO_LOG_DIR="$WORKDIR/log" + +# Change this to rename the libretro-super main log file +#LIBRETRO_LOG_SUPER="libretro-super.log" + +# Change this to rename core log files (%s for core's "safe" name) +#LIBRETRO_LOG_CORE="%s.log" + +# Comment this if you don't need to see developer output +LIBRETRO_DEVELOPER=1 + + +# COLOR IN OUTPUT +# =============== +# +# If you don't like ANSI-style color in your output, uncomment this line. +#NO_COLOR=1 + +# If you want to force it even in log files, uncomment this line. +#FORCE_COLOR=1 + +#USER DEFINES +#------------ +#These options should be defined inside your own +#local libretro-config-user.sh file rather than here. +#The following below is just a sample. + +if [ -f "$WORKDIR/libretro-config-user.sh" ]; then + . "$WORKDIR/libretro-config-user.sh" +fi + +################################################################### +# +# LIBRETRO-BUILD-COMMON +# Summary already re-written, CORE_SUFFIX def may be moved +# RARCH_DIST_DIR stuff will change with --platform +# +################################################################### + +CORE_SUFFIX="_libretro${FORMAT}.$FORMAT_EXT" + +summary() { + # fmt is external and may not be available + fmt_output="$(find_tool "fmt")" + local num_success="$(numwords $build_success)" + local fmt_success="${fmt_output:+$(echo " $build_success" | $fmt_output)}" + local num_fail="$(numwords $build_fail)" + local fmt_fail="${fmt_output:+$(echo " $build_fail" | $fmt_output)}" + + if [[ -z "$build_success" && -z "$build_fail" ]]; then + lsecho "No build actions performed." + return + fi + + if [ -n "$build_success" ]; then + secho "$(color 32)$num_success module(s)$(color) compiled successfully:" + lecho "$num_success module(s) successfully processed:" + lsecho "$fmt_success" + fi + if [ -n "$build_fail" ]; then + secho "$(color 31)$num_fail module(s)$(color) failed to compile:" + lecho "$num_fail module(s) failed:" + lsecho "$fmt_fail" + fi +} + +create_dist_dir() { + mkdir -p "$RARCH_DIST_DIR" +} + +if [ -z "$RARCH_DIST_DIR" ]; then + RARCH_DIR="$WORKDIR/dist" + RARCH_DIST_DIR="$RARCH_DIR/$DIST_DIR" +fi +create_dist_dir + +################################################################### +# +# LIBRETRO-BUILD-COMMON +# Default tool selection goes into --platform stuff +# +################################################################### + +if [ -z "$JOBS" ]; then + JOBS=7 +fi + +if [ "$HOST_CC" ]; then + CC="${HOST_CC}-gcc" + CXX="${HOST_CC}-g++" + CXX11="${HOST_CC}-g++" + STRIP="${HOST_CC}-strip" +fi + + +if [ -z "$MAKE" ]; then + if uname -s | grep -i MINGW > /dev/null 2>&1; then + MAKE=mingw32-make + else + if type gmake > /dev/null 2>&1; then + MAKE=gmake + else + MAKE=make + fi + fi +fi + +if [ -z "$CC" ]; then + if [ $FORMAT_COMPILER_TARGET = "osx" ]; then + CC=cc + elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then + CC=mingw32-gcc + else + CC=gcc + fi +fi + +if [ -z "$CXX" ]; then + if [ $FORMAT_COMPILER_TARGET = "osx" ]; then + CXX=c++ + CXX11="clang++ -std=c++11 -stdlib=libc++" + # FIXME: Do this right later. + if [ "$ARCH" = "i386" ]; then + CC="cc -arch i386" + CXX="c++ -arch i386" + CXX11="clang++ -arch i386 -std=c++11 -stdlib=libc++" + fi + elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then + CXX=mingw32-g++ + CXX11=mingw32-g++ + else + CXX=g++ + CXX11=g++ + fi +fi + +FORMAT_COMPILER_TARGET_ALT=$FORMAT_COMPILER_TARGET + + +################################################################### +# +# END OF INSERTED OLD SCRIPT BITS +# +################################################################### + +shopt -q nullglob || reset_nullglob=1 . "$BASE_DIR/script-modules/log.sh" . "$BASE_DIR/script-modules/util.sh" . "$BASE_DIR/script-modules/fetch-rules.sh" . "$BASE_DIR/script-modules/modules.sh" +. "$BASE_DIR/script-modules/cpu.sh" # Read all of the rules file shopt -s nullglob @@ -65,9 +575,12 @@ if [ -n "$1" ]; then ;; # - # Scope controls + # Configuration controls # + # TODO + --config|--configure) ;; + --devel) LIBRETRO_DEVELOPER=1 ;; --no-devel) LIBRETRO_DEVELOPER="" ;; @@ -103,6 +616,18 @@ if [ -n "$1" ]; then actions="$actions package" ;; + + # + # Platform controls + # + + --platform) + if [ -n "$2" ]; then + build_platforms="$build_platforms $2" + shift + fi + ;; + # # Module type controls # @@ -145,7 +670,7 @@ letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA." exit 0 fi lsecho "Licensed under CC-BY-4.0 (--license for details)" - +# XXX: MIT vs CC-BY vs CC-0? # Configure some defaults [ -z "$actions" ] && actions="$default_actions" @@ -172,9 +697,13 @@ fi ################################################################### # # MODULE PROCESSING +# To be moved out of main script # ################################################################### + +# All of the module_* vars are set here before calling any other module +# processing actions module_set_vars() { module_varname="$1" eval "module_name=\${libretro_${1}_name:-$1}" @@ -228,6 +757,9 @@ module_set_vars() { eval "module_build_cores=\${libretro_${1}_build_cores:-$1}" eval "module_build_products=\$libretro_${1}_build_products" + + # TODO: this too... + eval "module_build_compiler=\$libretro_${1}_build_compiler" ;; legacy) @@ -324,7 +856,13 @@ module_compile() { [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" - make_cmdline="$make_cmdline $COMPILER" + # TODO: Do this better too (only affects a few cores) + if [ -n "$module_build_compiler" ]; then + make_cmdline="$make_cmdline $module_build_compiler" + else + make_cmdline="$make_cmdline ${CC:+CC="$CC"} ${CXX:+CXX="$CXX"}" + fi + if [ -n "$module_build_makefile_targets" ]; then for target in $module_build_makefile_targets; do echo_cmd "$make_cmdline $module_build_args $target" @@ -333,9 +871,7 @@ module_compile() { echo_cmd "$make_cmdline $module_build_args" fi if [ $? -gt 0 ]; then - for core in $module_build_cores; do - build_summary_log 1 $core - done + build_fail="$build_fail$module_build_cores " return 1 fi @@ -344,11 +880,11 @@ module_compile() { module_src="${module_build_products:+$module_build_products/}$module$CORE_SUFFIX" module_dest="$module$CORE_SUFFIX" if [ -f "$module_src" ]; then - build_summary_log 0 $module + build_success="$build_success$module " echo_cmd "cp \"$module_src\" \"$RARCH_DIST_DIR/$module_dest\"" modules_copied="$modules_copied $module_dest" else - build_summary_log 1 $module + build_fail="$build_fail$module " fi done return 0 @@ -378,8 +914,8 @@ module_package() { if [ -n "$modules_copied" ]; then lsecho "Packaging ${module_varname}..." cd "$RARCH_DIST_DIR" + # TODO: Packaging other than zip (deb, etc?) for module in $modules_copied; do - # TODO: Support more than zip here zip -m9 "${module}.zip" $module done fi @@ -459,74 +995,12 @@ module_process() { log_module_stop } -################################# -# Borrowed from original libretro-build -# TODO: Replace this code using find_tool - -if [ -z "$RARCH_DIST_DIR" ]; then - RARCH_DIR="$WORKDIR/dist" - RARCH_DIST_DIR="$RARCH_DIR/$DIST_DIR" -fi - -if [ -z "$JOBS" ]; then - JOBS=7 -fi - -if [ "$HOST_CC" ]; then - CC="${HOST_CC}-gcc" - CXX="${HOST_CC}-g++" - CXX11="${HOST_CC}-g++" - STRIP="${HOST_CC}-strip" -fi - - -if [ -z "$MAKE" ]; then - if uname -s | grep -i MINGW > /dev/null 2>&1; then - MAKE=mingw32-make - else - if type gmake > /dev/null 2>&1; then - MAKE=gmake - else - MAKE=make - fi - fi -fi - -if [ -z "$CC" ]; then - if [ $FORMAT_COMPILER_TARGET = "osx" ]; then - CC=cc - elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then - CC=mingw32-gcc - else - CC=gcc - fi -fi - -if [ -z "$CXX" ]; then - if [ $FORMAT_COMPILER_TARGET = "osx" ]; then - CXX=c++ - CXX11="clang++ -std=c++11 -stdlib=libc++" - # FIXME: Do this right later. - if [ "$ARCH" = "i386" ]; then - CC="cc -arch i386" - CXX="c++ -arch i386" - CXX11="clang++ -arch i386 -std=c++11 -stdlib=libc++" - fi - elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then - CXX=mingw32-g++ - CXX11=mingw32-g++ - else - CXX=g++ - CXX11=g++ - fi -fi - -FORMAT_COMPILER_TARGET_ALT=$FORMAT_COMPILER_TARGET - -. "$BASE_DIR/libretro-build-common.sh" - -# End of borrowed code -################################# +################################################################### +# +# DO STUFF +# The bit of this script that actually does all the work is here +# +################################################################### for target in $process; do module_process $target From 5fc07c8a366c0ad4d453bb9612dca3fc41e6598c Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 12 Apr 2015 14:54:43 -0700 Subject: [PATCH 17/20] Make mame work with libretro-super Forgot to commit this a few days ago. --- rules.d/core-rules.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rules.d/core-rules.sh b/rules.d/core-rules.sh index ce5c5e73..f9f38e60 100644 --- a/rules.d/core-rules.sh +++ b/rules.d/core-rules.sh @@ -201,8 +201,16 @@ libretro_mame139_build_rule=none # NEED A BUILD RULE register_core "mame" -theos_ios -ngc -ps3 -psp1 -qnx -wii libretro_mame_name="MAME (git)" libretro_mame_git_url="https://github.com/libretro/mame.git" -libretro_mame_build_rule=legacy -libretro_mame_build_legacy=build_libretro_mame_prerule +libretro_mame_build_makefile=Makefile.libretro +libretro_mame_build_compiler="REALCC=\"${CC:-cc}\" CC=\"${CXX:-c++}\"" +libretro_mame_build_makefile_targets="TARGET=\"mame\" TARGET=\"mess\" TARGET=\"ume\"" +libretro_mame_build_cores="mame mess ume" +libretro_mame_configure() { + if [ "$platform" = "ios" ]; then + # We don't have the means to do this "properly" yet... + echo_cmd "$MAKE -C \"$module_build_dir\" -f Makefile.libretro platform=\"\" buildtools" + fi +} register_core "ffmpeg" -ios -theos_ios -osx -ngc -ps3 -psp1 -qnx -wii libretro_ffmpeg_name="FFmpeg" From ab3be555e667d83856477fed37c8b612772af330 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 12 Apr 2015 14:56:10 -0700 Subject: [PATCH 18/20] Move module processing to a script module --- libretro-build-common.sh | 2 +- libretro-fetch.sh | 2 +- libretro-super.sh | 306 +----------------- script-modules/{modules.sh => module_base.sh} | 0 4 files changed, 6 insertions(+), 304 deletions(-) rename script-modules/{modules.sh => module_base.sh} (100%) diff --git a/libretro-build-common.sh b/libretro-build-common.sh index ac0299cb..0a91c11b 100755 --- a/libretro-build-common.sh +++ b/libretro-build-common.sh @@ -4,7 +4,7 @@ . "$BASE_DIR/script-modules/util.sh" . "$BASE_DIR/script-modules/fetch-rules.sh" . "$BASE_DIR/script-modules/cpu.sh" -. "$BASE_DIR/script-modules/modules.sh" +. "$BASE_DIR/script-modules/module_base.sh" . "$BASE_DIR/rules.d/core-rules.sh" diff --git a/libretro-fetch.sh b/libretro-fetch.sh index dcc05074..66544719 100755 --- a/libretro-fetch.sh +++ b/libretro-fetch.sh @@ -18,7 +18,7 @@ fi . "$BASE_DIR/script-modules/log.sh" . "$BASE_DIR/script-modules/util.sh" . "$BASE_DIR/script-modules/fetch-rules.sh" -. "$BASE_DIR/script-modules/modules.sh" +. "$BASE_DIR/script-modules/module_base.sh" # Rules for fetching things are in these files: . "$BASE_DIR/rules.d/core-rules.sh" diff --git a/libretro-super.sh b/libretro-super.sh index 6be42495..e8640580 100755 --- a/libretro-super.sh +++ b/libretro-super.sh @@ -24,6 +24,8 @@ fi # ################################################################### +# TODO: implement register_toolchain + #register_toolchain OSX x86 x86_64 toolchain_OSX_CC="cc" toolchain_OSX_CXX="c++" @@ -533,8 +535,9 @@ shopt -q nullglob || reset_nullglob=1 . "$BASE_DIR/script-modules/log.sh" . "$BASE_DIR/script-modules/util.sh" . "$BASE_DIR/script-modules/fetch-rules.sh" -. "$BASE_DIR/script-modules/modules.sh" . "$BASE_DIR/script-modules/cpu.sh" +. "$BASE_DIR/script-modules/module_base.sh" +. "$BASE_DIR/script-modules/module_process.sh" # Read all of the rules file shopt -s nullglob @@ -694,307 +697,6 @@ else [ -z "$skip_unchanged" ] && skip_unchanged=0 fi -################################################################### -# -# MODULE PROCESSING -# To be moved out of main script -# -################################################################### - - -# All of the module_* vars are set here before calling any other module -# processing actions -module_set_vars() { - module_varname="$1" - eval "module_name=\${libretro_${1}_name:-$1}" - eval "module_dir=\${libretro_${1}_dir:-libretro-$1}" - - for func in configure preclean prepackage; do - if [ "$(type -t libretro_${1}_$func 2> /dev/null)" = "function" ]; then - eval "module_$func=libretro_${1}_$func" - else - eval "module_$func=do_nothing" - fi - done - - eval "module_fetch_rule=\${libretro_${1}_fetch_rule:-git}" - case "$module_fetch_rule" in - git) - eval "git_url=\$libretro_${1}_git_url" - eval "git_submodules=\$libretro_${1}_git_submodules" - ;; - - none) ;; - - *) - echo "Unknown fetch rule for $1: \"$module_fetch_rule\"." - ;; - esac - - eval "module_build_rule=\${libretro_${1}_build_rule:-generic_makefile}" - - # TODO: Do OpenGL better - eval "module_build_opengl=\$libretro_${1}_build_opengl" - module_opengl_type="" - if [ -n "$module_build_opengl" ]; then - if [ -n "$ENABLE_GLES" ]; then - module_opengl_type="-gles" - else - module_opengl_type="-opengl" - fi - fi - - module_build_subdir="" - case "$module_build_rule" in - generic_makefile) - eval "module_build_makefile=\$libretro_${1}_build_makefile" - eval "module_build_subdir=\$libretro_${1}_build_subdir" - eval "module_build_makefile_targets=\"\$libretro_${1}_build_makefile_targets\"" - eval "module_build_args=\$libretro_${1}_build_args" - - # TODO: change how $platform is done - eval "module_build_platform=\${libretro_${1}_build_platform:-$FORMAT_COMPILER_TARGET}$opengl_type" - - eval "module_build_cores=\${libretro_${1}_build_cores:-$1}" - eval "module_build_products=\$libretro_${1}_build_products" - - # TODO: this too... - eval "module_build_compiler=\$libretro_${1}_build_compiler" - ;; - - legacy) - eval "module_build_legacy=\$libretro_${1}_build_legacy" - ;; - - none) ;; - - *) - echo "Unknown build rule for $1: \"$module_build_rule\"." - ;; - esac - - module_build_dir="$WORKDIR/$module_dir${module_build_subdir:+/$module_build_subdir}" -} - -module_fetch() { - lsecho "Fetching ${module_varname}..." - - case "$module_fetch_rule" in - git) - if [ -z "$git_url" ]; then - echo "module_fetch: No URL set to fetch $1 via git." - exit 1 - fi - fetch_git "$git_url" "$module_dir" "$git_submodules" - ;; - - none) - # This module doesn't get fetched - ;; - - *) - secho "module_fetch: Unknown fetch rule for $module_varname: \"$module_fetch_rule\"." - return 1 - ;; - esac -} - -module_clean() { - if [ -z "$force" ] && ! can_build_module $1; then - lsecho "Skipping clean, $module_varname is disabled on ${platform}..." - return 0 - fi - - case "$module_build_rule" in - generic_makefile) - lsecho "Cleaning ${module_varname}..." - echo_cmd "cd \"$module_build_dir\"" - - make_cmdline="$MAKE" - if [ -n "$module_build_makefile" ]; then - make_cmdline="$make_cmdline -f $module_build_makefile" - fi - - # TODO: Do $platform type stuff better (requires modding each core) - make_cmdline="$make_cmdline platform=\"$module_build_platform\"" - - [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" - echo_cmd "$make_cmdline $module_build_args clean" - return $? - ;; - - legacy) - lsecho "Legacy rules cannot be cleaned separately, skipping..." - ;; - - none) - lsecho "No rule to clean ${module_varname}." - ;; - - *) ;; - esac -} - -module_compile() { - if [ -z "$force" ] && ! can_build_module $1; then - lsecho "Skipping compile, $module_varname is disabled on ${platform}..." - return 0 - fi - - case "$module_build_rule" in - generic_makefile) - lsecho "Compiling ${module_varname}..." - echo_cmd "cd \"$module_build_dir\"" - - make_cmdline="$MAKE" - if [ -n "$module_build_makefile" ]; then - make_cmdline="$make_cmdline -f $module_build_makefile" - fi - - # TODO: Do $platform type stuff better (requires modding each core) - make_cmdline="$make_cmdline platform=\"$module_build_platform\"" - - [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" - - # TODO: Do this better too (only affects a few cores) - if [ -n "$module_build_compiler" ]; then - make_cmdline="$make_cmdline $module_build_compiler" - else - make_cmdline="$make_cmdline ${CC:+CC="$CC"} ${CXX:+CXX="$CXX"}" - fi - - if [ -n "$module_build_makefile_targets" ]; then - for target in $module_build_makefile_targets; do - echo_cmd "$make_cmdline $module_build_args $target" - done - else - echo_cmd "$make_cmdline $module_build_args" - fi - if [ $? -gt 0 ]; then - build_fail="$build_fail$module_build_cores " - return 1 - fi - - modules_copied="" - for module in $module_build_cores; do - module_src="${module_build_products:+$module_build_products/}$module$CORE_SUFFIX" - module_dest="$module$CORE_SUFFIX" - if [ -f "$module_src" ]; then - build_success="$build_success$module " - echo_cmd "cp \"$module_src\" \"$RARCH_DIST_DIR/$module_dest\"" - modules_copied="$modules_copied $module_dest" - else - build_fail="$build_fail$module " - fi - done - return 0 - ;; - - legacy) - if [ -n "$module_build_legacy" ]; then - lsecho "Warning: $module_varname hasn't been ported to a modern build rule yet." - lsecho "Compiling $module_varname using legacy \"$module_build_legacy\"..." - $module_build_legacy - return $? - else - lsecho "module_compile: No legacy build rule for ${module_varname}." - return 1 - fi - ;; - - none) - lsecho "No rule to compile ${module_varname}." - ;; - - *) ;; - esac -} - -module_package() { - if [ -n "$modules_copied" ]; then - lsecho "Packaging ${module_varname}..." - cd "$RARCH_DIST_DIR" - # TODO: Packaging other than zip (deb, etc?) - for module in $modules_copied; do - zip -m9 "${module}.zip" $module - done - fi -} - -module_process() { - local module_changed - - if [[ "$libretro_modules" != *$1* ]]; then - secho "$(color 34)=== $(color 1)$1 $(color 31)not found$(color)" - lecho "=== $1 not found" - lsecho "" - return 1 - fi - if module_set_vars ${1%%:*}; then - secho "$(color 34)=== $(color 1)$module_name$(color)" - lecho "=== $module_name" - else - secho "$(color 34)=== $color 1)$1 $(color 31)rule error$(color)" - lecho "=== $1 rule error" - return 1 - fi - - log_module_start $module_varname - - module_revision_old="$(module_get_revision)" - if [[ "$actions" = *fetch* ]]; then - if ! module_fetch $1; then - log_module_stop "module_process: Unable to fetch ${module_varname}." - return 1 - fi - fi - module_revision="$(module_get_revision 1)" - if [ "0$skip_unchanged" -eq 1 ]; then - if [ "$module_revision_old" != "$module_revision" ]; then - module_changed=1 - else - module_changed="" - fi - else - module_changed=1 - fi - - if [[ -n "$module_changed" && "$actions" = *clean* ]]; then - if ! $module_preclean; then - log_module_stop "module_process: module_preclean for $module_varname failed." - return 1 - fi - if ! module_clean $1; then - log_module_stop "module_process: Unable to clean ${module_varname}." - return 1 - fi - fi - - if [[ -n "$module_changed" && "$actions" = *compile* ]]; then - if ! $module_configure; then - log_module_stop "module_process: module_configure for $module_varname failed." - return 1 - fi - if ! module_compile $1; then - log_module_stop "module_process: Unable to compile ${module_varname}." - return 1 - fi - fi - - if [[ -n "$module_changed" && "$actions" = *package* ]]; then - if ! $module_prepackage; then - log_module_stop "module_process: module_prepackage for $module_varname failed." - return 1 - fi - if ! module_package $1; then - log_module_stop "module_process: Unable to package ${module_varname}." - return 1 - fi - fi - - log_module_stop -} - ################################################################### # # DO STUFF diff --git a/script-modules/modules.sh b/script-modules/module_base.sh similarity index 100% rename from script-modules/modules.sh rename to script-modules/module_base.sh From bb67661a2edf99984d97cf127f602e2f227afe5f Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 26 Apr 2015 21:59:20 -0700 Subject: [PATCH 19/20] Comment out the new toolchain code for now It won't be able to be finished until I write the configurator. In the meantime, you should be able to pass platform and ARCH as with libretro-build.sh like so: platform=ios ./libretro-super.sh [args] That'll have to do for now. --- libretro-super.sh | 227 ++++++++++++++++++++++++++-------------------- 1 file changed, 127 insertions(+), 100 deletions(-) diff --git a/libretro-super.sh b/libretro-super.sh index e8640580..254ebd0c 100755 --- a/libretro-super.sh +++ b/libretro-super.sh @@ -17,56 +17,128 @@ else fi fi -################################################################### + +#################################################################### +## +## NEW TOOLCHAIN STUFF +## FIXME: This stuff is incomplete and won't quite work as I've done it here. +## Doing it right is going to depend on the config submodule which isn't +## written yet. Probably after 1.1... :/ +## +#################################################################### # -# NEW PLATFORM STUFF -# Move to rules files like cores are done +##register_toolchain osx x86 x86_64 +#toolchain_osx_CC="cc" +#toolchain_osx_CXX="c++" +#toolchain_osx_CXX11="clang++" +#toolchain_osx_CXX11_args="-std=c++11 -stdlib=libc++" +#toolchain_osx_x86_args=" -arch i386" +#toolchain_osx_x86_64_args=" -arch x86_64" +#toolchain_osx_platform="osx" # -################################################################### - -# TODO: implement register_toolchain - -#register_toolchain OSX x86 x86_64 -toolchain_OSX_CC="cc" -toolchain_OSX_CXX="c++" -toolchain_OSX_CXX11="clang++" -toolchain_OSX_CXX11_args="-std=c++11 -stdlib=libc++" -toolchain_OSX_x86_suffix=" -arch i386" -toolchain_OSX_x86_64_suffix=" -arch x86_64" -toolchain_OSX_platform="osx" - -#register_toolchain iOS armv7 # x86? -toolchain_iOS_CC="cc" -toolchain_iOS_CXX="c++" -toolchain_iOS_CXX11="clang++" -toolchain_iOS_CXX11_args="-std=c++11 -stdlib=libc++" -toolchain_iOS_armv7_suffix="-arch armv7 -marm -miphoneos-version-min=5.0 -isysroot \$IOSSDK" -toolchain_iOS_platform="ios" -toolchain_iOS_configure() { - if [ -z "$IOSSDK" ]; then - if [ -z "${xcodebuild:-$(find_tool xcodebuild)}" ]; then - lsecho "You must set IOSSDK or have xcodebuild in your path for iOS" - return 1 - fi - export IOSSDK=$(xcodebuild -version -sdk iphoneos Path) - fi - - if [ ! -d "$IOSSDK/usr" ]; then - lsecho "\"$IOSSDK\" does not appear to be a valid iOS SDK." - return 1 - fi -} - +##register_toolchain ios armv7 # x86? +#toolchain_ios_CC="cc" +#toolchain_ios_CXX="c++" +#toolchain_ios_CXX11="clang++" +#toolchain_ios_CXX11_args="-std=c++11 -stdlib=libc++" +#toolchain_ios_armv7_args="-arch armv7 -marm -miphoneos-version-min=5.0 -isysroot \$IOSSDK" +#toolchain_ios_platform="ios" +#toolchain_ios_configure() { +# if [ -z "$IOSSDK" ]; then +# if [ -z "${xcodebuild:-$(find_tool xcodebuild)}" ]; then +# lsecho "You must set IOSSDK or have xcodebuild in your path for ios" +# return 1 +# fi +# export IOSSDK=$(xcodebuild -version -sdk iphoneos Path) +# fi +# +# if [ ! -d "$IOSSDK/usr" ]; then +# lsecho "\"$IOSSDK\" does not appear to be a valid iOS SDK." +# return 1 +# fi +#} +# +#toolchain_guess() { +# if [ -z "${UNAME:+$(find_tool $LIBRETRO_UNAME uname)}" ]; then +# lsecho "toolchain_guess: cannot find the uname program to guess your platform" +# return 1 +# fi +# +# local cpu="$(uname -m)" +# case "$cpu" in +# x86_64) ;; +# i[3456]86) ;; +# armv4) ;; +# armv7) ;; +# esac +# +# local os="$(uname -s)" +# +# case "$(uname -s)" in +# # uname will find these +# +# *BSD*) os="bsd" ;; +# linux) os="linux" ;; +# *mingw*|*MINGW*|*MSYS_NT*) os="win" ;; +# +# Darwin) +# # TODO: This won't support iOS simulator, add something that will +# if [ "$cpu" = arm* ]; then +# os="ios" +# else +# os="osx" +# fi +# ;; +# +# # Consoles and mobile, uname won't usually report these +# android) os="android" ;; +# ios) os="ios" ;; +# ngc) os="ngc" ;; +# psp1) os="psp1" ;; +# wii) os="wii" ;; +# esac +#} +# +#toolchain_setup() { +# if [[ "$1" != *-* ]]; then +# lsecho "toolchain_setup: Invalid platform \"$1\"" +# return 1 +# fi +# local os="${1%%-*}" +# local cpu="${1#*-}" +# +# eval "local cpu_prefix=\"\$toolchain_${os}_${cpu}_prefix\"" +# eval "local cpu_suffix=\"\$toolchain_${os}_${cpu}_suffix\"" +# eval "local cpu_args=\"\$toolchain_${os}_${cpu}_args\"" +# toolchain_platform="$1" +# +# if [ "$(type -t toolchain_${os}_configure)" ]; then +# toolchain_configure=toolchatarget_in_${os}_configure +# else +# toolchain_configure=do_nothing +# fi +# +# for compiler in CC CXX CXX11; do +# eval "cmdline=\"\$toolchain_${os}_${cpu}_prefix\$toolchain_${os}_${compiler}\$toolchain_${os}_${cpu}_suffix\"" +# eval "compiler_args=\"\$toolchain_${os}_${compiler}_args\"" +# if command -v $cmdline > /dev/null; then +# eval "toolchain_$compiler=\"\$cmdline\${cpu_args:+ \$cpu_args}\${compiler_args:+ \$compiler_args}\"" +# else +# eval "toolchain_$compiler=\"\"" +# fi +# done +#} ################################################################### # -# LIBRETRO-CONFIG -# Replace with args, rules-based --platform selection, and config -# file to save user preferences +# OLD TOOLCHAIN STUFF (basically libretro-config.sh) +# For now, if you want to build for other than the detected default +# you're going to have to do it the old way. Something like this: # -# Config file generation will ultimately be something like Linux -# kernel menuconfig if you have dialog/whiptail, but those won't -# be required. +# platform= ARCH= ./libretro-super.sh +# +# This will be replaced by a rules-based solution (similar to how +# cores are handled, but not yet. # ################################################################### @@ -109,21 +181,6 @@ case "$platform" in CXX11="clang++ -std=c++11 -stdlib=libc++ -arch armv7 -marm -miphoneos-version-min=5.0 -isysroot $IOSSDK" ;; - theos_ios) - DIST_DIR="theos_ios" - BUILD_PRODUCT_PREFIX="objs/obj" - FORMAT_EXT=dylib - IOS=1 - ARCH=armv7 - FORMAT=_ios - FORMAT_COMPILER_TARGET=theos_ios - FORMAT_COMPILER_TARGET_ALT=theos_ios - - # Make sure that the cross bins you need are first in your path - CXX11="clang++ -std=c++11 -stdlib=libc++ -miphoneos-version-min=5.0" - - ;; - ## ## Original libretro-config path ## @@ -322,32 +379,11 @@ export RA_ANDROID_MIN_API=android-9 #OSX DEFINES #=========== -# Define this to skip the universal build -# export NOUNIVERSAL=1 - -# ARCHFLAGS is a very convenient way of doing this for simple/obvious cores -# that don't need anything defined on the command line for 32 vs 64 bit -# systems, however it won't work for anything that does. For that, you need -# to do two separate builds, one for each arch, and then do something like: -# lipo -create core_i386.dylib core_x86_64.dylib -output core_ub.dylib -# -# If building on 10.5/10.6, it's possible that you could actually build a UB -# for Intel/PowerPC, but please don't. ;) Consider this a proof of concept -# for now just to test a few cores. - -if [[ "$FORMAT_COMPILER_TARGET" = "osx" && -z "$NOUNIVERSAL" ]]; then - case "$ARCH" in - i386|x86_64) - export ARCHFLAGS="-arch i386 -arch x86_64" - ;; - ppc|ppc64) - export ARCHFLAGS="-arch ppc -arch ppc64" - ;; - *) - echo "Will not build universal binaries for unknown ARCH=\"$ARCH\"" - ;; - esac -fi +# [snip] +# Let's disable universal builds completely for now. We don't use it, the new +# toolchain code won't need it, and most of the cores don't currently support +# it anyway. We'll revisit this later. +export NOUNIVERSAL=1 # OUTPUT AND LOGGING # ================== @@ -420,7 +456,7 @@ fi # # LIBRETRO-BUILD-COMMON # Summary already re-written, CORE_SUFFIX def may be moved -# RARCH_DIST_DIR stuff will change with --platform +# RARCH_DIST_DIR stuff will change with new toolchain code # ################################################################### @@ -461,12 +497,9 @@ if [ -z "$RARCH_DIST_DIR" ]; then fi create_dist_dir -################################################################### -# -# LIBRETRO-BUILD-COMMON -# Default tool selection goes into --platform stuff -# -################################################################### + +# The following bits are from libretro-build.sh +# Will replace with new toolchain code later if [ -z "$JOBS" ]; then JOBS=7 @@ -621,15 +654,10 @@ if [ -n "$1" ]; then # - # Platform controls + # Toolchain controls # - --platform) - if [ -n "$2" ]; then - build_platforms="$build_platforms $2" - shift - fi - ;; + # TODO, requires configuration system # # Module type controls @@ -673,7 +701,6 @@ letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA." exit 0 fi lsecho "Licensed under CC-BY-4.0 (--license for details)" -# XXX: MIT vs CC-BY vs CC-0? # Configure some defaults [ -z "$actions" ] && actions="$default_actions" From a2953f33750de7b7df1c206d221f1dbad2a78003 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sun, 26 Apr 2015 22:07:47 -0700 Subject: [PATCH 20/20] Forgot a file --- script-modules/module_process.sh | 301 +++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 script-modules/module_process.sh diff --git a/script-modules/module_process.sh b/script-modules/module_process.sh new file mode 100644 index 00000000..8832a461 --- /dev/null +++ b/script-modules/module_process.sh @@ -0,0 +1,301 @@ +# vim: set ts=3 sw=3 noet ft=sh : bash + +################################################################### +# +# MODULE PROCESSING +# +################################################################### + + +# All of the module_* vars are set here before calling any other module +# processing actions +module_set_vars() { + module_varname="$1" + eval "module_name=\${libretro_${1}_name:-$1}" + eval "module_dir=\${libretro_${1}_dir:-libretro-$1}" + + for func in configure preclean prepackage; do + if [ "$(type -t libretro_${1}_$func 2> /dev/null)" = "function" ]; then + eval "module_$func=libretro_${1}_$func" + else + eval "module_$func=do_nothing" + fi + done + + eval "module_fetch_rule=\${libretro_${1}_fetch_rule:-git}" + case "$module_fetch_rule" in + git) + eval "git_url=\$libretro_${1}_git_url" + eval "git_submodules=\$libretro_${1}_git_submodules" + ;; + + none) ;; + + *) + echo "Unknown fetch rule for $1: \"$module_fetch_rule\"." + ;; + esac + + eval "module_build_rule=\${libretro_${1}_build_rule:-generic_makefile}" + + # TODO: Do OpenGL better + eval "module_build_opengl=\$libretro_${1}_build_opengl" + module_opengl_type="" + if [ -n "$module_build_opengl" ]; then + if [ -n "$ENABLE_GLES" ]; then + module_opengl_type="-gles" + else + module_opengl_type="-opengl" + fi + fi + + module_build_subdir="" + case "$module_build_rule" in + generic_makefile) + eval "module_build_makefile=\$libretro_${1}_build_makefile" + eval "module_build_subdir=\$libretro_${1}_build_subdir" + eval "module_build_makefile_targets=\"\$libretro_${1}_build_makefile_targets\"" + eval "module_build_args=\$libretro_${1}_build_args" + + # TODO: change how $platform is done + eval "module_build_platform=\${libretro_${1}_build_platform:-$FORMAT_COMPILER_TARGET}$opengl_type" + + eval "module_build_cores=\${libretro_${1}_build_cores:-$1}" + eval "module_build_products=\$libretro_${1}_build_products" + + # TODO: this too... + eval "module_build_compiler=\$libretro_${1}_build_compiler" + ;; + + legacy) + eval "module_build_legacy=\$libretro_${1}_build_legacy" + ;; + + none) ;; + + *) + echo "Unknown build rule for $1: \"$module_build_rule\"." + ;; + esac + + module_build_dir="$WORKDIR/$module_dir${module_build_subdir:+/$module_build_subdir}" +} + +module_fetch() { + lsecho "Fetching ${module_varname}..." + + case "$module_fetch_rule" in + git) + if [ -z "$git_url" ]; then + echo "module_fetch: No URL set to fetch $1 via git." + exit 1 + fi + fetch_git "$git_url" "$module_dir" "$git_submodules" + ;; + + none) + # This module doesn't get fetched + ;; + + *) + secho "module_fetch: Unknown fetch rule for $module_varname: \"$module_fetch_rule\"." + return 1 + ;; + esac +} + +module_clean() { + if [ -z "$force" ] && ! can_build_module $1; then + lsecho "Skipping clean, $module_varname is disabled on ${platform}..." + return 0 + fi + + case "$module_build_rule" in + generic_makefile) + lsecho "Cleaning ${module_varname}..." + echo_cmd "cd \"$module_build_dir\"" + + make_cmdline="$MAKE" + if [ -n "$module_build_makefile" ]; then + make_cmdline="$make_cmdline -f $module_build_makefile" + fi + + # TODO: Do $platform type stuff better (requires modding each core) + make_cmdline="$make_cmdline platform=\"$module_build_platform\"" + + [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" + echo_cmd "$make_cmdline $module_build_args clean" + return $? + ;; + + legacy) + lsecho "Legacy rules cannot be cleaned separately, skipping..." + ;; + + none) + lsecho "No rule to clean ${module_varname}." + ;; + + *) ;; + esac +} + +module_compile() { + if [ -z "$force" ] && ! can_build_module $1; then + lsecho "Skipping compile, $module_varname is disabled on ${platform}..." + return 0 + fi + + case "$module_build_rule" in + generic_makefile) + lsecho "Compiling ${module_varname}..." + echo_cmd "cd \"$module_build_dir\"" + + make_cmdline="$MAKE" + if [ -n "$module_build_makefile" ]; then + make_cmdline="$make_cmdline -f $module_build_makefile" + fi + + # TODO: Do $platform type stuff better (requires modding each core) + make_cmdline="$make_cmdline platform=\"$module_build_platform\"" + + [ -n "$JOBS" ] && make_cmdline="$make_cmdline -j$JOBS" + + # TODO: Do this better too (only affects a few cores) + if [ -n "$module_build_compiler" ]; then + make_cmdline="$make_cmdline $module_build_compiler" + else + make_cmdline="$make_cmdline ${CC:+CC=\"$CC\"} ${CXX:+CXX=\"$CXX\"}" + fi + + if [ -n "$module_build_makefile_targets" ]; then + for target in $module_build_makefile_targets; do + echo_cmd "$make_cmdline $module_build_args $target" + done + else + echo_cmd "$make_cmdline $module_build_args" + fi + if [ $? -gt 0 ]; then + build_fail="$build_fail$module_build_cores " + return 1 + fi + + modules_copied="" + for module in $module_build_cores; do + module_src="${module_build_products:+$module_build_products/}$module$CORE_SUFFIX" + module_dest="$module$CORE_SUFFIX" + if [ -f "$module_src" ]; then + build_success="$build_success$module " + echo_cmd "cp \"$module_src\" \"$RARCH_DIST_DIR/$module_dest\"" + modules_copied="$modules_copied $module_dest" + else + build_fail="$build_fail$module " + fi + done + return 0 + ;; + + legacy) + if [ -n "$module_build_legacy" ]; then + lsecho "Warning: $module_varname hasn't been ported to a modern build rule yet." + lsecho "Compiling $module_varname using legacy \"$module_build_legacy\"..." + $module_build_legacy + return $? + else + lsecho "module_compile: No legacy build rule for ${module_varname}." + return 1 + fi + ;; + + none) + lsecho "No rule to compile ${module_varname}." + ;; + + *) ;; + esac +} + +module_package() { + if [ -n "$modules_copied" ]; then + lsecho "Packaging ${module_varname}..." + cd "$RARCH_DIST_DIR" + # TODO: Packaging other than zip (deb, etc?) + for module in $modules_copied; do + zip -m9 "${module}.zip" $module + done + fi +} + +module_process() { + local module_changed + + if [[ "$libretro_modules" != *$1* ]]; then + secho "$(color 34)=== $(color 1)$1 $(color 31)not found$(color)" + lecho "=== $1 not found" + lsecho "" + return 1 + fi + if module_set_vars ${1%%:*}; then + secho "$(color 34)=== $(color 1)$module_name$(color)" + lecho "=== $module_name" + else + secho "$(color 34)=== $color 1)$1 $(color 31)rule error$(color)" + lecho "=== $1 rule error" + return 1 + fi + + log_module_start $module_varname + + module_revision_old="$(module_get_revision)" + if [[ "$actions" = *fetch* ]]; then + if ! module_fetch $1; then + log_module_stop "module_process: Unable to fetch ${module_varname}." + return 1 + fi + fi + module_revision="$(module_get_revision 1)" + if [ "0$skip_unchanged" -eq 1 ]; then + if [ "$module_revision_old" != "$module_revision" ]; then + module_changed=1 + else + module_changed="" + fi + else + module_changed=1 + fi + + if [[ -n "$module_changed" && "$actions" = *clean* ]]; then + if ! $module_preclean; then + log_module_stop "module_process: module_preclean for $module_varname failed." + return 1 + fi + if ! module_clean $1; then + log_module_stop "module_process: Unable to clean ${module_varname}." + return 1 + fi + fi + + if [[ -n "$module_changed" && "$actions" = *compile* ]]; then + if ! $module_configure; then + log_module_stop "module_process: module_configure for $module_varname failed." + return 1 + fi + if ! module_compile $1; then + log_module_stop "module_process: Unable to compile ${module_varname}." + return 1 + fi + fi + + if [[ -n "$module_changed" && "$actions" = *package* ]]; then + if ! $module_prepackage; then + log_module_stop "module_process: module_prepackage for $module_varname failed." + return 1 + fi + if ! module_package $1; then + log_module_stop "module_process: Unable to package ${module_varname}." + return 1 + fi + fi + + log_module_stop +}