aboutsummaryrefslogtreecommitdiff
path: root/XcodePlugin/GTMXcodeMenuItem.m
diff options
context:
space:
mode:
Diffstat (limited to 'XcodePlugin/GTMXcodeMenuItem.m')
-rw-r--r--XcodePlugin/GTMXcodeMenuItem.m21
1 files changed, 21 insertions, 0 deletions
diff --git a/XcodePlugin/GTMXcodeMenuItem.m b/XcodePlugin/GTMXcodeMenuItem.m
index b94ed98..701a00a 100644
--- a/XcodePlugin/GTMXcodeMenuItem.m
+++ b/XcodePlugin/GTMXcodeMenuItem.m
@@ -19,9 +19,13 @@
#import "GTMXcodeMenuItem.h"
#import "GTMNSEnumerator+Filter.h"
#import "PBXAppDelegate.h"
+#import "PBXProject.h"
+#import "PBXTarget.h"
#import "GTMMethodCheck.h"
#import "GTMDefines.h"
+static NSString *const kGTMSrcRootPath = @"$(SRCROOT)/";
+
@interface GTMXcodeMenuItem (GTMXcodeMenuItemPrivate)
// Used to figure out what order to install menu items
- (NSComparisonResult)compareDepth:(id<GTMXcodeMenuItemProtocol>)item;
@@ -117,4 +121,21 @@ GTM_METHOD_CHECK(NSEnumerator, gtm_enumeratorByMakingEachObjectPerformSelector:w
return YES;
}
+// Expand |path| based on |target| and |configuration|.
+// If newPath is not absolute, expand kSrcRootPath and prepend it to newPath.
+- (NSString *)pathByExpandingString:(NSString *)path
+ forBuildConfiguration:(NSString *)configuration
+ ofTarget:(PBXTarget *)target {
+ NSString *newPath = [target stringByExpandingString:path
+ forBuildConfigurationNamed:configuration];
+ if (![newPath hasPrefix:@"/"]) {
+ NSString *srcRoot = [target stringByExpandingString:kGTMSrcRootPath
+ forBuildConfigurationNamed:configuration];
+ if (srcRoot) {
+ newPath = [srcRoot stringByAppendingString:newPath];
+ }
+ }
+ return newPath;
+}
+
@end