diff mbox series

[meta-mingw,V2] meta-mingw: support generating Windows SDK with no symlink

Message ID 20251103021848.3068540-1-Qi.Chen@windriver.com
State New
Headers show
Series [meta-mingw,V2] meta-mingw: support generating Windows SDK with no symlink | expand

Commit Message

ChenQi Nov. 3, 2025, 2:18 a.m. UTC
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

Comments

ChenQi Nov. 10, 2025, 3:32 a.m. UTC | #1
ping

On 11/3/25 10:18, Qi.Chen@windriver.com wrote:
> 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"
Joshua Watt Nov. 11, 2025, 3:25 p.m. UTC | #2
On Sun, Nov 2, 2025 at 7:19 PM <Qi.Chen@windriver.com> wrote:
>
> 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"

Does this need to be unconditional? I'd prefer something like
INHERIT:mingw32 instead if that works

> --
> 2.34.1
>
ChenQi Nov. 12, 2025, 5:35 a.m. UTC | #3
On 11/11/25 23:25, Joshua Watt wrote:
> On Sun, Nov 2, 2025 at 7:19 PM <Qi.Chen@windriver.com> wrote:
>> 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"
> Does this need to be unconditional? I'd prefer something like
> INHERIT:mingw32 instead if that works

Hi Joshua,

I just tried it out. Using INHERIT:append:sdkmingw32 works.
We have to use :append instead of "+=" to avoid overriding settings.

I'll send out V3.

Regards,
Qi

>
>> --
>> 2.34.1
>>
Samuli Piippo Nov. 12, 2025, 7:39 a.m. UTC | #4
Would it make more sense to leave out the INHERIT and WINSDK_NO_SYMLINK.
Instead, if you need this, you can inherit the class in your recipe or
local.conf

-samuli

On Wed, 12 Nov 2025 at 07:35, Chen Qi via lists.yoctoproject.org <Qi.Chen=
windriver.com@lists.yoctoproject.org> wrote:

> On 11/11/25 23:25, Joshua Watt wrote:
> > On Sun, Nov 2, 2025 at 7:19 PM <Qi.Chen@windriver.com> wrote:
> >> 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"
> > Does this need to be unconditional? I'd prefer something like
> > INHERIT:mingw32 instead if that works
>
> Hi Joshua,
>
> I just tried it out. Using INHERIT:append:sdkmingw32 works.
> We have to use :append instead of "+=" to avoid overriding settings.
>
> I'll send out V3.
>
> Regards,
> Qi
>
> >
> >> --
> >> 2.34.1
> >>
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#2488):
> https://lists.yoctoproject.org/g/yocto-patches/message/2488
> Mute This Topic: https://lists.yoctoproject.org/mt/116091557/3617605
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe:
> https://lists.yoctoproject.org/g/yocto-patches/leave/14256716/3617605/551361261/xyzzy
> [samuli.piippo@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
>
ChenQi Nov. 12, 2025, 7:58 a.m. UTC | #5
On 11/12/25 15:39, Samuli Piippo via lists.yoctoproject.org wrote:
> Would it make more sense to leave out the INHERIT and WINSDK_NO_SYMLINK.
> Instead, if you need this, you can inherit the class in your recipe or 
> local.conf
>
> -samuli

 From my experience, users will usually prefer a variable setting when 
it's possible.

Take this case as an example, they could put this setting in their 
<distro>.conf, site.conf or local.conf, then no matter meta-mingw is 
included or not, 'bitbake <something>' still works.

Regards,
Qi

>
> On Wed, 12 Nov 2025 at 07:35, Chen Qi via lists.yoctoproject.org 
> <http://lists.yoctoproject.org> 
> <Qi.Chen=windriver.com@lists.yoctoproject.org> wrote:
>
>     On 11/11/25 23:25, Joshua Watt wrote:
>     > On Sun, Nov 2, 2025 at 7:19 PM <Qi.Chen@windriver.com> wrote:
>     >> 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"
>     > Does this need to be unconditional? I'd prefer something like
>     > INHERIT:mingw32 instead if that works
>
>     Hi Joshua,
>
>     I just tried it out. Using INHERIT:append:sdkmingw32 works.
>     We have to use :append instead of "+=" to avoid overriding settings.
>
>     I'll send out V3.
>
>     Regards,
>     Qi
>
>     >
>     >> --
>     >> 2.34.1
>     >>
>
>
>
>
>
>
> _._,_._,_
> ------------------------------------------------------------------------
> Links:
>
> You receive all messages sent to this group.
>
> View/Reply Online (#2490) 
> <https://lists.yoctoproject.org/g/yocto-patches/message/2490> | Reply 
> to Group 
> <mailto:yocto-patches@lists.yoctoproject.org?subject=Re:%20Re%3A%20%5Byocto-patches%5D%20%5Bmeta-mingw%5D%5BPATCH%20V2%5D%20meta-mingw%3A%20support%20generating%20Windows%20SDK%20with%20no%20symlink> 
> | Reply to Sender 
> <mailto:samuli.piippo@gmail.com?subject=Private:%20Re:%20Re%3A%20%5Byocto-patches%5D%20%5Bmeta-mingw%5D%5BPATCH%20V2%5D%20meta-mingw%3A%20support%20generating%20Windows%20SDK%20with%20no%20symlink> 
> | Mute This Topic 
> <https://lists.yoctoproject.org/mt/116091557/7304865> | New Topic 
> <https://lists.yoctoproject.org/g/yocto-patches/post>
> Your Subscription 
> <https://lists.yoctoproject.org/g/yocto-patches/editsub/7304865> | 
> Contact Group Owner 
> <mailto:yocto-patches+owner@lists.yoctoproject.org> | Unsubscribe 
> <https://lists.yoctoproject.org/g/yocto-patches/leave/13175947/7304865/1848005690/xyzzy> 
> [Qi.Chen@eng.windriver.com]
>
> _._,_._,_
ChenQi Nov. 12, 2025, 7:59 a.m. UTC | #6
On 11/12/25 15:39, Samuli Piippo via lists.yoctoproject.org wrote:
> Would it make more sense to leave out the INHERIT and WINSDK_NO_SYMLINK.
> Instead, if you need this, you can inherit the class in your recipe or 
> local.conf
>
> -samuli
Hi Samuli,

 From my experience, users will usually prefer a variable setting when 
it's possible.

Take this case as an example, they could put this setting in their 
<distro>.conf, site.conf or local.conf, then no matter meta-mingw is 
included or not, 'bitbake <something>' still works.

Regards,
Qi

>
> On Wed, 12 Nov 2025 at 07:35, Chen Qi via lists.yoctoproject.org 
> <http://lists.yoctoproject.org> 
> <Qi.Chen=windriver.com@lists.yoctoproject.org> wrote:
>
>     On 11/11/25 23:25, Joshua Watt wrote:
>     > On Sun, Nov 2, 2025 at 7:19 PM <Qi.Chen@windriver.com> wrote:
>     >> 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"
>     > Does this need to be unconditional? I'd prefer something like
>     > INHERIT:mingw32 instead if that works
>
>     Hi Joshua,
>
>     I just tried it out. Using INHERIT:append:sdkmingw32 works.
>     We have to use :append instead of "+=" to avoid overriding settings.
>
>     I'll send out V3.
>
>     Regards,
>     Qi
>
>     >
>     >> --
>     >> 2.34.1
>     >>
>
>
>
>
>
>
> _._,_._,_
> ------------------------------------------------------------------------
> Links:
>
> You receive all messages sent to this group.
>
> View/Reply Online (#2490) 
> <https://lists.yoctoproject.org/g/yocto-patches/message/2490> | Reply 
> to Group 
> <mailto:yocto-patches@lists.yoctoproject.org?subject=Re:%20Re%3A%20%5Byocto-patches%5D%20%5Bmeta-mingw%5D%5BPATCH%20V2%5D%20meta-mingw%3A%20support%20generating%20Windows%20SDK%20with%20no%20symlink> 
> | Reply to Sender 
> <mailto:samuli.piippo@gmail.com?subject=Private:%20Re:%20Re%3A%20%5Byocto-patches%5D%20%5Bmeta-mingw%5D%5BPATCH%20V2%5D%20meta-mingw%3A%20support%20generating%20Windows%20SDK%20with%20no%20symlink> 
> | Mute This Topic 
> <https://lists.yoctoproject.org/mt/116091557/7304865> | New Topic 
> <https://lists.yoctoproject.org/g/yocto-patches/post>
> Your Subscription 
> <https://lists.yoctoproject.org/g/yocto-patches/editsub/7304865> | 
> Contact Group Owner 
> <mailto:yocto-patches+owner@lists.yoctoproject.org> | Unsubscribe 
> <https://lists.yoctoproject.org/g/yocto-patches/leave/13175947/7304865/1848005690/xyzzy> 
> [Qi.Chen@eng.windriver.com]
>
> _._,_._,_
diff mbox series

Patch

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"