From e70e0e700457943a8d5b5cf73cb162d7aebe14cb Mon Sep 17 00:00:00 2001 From: Sergii Stoian Date: Mon, 5 May 2003 14:40:11 +0000 Subject: [PATCH] add pcproj_bundle.make git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@16637 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 21 +++++++ GNUmakefile | 4 +- PCAppProj/GNUmakefile | 4 +- PCBaseFileTypes/GNUmakefile | 4 +- PCBundleProj/GNUmakefile | 3 +- PCGormProj/GNUmakefile | 4 +- PCLib/PCBundleLoader.h | 5 +- PCLib/PCBundleLoader.m | 101 ++++++++++++++++++---------------- PCLibProj/GNUmakefile | 3 +- PCRenaissanceProj/GNUmakefile | 3 +- PCToolProj/GNUmakefile | 3 +- pcproj_bundle.make | 2 + 12 files changed, 90 insertions(+), 67 deletions(-) create mode 100644 pcproj_bundle.make diff --git a/ChangeLog b/ChangeLog index 61daeb9..8efffcf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2003-05-05 Serg Stoyan + + * GNUmakefile: Place ProjectCenter subproject after PCLib. + * pcproj_bundle.make: Added. + + * PCAppProj/GNUmakefile: Added include pcproj_bundle.make. + * PCBaseFileTypes/GNUmakefile: Ditto. + * PCBundleProj/GNUmakefile: Ditto. + * PCGormProj/GNUmakefile: Ditto. + * PCLibProj/GNUmakefile: Ditto. + * PCRenaissanceProj/GNUmakefile: Ditto. + * PCToolProj/GNUmakefile: Ditto. + + * PCLib/PCBundleLoader.h: + (loadBundlesAtPath:): Added. + * PCLib/PCBundleLoader.m: + (loadBundles): First load bundles from main bundle's resource + directory, then load third party bundles from directory + Library/ApplicationSupport/ProjectCenter. + (loadBundlesAtPath:): Added. Loads bundles from specified directory. + 2003-05-02 Serg Stoyan * PCLib/PCProjectBuilder.h: diff --git a/GNUmakefile b/GNUmakefile index ca27936..392f980 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -35,14 +35,14 @@ PACKAGE_NAME = ProjectCenter SUBPROJECTS = \ PCLib \ + ProjectCenter \ PCAppProj \ PCGormProj \ PCBundleProj \ PCToolProj \ PCLibProj \ PCBaseFileTypes \ - PCRenaissanceProj \ - ProjectCenter + PCRenaissanceProj -include GNUMakefile.preamble diff --git a/PCAppProj/GNUmakefile b/PCAppProj/GNUmakefile index 903acde..d56dd44 100644 --- a/PCAppProj/GNUmakefile +++ b/PCAppProj/GNUmakefile @@ -9,7 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make - +include ../pcproj_bundle.make # # Subprojects @@ -23,8 +23,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCAppProj BUNDLE_NAME = PCAppProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCAppProj_PRINCIPAL_CLASS = PCAppProj diff --git a/PCBaseFileTypes/GNUmakefile b/PCBaseFileTypes/GNUmakefile index 7e66554..946f722 100644 --- a/PCBaseFileTypes/GNUmakefile +++ b/PCBaseFileTypes/GNUmakefile @@ -9,7 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make - +include ../pcproj_bundle.make # # Subprojects @@ -23,8 +23,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCBaseFileTypes BUNDLE_NAME = PCBaseFileTypes -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCBaseFileTypes_PRINCIPAL_CLASS = PCBaseFileType diff --git a/PCBundleProj/GNUmakefile b/PCBundleProj/GNUmakefile index aa9c019..f03cdc7 100644 --- a/PCBundleProj/GNUmakefile +++ b/PCBundleProj/GNUmakefile @@ -9,6 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make +include ../pcproj_bundle.make # @@ -23,8 +24,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCBundleProj BUNDLE_NAME = PCBundleProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCBundleProj_PRINCIPAL_CLASS = PCBundleProj diff --git a/PCGormProj/GNUmakefile b/PCGormProj/GNUmakefile index 9c89a93..f6ea3d5 100644 --- a/PCGormProj/GNUmakefile +++ b/PCGormProj/GNUmakefile @@ -9,7 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make - +include ../pcproj_bundle.make # # Subprojects @@ -23,8 +23,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCGormProj BUNDLE_NAME = PCGormProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCGormProj_PRINCIPAL_CLASS = PCGormProj diff --git a/PCLib/PCBundleLoader.h b/PCLib/PCBundleLoader.h index 6362d34..f29af73 100644 --- a/PCLib/PCBundleLoader.h +++ b/PCLib/PCBundleLoader.h @@ -54,11 +54,12 @@ - (id)delegate; - (void)setDelegate:(id)aDelegate; -- (void)loadBundles; // Load all bundles found in the BundlePaths +- (void)loadBundles; +- (void)loadBundlesAtPath: (NSString *)path; +// Returns all loaded ProjectCenter bundles. - (NSArray *)loadedBundles; - // Returns all loaded ProjectCenter bundles. @end diff --git a/PCLib/PCBundleLoader.m b/PCLib/PCBundleLoader.m index 2b41821..d3871e0 100644 --- a/PCLib/PCBundleLoader.m +++ b/PCLib/PCBundleLoader.m @@ -40,30 +40,30 @@ - (void)loadAdditionalBundlesAt:(NSString *)path { - NSBundle *bundle; - - NSAssert(path,@"No valid bundle path specified!"); + NSBundle *bundle; + + NSAssert(path,@"No valid bundle path specified!"); #ifdef DEBUG - NSLog([NSString stringWithFormat:@"Loading bundle %@...",path]); + NSLog([NSString stringWithFormat:@"Loading bundle %@...",path]); #endif// DEBUG - if ((bundle = [NSBundle bundleWithPath:path])) + if ((bundle = [NSBundle bundleWithPath:path])) { - [loadedBundles addObject:bundle]; + [loadedBundles addObject:bundle]; #ifdef DEBUG - NSLog([NSString stringWithFormat:@"Bundle %@ successfully loaded!",path]); + NSLog([NSString stringWithFormat:@"Bundle %@ successfully loaded!",path]); #endif// DEBUG - if (delegate && [delegate respondsToSelector:@selector(bundleLoader: didLoadBundle:)]) + if (delegate && [delegate respondsToSelector:@selector(bundleLoader: didLoadBundle:)]) { - [delegate bundleLoader:self didLoadBundle:bundle]; - } + [delegate bundleLoader:self didLoadBundle:bundle]; + } } - else + else { - NSRunAlertPanel(@"Attention!",@"Could not load %@!",@"OK",nil,nil,path); + NSRunAlertPanel(@"Attention!",@"Could not load %@!",@"OK",nil,nil,path); } } @@ -100,58 +100,67 @@ delegate = aDelegate; } -- (void)loadBundles +- (void) loadBundles { - NSEnumerator *enumerator; - NSString *bundleName; - NSArray *dir; - NSString *path = [[NSUserDefaults standardUserDefaults] objectForKey:BundlePaths]; + NSString *path = nil; - if (!path || [path isEqualToString:@""]) + // Load bundles that comes with ProjectCenter + path = [[NSBundle mainBundle] resourcePath]; + if (![[NSFileManager defaultManager] fileExistsAtPath: path]) + { + [NSException raise: @"PCBundleLoaderPathException" + format: @"No valid bundles at path:\n%@", path]; + return; + } + [self loadBundlesAtPath: path]; + + // Load third party bundles + path = [[NSUserDefaults standardUserDefaults] objectForKey:BundlePaths]; + if (!path || [path isEqualToString: @""]) { NSDictionary *env = [[NSProcessInfo processInfo] environment]; - NSString *prefix = [env objectForKey:@"GNUSTEP_INSTALLATION_DIR"]; - - if (prefix && ![prefix isEqualToString:@""]) - { - path =[prefix stringByAppendingPathComponent:@"Library/ProjectCenter"]; - } - else - { - path = [NSString stringWithString:@"/usr/GNUstep/Local/Library/ProjectCenter"]; - } - - [[NSUserDefaults standardUserDefaults] setObject:path forKey:BundlePaths]; + NSString *prefix = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]; + + path = [prefix stringByAppendingPathComponent: + @"Library/ApplicationSupport/ProjectCenter"]; + + [[NSUserDefaults standardUserDefaults] setObject: path + forKey: BundlePaths]; [[NSUserDefaults standardUserDefaults] synchronize]; } - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) +#ifdef DEBUG + if (![[NSFileManager defaultManager] fileExistsAtPath: path]) { - [NSException raise:@"PCBundleLoaderPathException" - format:@"No valid bundle path specified:\n%@",path]; + NSLog([NSString stringWithFormat: @"No third party bundles at %@", path]); return; } -#ifdef DEBUG - else + else { - NSLog([NSString stringWithFormat:@"Loading bundles at %@",path]); + NSLog([NSString stringWithFormat: @"Loading bundles at %@", path]); } #endif// DEBUG + [self loadBundlesAtPath: path]; +} - NSLog([NSString stringWithFormat:@"Loading bundles at %@",path]); +- (void) loadBundlesAtPath: (NSString *)path +{ + NSEnumerator *enumerator; + NSString *bundleName; + NSArray *dir; - dir = [[NSFileManager defaultManager] directoryContentsAtPath:path]; - enumerator = [dir objectEnumerator]; + dir = [[NSFileManager defaultManager] directoryContentsAtPath: path]; + enumerator = [dir objectEnumerator]; - while (bundleName = [enumerator nextObject]) + while (bundleName = [enumerator nextObject]) { - if ([[bundleName pathExtension] isEqualToString:@"bundle"]) + if ([[bundleName pathExtension] isEqualToString:@"bundle"]) { - NSString *fullPath; - - fullPath = [NSString stringWithFormat:@"%@/%@",path,bundleName]; - [self loadAdditionalBundlesAt:fullPath]; - } + NSString *fullPath; + + fullPath = [NSString stringWithFormat:@"%@/%@",path,bundleName]; + [self loadAdditionalBundlesAt:fullPath]; + } } } diff --git a/PCLibProj/GNUmakefile b/PCLibProj/GNUmakefile index e3c9541..c09fdac 100644 --- a/PCLibProj/GNUmakefile +++ b/PCLibProj/GNUmakefile @@ -9,6 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make +include ../pcproj_bundle.make # @@ -23,8 +24,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCLibProj BUNDLE_NAME = PCLibProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCLibProj_PRINCIPAL_CLASS = PCLibProj diff --git a/PCRenaissanceProj/GNUmakefile b/PCRenaissanceProj/GNUmakefile index 2d85f98..15be494 100644 --- a/PCRenaissanceProj/GNUmakefile +++ b/PCRenaissanceProj/GNUmakefile @@ -9,6 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make +include ../pcproj_bundle.make # @@ -23,8 +24,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCRenaissanceProj BUNDLE_NAME = PCRenaissanceProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCRenaissanceProj_PRINCIPAL_CLASS = PCRenaissanceProj diff --git a/PCToolProj/GNUmakefile b/PCToolProj/GNUmakefile index 253ef59..2dc0ee2 100644 --- a/PCToolProj/GNUmakefile +++ b/PCToolProj/GNUmakefile @@ -9,6 +9,7 @@ # include $(GNUSTEP_MAKEFILES)/common.make +include ../pcproj_bundle.make # @@ -23,8 +24,6 @@ include $(GNUSTEP_MAKEFILES)/common.make PACKAGE_NAME = PCToolProj BUNDLE_NAME = PCToolProj -BUNDLE_EXTENSION = .bundle -BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Library/ProjectCenter PCToolProj_PRINCIPAL_CLASS = PCToolProj diff --git a/pcproj_bundle.make b/pcproj_bundle.make new file mode 100644 index 0000000..b58bd1a --- /dev/null +++ b/pcproj_bundle.make @@ -0,0 +1,2 @@ +BUNDLE_EXTENSION = .bundle +BUNDLE_INSTALL_DIR = $(GNUSTEP_SYSTEM_ROOT)/Applications/ProjectCenter.app/Resources