From d5df35a3e51028bfa6a37c12be2fc5b6792b0000 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Thu, 22 Sep 2016 17:01:14 +0200 Subject: [osx] - make GetHomePath more intelligent - it should finde the KODI_HOME dir now even when no env var is set via xcode --- xbmc/Util.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 9fb278691e..3c26df3012 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -196,6 +196,12 @@ std::string GetHomePath(const std::string& strTarget, std::string strPath) } #endif #if defined(TARGET_DARWIN) +bool IsDirectoryValidRoot(std::string path) +{ + path += "/system/settings/settings.xml"; + return CFile::Exists(path); +} + std::string GetHomePath(const std::string& strTarget, std::string strPath) { if (strPath.empty()) @@ -219,6 +225,26 @@ std::string GetHomePath(const std::string& strTarget, std::string strPath) strcat(given_path, "../Resources/"); strcat(given_path, CCompileInfo::GetAppName()); strcat(given_path, "/"); + + // if this path doesn't exist we + // might not be started from the app bundle + // but from the debugger/xcode. Lets + // see if this assumption is valid + if (!CDirectory::Exists(given_path)) + { + std::string given_path_stdstr = given_path; + // try to find the correct folder by going back + // in the executable path until settings.xml was found + bool validRoot = false; + do + { + given_path_stdstr = URIUtils::GetParentPath(given_path_stdstr); + validRoot = IsDirectoryValidRoot(given_path_stdstr); + } + while(given_path_stdstr.length() > 0 && !validRoot); + strncpy(given_path, given_path_stdstr.c_str(), sizeof(given_path)-1); + } + #endif // Convert to real path. -- cgit v1.2.3 From fbc59139074ac7ce1c2f6730f914b661138044c2 Mon Sep 17 00:00:00 2001 From: Memphiz Date: Thu, 22 Sep 2016 17:03:34 +0200 Subject: [osx/readme] - remove KODI_HOME bits from readme (not needed anymore) --- docs/README.osx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/docs/README.osx b/docs/README.osx index a4239f041f..76bc84c62e 100644 --- a/docs/README.osx +++ b/docs/README.osx @@ -136,14 +136,6 @@ binaries from git that might cause problems. 4.1 Using Xcode ----------------------------------------------------------------------------- Start XCode and open the Kodi project (Kodi.xcodeproj) located in $HOME/Kodi. -For development, Kodi is run from the $HOME/Kodi directory and needs to have -the KODI_HOME environment variable set to know where that directory is located. -To set KODI_HOME environment variable: - -Xcode 6 and later - Menu -> Product -> Edit Sheme -> "Run Kodi"/"Debug" -> Add KODI_HOME into - the List of "Environment Variables". Set the value to the path to the Kodi - root folder. For example, "/Users/bigdog/Documents/Kodi" There are two build targets "Kodi" and "Kodi.app" (each in 32Bit and 64Bit flavour) with debug and release settings. The "Kodi" target is used for rapid build and @@ -163,9 +155,8 @@ and dynamic libraries that will need to be built. Once these are built, subsequent builds will be faster. After the build, you can ether run Kodi for Mac from Xcode or run it from -the command-line. If you run it from the command-line, make sure your set -the KODI_HOME environment variable (export KODI_HOME=$HOME/Kodi). Then, to -run the debug version: +the command-line. +To run the debug version: $ ./build/Debug/Kodi @@ -193,14 +184,12 @@ below(normally unneeded - for advanced developers). a) $ cd $HOME/Kodi - $ export KODI_HOME=`pwd` $ make xcode_depends $ xcodebuild -sdk macosx10.9 -project Kodi.xcodeproj -target Kodi.app ONLY_ACTIVE_ARCH=YES \ ARCHS=x86_64 VALID_ARCHS=x86_64 -configuration Release build b) Building via make: $ cd $HOME/Kodi - $ export KODI_HOME=`pwd` $ make $ ./Kodi.bin -- cgit v1.2.3