Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${TARGET_PLATFORM})
# BUNDLE_ONLY mode: skip all source builds; only configure the msixbundle target and nuspec files.
# Used by the package pipeline stage to create the bundle from pre-built per-platform msix files.
option(BUNDLE_ONLY "Only configure the msixbundle target, skip all source builds" OFF)
option(INCLUDE_OPENVMM "Include OpenVMM build integrations" OFF)
if (BUNDLE_ONLY)
if (NOT PACKAGE_VERSION)
message(FATAL_ERROR "PACKAGE_VERSION is required for BUNDLE_ONLY mode")
Expand All @@ -63,7 +64,8 @@ include(FetchContent)

set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_deps/${TARGET_PLATFORM})

# N.B. Changes to any of the FetchContent dependencies below (GSL, nlohmannjson) must be reflected in cgmanifest.json
# N.B. Changes to any of the FetchContent dependencies below (GSL, nlohmannjson, yaml-cpp, boost, protobuf)
# must be reflected in cgmanifest.json

FetchContent_Declare(GSL
URL https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.tar.gz
Expand Down Expand Up @@ -104,7 +106,6 @@ FetchContent_Declare(

FetchContent_MakeAvailable(boost_headers)


# Import modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(IDL REQUIRED)
Expand All @@ -127,6 +128,7 @@ find_nuget_package(Microsoft.RemoteDesktop.Client.MSRDC.SessionHost MSRDC /build
find_nuget_package(Microsoft.Taef TAEF /)
find_nuget_package(Microsoft.Windows.ImplementationLibrary WIL /)
find_nuget_package(Microsoft.WSL.DeviceHost WSL_DEVICE_HOST /build/native)
set(WSL_DEVICE_HOST_NUGET_DIR "${WSL_DEVICE_HOST_SOURCE_DIR}")
find_nuget_package(Microsoft.WSL.Kernel KERNEL /build/native)
find_nuget_package(Microsoft.WSL.bsdtar BSDTARD /build/native/bin)
find_nuget_package(Microsoft.WSL.LinuxSdk LINUXSDK /)
Expand Down Expand Up @@ -169,6 +171,51 @@ if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/UserConfig.cmake")
find_package(USER REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR})
endif()

# Resolve OpenVMM packages. UserConfig.cmake can set WSL_DEVICE_HOST_SOURCE_DIR
# and/or WSL_VM_SERVICE_SOURCE_DIR to local paths to skip the NuGet lookup.
# When INCLUDE_OPENVMM is set and WSL_VM_SERVICE_SOURCE_DIR is not already
# overridden, resolve from the NuGet feed.
if (INCLUDE_OPENVMM AND NOT WSL_VM_SERVICE_SOURCE_DIR)
find_nuget_package(Microsoft.WSL.VmService WSL_VM_SERVICE /build/native)
endif()

# --- Local OpenVMM binary override ---
# Set OPENVMM_BUILD_DIR to use a locally built openvmm.exe instead of the version
# from the Microsoft.WSL.DeviceHost NuGet package. This is useful when iterating
# on changes that span both the OpenVMM and WSL/WSLC projects.
#
# Usage:
# cmake . -DINCLUDE_OPENVMM=ON -DOPENVMM_BUILD_DIR="d:/src/openvmm/target/release"
#
# Or set in UserConfig.cmake:
# set(OPENVMM_BUILD_DIR "d:/src/openvmm/target/release")

set(OPENVMM_BUILD_DIR "" CACHE PATH "Path to directory containing a locally built openvmm.exe (overrides NuGet package)")

if (OPENVMM_BUILD_DIR)
if (NOT INCLUDE_OPENVMM)
message(WARNING "OPENVMM_BUILD_DIR is set but INCLUDE_OPENVMM is OFF. "
"Pass -DINCLUDE_OPENVMM=ON to use the local openvmm build.")
elseif (EXISTS "${OPENVMM_BUILD_DIR}/openvmm.exe")
message(STATUS "Using local openvmm build: ${OPENVMM_BUILD_DIR}/openvmm.exe")
file(MAKE_DIRECTORY "${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}")
file(CREATE_LINK "${OPENVMM_BUILD_DIR}/openvmm.exe"
"${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}/openvmm.exe" COPY_ON_ERROR)

# When WSL_DEVICE_HOST_SOURCE_DIR was overridden (e.g. to local_overrides/),
# the proto file from the NuGet package is no longer reachable. Copy it over.
if (NOT EXISTS "${WSL_DEVICE_HOST_SOURCE_DIR}/proto/VMService.proto"
AND EXISTS "${WSL_DEVICE_HOST_NUGET_DIR}/proto/VMService.proto")
file(MAKE_DIRECTORY "${WSL_DEVICE_HOST_SOURCE_DIR}/proto")
file(CREATE_LINK "${WSL_DEVICE_HOST_NUGET_DIR}/proto/VMService.proto"
"${WSL_DEVICE_HOST_SOURCE_DIR}/proto/VMService.proto" COPY_ON_ERROR)
endif()
else()
message(WARNING "OPENVMM_BUILD_DIR is set but openvmm.exe was not found at '${OPENVMM_BUILD_DIR}'. "
"Build it first: cargo build -p openvmm")
endif()
endif()

# Optional target configuration

if (NOT DEFINED WSL_BUILD_WSL_SETTINGS)
Expand Down
20 changes: 20 additions & 0 deletions UserConfig.cmake.sample
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,32 @@ endif()
# # Uncomment to generate a "thin" MSI package which builds and installs faster
# set(WSL_BUILD_THIN_PACKAGE true)

# # Uncomment to use a locally built openvmm.exe instead of the NuGet package version.
# # Requires INCLUDE_OPENVMM=ON (pass -DINCLUDE_OPENVMM=ON when generating).
# # Point to the cargo output directory containing openvmm.exe:
# # Debug: set(OPENVMM_BUILD_DIR "d:/src/openvmm/target/debug")
# # Release: set(OPENVMM_BUILD_DIR "d:/src/openvmm/target/release")
set(OPENVMM_/BUILD_DIR "d:/src/openvmm/target/release")
Comment on lines +45 to +50

# # Uncomment to install the package as part of the build
# set(WSL_POST_BUILD_COMMAND "powershell;-ExecutionPolicy;Bypass;-NoProfile;-NonInteractive;./tools/deploy/deploy-to-host.ps1")

# # Uncomment to reduce the verbosity of the appx package build
# set(WSL_SILENT_APPX_BUILD true)

# # --- Local hvlite / OpenVMM development ---
# # Set HVLITE_BUILD_DIR to consume locally built DLLs from your hvlite checkout
# # (wsldevicehost.dll, wslvmservice.dll). Set OPENVMM_BUILD_DIR for openvmm.exe,
# # which builds from the separate oss/ submodule workspace.
# #
# # Build in hvlite first:
# # cargo build -p wsldevicehost -p wslvmservice
# # cd oss && cargo build -p openvmm
# #
# # Then uncomment and adjust the paths:
# set(HVLITE_BUILD_DIR "d:/src/hvlite/target/debug")
# set(OPENVMM_BUILD_DIR "d:/src/hvlite/oss/target/debug")

# # Uncomment to change the pre-commit hook behavior (default: warn)
# # warn - report formatting issues without blocking the commit
# # error - block the commit when formatting issues are found
Expand Down
11 changes: 11 additions & 0 deletions cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@
"hash": "sha256:42f6e95cad6ec532fd372391373363b62a14af6d771056dbfc86160e6dfff7aa"
}
}
},
{
"component": {
"type": "other",
"other": {
"name": "protobuf",
"version": "34.1",
"downloadUrl": "https://github.com/protocolbuffers/protobuf/releases/download/v34.1/protobuf-34.1.tar.gz",
"hash": "sha256:e4e6ff10760cf747a2decd1867741f561b216bd60cc4038c87564713a6da1848"
}
}
}
]
}
Loading