[PATCH v2 05/30] pylibfdt: Allow building on Windows

Bin Meng bmeng.cn at gmail.com
Mon May 1 04:21:11 CEST 2023


Hi Simon,

On Sun, Apr 30, 2023 at 9:30 AM Simon Glass <sjg at chromium.org> wrote:
>
> Handle the different shared-object extension with MSYS2 by creating a new
> SOEXT variable.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2:
> - Use LIBEXT instead of SOEXT
>
>  Makefile                      | 11 +++++++++++
>  scripts/dtc/pylibfdt/Makefile | 16 +++++++++-------
>  2 files changed, 20 insertions(+), 7 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 166acba27032..2453a80eca62 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -39,6 +39,17 @@ else ifeq ("riscv64", $(MK_ARCH))
>  endif
>  undefine MK_ARCH
>
> +# Building on Windows with MSYS2
> +export MSYS_VERSION = $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0)

It looks like the exact version of MSYS2 is not useful to U-Boot
build? What we only need is to detect whether we are building for
MSYS2.

So parsing `shell uname -o` should be enough. Then the variable name
can be named as MSYS?

> +# $(info The version of MSYS you are running is $(MSYS_VERSION) (0 meaning not MSYS at all))

Commented out?

> +
> +# Sets the extension to use for shared-object files
> +ifeq ($(MSYS_VERSION),0)
> +export LIBEXT := so
> +else
> +export LIBEXT := dll
> +endif
> +
>  # Avoid funny character set dependencies
>  unexport LC_ALL
>  LC_COLLATE=C
> diff --git a/scripts/dtc/pylibfdt/Makefile b/scripts/dtc/pylibfdt/Makefile
> index e442d5c24201..314ef91e527b 100644
> --- a/scripts/dtc/pylibfdt/Makefile
> +++ b/scripts/dtc/pylibfdt/Makefile
> @@ -7,6 +7,8 @@ LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
>
>  include $(LIBFDT_srcdir)/Makefile.libfdt
>
> +LIBFILE := _libfdt.$(LIBEXT)
> +
>  # Unfortunately setup.py (or actually the Python distutil implementation) puts
>  # files into the same directory as the .i file. We cannot touch the source
>  # directory, so we "ship" .i file into the objtree.
> @@ -29,16 +31,16 @@ quiet_cmd_pymod = PYMOD   $@
>  rebuild: $(src)/setup.py $(PYLIBFDT_srcs)
>         @# Remove the library since otherwise Python doesn't seem to regenerate
>         @# the libfdt.py file if it is missing.
> -       @rm -f $(obj)/_libfdt*.so
> +       @rm -f $(obj)/_libfdt*.$(LIBEXT)
>         $(call if_changed,pymod)
> -       @# Rename the file to _libfdt.so so this Makefile doesn't run every time
> -       @if [ ! -e $(obj)/_libfdt.so ]; then \
> -               mv $(obj)/_libfdt*.so $(obj)/_libfdt.so; \
> +       @# Rename the file to $(LIBFILE) so this Makefile doesn't run every time
> +       @if [ ! -e $(obj)/$(LIBFILE) ]; then \
> +               mv $(obj)/_libfdt*.$(LIBEXT) $(obj)/$(LIBFILE); \
>         fi
>
> -$(obj)/_libfdt.so $(obj)/libfdt.py &: rebuild
> +$(obj)/$(LIBFILE) $(obj)/libfdt.py &: rebuild
>         @:
>
> -always += _libfdt.so libfdt.py
> +always += $(LIBFILE) libfdt.py
>
> -clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
> +clean-files += libfdt.i $(LIBFILE) libfdt.py libfdt_wrap.c
> --

Regards,
Bin


More information about the U-Boot mailing list