Skip to content

Commit efd7cd4

Browse files
Ben HillisCopilot
andcommitted
Gate Source Link on pipeline builds only
Only generate sourcelink.json and pass /SOURCELINK to the linker when PIPELINE_BUILD_ID is defined (i.e. during CI pipeline builds). This avoids unnecessary Source Link artifacts in local developer builds. Co-authored-by: Copilot <[email protected]>
1 parent 51a0268 commit efd7cd4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ file(MAKE_DIRECTORY ${BIN})
156156
set (GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
157157
file(MAKE_DIRECTORY ${GENERATED_DIR})
158158

159-
# Generate Source Link JSON so debuggers can fetch source from GitHub
160-
set(SOURCELINK_JSON "${GENERATED_DIR}/sourcelink.json")
161-
file(WRITE "${SOURCELINK_JSON}" "{\"documents\":{\"${CMAKE_SOURCE_DIR}/*\":\"https://raw.githubusercontent.com/microsoft/WSL/${COMMIT_HASH}/*\"}}")
159+
# Generate Source Link JSON so debuggers can fetch source from GitHub (pipeline builds only)
160+
if (DEFINED PIPELINE_BUILD_ID)
161+
set(SOURCELINK_JSON "${GENERATED_DIR}/sourcelink.json")
162+
file(WRITE "${SOURCELINK_JSON}" "{\"documents\":{\"${CMAKE_SOURCE_DIR}/*\":\"https://raw.githubusercontent.com/microsoft/WSL/${COMMIT_HASH}/*\"}}")
163+
endif()
162164

163165
set(PACKAGE_CERTIFICATE ${GENERATED_DIR}/dev-cert.pfx)
164166
file(CREATE_LINK ${WSL_DEVICE_HOST_SOURCE_DIR}/bin/${TARGET_PLATFORM}/wsldevicehost.dll ${BIN}/wsldevicehost.dll)
@@ -236,8 +238,10 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /guard:cf /Qspectre"
236238
# Linker flags
237239
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /debug:full /debugtype:cv,fixup /guard:cf /DYNAMICBASE")
238240
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug:full /debugtype:cv,fixup /guard:cf /DYNAMICBASE")
239-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SOURCELINK:\"${SOURCELINK_JSON}\"")
240-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SOURCELINK:\"${SOURCELINK_JSON}\"")
241+
if (DEFINED SOURCELINK_JSON)
242+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SOURCELINK:\"${SOURCELINK_JSON}\"")
243+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SOURCELINK:\"${SOURCELINK_JSON}\"")
244+
endif()
241245
if (${TARGET_PLATFORM} STREQUAL "x64")
242246
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /CETCOMPAT")
243247
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /CETCOMPAT")

0 commit comments

Comments
 (0)