Skip to contentSkip to conversation

meta-mingw: support generating Windows SDK with no symlink

PATCH New [email protected] 1 participant 1 message Nov 12, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 meta-mingw: support generating Windows SDK with no symlink

From: Chen Qi <[email protected]>

On some Windows systems, symlinks are not allowed due to IT policy. We need to be able to generate Windows SDK without symlinks.

To do this, a new variable, WINSDK_NO_SYMLINK, and a new bbclass, mingw_sdk_handle_symlink.bbclass, are introduced to achieve this.

By default, things work as before; when setting WINSDK_NO_SYMLINK to "1", SDK will replace all symlinks with the actual contents.

---
 classes/mingw_sdk_handle_symlink.bbclass    | 25 +++++++++++++++++++++
 conf/machine-sdk/include/mingw32-common.inc |  3 +++
 2 files changed, 28 insertions(+)
 create mode 100644 classes/mingw_sdk_handle_symlink.bbclass
classes/mingw_sdk_handle_symlink.bbclass new file +25 -0
new file mode 100644
index 0000000..2f6dbe6
@@ -0,0 +1,25 @@
+WINSDK_NO_SYMLINK ?= "0"
+
+archive_sdk:prepend:sdkmingw32 () {
+	if [ "${WINSDK_NO_SYMLINK}" = "1" ]; then
+		for parse_type in "file" "directory"; do
+			find "${SDK_OUTPUT}/${SDKPATH}" -type l -print0 | while IFS= read -r -d '' symlink; do
+				target=$(readlink -f "$symlink" || echo "NOTVALID")
+				if [ "$target" = "NOTVALID" ]; then
+					continue
+				fi
+				if [ ! -e "$target" ]; then
+					continue
+				elif [ -d "$target" ]; then
+					if [ "$parse_type" = "directory" ]; then
+						rm "$symlink" && cp -r "$target" "$symlink"
+					fi
+				else
+					if [ "$parse_type" = "file" ]; then
+						rm "$symlink" && cp "$target" "$symlink"
+					fi
+				fi
+			done
+		done
+	fi
+}
conf/machine-sdk/include/mingw32-common.inc +3 -0
index 56b8052..7cb1f9b 100644
@@ -59,3 +59,6 @@ GCCPIE:mingw32 = ""
 
 # wine and wineserver are required to test MinGW SDKs
 HOSTTOOLS_NONFATAL += "wine wineserver"
+
+# handle symlinks
+INHERIT:append:sdkmingw32 = " mingw_sdk_handle_symlink"
Signature · 1 line
2.34.1