when $(WORKSPACE) is used in the DSC file [BuildOptions], enable the
multiple workspace, the build options is not expand to use the correct
path (it still use $(WORKSPACE), even though it is in a PACKAGES_PATH
folder), which would cause build failure.

Cc: Liming Gao <liming....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong....@intel.com>
---
 BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 
b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index b2c4d6e..a4556c9 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -785,10 +785,22 @@ class DscBuildData(PlatformBuildClassObject):
                 for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, 
Dummy3, Dummy4 in RecordList:
                     CurKey = (ToolChainFamily, ToolChain, CodeBase)
                     #
                     # Only flags can be appended
                     #
+                    if os.getenv("PACKAGES_PATH"):
+                        OptionList = Option.split()
+                        if OptionList:
+                            for index, str in enumerate(OptionList):
+                                if str.find('$(WORKSPACE)') != -1:
+                                    MacroStartPos = str.find('$(WORKSPACE')
+                                    MacroEndPos = str.find(')', MacroStartPos)
+                                    Substr = str[MacroEndPos+1:]
+                                    if Substr.startswith('/') or 
Substr.startswith('\\'):
+                                        Substr = Substr[1:]
+                                    OptionList[index] = str[0:MacroStartPos] + 
os.path.normpath(mws.join(GlobalData.gWorkspace, Substr))
+                        Option = ' '.join(OptionList)
                     if CurKey not in self._BuildOptions or not 
ToolChain.endswith('_FLAGS') or Option.startswith('='):
                         self._BuildOptions[CurKey] = Option
                     else:
                         self._BuildOptions[CurKey] += ' ' + Option
         return self._BuildOptions
-- 
2.6.1.windows.1

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

Reply via email to