All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-mingw][PATCH V2] meta-mingw: support generating Windows SDK with no symlink
@ 2025-11-03  2:18 Qi.Chen
  2025-11-10  3:32 ` ChenQi
  2025-11-11 15:25 ` Joshua Watt
  0 siblings, 2 replies; 7+ messages in thread
From: Qi.Chen @ 2025-11-03  2:18 UTC (permalink / raw)
  To: yocto-patches; +Cc: jpewhacker, qi.chen, paul

From: Chen Qi <Qi.Chen@windriver.com>

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.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 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

diff --git a/classes/mingw_sdk_handle_symlink.bbclass b/classes/mingw_sdk_handle_symlink.bbclass
new file mode 100644
index 0000000..2f6dbe6
--- /dev/null
+++ b/classes/mingw_sdk_handle_symlink.bbclass
@@ -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
+}
diff --git a/conf/machine-sdk/include/mingw32-common.inc b/conf/machine-sdk/include/mingw32-common.inc
index 56b8052..bf3f14e 100644
--- a/conf/machine-sdk/include/mingw32-common.inc
+++ b/conf/machine-sdk/include/mingw32-common.inc
@@ -59,3 +59,6 @@ GCCPIE:mingw32 = ""
 
 # wine and wineserver are required to test MinGW SDKs
 HOSTTOOLS_NONFATAL += "wine wineserver"
+
+# handle symlinks
+INHERIT += "mingw_sdk_handle_symlink"
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-11-12  7:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-03  2:18 [meta-mingw][PATCH V2] meta-mingw: support generating Windows SDK with no symlink Qi.Chen
2025-11-10  3:32 ` ChenQi
2025-11-11 15:25 ` Joshua Watt
2025-11-12  5:35   ` ChenQi
2025-11-12  7:39     ` [yocto-patches] " Samuli Piippo
2025-11-12  7:58       ` ChenQi
2025-11-12  7:59       ` ChenQi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.