Explorar o código

Merge pull request #232 from attilaz/xcde4_v3

added separate ios/osx Xcode project generation
Branimir Karadžić %!s(int64=11) %!d(string=hai) anos
pai
achega
f4123e6483

+ 11 - 5
examples/common/entry/entry_ios.mm

@@ -60,13 +60,19 @@ namespace entry
 	int32_t MainThreadEntry::threadFunc(void* _userData)
 	{
 		CFBundleRef mainBundle = CFBundleGetMainBundle();
-		CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
-		char path[PATH_MAX];
-		if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) )
+		if ( mainBundle != nil )
 		{
-			chdir(path);
+			CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
+			if ( resourcesURL != nil )
+			{
+				char path[PATH_MAX];
+				if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) )
+				{
+					chdir(path);
+				}
+				CFRelease(resourcesURL);
+			}
 		}
-		CFRelease(resourcesURL);
 
 		MainThreadEntry* self = (MainThreadEntry*)_userData;
 		int32_t result = main(self->m_argc, self->m_argv);

+ 15 - 0
examples/common/entry/entry_osx.mm

@@ -57,6 +57,21 @@ namespace entry
 
 		static int32_t threadFunc(void* _userData)
 		{
+            CFBundleRef mainBundle = CFBundleGetMainBundle();
+            if ( mainBundle != nil )
+            {
+                CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
+                if ( resourcesURL != nil )
+                {
+                    char path[PATH_MAX];
+                    if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX) )
+                    {
+                        chdir(path);
+                    }
+                    CFRelease(resourcesURL);
+                }
+            }
+            
 			MainThreadEntry* self = (MainThreadEntry*)_userData;
 			return main(self->m_argc, self->m_argv);
 		}

+ 45 - 0
examples/runtime/iOS-Info.plist

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>com.company.$(PRODUCT_NAME:rfc1034identifier)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>1</string>
+	<key>LSRequiresIPhoneOS</key>
+	<true/>
+	<key>UIRequiredDeviceCapabilities</key>
+	<array>
+		<string>armv7</string>
+	</array>
+	<key>UIStatusBarHidden</key>
+	<true/>
+	<key>UISupportedInterfaceOrientations</key>
+	<array>
+		<string>UIInterfaceOrientationPortrait</string>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+	<key>UISupportedInterfaceOrientations~ipad</key>
+	<array>
+		<string>UIInterfaceOrientationPortrait</string>
+		<string>UIInterfaceOrientationPortraitUpsideDown</string>
+		<string>UIInterfaceOrientationLandscapeLeft</string>
+		<string>UIInterfaceOrientationLandscapeRight</string>
+	</array>
+</dict>
+</plist>

+ 2 - 1
makefile

@@ -24,7 +24,8 @@ all:
 	$(GENIE) --with-tools --with-shared-lib --gcc=mingw-gcc gmake
 	$(GENIE) --with-tools --with-shared-lib --gcc=linux-gcc gmake
 	$(GENIE) --with-tools --with-shared-lib --gcc=osx gmake
-	$(GENIE) --with-tools --with-shared-lib xcode4
+	$(GENIE) --with-tools --with-shared-lib --xcode=osx xcode4
+	$(GENIE) --with-tools --with-shared-lib --xcode=ios xcode4
 	
 	$(GENIE) --gcc=android-arm gmake
 	$(GENIE) --gcc=android-mips gmake

+ 0 - 4
scripts/example-common.lua

@@ -34,10 +34,6 @@ project ("example-common")
 			"$(DXSDK_DIR)/include",
 		}
 
-	configuration { "xcode4" }
-		includedirs {
-			BX_DIR .. "include/compat/osx",
-		}
 
 	configuration { "winphone8*"}
 		linkoptions {

+ 17 - 18
scripts/genie.lua

@@ -29,12 +29,18 @@ solution "bgfx"
 		"Release",
 	}
 
-	platforms {
-		"x32",
-		"x64",
---		"Xbox360",
-		"Native", -- for targets where bitness is not specified
+	if _ACTION == "xcode4" then
+		platforms {
+			"Universal",
+	}
+	else
+		platforms {
+			"x32",
+			"x64",
+--			"Xbox360",
+			"Native", -- for targets where bitness is not specified
 	}
+	end
 
 	language "C++"
 	startproject "example-00-helloworld"
@@ -237,19 +243,6 @@ function exampleProject(_name)
 			"OpenGL.framework",
 		}
 
-	configuration { "xcode4" }
-		platforms {
-			"Universal"
-		}
-		files {
-			BGFX_DIR .. "examples/common/**.mm",
-		}
-		links {
-			"Cocoa.framework",
-			"Foundation.framework",
-			"OpenGL.framework",
-		}
-
 	configuration { "ios*" }
 		kind "ConsoleApp"
 		files {
@@ -263,6 +256,12 @@ function exampleProject(_name)
 			"-framework QuartzCore",
 		}
 
+	configuration { "xcode4", "ios" }
+		kind "WindowedApp"
+		files {
+			BGFX_DIR .. "examples/runtime/iOS-Info.plist"
+		}
+
 	configuration { "qnx*" }
 		targetextension ""
 		links {