Lion + Xcode 4
by Thomas -elfprince13- Dickerson · in Torque 3D Professional · 07/20/2011 (9:15 pm) · 6 replies
I'd like to have this thread be a place to collaborate on getting T3D building under Lion with Xcode 4 and either GCC + LLVM or Clang. As of right now, I'm having a hell of a time getting everything to go. LLVM is much pickier, but GCC is slowly being deprecated from the SDKs.
About the author
C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.
#2
07/21/2011 (10:56 am)
I've made it through application startup, though I just had a crash in the OpenAL routines.Index: main.cpp
===================================================================
--- main.cpp (revision 49)
+++ main.cpp (working copy)
@@ -100,7 +100,7 @@
FSSpec fss2;
- strcpy(name, &pspec.name[1]);
+ strcpy(name, (char*)(&pspec.name[1]));
err = FSMakeFSSpec(pspec.vRefNum, pspec.parID, 0, &fss2);
@@ -117,60 +117,62 @@
{
void *gameBundle = 0;
char gameBundleFilename[2049];
+
+ int ret = -1;
- const char* basePath;
- const char* appName;
+ char basePath[2049];
+ char appName[2049];
+ OSStatus err;
+
+ CFDictionaryRef appDict;
+ ProcessSerialNumber PSN;
+ err = GetCurrentProcess(&PSN);
+ if(!err){
+ appDict = ProcessInformationCopyDictionary(&PSN, kProcessDictionaryIncludeAllInformationMask);
+ CFStringRef cfBundlePath;
+ CFStringRef cfAppName;
+ bool inBundle = CFDictionaryGetValueIfPresent(appDict, CFSTR("BundlePath"), (const void**)(&cfBundlePath));
+ bool hasName = CFDictionaryGetValueIfPresent(appDict, kCFBundleNameKey, (const void**)(&cfAppName));
+ if(inBundle && hasName)
+ {
+ CFRetain(cfBundlePath);
+ CFRetain(cfAppName);
- // Get the path to our app binary and the app name
+ CFStringGetCString( cfBundlePath, basePath, 2049, kCFStringEncodingASCII );
+ CFStringGetCString( cfAppName, appName, 2049, kCFStringEncodingASCII );
+
+ int i = strlen(appName);
+ while (i > 0)
+ {
+ if (strstr(&appName[i], "-DEBUG") == &appName[i])
+ {
+ appName[i] = 0;
+ break;
+ }
+
+ i--;
+ }
+
+ sprintf(gameBundleFilename, "%s/Contents/Frameworks/%s-Bundle.bundle/Contents/MacOS/%s-Bundle", basePath, appName, appName);
+
+ chdir(basePath);
+ chdir("..");
+ gameBundle = dlopen(gameBundleFilename, RTLD_LAZY | RTLD_LOCAL);
+ const char * bundleError = dlerror();
+
+
+ CFRelease(cfAppName);
+ CFRelease(cfBundlePath);
+
+ if ( gameBundle && (torque_macmain = (int (*)(int argc, const char **argv)) dlsym(gameBundle, "torque_macmain")))
+ ret = torque_macmain(argc, argv);
+ else if (bundleError) printf("%sn",bundleError);
+
+ }
+
+ }
+ return ret;
- GetBasePath(&basePath, &appName);
-
- if (!basePath[0] || !appName[0])
- return;
-
- char appNameNoDebug[2049];
-
- strcpy(appNameNoDebug, appName);
-
- int i = strlen(appName);
- while (i > 0)
- {
- if (!strcmp(&appName[i], "_DEBUG"))
- {
- appNameNoDebug[i] = 0;
- break;
- }
-
- i--;
- }
-
- sprintf(gameBundleFilename, "%s.app/Contents/Frameworks/%s Bundle.bundle/Contents/MacOS/%s Bundle", appName, appNameNoDebug, appNameNoDebug);
-
- // first see if the current directory is set properly
- gameBundle = dlopen(gameBundleFilename, RTLD_LAZY | RTLD_LOCAL);
-
- if (!gameBundle)
- {
- // Couldn't load the game bundle... so, using the path to the bundle binary fix up the cwd
-
- if (basePath[0]) {
- chdir( basePath );
- chdir( "../../../" );
- }
-
- // and try again
- gameBundle = dlopen( gameBundleFilename, RTLD_LAZY | RTLD_LOCAL);
- }
-
- if (!gameBundle)
- return -1;
-
- torque_macmain = (int (*)(int argc, const char **argv)) dlsym(gameBundle, "torque_macmain");
-
- if (!torque_macmain)
- return -1;
-
- return torque_macmain(argc, argv);
}
#endif // __MACOSX
#3
07/21/2011 (10:58 am)
Index: core/stringBuffer.h
===================================================================
--- core/stringBuffer.h (revision 49)
+++ core/stringBuffer.h (working copy)
@@ -29,11 +29,11 @@
public:
#if defined(TORQUE_DEBUG)
- typedef struct RequestCounts
+ typedef struct _RequestCounts
{
U64 requestCount8;
U64 requestCount16;
- };
+ } RequestCounts;
RequestCounts *rc;
#endifIndex: windowManager/mac/macWindow.mm
===================================================================
--- windowManager/mac/macWindow.mm (revision 49)
+++ windowManager/mac/macWindow.mm (working copy)
@@ -224,7 +224,7 @@
GGMacView* view = [[GGMacView alloc] initWithFrame:contentRect pixelFormat:[NSOpenGLView defaultPixelFormat]];
[view setTorqueWindow:this];
[mCocoaWindow setContentView:view];
- [mCocoaWindow setDelegate:view];
+ [mCocoaWindow setDelegate:static_cast<id<NSWindowDelegate> >(view)];
}Index: platform.h
===================================================================
--- platform.h (revision 49)
+++ platform.h (working copy)
@@ -529,17 +529,17 @@
dst[i] = (T)src[i];
}
+extern void* dMemcpy(void *dst, const void *src, dsize_t size);
+extern void* dMemmove(void *dst, const void *src, dsize_t size);
+extern void* dMemset(void *dst, int c, dsize_t size);
+extern int dMemcmp(const void *ptr1, const void *ptr2, dsize_t size);
+
// Special case of the above function when the arrays are the same type (use memcpy)
template<class T> void dCopyArray(T *dst, const T *src, dsize_t size)
{
dMemcpy(dst, src, size * sizeof(T));
}
-extern void* dMemcpy(void *dst, const void *src, dsize_t size);
-extern void* dMemmove(void *dst, const void *src, dsize_t size);
-extern void* dMemset(void *dst, int c, dsize_t size);
-extern int dMemcmp(const void *ptr1, const void *ptr2, dsize_t size);
-
//------------------------------------------------------------------------------
// FileIO functions
extern bool dFileDelete(const char *name);
#4
07/21/2011 (10:59 am)
Index: threads/threadSafeDeque.h
===================================================================
--- threads/threadSafeDeque.h (revision 52)
+++ threads/threadSafeDeque.h (working copy)
@@ -205,9 +205,9 @@
mTail.trySetFromTo( head, next, NodeRef::TAG_Unset );
if( next != NULL )
- next->mPrev.trySetFromTo( head, NULL );
+ next->mPrev.trySetFromTo( head, NodeRef(NULL) );
- head->mNext.trySetFromTo( next, NULL, NodeRef::TAG_Set );
+ head->mNext.trySetFromTo( next, NodeRef(NULL), NodeRef::TAG_Set );
continue; // Restart.
}
@@ -281,11 +281,10 @@
mHead.trySetFromTo( tail, prev, NodeRef::TAG_Unset );
mTail.trySetFromTo( tail, prev, NodeRef::TAG_Unset );
-
if( prev != NULL )
- prev->mNext.trySetFromTo( tail, NULL );
+ prev->mNext.trySetFromTo( tail, NodeRef(NULL) );
- tail->mPrev.trySetFromTo( prev, NULL, NodeRef::TAG_Set );
+ tail->mPrev.trySetFromTo( prev, NodeRef(NULL), NodeRef::TAG_Set );
continue; // Restart.
}
@@ -398,7 +397,8 @@
// Try to claim the node.
- if( oldHead->mPrev.trySetFromTo( NULL, NULL, NodeRef::TAG_SetOrFail ) )
+ ThreadSafeDeque<T>::Node *const volatile ptr = NULL;
+ if( oldHead->mPrev.trySetFromTo( NULL, ptr, NodeRef::TAG_SetOrFail ) )
{
if( dCompareAndSwap( oldHead->mIsClaimed, 0, 1 ) )
break;
@@ -431,8 +431,9 @@
return false;
// Try to claim the node.
-
- if( oldTail->mNext.trySetFromTo( NULL, NULL, NodeRef::TAG_SetOrFail ) )
+
+ ThreadSafeDeque<T>::Node *const volatile ptr = NULL;
+ if( oldTail->mNext.trySetFromTo( NULL, ptr, NodeRef::TAG_SetOrFail ) )
{
if( dCompareAndSwap( oldTail->mIsClaimed, 0, 1 ) )
break;Index: test/testThreadSafeRefCount.cpp
===================================================================
--- test/testThreadSafeRefCount.cpp (revision 49)
+++ test/testThreadSafeRefCount.cpp (working copy)
@@ -156,30 +156,30 @@
TEST( !ref );
TEST( !ref.ptr() );
- TEST( ref.trySetFromTo( ref, NULL ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL) ) );
TEST( !ref.isTagged() );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_Set ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_Set ) );
TEST( ref.isTagged() );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_Set ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_Set ) );
TEST( ref.isTagged() );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_Unset ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_Unset ) );
TEST( !ref.isTagged() );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_Unset ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_Unset ) );
TEST( !ref.isTagged() );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_SetOrFail ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_SetOrFail ) );
TEST( ref.isTagged() );
- TEST( !ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_SetOrFail ) );
+ TEST( !ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_SetOrFail ) );
TEST( ref.isTagged() );
- TEST( !ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_FailIfSet ) );
+ TEST( !ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_FailIfSet ) );
- TEST( ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_UnsetOrFail ) );
+ TEST( ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_UnsetOrFail ) );
TEST( !ref.isTagged() );
- TEST( !ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_UnsetOrFail ) );
+ TEST( !ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_UnsetOrFail ) );
TEST( !ref.isTagged() );
- TEST( !ref.trySetFromTo( ref, NULL, TestObjectRef::TAG_FailIfUnset ) );
+ TEST( !ref.trySetFromTo( ref, TestObjectRef(NULL), TestObjectRef::TAG_FailIfUnset ) );
TestObjectRef objectA = new TestObject;
TestObjectRef objectB = new TestObject;
#5

07/22/2011 (7:25 am)
I have no problem compiling stock T3D 1.1 on Xcode 4 as long as I change the "Base SDK" to 10.6 on all projects. Now it will compile but won't run, that requires changes to the bundle loading system. Easy enough, once those are finished now I find that because of the huge changes in openGL for 10.7 nothing renders correctly. (see screenshots). I'm no graphics master so I got stuck here.
#6
I changed the Base SDK to 10.6 and using a mix of GCC + Clang for different projects (notably the Collada wouldn't compile with GCC) I got it up and running - the 3 compiler options are ABI compatible. I did notice some graphics glitches though.
07/22/2011 (10:33 am)
I fixed the bundle loading with a resource: www.garagegames.com/community/resources/view/21146I changed the Base SDK to 10.6 and using a mix of GCC + Clang for different projects (notably the Collada wouldn't compile with GCC) I got it up and running - the 3 compiler options are ABI compatible. I did notice some graphics glitches though.
Torque 3D Owner Thomas -elfprince13- Dickerson
It seems to be related to more aggressive const + volatile correct typechecking in the platform/thread/threadSafe_____.__ code. I am getting 4 errors telling me that trySetFromTo are ambiguous, and one that a volatile lvalue of type ThreadSafeDeque<OggTheoraFrame*>::Node *const volatile can't be passed a temporary of type int (a NULL in the sourcecode).
[edit]
20 minutes of typecasting later I'm getting a new set of errors:
[edit 2]
This is also a typecasting issue.
The first issue I've had which wasn't a typecasting problem is that my application executable can't find the game bundle. I'm stepping through GetBasePath to figure out why the name it is returning isn't null terminated where it should be.