[38501] branches/gsoc08-framework/MacPorts_Framework

armahg at macports.org armahg at macports.org
Tue Jul 22 14:03:12 PDT 2008


Revision: 38501
          http://trac.macosforge.org/projects/macports/changeset/38501
Author:   armahg at macports.org
Date:     2008-07-22 14:03:11 -0700 (Tue, 22 Jul 2008)
Log Message:
-----------
Added initWithTclPkgPath and sharedInstanceWithPkgPath methods to MPMacPorts and MPInterpreter classes. This enables Framework users to initialize MacPorts with macport1.0 package paths for their own customized MacPorts builds.

Modified Paths:
--------------
    branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
    branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
    branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
    branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
    branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
    branches/gsoc08-framework/MacPorts_Framework/init.tcl

Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h	2008-07-22 21:03:11 UTC (rev 38501)
@@ -65,7 +65,10 @@
  */
 + (MPInterpreter *)sharedInterpreter;
 
++ (MPInterpreter *)sharedInterpreterWithPkgPath:(NSString *)path;
+- (id) initWithPkgPath:(NSString *)path;
 
+
 #pragma Port Operations
 
 #pragma Port Settings

Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m	2008-07-22 21:03:11 UTC (rev 38501)
@@ -140,7 +140,13 @@
 #pragma mark -
 
 #pragma mark MPInterpreter Code
+/*
 - (id) init {
+	return [self initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"];
+}
+*/
+
+- (id) initWithPkgPath:(NSString *)path {
 	if (self = [super init]) {
 		_interpreter = Tcl_CreateInterp();
 		if(_interpreter == NULL) {
@@ -151,13 +157,15 @@
 			Tcl_DeleteInterp(_interpreter);
 		}
 		
-		/*
-		 //TO DO ...
-		 //Use client provided .tcl file if any
-		 
-		 //Finally load our own init.tcl file
-		 */
 		
+		NSString * mport_fastload = [[@"source [file join \"" stringByAppendingString:path]
+									 stringByAppendingString:@"\" macports1.0 macports_fastload.tcl]"];
+		if(Tcl_Eval(_interpreter, [mport_fastload UTF8String]) != TCL_OK) {
+			NSLog(@"Error in Tcl_EvalFile macports_fastload.tcl: %s", Tcl_GetStringResult(_interpreter));
+			Tcl_DeleteInterp(_interpreter);
+		}
+		
+		
 		Tcl_CreateObjCommand(_interpreter, "notifications", Notifications_Command, NULL, NULL);
 		
 		if (Tcl_PkgProvide(_interpreter, "notifications", "1.0") != TCL_OK) {
@@ -165,7 +173,7 @@
 			Tcl_DeleteInterp(_interpreter);
 		}
 		if( Tcl_EvalFile(_interpreter, [[[NSBundle bundleWithIdentifier:@"org.macports.frameworks.macports"] pathForResource:@"init" ofType:@"tcl"] UTF8String]) != TCL_OK) {
-			NSLog(@"Error in Tcl_EvalFile: %s", Tcl_GetStringResult(_interpreter));
+			NSLog(@"Error in Tcl_EvalFile init.tcl: %s", Tcl_GetStringResult(_interpreter));
 			Tcl_DeleteInterp(_interpreter);
 		}
 		
@@ -173,15 +181,26 @@
 	return self;
 }
 
+
 + (MPInterpreter*)sharedInterpreter {
 	@synchronized(self) {
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
-			[[self alloc] init]; // assignment not done here
+			[[self alloc] initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"]; // assignment not done here
 		}
 	}
 	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
 }
 
++ (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path {
+	@synchronized(self) {
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
+			[[self alloc] initWithPkgPath:path]; // assignment not done here
+		}
+	}
+	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
+}
+
+
 + (id)allocWithZone:(NSZone*)zone {
 	@synchronized(self) {
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {

Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h	2008-07-22 21:03:11 UTC (rev 38501)
@@ -69,6 +69,10 @@
  */
 + (MPMacPorts *)sharedInstance;
 
+//Names of messages below are subject to change
++ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path;
+- (id) initWithPkgPath:(NSString *)path;
+
 /*!
  @brief Synchronizes the ports tree without checking for upgrades to the MacPorts base.
  */

Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m	2008-07-22 21:03:11 UTC (rev 38501)
@@ -34,10 +34,12 @@
  */
 
 #import "MPMacPorts.h"
+#import "MPNotifications.h"
 
 
 @implementation MPMacPorts
 
+/*
 - (id) init {
 	if (self = [super init]) {
 		interpreter = [MPInterpreter sharedInterpreter];
@@ -45,16 +47,37 @@
 	}
 	return self;
 }
+ */
 
+- (id) initWithPkgPath:(NSString *)path {
+	if (self = [super init]) {
+		interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path];
+		[self registerForLocalNotifications];
+	}
+	return self;
+}
+
 + (MPMacPorts *)sharedInstance {
 	@synchronized(self) {
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
-			[[self alloc] init]; // assignment not done here
+			[[self alloc] initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"]; // assignment not done here
 		}
 	}
 	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
 }
 
++ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path {
+	@synchronized(self) {
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
+			[[self alloc] initWithPkgPath:path]; // assignment not done here
+		}
+	}
+	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
+}
+
+
+
+
 + (id)allocWithZone:(NSZone*)zone {
 	@synchronized(self) {
 		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
@@ -208,22 +231,22 @@
 -(void) registerForLocalNotifications {
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(respondToLocalNotification:) 
-												 name:@"MPInfoNotification"
+												 name:MPINFO
 											   object:nil];
 	
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(respondToLocalNotification:) 
-												 name:@"MPMsgNotification"
+												 name:MPMSG
 											   object:nil];
 	
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(respondToLocalNotification:) 
-												 name:@"MPErrorNotification"
+												 name:MPERROR
 											   object:nil];
 	
 	[[NSNotificationCenter defaultCenter] addObserver:self
 											 selector:@selector(respondToLocalNotification:) 
-												 name:@"MPWarnNotification"
+												 name:MPWARN
 											   object:nil];
 	
 	[[NSNotificationCenter defaultCenter] addObserver:self

Modified: branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2008-07-22 21:03:11 UTC (rev 38501)
@@ -44,7 +44,6 @@
 		6E49F37B0DFFAB0B0030C3AF /* MPInterpreterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 489DD92E0C94674B00595506 /* MPInterpreterTest.m */; };
 		6E49F37F0DFFAFF80030C3AF /* MacPorts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* MacPorts.framework */; };
 		6EA294590E080DEB00902D12 /* MPMacPortsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E88D1CB0DF4B90B00684E9F /* MPMacPortsTest.m */; };
-		6EEB13000E2BFA3000BFEC81 /* notifications.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EEB12FF0E2BFA3000BFEC81 /* notifications.h */; };
 		8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };
 		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; };
 /* End PBXBuildFile section */
@@ -88,16 +87,13 @@
 		48E9939E0C82CEB000219DDF /* init.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl; sourceTree = "<group>"; };
 		48F811BE0CE4636A009630DE /* MPRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRegistry.h; sourceTree = "<group>"; };
 		48F811BF0CE4638C009630DE /* MPRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRegistry.m; sourceTree = "<group>"; };
-		6E270C080E148F4E00BAE687 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
 		6E270D070E158CED00BAE687 /* MPNotifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNotifications.h; sourceTree = "<group>"; };
 		6E270D080E158CED00BAE687 /* MPNotifications.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNotifications.m; sourceTree = "<group>"; };
 		6E44A00C0E2DAD66007DE8EC /* ToDo.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ToDo.txt; sourceTree = "<group>"; };
 		6E88D1CA0DF4B90B00684E9F /* MPMacPortsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMacPortsTest.h; sourceTree = "<group>"; };
 		6E88D1CB0DF4B90B00684E9F /* MPMacPortsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMacPortsTest.m; sourceTree = "<group>"; };
 		6EA0F56E0DFEB55E00C15082 /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = System/Library/Frameworks/Tcl.framework; sourceTree = SDKROOT; };
-		6EA293570E05C8FC00902D12 /* notifications.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = notifications.m; sourceTree = "<group>"; };
 		6EAFD8B70DEC614E00E97270 /* dummycommit.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = dummycommit.test; sourceTree = "<group>"; };
-		6EEB12FF0E2BFA3000BFEC81 /* notifications.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = notifications.h; sourceTree = "<group>"; };
 		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
 		8DC2EF5B0486A6940098B216 /* MacPorts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MacPorts.framework; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
@@ -241,11 +237,8 @@
 		6EA293540E05C8C600902D12 /* Tcl Notifications  */ = {
 			isa = PBXGroup;
 			children = (
-				6E270C080E148F4E00BAE687 /* Makefile */,
-				6EA293570E05C8FC00902D12 /* notifications.m */,
 				6E270D070E158CED00BAE687 /* MPNotifications.h */,
 				6E270D080E158CED00BAE687 /* MPNotifications.m */,
-				6EEB12FF0E2BFA3000BFEC81 /* notifications.h */,
 			);
 			name = "Tcl Notifications ";
 			sourceTree = "<group>";
@@ -266,7 +259,6 @@
 				48A866AA0CD364F700B521BC /* MPReceipt.h in Headers */,
 				481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */,
 				6E270D090E158CED00BAE687 /* MPNotifications.h in Headers */,
-				6EEB13000E2BFA3000BFEC81 /* notifications.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: branches/gsoc08-framework/MacPorts_Framework/init.tcl
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/init.tcl	2008-07-22 19:55:04 UTC (rev 38500)
+++ branches/gsoc08-framework/MacPorts_Framework/init.tcl	2008-07-22 21:03:11 UTC (rev 38501)
@@ -2,8 +2,8 @@
 #	[file join "/Library/Tcl" macports1.0 macports_fastload.tcl]}
 
 #Trying my own MacPorts build rather than default one on the system
-catch {source \
-	[file join "/Users/Armahg/macportsbuild/build1/Library/Tcl" macports1.0 macports_fastload.tcl]}
+#catch {source \
+#	[file join "/Users/Armahg/macportsbuild/build1/Library/Tcl" macports1.0 macports_fastload.tcl]}
 
 
 
@@ -137,8 +137,8 @@
         	}]
         }
         
-    # Call ui_$priority
-	#::ui_$priority $message
+    # Call ui_$priority - Is this step necessary? Consult with Randall
+    #::ui_$priority $message
     }
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080722/58df7db0/attachment.html 


More information about the macports-changes mailing list