summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Sutton <al@funkyandroid.com>2014-11-19 19:50:48 +0000
committerJean-Michel Trivi <jmtrivi@google.com>2015-01-14 09:32:36 -0800
commit017c97a5b1a55d402da1a793c91fc37f11b05747 (patch)
tree2349f325f81451641a75b859cf201119f2446bec
parentf2bd3fdd190fc1234913febfe254f8bcc4e675da (diff)
downloadcore-017c97a5b1a55d402da1a793c91fc37f11b05747.tar.gz
Fix building on modern versions of Xcode and OS X.
Recent versions of XCode fail to compile the adb and fastboot binaries due to two functions being deprecated in 10.9 (GetCurrentProcess and ProcessInformationCopyDictionary), and the use of -Werrror. This patch replaces the method implementations which use calls to methods deprecated in the 10.9 SDK with versions which only call non-deprecated methods. (cherry picked from commit f456d47c506d87265ce0ff6080cba5374dced011) Change-Id: Ibd80dda73ccdd7c561b50b4065581e645d9855d6
-rw-r--r--adb/get_my_path_darwin.c14
-rw-r--r--fastboot/util_osx.c17
2 files changed, 16 insertions, 15 deletions
diff --git a/adb/get_my_path_darwin.c b/adb/get_my_path_darwin.c
index 5b95d1534..9141b5799 100644
--- a/adb/get_my_path_darwin.c
+++ b/adb/get_my_path_darwin.c
@@ -19,12 +19,12 @@
void get_my_path(char *s, size_t maxLen)
{
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- CFDictionaryRef dict;
- dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
- CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
- CFSTR("CFBundleExecutable"));
- CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8);
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
+ CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
+ CFRelease(bundleURL);
+
+ CFStringGetCString(bundlePathString, s, maxLen, kCFStringEncodingASCII);
+ CFRelease(bundlePathString);
}
diff --git a/fastboot/util_osx.c b/fastboot/util_osx.c
index 26b832a35..e80a8f356 100644
--- a/fastboot/util_osx.c
+++ b/fastboot/util_osx.c
@@ -31,14 +31,15 @@
void get_my_path(char s[PATH_MAX])
{
- char *x;
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- CFDictionaryRef dict;
- dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
- CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
- CFSTR("CFBundleExecutable"));
- CFStringGetCString(value, s, PATH_MAX - 1, kCFStringEncodingUTF8);
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
+ CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
+ CFRelease(bundleURL);
+
+ CFStringGetCString(bundlePathString, s, PATH_MAX - 1, kCFStringEncodingASCII);
+ CFRelease(bundlePathString);
+
+ char *x;
x = strrchr(s, '/');
if(x) x[1] = 0;
}