diff --git a/build.psm1 b/build.psm1 index f4d4bd1f84..990f0d37e6 100644 --- a/build.psm1 +++ b/build.psm1 @@ -93,6 +93,13 @@ function Start-PSBuild { } $precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.') + + #mc.exe is Message Compiler for native resources + $mcexe = Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\" -Recurse -Filter 'mc.exe' | ? {$_.FullName -match 'x64'} | select -First 1 | % {$_.FullName} + if (-not $mcexe) { + throw 'mc.exe not found. Install Microsoft Windows SDK.' + } + } elseif ($IsLinux -or $IsOSX) { $InstallCommand = if ($IsLinux) { 'apt-get' @@ -182,6 +189,14 @@ function Start-PSBuild { try { Push-Location "$PSScriptRoot\src\powershell-native" + # Compile native resources + @("nativemsh/pwrshplugin") | % { + $nativeResourcesFolder = $_ + Get-ChildItem $nativeResourcesFolder -Filter "*.mc" | % { + & $mcexe -c -U $_.FullName -h $nativeResourcesFolder -r $nativeResourcesFolder + } + } + if ($cmakeGenerator) { cmake -G $cmakeGenerator . } else { @@ -189,6 +204,7 @@ function Start-PSBuild { } Start-NativeExecution { msbuild powershell.vcxproj /p:Configuration=$msbuildConfiguration } + Start-NativeExecution { msbuild pwrshmsg.vcxproj /p:Configuration=$msbuildConfiguration } } finally { Pop-Location diff --git a/src/powershell-native/.gitignore b/src/powershell-native/.gitignore index 4f159ef0a7..0c47ffe29d 100644 --- a/src/powershell-native/.gitignore +++ b/src/powershell-native/.gitignore @@ -8,6 +8,11 @@ x64/ ZERO_CHECK.vcxproj ZERO_CHECK.vcxproj.filters cmake_install.cmake -powershell.dir/ -powershell.vcxproj -powershell.vcxproj.filters +*.dir/ +*.vcxproj +*.vcxproj.filters + +# Resources +MSG*.bin +pwrshpluginerrorcodes.h +pwrshpluginerrorcodes.rc \ No newline at end of file diff --git a/src/powershell-native/CMakeLists.txt b/src/powershell-native/CMakeLists.txt index 885acfcbef..259030d672 100644 --- a/src/powershell-native/CMakeLists.txt +++ b/src/powershell-native/CMakeLists.txt @@ -16,7 +16,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") include_directories( - nativemsh/pwrshcommon) + nativemsh/pwrshcommon + nativemsh/pwrshplugin) link_directories( nativemsh/pwrshcommon) @@ -27,9 +28,14 @@ add_definitions(-D_UNICODE) add_executable(powershell WIN32 nativemsh/pwrshcommon/pwrshcommon.cpp nativemsh/pwrshcommon/WinSystemCallFacade.cpp - nativemsh/pwrshexe/MainEntry.cpp) +add_library(pwrshmsg + nativemsh/pwrshplugin/entrypoints.cpp + nativemsh/pwrshplugin/pwrshclrhost.cpp + nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc + nativemsh/pwrshplugin/pwrshpluginerrorcodes.rc) + # This subsystem definition is using old policy. TODO: figure out for release and the rest set_target_properties(powershell PROPERTIES COMPILE_DEFINITIONS "_CONSOLE") set_target_properties(powershell PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") @@ -44,3 +50,11 @@ target_link_libraries(powershell kernel32.lib msxml6.lib legacy_stdio_definitions.lib) + +target_link_libraries(pwrshmsg + mscoree.lib + MUILoad.lib + kernel32.lib + msxml6.lib + legacy_stdio_definitions.lib) + diff --git a/src/powershell-native/map.json b/src/powershell-native/map.json index cdcb1cc0ed..a1d67a7940 100644 --- a/src/powershell-native/map.json +++ b/src/powershell-native/map.json @@ -8,5 +8,16 @@ "monad/nttargets/assemblies/nativemsh/pwrshcommon/WinSystemCallFacade.h": "nativemsh/pwrshcommon/WinSystemCallFacade.h", "monad/nttargets/assemblies/nativemsh/pwrshcommon/IPwrshCommonOutput.h": "nativemsh/pwrshcommon/IPwrshCommonOutput.h", "monad/nttargets/assemblies/nativemsh/pwrshexe/MainEntry.cpp": "nativemsh/pwrshexe/MainEntry.cpp", - "monad/nttargets/assemblies/nativemsh/pwrshcommon/ClrHostWrapper.h": "nativemsh/pwrshcommon/ClrHostWrapper.h" + "monad/nttargets/assemblies/nativemsh/pwrshcommon/ClrHostWrapper.h": "nativemsh/pwrshcommon/ClrHostWrapper.h", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/entrypoints.cpp": "nativemsh/pwrshplugin/entrypoints.cpp", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshclrhost.cpp": "nativemsh/pwrshplugin/pwrshclrhost.cpp", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc": "nativemsh/pwrshplugin/pwrshpluginerrorcodes.mc", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshpluginResources.rc": "nativemsh/pwrshplugin/pwrshpluginResources.rc", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugin.dll.manifest": "nativemsh/pwrshplugin/pwrshplugin.dll.manifest", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/version.rc": "nativemsh/pwrshplugin/version.rc", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/entrypoints.h": "nativemsh/pwrshplugin/entrypoints.h", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshclrhost.h": "nativemsh/pwrshplugin/pwrshclrhost.h", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshheaders.h": "nativemsh/pwrshplugin/pwrshheaders.h", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugin.h": "nativemsh/pwrshplugin/pwrshplugin.h", + "monad/nttargets/assemblies/nativemsh/pwrshplugin/pwrshplugindefs.h": "nativemsh/pwrshplugin/pwrshplugindefs.h" }