Browse Source

Removed wasm target - now an appType for emscripten target.

Mark Sibly 8 years ago
parent
commit
6145240f09

+ 3 - 5
src/mx2cc/builder.monkey2

@@ -31,8 +31,6 @@ Class BuildOpts
 	
 	
 	Field reflection:Bool
 	Field reflection:Bool
 	
 	
-	Field wasm:Bool
-	
 End
 End
 
 
 Class BuilderInstance
 Class BuilderInstance
@@ -89,10 +87,10 @@ Class BuilderInstance
 		
 		
 			SetEnv( "PATH",GetEnv( "MX2_RASPBIAN_TOOLS" )+";"+GetEnv( "PATH" ) )
 			SetEnv( "PATH",GetEnv( "MX2_RASPBIAN_TOOLS" )+";"+GetEnv( "PATH" ) )
 			
 			
-		Else If opts.target="wasm"
+'		Else If opts.target="wasm"
 		
 		
-			opts.target="emscripten"
-			opts.wasm=True
+'			opts.target="emscripten"
+'			opts.wasm=True
 			
 			
 		Endif
 		Endif
 		
 		

+ 7 - 1
src/mx2cc/buildproduct.monkey2

@@ -557,7 +557,7 @@ Class GccBuildProduct Extends BuildProduct
 			
 			
 			cmd+=" --preload-file ~q"+assetsDir+"@/assets~q"
 			cmd+=" --preload-file ~q"+assetsDir+"@/assets~q"
 			
 			
-			If opts.wasm cmd+=" -s BINARYEN=1 -s BINARYEN_TRAP_MODE='allow'"
+			If opts.appType.StartsWith( "wasm" ) cmd+=" -s BINARYEN=1 -s BINARYEN_TRAP_MODE='allow'"
 		End
 		End
 		
 		
 		If opts.verbose>=0 Print "Linking "+outputFile+"..."
 		If opts.verbose>=0 Print "Linking "+outputFile+"..."
@@ -595,6 +595,12 @@ Class GccBuildProduct Extends BuildProduct
 		CopyDlls( dllsDir )
 		CopyDlls( dllsDir )
 		
 		
 		Exec( cmd )
 		Exec( cmd )
+		
+		If opts.target="emscripten"
+			If opts.appType="wasm"
+				DeleteFile( StripExt( outputFile )+".asm.js" )
+			Endif
+		Endif
 
 
 	End
 	End
 	
 	

+ 17 - 9
src/mx2cc/mx2cc.monkey2

@@ -23,7 +23,7 @@ Global StartDir:String
 
 
 'Const TestArgs:="mx2cc makemods"
 'Const TestArgs:="mx2cc makemods"
 
 
-Const TestArgs:="mx2cc makeapp -target=desktop -apptype=console -run src/mx2cc/test.monkey2"
+Const TestArgs:="mx2cc makeapp -target=emscripten -apptype=wasm+asmjs src/mx2cc/test.monkey2"
 
 
 'Const TestArgs:="mx2cc makedocs mojo3d"
 'Const TestArgs:="mx2cc makedocs mojo3d"
 
 
@@ -381,18 +381,13 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 		Case "-product"
 		Case "-product"
 			opts.product=path
 			opts.product=path
 		Case "-apptype"
 		Case "-apptype"
-			Select val
-			Case "gui","console"
-				opts.appType=val
-			Default
-				Fail( "Invalid value for 'apptype' option: '"+val+"' - must be 'gui' or 'console'" )
-			End
+			opts.appType=val
 		Case "-target"
 		Case "-target"
 			Select val
 			Select val
-			Case "desktop","windows","macos","linux","raspbian","emscripten","wasm","android","ios"
+			Case "desktop","windows","macos","linux","raspbian","emscripten","android","ios"
 				opts.target=val
 				opts.target=val
 			Default
 			Default
-				Fail( "Invalid value for 'target' option: '"+val+"' - must be 'desktop', 'raspbian', 'emscripten', 'wasm', 'android' or 'ios'" )
+				Fail( "Invalid value for 'target' option: '"+val+"' - must be 'desktop', 'raspbian', 'emscripten', 'android' or 'ios'" )
 			End
 			End
 		Case "-config"
 		Case "-config"
 			Select val
 			Select val
@@ -414,6 +409,19 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 	
 	
 	Next
 	Next
 	
 	
+	Select opts.appType
+	Case "console","gui"
+		Select opts.target
+		Case "desktop","windows","macos","linux","raspbian"
+		Default
+			Fail( "apptype '"+opts.appType+"' may ponly be used with desktop targets" )
+		End
+	case "wasm","asmjs","wasm+asmjs"
+		If opts.target<>"emscripten" Fail( "apptype '"+opts.appType+"' is only valid for emscripten target" )
+	Default
+		Fail( "Unrecognized apptype '"+opts.appType+"'" )
+	End
+		
 	Return Null
 	Return Null
 End
 End
 
 

+ 1 - 3
src/mx2cc/test.monkey2

@@ -1,8 +1,6 @@
 
 
 Function Main()
 Function Main()
 	
 	
-	Local t:=-.1
-	
-	Print t
+	Print "Hello World!"
 
 
 End
 End

+ 0 - 6
src/mx2cc/var.monkey2

@@ -73,12 +73,6 @@ Class VarValue Extends Value
 	
 	
 	Method OnSemant:SNode() Override
 	Method OnSemant:SNode() Override
 		
 		
-		Select vdecl.ident
-		Case "B","D"
-			Print "Semanting "+vdecl.ident
-			Print "scope="+Cast<ClassScope>( scope ).ctype.ToString()
-		End
-	
 		Scope.semanting.Push( scope )
 		Scope.semanting.Push( scope )
 		
 		
 		If vdecl.type
 		If vdecl.type

+ 1 - 16
src/ted2/buildactions.monkey2

@@ -109,9 +109,6 @@ Class BuildActions
 		_emscriptenTarget=New CheckButton( "Emscripten",,group )
 		_emscriptenTarget=New CheckButton( "Emscripten",,group )
 		_emscriptenTarget.Layout="fill-x"
 		_emscriptenTarget.Layout="fill-x"
 		
 		
-		_wasmTarget=New CheckButton( "Wasm",,group )
-		_wasmTarget.Layout="fill-x"
-		
 		_androidTarget=New CheckButton( "Android",,group )
 		_androidTarget=New CheckButton( "Android",,group )
 		_androidTarget.Layout="fill-x"
 		_androidTarget.Layout="fill-x"
 		
 		
@@ -124,7 +121,6 @@ Class BuildActions
 		targetMenu.AddSeparator()
 		targetMenu.AddSeparator()
 		targetMenu.AddView( _desktopTarget )
 		targetMenu.AddView( _desktopTarget )
 		targetMenu.AddView( _emscriptenTarget )
 		targetMenu.AddView( _emscriptenTarget )
-		targetMenu.AddView( _wasmTarget )
 		targetMenu.AddView( _androidTarget )
 		targetMenu.AddView( _androidTarget )
 		targetMenu.AddView( _iosTarget )
 		targetMenu.AddView( _iosTarget )
 		targetMenu.AddSeparator()
 		targetMenu.AddSeparator()
@@ -152,14 +148,6 @@ Class BuildActions
 			_emscriptenTarget.Enabled=False
 			_emscriptenTarget.Enabled=False
 		Endif
 		Endif
 
 
-		If _validTargets.Contains( "wasm" )
-			_wasmTarget.Clicked+=Lambda()
-				_buildTarget="wasm"
-			End
-		Else
-			_wasmTarget.Enabled=False
-		Endif
-
 		If _validTargets.Contains( "android" )
 		If _validTargets.Contains( "android" )
 			_androidTarget.Clicked+=Lambda()
 			_androidTarget.Clicked+=Lambda()
 				_buildTarget="android"
 				_buildTarget="android"
@@ -218,8 +206,6 @@ Class BuildActions
 					_desktopTarget.Checked=True
 					_desktopTarget.Checked=True
 				Case "emscripten"
 				Case "emscripten"
 					_emscriptenTarget.Checked=True
 					_emscriptenTarget.Checked=True
-				Case "wasm"
-					_wasmTarget.Checked=True
 				Case "android"
 				Case "android"
 					_androidTarget.Checked=True
 					_androidTarget.Checked=True
 				Case "ios"
 				Case "ios"
@@ -267,7 +253,6 @@ Class BuildActions
 	Field _releaseConfig:CheckButton
 	Field _releaseConfig:CheckButton
 	Field _desktopTarget:CheckButton
 	Field _desktopTarget:CheckButton
 	Field _emscriptenTarget:CheckButton
 	Field _emscriptenTarget:CheckButton
-	Field _wasmTarget:CheckButton
 	Field _androidTarget:CheckButton
 	Field _androidTarget:CheckButton
 	Field _iosTarget:CheckButton
 	Field _iosTarget:CheckButton
 	
 	
@@ -475,7 +460,7 @@ Class BuildActions
 
 
 			_debugView.DebugApp( exeFile,config )
 			_debugView.DebugApp( exeFile,config )
 
 
-		Case "emscripten","wasm"
+		Case "emscripten"
 		
 		
 			Local mserver:=GetEnv( "MX2_MSERVER" )
 			Local mserver:=GetEnv( "MX2_MSERVER" )
 			If mserver _console.Run( mserver+" ~q"+exeFile+"~q" )
 			If mserver _console.Run( mserver+" ~q"+exeFile+"~q" )

+ 8 - 3
src/ted2/buildproduct.monkey2

@@ -38,8 +38,6 @@ Class BuildProduct
 #endif
 #endif
 		Case "emscripten"
 		Case "emscripten"
 			product=New EmscriptenProduct( srcPath )
 			product=New EmscriptenProduct( srcPath )
-		Case "wasm"
-			product=New WasmProduct( srcPath )
 		Case "android"
 		Case "android"
 			product=New AndroidProduct( srcPath )
 			product=New AndroidProduct( srcPath )
 		Case "ios"
 		Case "ios"
@@ -434,6 +432,8 @@ Class EmscriptenProduct Extends BuildProduct
 		Super.New( srcPath,"emscripten" )
 		Super.New( srcPath,"emscripten" )
 
 
 		AddExts( New String[]( ".html" ) )
 		AddExts( New String[]( ".html" ) )
+		
+		AddVar( "Application Type","asmjs","options:asmjs|wasm|wasm+asmjs" )
 	End
 	End
 	
 	
 	Protected
 	Protected
@@ -454,10 +454,13 @@ Class EmscriptenProduct Extends BuildProduct
 	
 	
 	Method OnGetMx2ccOpts:String() Override
 	Method OnGetMx2ccOpts:String() Override
 
 
+		Local appType:=GetVar( "APPLICATION_TYPE" )
+
 		Local opts:=""
 		Local opts:=""
 		
 		
 		opts+=" ~q-product="+ProductDir+AppName+".js~q"
 		opts+=" ~q-product="+ProductDir+AppName+".js~q"
-		
+		opts+=" -apptype="+appType
+
 		Return opts
 		Return opts
 	End
 	End
 
 
@@ -468,6 +471,7 @@ Class EmscriptenProduct Extends BuildProduct
 	End
 	End
 End
 End
 
 
+#rem
 Class WasmProduct Extends BuildProduct
 Class WasmProduct Extends BuildProduct
 
 
 	Method New( srcPath:String )
 	Method New( srcPath:String )
@@ -507,6 +511,7 @@ Class WasmProduct Extends BuildProduct
 	
 	
 	End
 	End
 End
 End
+#end
 
 
 Class AndroidProduct Extends BuildProduct
 Class AndroidProduct Extends BuildProduct
 
 

+ 10 - 1
src/ted2/mainwindow.monkey2

@@ -14,6 +14,11 @@ Class MainWindowInstance Extends Window
 		
 		
 		MainWindow=Self
 		MainWindow=Self
 		
 		
+		If Not App.Theme.Load( jobj.GetString( "theme" ) )
+			jobj.SetString( "theme","ted2-default" )
+			App.Theme.Load( "ted2-default" )
+		Endif
+		
 		_tmp=RealPath( "tmp/" )
 		_tmp=RealPath( "tmp/" )
 		
 		
 #If __TARGET__="macos"
 #If __TARGET__="macos"
@@ -630,7 +635,11 @@ Class MainWindowInstance Extends Window
 			Local value:=it.Value.ToString()
 			Local value:=it.Value.ToString()
 			menu.AddAction( name ).Triggered=Lambda()
 			menu.AddAction( name ).Triggered=Lambda()
 				_theme=value
 				_theme=value
-				App.Theme.Load( _theme,New Vec2f( _themeScale ) )
+				If Not App.Theme.Load( _theme,New Vec2f( _themeScale ) )
+					If Not App.Theme.Load( "ted2-default" )
+					Endif
+					_theme="ted2-default"
+				Endif
 				SaveState()
 				SaveState()
 			End
 			End
 		Next
 		Next

+ 0 - 1
src/ted2/mx2ccenv.monkey2

@@ -90,7 +90,6 @@ Function EnumValidTargets:StringStack( console:Console )
 	
 	
 	targets.Push( "desktop" )
 	targets.Push( "desktop" )
 	targets.Push( "emscripten" )
 	targets.Push( "emscripten" )
-	targets.Push( "wasm" )
 	targets.Push( "android" )
 	targets.Push( "android" )
 #If __TARGET__="macos"
 #If __TARGET__="macos"
 	targets.Push( "ios" )
 	targets.Push( "ios" )

+ 2 - 2
src/ted2/ted2.monkey2

@@ -81,8 +81,8 @@ Function Main()
 	
 	
 	Local config:=New StringMap<String>
 	Local config:=New StringMap<String>
 	
 	
-	config["initialTheme"]=jobj.GetString( "theme" )
-	config["initialThemeScale"]=jobj.GetNumber( "themeScale" )
+	'config["initialTheme"]=jobj.GetString( "theme" )
+	'config["initialThemeScale"]=jobj.GetNumber( "themeScale" )
 	
 	
 	'initial window state
 	'initial window state
 	'
 	'