set(CORECLR_DIR "" CACHE FILEPATH "Path to CoreCLR source directory")
set(DOTNET_DIR "" CACHE FILEPATH "Path to .NET SDK directory")
-# Note, since 5.0 src are broken and will not build netcoredbg without patch, stay with 3.1 for now.
-set(CORECLR_BRANCH "release/3.1" CACHE STRING "CoreCLR source branch")
-# Note, we must use latest runtime, since we need copy latest dbgshim in order to work with all runtime versions.
-# https://github.com/dotnet/runtime/pull/44748#issuecomment-729268650
-set(DOTNET_CHANNEL "6.0" CACHE STRING ".NET SDK channel")
+set(CORECLR_BRANCH "release/7.0" CACHE STRING "CoreCLR source branch")
+# After move of dbgshim from runtime to diagnostics, this sdk is used only for build of managed part.
+set(DOTNET_CHANNEL "7.0" CACHE STRING ".NET SDK channel")
set(BUILD_MANAGED ON CACHE BOOL "Build managed part")
-set(DBGSHIM_RUNTIME_DIR "" CACHE FILEPATH "Path to dbgshim library directory (at runtime)")
+set(DBGSHIM_DIR "" CACHE FILEPATH "Path to dbgshim library directory")
function(clr_unknown_arch)
message(FATAL_ERROR "Only AMD64, ARM64, ARM, ARMEL, I386 and WASM are supported")
include(fetchdeps.cmake)
set(CORECLR_SRC_DIR "${CORECLR_DIR}/src")
+set(VERSION_PROPS_PATH "${CORECLR_DIR}/eng/Versions.props")
if (NOT EXISTS "${CORECLR_SRC_DIR}/pal")
- set(CORECLR_SRC_DIR "${CORECLR_DIR}")
+ set(CORECLR_SRC_DIR "${CORECLR_DIR}")
+ set(VERSION_PROPS_PATH "${CORECLR_DIR}/../../eng/Versions.props")
endif()
+if (WIN32)
+ execute_process(
+ COMMAND powershell -Command "Select-Xml -Path ${VERSION_PROPS_PATH} -XPath '/Project/PropertyGroup/ProductVersion' | ForEach-Object { $_.Node.InnerXML }"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE CORECLR_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE errout
+ RESULT_VARIABLE retcode)
+else()
+ execute_process(
+ COMMAND bash -c "grep ProductVersion ${VERSION_PROPS_PATH} | sed 's,</.*,,;s,.*>,,'"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ OUTPUT_VARIABLE CORECLR_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE errout
+ RESULT_VARIABLE retcode)
+endif()
+
+if (NOT "${retcode}" STREQUAL "0" OR "${CORECLR_VERSION}" STREQUAL "")
+ # For some version of runtime Versions.props file doesn't exist
+ set(CORECLR_VERSION "unknown")
+endif()
+
+message("Building with ${CORECLR_VERSION} CoreCLR")
+
# Basic checks for valid paths
if (NOT IS_DIRECTORY "${CORECLR_SRC_DIR}/pal")
message(FATAL_ERROR "Invalid CoreCLR source directory")
5. It is expected, that Netcoredbg sources placed to some directory;
-6. Optional step: Netcoredbg requires **Core CLR runtime source code**, which is typically downloaded automatically, but you can download it from here: https://github.com/dotnet/coreclr
+6. Optional step: Netcoredbg requires **CoreCLR runtime source code**, which is typically downloaded automatically, but you can download it from here: https://github.com/dotnet/runtime
- You should check out tag v3.x.
+ You should check out tag v7.x.
7. Optional step: Netcoredbg requires **.NET SDK**, which can be downloaded automatically, but you can download it manually from here: https://dotnet.microsoft.com/download
- You need .NET SDK 3.1.
+ You need .NET SDK 7.0.
#### Compiling
For running tests after build has succeed you need to add option `-DCMAKE_INSTALL_PREFIX=$PWD/../bin`.
-If you have previously downloaded .NET SDK or Core CLR sources, then you should modify command line and add following options: `-DDOTNET_DIR=/path/to/sdk/dir -DCORECLR_DIR=/path/to/coreclr/sources`
+If you have previously downloaded .NET SDK or CoreCLR sources, then you should modify command line and add following options: `-DDOTNET_DIR=/path/to/sdk/dir -DCORECLR_DIR=/path/to/coreclr/sources`
-If cmake tries to download .NET SDK or Core CLR sources and fails -- see bullets 6 and 7 above. You can download required files manually.
+If cmake tries to download .NET SDK or CoreCLR sources and fails -- see bullets 6 and 7 above. You can download required files manually.
After configuration has finished, you can build Netcoredbg:
5. This step might be omitted, in this case cmake automatically downloads necessary files.
- But if it fails, you should then checkout **Core CLR sources** to another directory from here: https://github.com/dotnet/coreclr
+ But if it fails, you should then checkout **CoreCLR sources** to another directory from here: https://github.com/dotnet/runtime
- You need latest tag **v3.x**.
+ You need latest tag **v7.x**.
6. This step might be omitted too, and cmake will automatically downloads that it needs.
- But in case of failure you need download and install **.NET Core 3.1 SDK** from here: https://dotnet.microsoft.com/download
+ But in case of failure you need download and install **.NET Core 7.0 SDK** from here: https://dotnet.microsoft.com/download
#### Compiling
file(REMOVE_RECURSE "${CORECLR_DIR}")
endif()
execute_process(
- COMMAND ${GIT_EXECUTABLE} clone --progress --depth 1 https://github.com/dotnet/coreclr "${CORECLR_DIR}" -b "${CORECLR_BRANCH}"
+ COMMAND ${GIT_EXECUTABLE} clone --progress --depth 1 https://github.com/dotnet/runtime "${CORECLR_DIR}" -b "${CORECLR_BRANCH}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE retcode)
if (NOT "${retcode}" STREQUAL "0")
message(FATAL_ERROR "Fatal error when cloning coreclr sources")
endif()
endif()
+
+ set(CORECLR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.coreclr/src/coreclr)
endif()
# Fetch .NET SDK binaries if necessary
-if ("${DOTNET_DIR}" STREQUAL "" AND (("${DBGSHIM_RUNTIME_DIR}" STREQUAL "") OR ${BUILD_MANAGED}))
+if ("${DOTNET_DIR}" STREQUAL "" AND ${BUILD_MANAGED})
set(DOTNET_DIR ${CMAKE_CURRENT_SOURCE_DIR}/.dotnet)
if (WIN32)
if (NOT "${retcode}" STREQUAL "0")
message(FATAL_ERROR "Fatal error when installing dotnet")
endif()
- else()
+ else()
execute_process(
COMMAND bash -c "curl -sSL \"https://dot.net/v1/dotnet-install.sh\" | bash /dev/stdin --channel \"${DOTNET_CHANNEL}\" --install-dir \"${DOTNET_DIR}\" --verbose"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-DCMAKE_INSTALL_PREFIX=%{install_prefix} \
-DCMAKE_BUILD_TYPE=%{build_type} \
-DCLR_CMAKE_LINUX_ID=tizen \
- -DDBGSHIM_RUNTIME_DIR=$NETCOREAPPDIR \
+ -DDBGSHIM_DIR=$NETCOREAPPDIR \
-DBUILD_MANAGED=OFF \
-DNCDB_DOTNET_STARTUP_HOOK=$STARTUP_HOOK \
-DBUILD_TESTING=%{build_testing}
# application name for tizens logger
add_definitions(-DLOG_TAG="NETCOREDBG")
-if (NOT DBGSHIM_RUNTIME_DIR STREQUAL "")
- add_definitions(-DDBGSHIM_RUNTIME_DIR="${DBGSHIM_RUNTIME_DIR}")
-else()
- find_file(DBGSHIM_LOCATION NAMES dbgshim.dll libdbgshim.so libdbgshim.dylib PATHS "${DOTNET_DIR}/shared/Microsoft.NETCore.App/*" NO_DEFAULT_PATH)
+if (NOT DBGSHIM_DIR STREQUAL "")
+ add_definitions(-DDBGSHIM_DIR="${DBGSHIM_DIR}")
endif()
# Build corguids static library from coreclr source files
)
install(TARGETS netcoredbg DESTINATION ${CMAKE_INSTALL_PREFIX})
-if (DBGSHIM_LOCATION)
- install(FILES ${DBGSHIM_LOCATION} DESTINATION ${CMAKE_INSTALL_PREFIX})
-endif()
# Build managed part of the debugger (ManagedPart.dll)
set(MANAGEDPART_BUILD_TYPE "Release")
endif()
+ set(USE_DBGSHIM_DEPENDENCY "")
+ if (DBGSHIM_DIR STREQUAL "")
+ set(USE_DBGSHIM_DEPENDENCY "/p:UseDbgShimDependency=true")
+ endif()
+
+ if (CLR_CMAKE_PLATFORM_UNIX)
+ if (CLR_CMAKE_PLATFORM_DARWIN)
+ set(RID_NAME "osx")
+ else()
+ set(RID_NAME "linux")
+ endif()
+ elseif (WIN32)
+ set(RID_NAME "win")
+ else()
+ message(FATAL_ERROR "Unsupported platform")
+ endif()
+
add_custom_command(OUTPUT ${DOTNET_BUILD_RESULT}
- COMMAND ${DOTNETCLI} publish ${MANAGEDPART_PROJECT} -c ${MANAGEDPART_BUILD_TYPE} -o ${CMAKE_CURRENT_BINARY_DIR} /p:BaseIntermediateOutputPath=${CMAKE_CURRENT_BINARY_DIR}/obj/ /p:BaseOutputPath=${CMAKE_CURRENT_BINARY_DIR}/bin/
+ COMMAND ${DOTNETCLI} publish ${MANAGEDPART_PROJECT} -r ${RID_NAME}-${CLR_CMAKE_TARGET_ARCH} --self-contained -c ${MANAGEDPART_BUILD_TYPE} -o ${CMAKE_CURRENT_BINARY_DIR} /p:BaseIntermediateOutputPath=${CMAKE_CURRENT_BINARY_DIR}/obj/ /p:BaseOutputPath=${CMAKE_CURRENT_BINARY_DIR}/bin/ ${USE_DBGSHIM_DEPENDENCY}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/managed/*.cs" "${MANAGEDPART_PROJECT}"
COMMENT "Compiling ${MANAGEDPART_DLL_NAME}"
endforeach()
install(FILES ${DLLS_TO_DEPLOY} DESTINATION ${CMAKE_INSTALL_PREFIX})
+
+ if (DBGSHIM_DIR STREQUAL "")
+ if (CLR_CMAKE_PLATFORM_UNIX)
+ if (CLR_CMAKE_PLATFORM_DARWIN)
+ set(DBGSHIM_LIB_NAME "libdbgshim.dylib")
+ else()
+ set(DBGSHIM_LIB_NAME "libdbgshim.so")
+ endif()
+ elseif (WIN32)
+ set(DBGSHIM_LIB_NAME "dbgshim.dll")
+ else()
+ message(FATAL_ERROR "Unsupported platform")
+ endif()
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DBGSHIM_LIB_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX})
+ endif()
endif()
# Build Hot Reload managed dll (ncdbhook.dll)
CreateDebuggingInterfaceFromVersionEx(nullptr),
m_module(nullptr)
{
-#ifdef DBGSHIM_RUNTIME_DIR
- std::string libName(DBGSHIM_RUNTIME_DIR);
+#ifdef DBGSHIM_DIR
+ std::string libName(DBGSHIM_DIR);
libName += DIRECTORY_SEPARATOR_STR_A;
#else
std::string exe = GetExeAbsPath();
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="[4.4,)" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="[2.3,)" />
+ <PackageReference Include="Microsoft.Diagnostics.DbgShim" Condition="'$(UseDbgShimDependency)' == 'true'" Version="*" />
</ItemGroup>
</Project>