Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eng
diff options
context:
space:
mode:
authorElinor Fung <elfung@microsoft.com>2022-03-08 20:14:43 +0300
committerGitHub <noreply@github.com>2022-03-08 20:14:43 +0300
commit627851323fe8f15539c163aabd7d7c644766c549 (patch)
tree3c78a019d87eee41fcfdc0d78042955da7676408 /eng
parentfa5dcda23c681031b5d2bd68482702baef80b836 (diff)
Add tests for `ijwhost` (#66308)
Diffstat (limited to 'eng')
-rw-r--r--eng/native/ijw/IJW.cmake81
-rw-r--r--eng/native/ijw/getRefPackFolderFromArtifacts.ps121
-rw-r--r--eng/native/ijw/getRefPackFolderFromSdk.ps127
3 files changed, 129 insertions, 0 deletions
diff --git a/eng/native/ijw/IJW.cmake b/eng/native/ijw/IJW.cmake
new file mode 100644
index 00000000000..3de8a673c8b
--- /dev/null
+++ b/eng/native/ijw/IJW.cmake
@@ -0,0 +1,81 @@
+if (CLR_CMAKE_HOST_WIN32)
+
+ function(remove_ijw_incompatible_options options updatedOptions)
+
+ # IJW isn't compatible with Ehsc, which CMake enables by default,
+ if(options MATCHES "/EHsc")
+ string(REPLACE "/EHsc" "" options "${options}")
+ endif()
+
+ # IJW isn't compatible with CFG
+ if(options MATCHES "/guard:cf")
+ string(REPLACE "/guard:cf" "" options "${options}")
+ endif()
+
+ # IJW isn't compatible with EHCONT, which requires CFG
+ if(options MATCHES "/guard:ehcont")
+ string(REPLACE "/guard:ehcont" "" options "${options}")
+ endif()
+
+ # IJW isn't compatible with GR-
+ if(options MATCHES "/GR-")
+ string(REPLACE "/GR-" "" options "${options}")
+ endif()
+
+ SET(${updatedOptions} "${options}" PARENT_SCOPE)
+ endfunction()
+
+ function(remove_ijw_incompatible_target_options targetName)
+ get_target_property(compileOptions ${targetName} COMPILE_OPTIONS)
+ remove_ijw_incompatible_options("${compileOptions}" compileOptions)
+ set_target_properties(${targetName} PROPERTIES COMPILE_OPTIONS "${compileOptions}")
+ endfunction()
+
+ # 4365 - signed/unsigned mismatch
+ add_compile_options(/wd4365)
+
+ # IJW
+ add_compile_options(/clr:netcore)
+
+ # IJW requires the CRT as a dll, not linked in
+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:Checked>>:Debug>DLL)
+
+ # CMake enables /RTC1 and /EHsc by default, but they're not compatible with /clr, so remove them
+ if(CMAKE_CXX_FLAGS_DEBUG MATCHES "/RTC1")
+ string(REPLACE "/RTC1" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ endif()
+
+ remove_ijw_incompatible_options("${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
+
+ set(CLR_SDK_REF_PACK_OUTPUT "")
+ set(CLR_SDK_REF_PACK_DISCOVERY_ERROR "")
+ set(CLR_SDK_REF_PACK_DISCOVERY_RESULT 0)
+
+ if (CPP_CLI_LIVE_REF_ASSEMBLIES)
+ message("Using live-built ref assemblies for C++/CLI runtime tests.")
+ execute_process(
+ COMMAND powershell -ExecutionPolicy ByPass -NoProfile "${CMAKE_CURRENT_LIST_DIR}/getRefPackFolderFromArtifacts.ps1"
+ OUTPUT_VARIABLE CLR_SDK_REF_PACK_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_ERROR
+ RESULT_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_RESULT)
+ else()
+ execute_process(
+ COMMAND powershell -ExecutionPolicy ByPass -NoProfile "${CMAKE_CURRENT_LIST_DIR}/getRefPackFolderFromSdk.ps1"
+ OUTPUT_VARIABLE CLR_SDK_REF_PACK_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_ERROR
+ RESULT_VARIABLE CLR_SDK_REF_PACK_DISCOVERY_RESULT)
+ endif()
+
+ if (NOT CLR_SDK_REF_PACK_DISCOVERY_RESULT EQUAL 0)
+ message(FATAL_ERROR "Unable to find reference assemblies: ${CLR_SDK_REF_PACK_DISCOVERY_ERROR}")
+ endif()
+
+ string(REGEX REPLACE ".*refPackPath=(.*)" "\\1" CLR_SDK_REF_PACK ${CLR_SDK_REF_PACK_OUTPUT})
+
+ add_compile_options(/AI${CLR_SDK_REF_PACK})
+
+ list(APPEND LINK_LIBRARIES_ADDITIONAL ijwhost)
+
+endif()
diff --git a/eng/native/ijw/getRefPackFolderFromArtifacts.ps1 b/eng/native/ijw/getRefPackFolderFromArtifacts.ps1
new file mode 100644
index 00000000000..f9b53286c2b
--- /dev/null
+++ b/eng/native/ijw/getRefPackFolderFromArtifacts.ps1
@@ -0,0 +1,21 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+
+$engNativeFolder = Split-Path $PSScriptRoot -Parent
+$engFolder = Split-Path $engNativeFolder -Parent
+$repoRoot = Split-Path $engFolder -Parent
+
+$versionPropsFile = "$repoRoot/eng/Versions.props"
+
+$majorVersion = Select-Xml -Path $versionPropsFile -XPath "/Project/PropertyGroup/MajorVersion" | %{$_.Node.InnerText}
+$minorVersion = Select-Xml -Path $versionPropsFile -XPath "/Project/PropertyGroup/MinorVersion" | %{$_.Node.InnerText}
+
+$refPackPath = "$repoRoot/artifacts/bin/ref/net$majorVersion.$minorVersion"
+
+if (-not (Test-Path $refPackPath))
+{
+ Write-Error "Reference assemblies not found in the artifacts folder at '$refPackPath'. Did you invoke 'build.cmd libs.sfx+libs.oob /p:RefOnly=true' to make sure that refs are built? Did the repo layout change?"
+ exit 1
+}
+
+Write-Output "refPackPath=$refPackPath"
diff --git a/eng/native/ijw/getRefPackFolderFromSdk.ps1 b/eng/native/ijw/getRefPackFolderFromSdk.ps1
new file mode 100644
index 00000000000..1b59248cb42
--- /dev/null
+++ b/eng/native/ijw/getRefPackFolderFromSdk.ps1
@@ -0,0 +1,27 @@
+# Licensed to the .NET Foundation under one or more agreements.
+# The .NET Foundation licenses this file to you under the MIT license.
+
+$engNativeFolder = Split-Path $PSScriptRoot -Parent
+$engFolder = Split-Path $engNativeFolder -Parent
+$repoRoot = Split-Path $engFolder -Parent
+
+. "$repoRoot/eng/common/tools.ps1"
+
+$dotnetRoot = InitializeDotNetCli $true $false
+
+$dotnetSdkVersion = $GlobalJson.tools.dotnet
+
+$sdkBundledVersionsFile = "$dotnetRoot/sdk/$dotnetSdkVersion/Microsoft.NETCoreSdk.BundledVersions.props"
+
+$refPackVersion = Select-Xml -Path $sdkBundledVersionsFile -XPath "/Project/PropertyGroup/BundledNETCoreAppPackageVersion" | %{$_.Node.InnerText}
+$refPackTfmVersion = Select-Xml -Path $sdkBundledVersionsFile -XPath "/Project/PropertyGroup/BundledNETCoreAppTargetFrameworkVersion" | %{$_.Node.InnerText}
+
+$refPackPath = "$dotnetRoot/packs/Microsoft.NETCore.App.Ref/$refPackVersion/ref/net$refPackTfmVersion"
+
+if (-not (Test-Path $refPackPath))
+{
+ Write-Error "Reference assemblies not found in the SDK folder. Did the SDK layout change? Did the SDK change how it describes the bundled runtime version?"
+ exit 1
+}
+
+Write-Output "refPackPath=$refPackPath"