Add reference to .j too in a group called Sources

This commit is contained in:
Antoine Mercadal
2012-08-08 22:35:35 -07:00
parent 6a2d7bd2df
commit 4e13f3f2fd
3 changed files with 42 additions and 42 deletions
-1
View File
@@ -42,7 +42,6 @@ extern NSString * const XCCListeningStartNotification;
NSString *profilePath;
NSString *PBXModifierScriptPath;
NSURL *currentProjectURL;
NSURL *XCodeSupportFolder;
NSURL *XCodeSupportProject;
NSURL *XCodeSupportProjectSources;
PRHEmptyGrowlDelegate *growlDelegateRef;
+16 -10
View File
@@ -349,11 +349,13 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
@"",nil];
PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ add '%@' '%@') 2>&1",
[NSString stringWithFormat:@"(%@; python %@ add '%@' '%@' '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];
shadowPath,
fullPath,
[currentProjectURL path]],nil];
successTitle = @"Objective-J source processed";
successMsg = splitPath;
@@ -420,11 +422,13 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
NSString *shadowPath = [[self shadowURLForSourceURL:[NSURL URLWithString:[fullPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] path];
NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@' '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowPath],nil];
shadowPath,
fullPath,
[currentProjectURL path]],nil];
DLog(@"Removing shadow file: %@", shadowPath);
[fm removeItemAtPath:shadowPath error:nil];
@@ -484,14 +488,14 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
{
XCodeSupportProjectName = [NSString stringWithFormat:@"%@.xcodeproj/", currentProjectName];
XCodeTemplatePBXPath = [[NSBundle mainBundle] pathForResource:@"project.pbxproj" ofType:@"sample"];
XCodeSupportFolder = currentProjectURL;
XCodeSupportProject = [NSURL URLWithString:XCodeSupportProjectName relativeToURL:XCodeSupportFolder];
XCodeSupportProjectSources = [NSURL URLWithString:@".XcodeSupport/" relativeToURL:XCodeSupportFolder];
XCodeSupportProject = [NSURL URLWithString:XCodeSupportProjectName relativeToURL:currentProjectURL];
XCodeSupportProjectSources = [NSURL URLWithString:@".XcodeSupport/" relativeToURL:currentProjectURL];
XCodeSupportPBXPath = [NSString stringWithFormat:@"%@/project.pbxproj", [XCodeSupportProject path]];
PBXModifierScriptPath = [[NSBundle mainBundle] pathForResource:@"pbxprojModifier" ofType:@"py"];
//[fm removeItemAtURL:XCodeSupportFolder error:nil];
//[fm removeItemAtURL:XCodeSupportProjectSources error:nil];
//[fm removeItemAtURL:XCodeSupportProject error:nil];
// create the template project if it doesn't exist
if (![fm fileExistsAtPath:[XCodeSupportProjectSources path]])
@@ -748,11 +752,13 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification
[fm removeItemAtPath:shadowFullPath error:nil];
NSArray *PBXArguments = [NSArray arrayWithObjects: @"-c",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@') 2>&1",
[NSString stringWithFormat:@"(%@; python %@ remove '%@' '%@' '%@' '%@') 2>&1",
profilePath,
PBXModifierScriptPath,
XCodeSupportPBXPath,
shadowFullPath],nil];
shadowFullPath,
unshadowed,
[currentProjectURL path]],nil];
DLog(@"Cleaning PBX reference task...");
NSArray *statusInfo = [self runTask:PBXArguments];
+26 -31
View File
@@ -1,47 +1,42 @@
import sys, os
from mod_pbxproj import XcodeProject
XCODESUPPORTFOLDER = ".XcodeSupport"
def add_file(PBXProjectFilePath, path):
def add_file(project, shadowGroup, sourceGroup, shadowPath, sourcePath, projectBaseURL):
project.add_file(shadowPath, parent=shadowGroup)
project.add_file(sourcePath, parent=sourceGroup)
project.save()
project = XcodeProject.Load(PBXProjectFilePath)
shadowGroup = project.get_or_create_group('Shadows')
files = project.get_files_by_os_path("XcodeSupport/%s" % os.path.basename(path))
if "main.m" in path:
sys.exit(0)
if len(files) == 0:
project.add_file(path, parent=shadowGroup)
project.save()
def remove_file(PBXProjectFilePath, path):
project = XcodeProject.Load(PBXProjectFilePath)
shadowGroup = project.get_or_create_group('Shadows')
files = project.get_files_by_os_path("XcodeSupport/%s" % os.path.basename(path))
if "main.m" in path:
sys.exit(0)
if len(files) == 1:
project.remove_file("XcodeSupport/%s" % os.path.basename(path), parent=shadowGroup)
project.save()
def remove_file(project, shadowGroup, sourceGroup, shadowPath, sourcePath, projectBaseURL):
project.remove_file("%s/%s" % (XCODESUPPORTFOLDER, os.path.basename(shadowPath)), parent=shadowGroup)
project.remove_file(os.path.relpath(sourcePath, projectBaseURL), parent=sourceGroup)
project.save()
if __name__ == '__main__':
action = sys.argv[1]
PBXProjectFilePath = sys.argv[2]
currentFilePath = sys.argv[3]
shadowFilePath = sys.argv[3]
sourceFilePath = sys.argv[4]
projectBaseURL = sys.argv[5]
if action == "add":
add_file(PBXProjectFilePath, currentFilePath)
elif action == "remove":
remove_file(PBXProjectFilePath, currentFilePath)
project = XcodeProject.Load(PBXProjectFilePath)
shadowGroup = project.get_or_create_group('Shadows')
sourceGroup = project.get_or_create_group('Sources')
if "main.m" in shadowFilePath:
sys.exit(0)
files = project.get_files_by_os_path("%s/%s" % (XCODESUPPORTFOLDER, os.path.basename(shadowFilePath)))
if action == "add" and len(files) == 0:
add_file(project, shadowGroup, sourceGroup, shadowFilePath, sourceFilePath, projectBaseURL)
elif action == "remove" and len(files) == 1:
remove_file(project, shadowGroup, sourceGroup, shadowFilePath, sourceFilePath, projectBaseURL)