From cb0f3d844fea65fb55c701e283a548ffcec73cea Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sat, 14 Mar 2015 19:40:41 -0700 Subject: [PATCH 1/4] Make cg2glsl.py fail gracefully if python is too old --- tools/cg2glsl.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/cg2glsl.py b/tools/cg2glsl.py index 1db1a47c39..8f81bfbb6b 100755 --- a/tools/cg2glsl.py +++ b/tools/cg2glsl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python """ Python 3 script which converts simple RetroArch Cg shaders to modern GLSL (ES) format. @@ -7,6 +7,10 @@ License: Public domain """ import sys +if sys.version_info<(3,0,0): + sys.stderr.write("You need python 3.0 or later to run this script\n") + exit(1) + import os import errno import subprocess From 28740e969d97ba1efd8b4c8998fa790b70f0fb06 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sat, 14 Mar 2015 19:54:54 -0700 Subject: [PATCH 2/4] Some improvements to fetch-submodules.sh I thought I committed weeks ago --- fetch-submodules.sh | 71 ++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/fetch-submodules.sh b/fetch-submodules.sh index 6a4e378870..3cb3f53eed 100755 --- a/fetch-submodules.sh +++ b/fetch-submodules.sh @@ -1,58 +1,77 @@ #! /usr/bin/env bash # vim: set ts=3 sw=3 noet ft=sh : bash +# TODO: This entire script _should_ be replaced with git submodules, but +# that cannot be done until we sort out the limitations of that option. At +# this time, this script is called by libretro-super. Revisit the whole +# issue at some point. + SCRIPT="${0#./}" BASE_DIR="${SCRIPT%/*}" -WORKDIR=$(pwd) +WORKDIR="$PWD" if [ "$BASE_DIR" = "$SCRIPT" ]; then BASE_DIR="$WORKDIR" else - BASE_DIR="$WORKDIR/$BASE_DIR" + if [[ "$0" != /* ]]; then + # Make the path absolute + BASE_DIR="$WORKDIR/$BASE_DIR" + fi fi -WORKDIR=$(pwd) +# Inserted here is libretro-super's script-modules/fetch-rules.sh, with a +# couple of features related to core submodules removed from fetch_git. If +# that file is changed, it should be safe to import it verbatim. +### START OF FETCH-RULES.SH (with mods) -# A stripped-down version of the fetch_git rule from libretro-super -# Clones or pulls updates from a git repository into a local directory +# fetch_git: Clones or pulls updates from a git repository into a local directory # # $1 The URI to fetch # $2 The local directory to fetch to (relative) +# +# NOTE: git _now_ has a -C argument that would replace the cd commands in +# this rule, but this is a fairly recent addition to git, so we can't +# use it here. --iKarith fetch_git() { fetch_dir="$WORKDIR/$2" if [ -d "$fetch_dir/.git" ]; then echo "cd \"$fetch_dir\"" cd "$fetch_dir" - echo git pull + echo "git pull" git pull else - echo "git clone \"$1\" \"$fetch_dir\"" - git clone "$1" "$fetch_dir" + clone_type= + [ -n "$SHALLOW_CLONE" ] && depth="--depth 1" + echo "git clone $depth \"$1\" \"$WORKDIR/$2\"" + git clone $depth "$1" "$WORKDIR/$2" fi } +# fetch_revision_git: Output the hash of the last commit in a git repository +# +# $1 Local directory to run git in +fetch_revision_git() { + [ -n "$1" ] && cd "$1" + git log -n 1 --pretty=format:%H +} + + +# fetch_revision: Output SCM-dependent revision string of a module +# (currently just calls fetch_revision_git) +# +# $1 The directory of the module +fetch_revision() { + fetch_revision_git $1 +} + + +### END OF FETCH-RULES.SH + + echo "Fetching RetroArch's submodules..." fetch_git "https://github.com/libretro/common-shaders.git" "media/shaders_cg" fetch_git "https://github.com/libretro/common-overlays.git" "media/overlays" fetch_git "https://github.com/libretro/retroarch-assets.git" "media/assets" fetch_git "https://github.com/libretro/retroarch-joypad-autoconfig.git" "media/autoconfig" fetch_git "https://github.com/libretro/libretro-database.git" "media/libretrodb" - -# FIXME: This entire script should be unnecessary. It exists because we don't -# use git submodules in libretro/RetroArch, which introduces one of three -# possible build dependencies: -# -# 1. The user is using libretro-super. But libretro-super is not supposed to -# be required because "no dependencies!" -# -# 2. Unreasonable expectations of the user: That they are deeply versed in the -# changing inner workings of a massively-multi-platform project with dozens -# of modules and submodules, or that they are somehow psychic. -# -# 3. The user has a script which cannot depend on libretro-super to fetch the -# submodules for them. This is it. -# -# The third choice is the path of least resistance, but the correct solution -# is to fix the submodules issue. - From f40209c659cfdd2ec3ca11c4ae9ebb5c5ac77b32 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sat, 14 Mar 2015 19:56:36 -0700 Subject: [PATCH 3/4] Try to build shaders for iOS --- .../iOS/RetroArch_iOS.xcodeproj/project.pbxproj | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index 727e96a634..6b84ce12a3 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -235,6 +235,7 @@ buildPhases = ( 96AFAE2116C1D4EA009DE44C /* Sources */, 96AFAE2216C1D4EA009DE44C /* Frameworks */, + 84FD66AC1AB520100074AC3A /* ShellScript */, 96AFAE2316C1D4EA009DE44C /* Resources */, ); buildRules = ( @@ -298,6 +299,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 84FD66AC1AB520100074AC3A /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "for a in python3.4 python3.3 python3.2 python3.1 python3 python; do\n if command -v $a > /dev/null; then\n PYTHON3=$a make -f Makefile.griffin shaders-convert-glsl\n break\n fi\ndone"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 96AFAE2116C1D4EA009DE44C /* Sources */ = { isa = PBXSourcesBuildPhase; From 4d89fedb07f7a6087b972a6d9fa8f90303c37f65 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Sat, 14 Mar 2015 20:19:52 -0700 Subject: [PATCH 4/4] iOS: Fix Xcode GLSL shader script & copy shaders to bundle --- apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index 6b84ce12a3..2c602bb70d 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 84F9A9C51A87E1D0003AF12F /* cursors in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A9C41A87E1D0003AF12F /* cursors */; }; 84F9A9C71A87E1E8003AF12F /* rdb in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A9C61A87E1E8003AF12F /* rdb */; }; 84F9A9C81A87E250003AF12F /* cht in Resources */ = {isa = PBXBuildFile; fileRef = 84F9A9C11A87E180003AF12F /* cht */; }; + 84FD66AE1AB530B20074AC3A /* shaders_glsl in Resources */ = {isa = PBXBuildFile; fileRef = 84FD66AD1AB530B20074AC3A /* shaders_glsl */; }; 96366C5516C9AC3300D64A22 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5416C9AC3300D64A22 /* CoreAudio.framework */; }; 96366C5916C9ACF500D64A22 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5816C9ACF500D64A22 /* AudioToolbox.framework */; }; 967894631788EBD800D6CA69 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 967894611788EBD800D6CA69 /* InfoPlist.strings */; }; @@ -61,6 +62,7 @@ 84F9A9C11A87E180003AF12F /* cht */ = {isa = PBXFileReference; lastKnownFileType = folder; name = cht; path = ../../../media/libretrodb/cht; sourceTree = ""; }; 84F9A9C41A87E1D0003AF12F /* cursors */ = {isa = PBXFileReference; lastKnownFileType = folder; name = cursors; path = ../../../media/libretrodb/cursors; sourceTree = ""; }; 84F9A9C61A87E1E8003AF12F /* rdb */ = {isa = PBXFileReference; lastKnownFileType = folder; name = rdb; path = ../../../media/libretrodb/rdb; sourceTree = ""; }; + 84FD66AD1AB530B20074AC3A /* shaders_glsl */ = {isa = PBXFileReference; lastKnownFileType = folder; name = shaders_glsl; path = ../../../media/shaders_glsl; sourceTree = ""; }; 96366C5416C9AC3300D64A22 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; }; 96366C5816C9ACF500D64A22 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 963C3C33186E3DED00A6EB1E /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; @@ -104,6 +106,7 @@ 83D632D719ECFCC4009E3161 /* Assets */ = { isa = PBXGroup; children = ( + 84FD66AD1AB530B20074AC3A /* shaders_glsl */, 84F9A9C31A87E1AA003AF12F /* Database */, 83EB675F19EEAF050096F441 /* modules */, 84F9A9BB1A87E068003AF12F /* assets */, @@ -283,6 +286,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 84FD66AE1AB530B20074AC3A /* shaders_glsl in Resources */, 83D632E219ECFCC4009E3161 /* ic_pause.png in Resources */, 967894631788EBD800D6CA69 /* InfoPlist.strings in Resources */, 69D31DE41A547EC800EF4C92 /* Media.xcassets in Resources */, @@ -311,7 +315,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "for a in python3.4 python3.3 python3.2 python3.1 python3 python; do\n if command -v $a > /dev/null; then\n PYTHON3=$a make -f Makefile.griffin shaders-convert-glsl\n break\n fi\ndone"; + shellScript = "cd ../..\n\necho \"=== GLSL shaders\"\nmkdir -p \"media/shaders_glsl\"\nfor a in \"python3.4\" \"python3.3\" \"python3.2\" \"python3.1\" \"python3\" \"python\"; do\n echo -n \"Checking for $a... \"\n if command -v $a > /dev/null; then\n echo \"yes.\"\n make -f Makefile.griffin PYTHON3=$a shaders-convert-glsl\n break\n else\n echo \"no.\"\n fi\ndone"; }; /* End PBXShellScriptBuildPhase section */