Enable native test binaries to be built for Arm64
authorRama Krishnan Raghupathy <ramarag@microsoft.com>
Wed, 9 Mar 2016 02:26:13 +0000 (18:26 -0800)
committerRama Krishnan Raghupathy <ramarag@microsoft.com>
Wed, 9 Mar 2016 22:27:22 +0000 (14:27 -0800)
build.cmd
netci.groovy
tests/CMakeLists.txt
tests/buildtest.cmd
tests/src/Interop/common/xplatform.h

index 4f3d410..3b9c8d1 100644 (file)
--- a/build.cmd
+++ b/build.cmd
@@ -181,9 +181,6 @@ set "__TestRootDir=%__RootBinDir%\tests"
 set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
 set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
 
-:: Use this variable to locate dynamically generated files; the actual location though will be different.
-set "__GeneratedIntermediatesDir=%__IntermediatesDir%\Generated_latest"
-
 :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
 set "__CMakeBinDir=%__BinDir%"
 set "__CMakeBinDir=%__CMakeBinDir:\=/%"
@@ -278,28 +275,13 @@ echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__Build
 REM Use setlocal to restrict environment changes form vcvarsall.bat and more to just this native components build section.
 setlocal EnableDelayedExpansion EnableExtensions
 
-if /i not "%__BuildArch%" == "arm64" goto NotArm64Build
-
+if /i "%__BuildArch%" == "arm64" ( 
 rem arm64 builds currently use private toolset which has not been released yet
 REM TODO, remove once the toolset is open.
-
-if /i "%__ToolsetDir%" == "" (
-    echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.
-    exit /b 1
-)
-
-set PATH=%PATH%;%__ToolsetDir%\cpp\bin
-set LIB=%__ToolsetDir%\OS\lib;%__ToolsetDir%\cpp\lib
-set INCLUDE=^
-%__ToolsetDir%\cpp\inc;^
-%__ToolsetDir%\OS\inc\Windows;^
-%__ToolsetDir%\OS\inc\Windows\crt;^
-%__ToolsetDir%\cpp\inc\vc;^
-%__ToolsetDir%\OS\inc\win8
+call :PrivateToolSet
 
 goto GenVSSolution
-
-:NotArm64Build
+)
 
 :: Set the environment for the native build
 set __VCBuildArch=x86_amd64
@@ -509,6 +491,10 @@ if defined __TestPriority (
     set "__BuildtestArgs=%__BuildtestArgs% Priority %__TestPriority%"
 )
 
+rem arm64 builds currently use private toolset which has not been released yet
+REM TODO, remove once the toolset is open.
+if /i "%__BuildArch%" == "arm64" call :PrivateToolSet 
+
 call %__ProjectDir%\tests\buildtest.cmd %__BuildtestArgs%
 
 if errorlevel 1 (
@@ -676,3 +662,22 @@ echo Visual Studio Express does not include the DIA SDK. ^
 You need Visual Studio 2015+ (Community is free).
 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
 exit /b 1
+
+:PrivateToolSet
+
+echo %__MsgPrefix% Setting Up the usage of __ToolsetDir:%__ToolsetDir%
+
+if /i "%__ToolsetDir%" == "" (
+    echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.
+    exit /b 1
+)
+
+set PATH=%PATH%;%__ToolsetDir%\cpp\bin
+set LIB=%__ToolsetDir%\OS\lib;%__ToolsetDir%\cpp\lib
+set INCLUDE=^
+%__ToolsetDir%\cpp\inc;^
+%__ToolsetDir%\OS\inc\Windows;^
+%__ToolsetDir%\OS\inc\Windows\crt;^
+%__ToolsetDir%\cpp\inc\vc;^
+%__ToolsetDir%\OS\inc\win8
+exit /b 0
index e8f9f4c..24fe4c4 100644 (file)
@@ -844,7 +844,7 @@ combinedScenarios.each { scenario ->
                                     break
                                 case 'arm64':
                                     assert scenario == 'default'
-                                    buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} skiptestbuild /toolset_dir C:\\ats"
+                                    buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} /toolset_dir C:\\ats"
 
                                     if (lowerConfiguration == "release") {
                                        buildCommands += "C:\\arm64PostBuild.cmd %WORKSPACE% ${architecture} ${lowerConfiguration}"
index 119266c..813d973 100644 (file)
@@ -12,6 +12,23 @@ set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "")
 set(INC_PLATFORM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Common/Platform)
 if (WIN32)
     add_definitions(-DWINDOWS=1)
+
+    if (DEFINED ENV{__ToolsetDir})
+        # Hack for private Tool Set
+        # CMAKE_CXX_COMPILER will default to the compiler installed with
+        # Visual studio. Overwrite it to the compiler on the path.
+
+        find_program(PATH_CXX_COMPILER cl)
+        set(CMAKE_CXX_COMPILER ${PATH_CXX_COMPILER})
+
+        message("Overwriting the CMAKE_CXX_COMPILER.")
+        message("CMAKE_CXX_COMPILER found:${CMAKE_CXX_COMPILER}")
+      
+        # Temporary until cmake has VS generators for hacky toolsets [arm64]
+        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
+        set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
+        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /machine:${CLR_CMAKE_TARGET_ARCH}")
+    endif()
 endif()
 
 # Compile options
index cdb3948..eb92ee6 100644 (file)
@@ -96,7 +96,7 @@ set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
 if not defined __TestIntermediateDir (
     set "__TestIntermediateDir=tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
 )
-set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDirDir%\Native"
+set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native"
 set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed"
 
 :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
@@ -181,6 +181,11 @@ setlocal EnableDelayedExpansion
 
 echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%__BuildType%
 
+if defined __ToolsetDir (
+ echo %__MsgPrefix%ToolsetDir is defined to be :%__ToolsetDir%
+ goto GenVSSolution :: Private ToolSet is Defined
+)
+
 :: Set the environment for the native build
 echo %__MsgPrefix%Using environment: "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" %__VCBuildArch%
 call                                 "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" x86_amd64
@@ -192,7 +197,8 @@ if not defined VSINSTALLDIR (
 )
 if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
 
-echo %__MsgPrefix%Regenerating the Visual Studio solution
+:GenVSSolution
+echo %__MsgPrefix%Regenerating the Visual Studio solution in %__NativeTestIntermediatesDir%
 
 pushd "%__NativeTestIntermediatesDir%"
 call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectFilesDir%\" %__VSVersion% %__BuildArch%
@@ -204,10 +210,17 @@ if not exist "%__NativeTestIntermediatesDir%\install.vcxproj" (
     exit /b 1
 )
 
+set __msbuildNativeArgs=%__msbuildCleanBuildArgs% /p:Configuration=%__BuildType%
+
+if defined __ToolsetDir (
+    set __msbuildNativeArgs=%__msbuildNativeArgs% /p:UseEnv=true
+) else (
+    set __msbuildNativeArgs=%__msbuildNativeArgs% /p:Platform=%__BuildArch%
+)
+
 set __BuildLogRootName=Tests_Native
-call :msbuild "%__NativeTestIntermediatesDir%\install.vcxproj" %__msbuildCleanBuildArgs% /p:Configuration=%__BuildType% /p:Platform=%__BuildArch%
+call :msbuild "%__NativeTestIntermediatesDir%\install.vcxproj" %__msbuildNativeArgs%
 if errorlevel 1 exit /b 1
-
 REM endlocal to rid us of environment changes from vcvarsall.bat
 endlocal
 
index 3d30f0b..e830327 100644 (file)
 // dllexport
 #if defined _WIN32
 #define DLL_EXPORT __declspec(dllexport)
+
+#ifndef snprintf
+#define snprintf _snprintf
+#endif //snprintf
+
 #else //!_Win32
 #if __GNUC__ >= 4    
 #define DLL_EXPORT __attribute__ ((visibility ("default")))