diff mbox

[edk2,3/3] BaseTools: handleWsMacro: keep trailing os.sep in WORKSPACE substitution

Message ID 1460646818-26390-4-git-send-email-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek April 14, 2016, 3:13 p.m. UTC
The NASM utility requires a trailing directory separator for its -I and -i
options (this is a documented requirement). The INF file
"OvmfPkg/ResetVector/ResetVector.inf" conforms to it:

  [BuildOptions]
     *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/
     *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/

but handleWsMacro currently removes such trailing separators with the
os.path.normpath() function, breaking the OVMF build. Restore the trailing
separator when necessary.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Fixes: 2b1c08acfceb94326c67b7d8f9fe5d8ab4cb7f61
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---
 BaseTools/Source/Python/Common/MultipleWorkspace.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
1.8.3.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Laszlo Ersek April 14, 2016, 4:22 p.m. UTC | #1
On 04/14/16 17:54, Zhu, Yonghong wrote:
> Hi Laszlo,

> 

> Thanks for the fix, this patch can fix the bug. 

> for the patch3, I'd like to retire the os.path.normpath() since it may normalization others. And direct to replace the $(workspace) with every Package in the Packages_Path env to find the correct path. Is it OK to you ?

> I attached one patch for you. So May I know which one is more prefer by you ? thanks.

> Thanks again for you quick fix.


I'm perfectly fine if we go with your approach -- please submit your
patch as a standalone email, and I'll try to test it.

Thanks!
Laszlo

> Best Regards,

> Zhu Yonghong

> 

> 

> -----Original Message-----

> From: Laszlo Ersek [mailto:lersek@redhat.com] 

> Sent: Thursday, April 14, 2016 11:14 PM

> To: edk2-devel-01 <edk2-devel@ml01.01.org>

> Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com>

> Subject: [PATCH 3/3] BaseTools: handleWsMacro: keep trailing os.sep in WORKSPACE substitution

> 

> The NASM utility requires a trailing directory separator for its -I and -i options (this is a documented requirement). The INF file "OvmfPkg/ResetVector/ResetVector.inf" conforms to it:

> 

>   [BuildOptions]

>      *_*_IA32_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/

>      *_*_X64_NASMB_FLAGS = -I$(WORKSPACE)/UefiCpuPkg/ResetVector/Vtf0/

> 

> but handleWsMacro currently removes such trailing separators with the

> os.path.normpath() function, breaking the OVMF build. Restore the trailing separator when necessary.

> 

> Cc: Yonghong Zhu <yonghong.zhu@intel.com>

> Cc: Liming Gao <liming.gao@intel.com>

> Fixes: 2b1c08acfceb94326c67b7d8f9fe5d8ab4cb7f61

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

> ---

>  BaseTools/Source/Python/Common/MultipleWorkspace.py | 6 +++++-

>  1 file changed, 5 insertions(+), 1 deletion(-)

> 

> diff --git a/BaseTools/Source/Python/Common/MultipleWorkspace.py b/BaseTools/Source/Python/Common/MultipleWorkspace.py

> index d546c627a45a..e20ec692acfd 100644

> --- a/BaseTools/Source/Python/Common/MultipleWorkspace.py

> +++ b/BaseTools/Source/Python/Common/MultipleWorkspace.py

> @@ -137,7 +137,11 @@ class MultipleWorkspace(object):

>                          Substr = str[MacroEndPos+1:]

>                          if Substr.startswith(os.sep):

>                              Substr = Substr[1:]

> -                        PathList[i] = str[0:MacroStartPos] + os.path.normpath(cls.join(cls.WORKSPACE, Substr))

> +                        if Substr.endswith(os.sep):

> +                            Final = os.sep

> +                        else:

> +                            Final = ''

> +                        PathList[i] = str[0:MacroStartPos] + 

> + os.path.normpath(cls.join(cls.WORKSPACE, Substr)) + Final

>              PathStr = ' '.join(PathList)

>          return PathStr

>      

> --

> 1.8.3.1

> 


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/BaseTools/Source/Python/Common/MultipleWorkspace.py b/BaseTools/Source/Python/Common/MultipleWorkspace.py
index d546c627a45a..e20ec692acfd 100644
--- a/BaseTools/Source/Python/Common/MultipleWorkspace.py
+++ b/BaseTools/Source/Python/Common/MultipleWorkspace.py
@@ -137,7 +137,11 @@  class MultipleWorkspace(object):
                         Substr = str[MacroEndPos+1:]
                         if Substr.startswith(os.sep):
                             Substr = Substr[1:]
-                        PathList[i] = str[0:MacroStartPos] + os.path.normpath(cls.join(cls.WORKSPACE, Substr))
+                        if Substr.endswith(os.sep):
+                            Final = os.sep
+                        else:
+                            Final = ''
+                        PathList[i] = str[0:MacroStartPos] + os.path.normpath(cls.join(cls.WORKSPACE, Substr)) + Final
             PathStr = ' '.join(PathList)
         return PathStr