Message ID | 20230430013003.1047454-18-sjg@chromium.org |
---|---|
State | Changes Requested |
Delegated to: | Tom Rini |
Headers | show |
Series | Allow building sandbox with MSYS2 | expand |
On Sat, Apr 29, 2023 at 07:29:50PM -0600, Simon Glass wrote: > The source-tree directory is prepended to relative include paths, but this > does not work on Windows, where a path may have a drive letter like C: at > the start of it. > > This breaks SDL which includes an absolute path to the header directory to > the C flags, e.g. -IC:/msys64/mingw64/include/SDL2 > > Add this as a special case to leave these absolute paths alone on Windows. > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > (no changes since v1) > > scripts/Kbuild.include | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include > index 62e0207f91b4..411a768a7767 100644 > --- a/scripts/Kbuild.include > +++ b/scripts/Kbuild.include > @@ -205,9 +205,10 @@ clean := -f $(srctree)/scripts/Makefile.clean obj > hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj > > # Prefix -I with $(srctree) if it is not an absolute path. > +# Detect C: (C drive) with MSYS2 > # skip if -I has no parameter > addtree = $(if $(patsubst -I%,%,$(1)), \ > -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) > +$(if $(filter-out -I/% -I./% -I../% -IC:%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) > > # Find all -I options and call addtree > flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) This feels a bit fragile, stuff could be on some network drive instead and so another letter, can we make this a bit more generic?
Hi Simon, On Sun, Apr 30, 2023 at 9:30 AM Simon Glass <sjg@chromium.org> wrote: > > The source-tree directory is prepended to relative include paths, but this > does not work on Windows, where a path may have a drive letter like C: at > the start of it. > > This breaks SDL which includes an absolute path to the header directory to > the C flags, e.g. -IC:/msys64/mingw64/include/SDL2 > > Add this as a special case to leave these absolute paths alone on Windows. > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- > > (no changes since v1) > > scripts/Kbuild.include | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include > index 62e0207f91b4..411a768a7767 100644 > --- a/scripts/Kbuild.include > +++ b/scripts/Kbuild.include > @@ -205,9 +205,10 @@ clean := -f $(srctree)/scripts/Makefile.clean obj > hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj > > # Prefix -I with $(srctree) if it is not an absolute path. > +# Detect C: (C drive) with MSYS2 > # skip if -I has no parameter > addtree = $(if $(patsubst -I%,%,$(1)), \ > -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) > +$(if $(filter-out -I/% -I./% -I../% -IC:%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) What happens if MSYS2 is not installed to the C drive? > > # Find all -I options and call addtree > flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) > -- Regards, Bin
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 62e0207f91b4..411a768a7767 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -205,9 +205,10 @@ clean := -f $(srctree)/scripts/Makefile.clean obj hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj # Prefix -I with $(srctree) if it is not an absolute path. +# Detect C: (C drive) with MSYS2 # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) +$(if $(filter-out -I/% -I./% -I../% -IC:%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)),$(1)) # Find all -I options and call addtree flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
The source-tree directory is prepended to relative include paths, but this does not work on Windows, where a path may have a drive letter like C: at the start of it. This breaks SDL which includes an absolute path to the header directory to the C flags, e.g. -IC:/msys64/mingw64/include/SDL2 Add this as a special case to leave these absolute paths alone on Windows. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) scripts/Kbuild.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)