Sfoglia il codice sorgente

Merge branch 'develop' of https://github.com/blitz-research/monkey2 into develop

Mark Sibly 7 anni fa
parent
commit
839ba5fe2c

+ 2 - 0
VERSIONS.TXT

@@ -1,4 +1,6 @@
 
+Added simple support for iphone simulator. Alas, I've had to implement this as a sort of pseudo target: set MX2_IOS_USE_SIMULATOR=1 in env_macos.txt to enable simulator and rebuild modules. You'll need to change this env var to switch between simulator/hardware builds, you don't have to rebuild modules each time you switch though. Also note that apps builds to the same product project. Far from elegant sorry, I may be able to do something with lipo etc eventually.
+
 Mojo3d camera's can now be attached to a view, which will take care of autoresizing camera viewport etc.
 
 Camera param removed from Scene.Render. Scene.Render now renders all cameras in a scene. Add Camera.Render for just rendering a single camera - this is now recommended way to render a scene, multiple cameras not dealt with yet.

+ 11 - 3
bin/env_macos.txt

@@ -101,6 +101,10 @@ MX2_ANDROID_APP_STL=c++_static
 
 '***** IOS TARGET *****
 
+'Note: must appear BEFORE first use of MX2_IOS_SDK
+'
+MX2_IOS_USE_SIMULATOR=1
+
 'This is now set for you by mx2cc.
 '
 'MX2_IOS_SDK=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.1.sdk
@@ -108,16 +112,20 @@ MX2_ANDROID_APP_STL=c++_static
 MX2_IOS_DEPLOYMENT_TARGET=8.0
 
 'LD options
-MX2_LD_OPTS_IOS=-arch armv7 -arch arm64 -isysroot ${MX2_IOS_SDK}
+MX2_LD_OPTS_IOS=${MX2_IOS_ARCHS} -isysroot ${MX2_IOS_SDK}
 MX2_LD_OPTS_IOS_DEBUG=
 MX2_LD_OPTS_IOS_RELEASE=-O3 
 
 'C compiler options
-MX2_CC_OPTS_IOS=-std=gnu99 -arch armv7 -arch arm64 -miphoneos-version-min=${MX2_IOS_DEPLOYMENT_TARGET} -isysroot ${MX2_IOS_SDK} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+'
+MX2_CC_OPTS_IOS=-std=gnu99 ${MX2_IOS_ARCHS} -miphoneos-version-min=${MX2_IOS_DEPLOYMENT_TARGET} -isysroot ${MX2_IOS_SDK} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+
 MX2_CC_OPTS_IOS_DEBUG=
 MX2_CC_OPTS_IOS_RELEASE=-O3 -DNDEBUG
 
 'C++ compiler options
-MX2_CPP_OPTS_IOS=-std=c++14 -arch armv7 -arch arm64 -miphoneos-version-min=${MX2_IOS_DEPLOYMENT_TARGET} -isysroot ${MX2_IOS_SDK} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+'
+MX2_CPP_OPTS_IOS=-std=c++11 ${MX2_IOS_ARCHS} -miphoneos-version-min=${MX2_IOS_DEPLOYMENT_TARGET} -isysroot ${MX2_IOS_SDK} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+
 MX2_CPP_OPTS_IOS_DEBUG=-O0 -g
 MX2_CPP_OPTS_IOS_RELEASE=-O3 -DNDEBUG

+ 2 - 0
modules/monkey/native/bbplatform.h

@@ -16,6 +16,8 @@
     
     #if TARGET_IPHONE_SIMULATOR
     
+    	#define BB_IOS 1
+    
     #elif TARGET_OS_IPHONE
     
     	#define BB_IOS 1

+ 4 - 0
src/mx2cc/builder.monkey2

@@ -124,6 +124,10 @@ Class BuilderInstance
 				
 			If opts.arch="x64" profileName+="_x64"
 				
+		Elseif opts.target="ios"
+			
+			If opts.arch="x64" profileName+="_x64"
+				
 		Endif
 		
 		If opts.productType="app" APP_DIR=ExtractDir( opts.mainSource )

+ 2 - 1
src/mx2cc/buildproduct.monkey2

@@ -425,7 +425,8 @@ Class GccBuildProduct Extends BuildProduct
 						If i1=-1 Exit
 						tmp=tmp.Slice( 0,i0+1 )+tmp.Slice( i1+1 )
 					Forever
-					tmp+=" -arch armv7"
+					
+					If opts.arch<>"x64" tmp+=" -arch armv7"
 					
 				Endif
 				

+ 32 - 12
src/mx2cc/mx2cc.monkey2

@@ -24,7 +24,7 @@ Global opts_time:Bool
 
 Global StartDir:String
 
-Const TestArgs:="mx2cc makemods"
+Const TestArgs:="mx2cc makemods -target=ios"' monkey libc"
  
 'Const TestArgs:="mx2cc makeapp -clean src/mx2cc/test.monkey2"
 
@@ -65,16 +65,6 @@ Function Main()
 	args=AppArgs()
 #endif
 
-	For Local i:=0 Until args.Length
-		If args[i]="-target=ios"
-			system( "xcrun --sdk iphoneos --show-sdk-path >tmp/_p.txt" )
-			Local p:=LoadString( "tmp/_p.txt" ).Trim()
-			SetEnv( "MX2_IOS_SDK",p )
-			'Print "MX2_IOS_SDK="+p
-			Exit
-		Endif
-	Next
-	
 	LoadEnv( env )
 	
 	Local moddirs:=New StringStack
@@ -517,7 +507,9 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 		
 	Case "ios"
 		
-		opts.arch="arm64"
+		opts.arch="armv7 arm64"
+		
+		If Int( GetEnv( "MX2_IOS_USE_SIMULATOR" ) ) opts.arch="x64"
 		
 	Default
 		
@@ -646,10 +638,38 @@ Function ReplaceEnv:String( str:String,lineid:Int )
 		If i2=-1 Fail( "Env config file error at line "+lineid )
 		
 		Local name:=str.Slice( i1+2,i2 ).Trim()
+		
 		Local value:=GetEnv( name )
 		
+		If Not value
+			
+			Select name
+			Case "MX2_IOS_SDK"
+				
+				Local sdk:="iphoneos"
+				
+				If Int( GetEnv( "MX2_IOS_USE_SIMULATOR" ) ) sdk="iphonesimulator"
+		
+				system( "xcrun --sdk "+sdk+" --show-sdk-path >tmp/_p.txt" )
+				
+				value=LoadString( "tmp/_p.txt" ).Trim()
+				
+				SetEnv( "MX2_IOS_SDK",value )
+				
+			Case "MX2_IOS_ARCHS"
+				
+				value="-arch armv7 -arch arm64"
+				
+				If Int( GetEnv( "MX2_IOS_USE_SIMULATOR" ) ) value="-arch x86_64"
+			End
+			
+			If value SetEnv( name,value )
+			
+		Endif
+		
 		str=str.Slice( 0,i1 )+value+str.Slice( i2+1 )
 		i0=i1+value.Length
+		
 	Forever
 	Return ""
 End