瀏覽代碼

Added msvc autodetect.

Mark Sibly 7 年之前
父節點
當前提交
9b10cf600e
共有 6 個文件被更改,包括 139 次插入55 次删除
  1. 2 0
      VERSIONS.TXT
  2. 40 41
      bin/env_windows.txt
  3. 5 3
      src/createrelease/createrelease.monkey2
  4. 79 0
      src/mx2cc/findmsvc.monkey2
  5. 12 3
      src/mx2cc/mx2cc.monkey2
  6. 1 8
      src/mx2cc/test.monkey2

+ 2 - 0
VERSIONS.TXT

@@ -1,6 +1,8 @@
 
 ***** Monkey-v2018.07 ***** 
 
+Added thread support and std.thread module!
+
 Updated android SDK to: Android Studio 3.1.3 ; Android SDK 27 (Oreo 8.1) ; NDK 17.1.4828580 ; Android SDK Tools 26.1.1
 
 Added simple FXAAEffect post effect for simple antialiasing - see modules/mojo3d/tests/effects.monkey2

+ 40 - 41
bin/env_windows.txt

@@ -1,4 +1,11 @@
-'Use msvc 2017 community edition (mainly for x64 support, but it's also the latest/greatest).
+
+'Hyper experimental thread builds!
+'
+MX2_THREADS=1
+
+'Use MX2_USE_MSVC=1 to force use of msvc, or MX2_USE_MSVC=0 to force use of mingw.
+'
+'If MX2_USE_MSVC is not set, mx2cc will attempt to autodetect msvc.
 '
 MX2_USE_MSVC=0
 
@@ -41,38 +48,21 @@ MX2_CPP_OPTS_WINDOWS=-std=c++11 -D_WIN32_WINNT=0x0603 -m32
 MX2_CPP_OPTS_WINDOWS_DEBUG=-O2
 MX2_CPP_OPTS_WINDOWS_RELEASE=-O3 -DNDEBUG
 
+
 '***** WINDOWS DESKTOP TARGET - MSVC *****
 
-'directories
+'Note: these paths are only used if legacy MX2_USE_MSVC=1
+'
+'If MX2_USE_MSVC is not set, mx2cc attempts to autodetect latest version of msvc and latest windows kit.
+'
 MX2_MSVC_DIR=${ProgramFiles(x86)}\Microsoft Visual Studio\2017\Community\VC
 
-'For Visual Studio Community Edition 2017 15.6.2
-MX2_MSVC_TOOLS_DIR=${MX2_MSVC_DIR}\Tools\MSVC\14.13.26128
+MX2_MSVC_TOOLS_DIR=${MX2_MSVC_DIR}\Tools\MSVC\14.14.26428
 
 MX2_WINDOWS_KITS_DIR=${ProgramFiles(x86)}\Windows Kits\10
 
 MX2_WINDOWS_KIT=10.0.16299.0
 
-'Linker options
-MX2_LD_OPTS_MSVC=
-MX2_LD_OPTS_MSVC_DEBUG=
-MX2_LD_OPTS_MSVC_RELEASE=
-
-'C Compiler options
-MX2_CC_OPTS_MSVC=-EHs -W0 -MT -utf-8 -bigobj
-MX2_CC_OPTS_MSVC_DEBUG=-O1
-MX2_CC_OPTS_MSVC_RELEASE=-O2 -DNDEBUG
-
-'C++ Compiler options
-MX2_CPP_OPTS_MSVC=-EHs -W0 -MT -utf-8 -bigobj
-MX2_CPP_OPTS_MSVC_DEBUG=-O1
-MX2_CPP_OPTS_MSVC_RELEASE=-O2 -DNDEBUG
-
-'assembler opts
-MX2_AS_OPTS_MSVC=-DBOOST_CONTEXT_EXPORT=
-
-'***** MSVC X86 PATHS *****
-
 MX2_MSVC_PATH_X86=${MX2_MSVC_TOOLS_DIR}\bin\Hostx86\x86
 
 MX2_MSVC_INCLUDE_X86=${MX2_MSVC_TOOLS_DIR}\include;
@@ -84,8 +74,6 @@ MX2_MSVC_LIB_X86=${MX2_MSVC_TOOLS_DIR}\lib\x86;
 MX2_MSVC_LIB_X86=${MX2_MSVC_LIB_X86}${MX2_WINDOWS_KITS_DIR}\Lib\${MX2_WINDOWS_KIT}\ucrt\x86;
 MX2_MSVC_LIB_X86=${MX2_MSVC_LIB_X86}${MX2_WINDOWS_KITS_DIR}\Lib\${MX2_WINDOWS_KIT}\um\x86;
 
-'***** MSVC X64 PATHS *****
-
 MX2_MSVC_PATH_X64=${MX2_MSVC_TOOLS_DIR}\bin\Hostx64\x64
 
 MX2_MSVC_INCLUDE_X64=${MX2_MSVC_TOOLS_DIR}\include;
@@ -97,6 +85,27 @@ MX2_MSVC_LIB_X64=${MX2_MSVC_TOOLS_DIR}\lib\x64;
 MX2_MSVC_LIB_X64=${MX2_MSVC_LIB_X64}${MX2_WINDOWS_KITS_DIR}\Lib\${MX2_WINDOWS_KIT}\ucrt\x64;
 MX2_MSVC_LIB_X64=${MX2_MSVC_LIB_X64}${MX2_WINDOWS_KITS_DIR}\Lib\${MX2_WINDOWS_KIT}\um\x64;
 
+'***** MSVC COMMAND LINE OPTIONS *****
+
+'Linker options
+MX2_LD_OPTS_MSVC=user32.lib
+MX2_LD_OPTS_MSVC_DEBUG=
+MX2_LD_OPTS_MSVC_RELEASE=
+
+'C Compiler options
+MX2_CC_OPTS_MSVC=-EHs -W0 -MT -utf-8 -bigobj
+MX2_CC_OPTS_MSVC_DEBUG=-O1
+MX2_CC_OPTS_MSVC_RELEASE=-O2 -DNDEBUG
+
+'C++ Compiler options
+MX2_CPP_OPTS_MSVC=-EHs -W0 -MT -utf-8 -bigobj
+MX2_CPP_OPTS_MSVC_DEBUG=-O1
+MX2_CPP_OPTS_MSVC_RELEASE=-O2 -DNDEBUG
+
+'assembler opts
+MX2_AS_OPTS_MSVC=-DBOOST_CONTEXT_EXPORT=
+
+
 '***** EMSCRIPTEN TARGET *****
 
 'This is for the emsdk download available at http://monkeycoder.co.nz/monkey2-files/
@@ -146,26 +155,16 @@ MX2_CPP_OPTS_EMSCRIPTEN_RELEASE=-O3 -DNDEBUG
 
 'This is where *my* ndk-bundle is located - yours is probably somewhere else!
 '
-'For android builds, you need to either set this correctly or make sure 'ndk-build' is available from the command line.
+'For android builds, you need to either set this correctly or make sure 'ndk-build' is available from the command line via you PATH.
 '
 'PATH=D:\devtools\Android\sdk\ndk-bundle;${PATH}
 
-'Controls APP_ABI in Application.mk for NDK
-'
-MX2_ANDROID_APP_ABI=armeabi-v7a x86
-'MX2_ANDROID_APP_ABI=all
-
-'Controls APP_PLATFORM in Application.mk for NDK
+'Application.mk
 '
+MX2_ANDROID_APP_CFLAGS=-std=gnu99 -fno-stack-protector
+MX2_ANDROID_APP_CPPFLAGS=-std=c++11 -fno-stack-protector -frtti -fexceptions
 MX2_ANDROID_APP_PLATFORM=android-14
-
-'Android app compiler Compiler flags
-'
-MX2_ANDROID_APP_CFLAGS=-std=gnu99 -fno-stack-protector -w
-MX2_ANDROID_APP_CPPFLAGS=-std=c++11 -fno-stack-protector -frtti -fexceptions -w
-
-'Controls version of STL used by android apps.
-'
+MX2_ANDROID_APP_ABI=armeabi-v7a x86
 MX2_ANDROID_APP_STL=c++_static
 
 '***** RASPBIAN *****

+ 5 - 3
src/createrelease/createrelease.monkey2

@@ -5,9 +5,9 @@
 Using libc..
 Using std..
 
-Const MONKEY2_VERSION:="2018.06"
+Const MONKEY2_VERSION:="2018.07"
 
-Const MX2CC_VERSION:="1.1.14"
+Const MX2CC_VERSION:="1.1.15"
 
 Const RELEASE_SUFFIX:=""
 
@@ -91,10 +91,12 @@ Function CopyFiles( dir:String )
 				
 			Else If dir.Contains( ".buildv" )
 				
+				If Not file.EndsWith( "_mx" ) Continue
+				
 				If file.StartsWith( "emscripten_" ) Continue
 				If file.StartsWith( "android_" ) Continue
 				If file.StartsWith( "ios_" ) Continue
-				If file.EndsWith( "_msvc" )  Continue
+'				If file.EndsWith( "_msvc" )  Continue
 				If file.EndsWith( "_x64" ) Continue
 				If file="build" Continue
 				If file="src" Continue

+ 79 - 0
src/mx2cc/findmsvc.monkey2

@@ -0,0 +1,79 @@
+
+Namespace mx2cc
+
+#If __TARGET__="windows"
+
+Function FindMSVC:Bool()
+
+	Local msvcs:=GetEnv( "ProgramFiles(x86)" )+"\Microsoft Visual Studio\2017"
+	If GetFileType( msvcs )<>FileType.Directory Return False
+	
+	Local wkits:=GetEnv( "ProgramFiles(x86)" )+"\Windows Kits\10"
+	If GetFileType( wkits )<>FileType.Directory Return False
+	
+	Local toolsDir:="",maxver:=0
+	
+	For Local f:=Eachin LoadDir( msvcs )
+		
+		Local dir:=msvcs+"\"+f+"\VC\Tools\MSVC"
+		If GetFileType( dir )<>FileType.Directory Continue
+		
+		For Local f:=Eachin LoadDir( dir )
+			Local verDir:=dir+"\"+f
+			If GetFileType( verDir )<>FileType.Directory Continue
+			Local ver:=Int( f.Replace( ".","" ) )
+			If ver>maxver
+				toolsDir=verDir
+				maxver=ver
+			Endif
+		Next
+	Next
+
+	Local incsDir:=FindMaxVerDir( wkits+"\Include" )
+	If Not incsDir Return False
+
+	Local libsDir:=FindMaxVerDir( wkits+"\Lib" )
+	If Not libsDir Return False
+	
+'	Print toolsDir
+'	Print incsDir
+'	Print libsDir
+	
+	SetEnv( "MX2_MSVC_PATH_X86",toolsDir+"\bin\Hostx86\x86" )
+	SetEnv( "MX2_MSVC_INCLUDE_X86",toolsDir+"\include;"+incsDir+"\ucrt;"+incsDir+"\shared;"+incsDir+"\um" )
+	SetEnv( "MX2_MSVC_LIB_X86",toolsDir+"\lib\x86;"+libsDir+"\ucrt\x86;"+libsDir+"\um\x86" )
+	
+	SetEnv( "MX2_MSVC_PATH_X64",toolsDir+"\bin\Hostx64\x64" )
+	SetEnv( "MX2_MSVC_INCLUDE_X64",toolsDir+"\include;"+incsDir+"\ucrt;"+incsDir+"\shared;"+incsDir+"\um" )
+	SetEnv( "MX2_MSVC_LIB_X64",toolsDir+"\lib\x64;"+libsDir+"\ucrt\x64;"+libsDir+"\um\x64" )
+	
+	Return True
+End
+
+Function FindMaxVerDir:String( dir:String )
+	
+	Local maxver:Long=0,maxverDir:=""
+	
+	For Local f:=Eachin LoadDir( dir )
+		
+		Local verDir:=dir+"\"+f
+		If GetFileType( verDir )<>FileType.Directory Continue
+		
+		Local ver:Long=Int( f.Replace( ".","" ) )
+		
+		If ver>maxver
+			maxver=ver
+			maxverDir=verDir
+		Endif
+	Next
+	
+	Return maxverDir
+End
+
+#else
+
+Function FindMSVC:Bool()
+	Return False
+End
+
+#endif

+ 12 - 3
src/mx2cc/mx2cc.monkey2

@@ -4,6 +4,7 @@ Namespace mx2cc
 #Import "<std>"
 
 #Import "mx2"
+#Import "findmsvc"
 
 #Import "newdocs/docsnode"
 #Import "newdocs/docsbuffer"
@@ -24,9 +25,9 @@ Global StartDir:String
 
 Global profileName:String
 
-'Const TestArgs:="mx2cc makemods"
+Const TestArgs:="mx2cc makemods"
 
-Const TestArgs:="mx2cc geninfo -semant src/mx2cc/test.monkey2"
+'Const TestArgs:="mx2cc makeapp src/mx2cc/test.monkey2"
 
 Function Main()
 	
@@ -494,7 +495,15 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 			Fail( "Unrecognized architecture '"+opts.arch+"'" )
 		Endif
 		
-		If Int( GetEnv( "MX2_USE_MSVC" ) )
+'		Print "MX2_USE_MSVC='"+GetEnv( "MX2_USE_MSVC" )+"'"
+		
+		Local msvc:=GetEnv( "MX2_USE_MSVC" )
+		
+		If msvc=""
+			msvc=FindMSVC() ? "1" Else "0"
+		Endif
+		
+		If Int( msvc )
 			
 			opts.toolchain="msvc"
 			

+ 1 - 8
src/mx2cc/test.monkey2

@@ -1,11 +1,4 @@
 
-#Import "<box2d>"
-
-Using std..
-Using mojo..
-Using box2d..
-
 Function Main()
-	Test()
-    Print "monkey2 box2d text simple test"
+	Print "Hello World!"
 End