\r
from .StrGather import *\r
from .BuildEngine import BuildRule\r
-\r
+import shutil\r
from Common.LongFilePathSupport import CopyLongFilePath\r
from Common.BuildToolError import *\r
from Common.DataType import *\r
## @AsBuilt${BEGIN}\r
## ${flags_item}${END}\r
""")\r
+## Split command line option string to list\r
+#\r
+# subprocess.Popen needs the args to be a sequence. Otherwise there's problem\r
+# in non-windows platform to launch command\r
+#\r
+def _SplitOption(OptionString):\r
+ OptionList = []\r
+ LastChar = " "\r
+ OptionStart = 0\r
+ QuotationMark = ""\r
+ for Index in range(0, len(OptionString)):\r
+ CurrentChar = OptionString[Index]\r
+ if CurrentChar in ['"', "'"]:\r
+ if QuotationMark == CurrentChar:\r
+ QuotationMark = ""\r
+ elif QuotationMark == "":\r
+ QuotationMark = CurrentChar\r
+ continue\r
+ elif QuotationMark:\r
+ continue\r
+\r
+ if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:\r
+ if Index > OptionStart:\r
+ OptionList.append(OptionString[OptionStart:Index - 1])\r
+ OptionStart = Index\r
+ LastChar = CurrentChar\r
+ OptionList.append(OptionString[OptionStart:])\r
+ return OptionList\r
+\r
+#\r
+# Convert string to C format array\r
+#\r
+def _ConvertStringToByteArray(Value):\r
+ Value = Value.strip()\r
+ if not Value:\r
+ return None\r
+ if Value[0] == '{':\r
+ if not Value.endswith('}'):\r
+ return None\r
+ Value = Value.replace(' ', '').replace('{', '').replace('}', '')\r
+ ValFields = Value.split(',')\r
+ try:\r
+ for Index in range(len(ValFields)):\r
+ ValFields[Index] = str(int(ValFields[Index], 0))\r
+ except ValueError:\r
+ return None\r
+ Value = '{' + ','.join(ValFields) + '}'\r
+ return Value\r
+\r
+ Unicode = False\r
+ if Value.startswith('L"'):\r
+ if not Value.endswith('"'):\r
+ return None\r
+ Value = Value[1:]\r
+ Unicode = True\r
+ elif not Value.startswith('"') or not Value.endswith('"'):\r
+ return None\r
+\r
+ Value = eval(Value) # translate escape character\r
+ NewValue = '{'\r
+ for Index in range(0, len(Value)):\r
+ if Unicode:\r
+ NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','\r
+ else:\r
+ NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','\r
+ Value = NewValue + '0}'\r
+ return Value\r
\r
## Base class for AutoGen\r
#\r
def BuildCommand(self):\r
RetVal = []\r
if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:\r
- RetVal += SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
+ RetVal += _SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
if "FLAGS" in self.ToolDefinition["MAKE"]:\r
NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()\r
if NewOption != '':\r
- RetVal += SplitOption(NewOption)\r
+ RetVal += _SplitOption(NewOption)\r
if "MAKE" in self.EdkIIBuildOption:\r
if "FLAGS" in self.EdkIIBuildOption["MAKE"]:\r
Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]\r
Guid = gEfiVarStoreGuidPattern.search(Content, Pos)\r
if not Guid:\r
break\r
- NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
+ NameArray = _ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r
Pos = Content.find('efivarstore', Name.end())\r
if not NameGuids:\r
Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)\r
if not Value:\r
continue\r
- Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
+ Name = _ConvertStringToByteArray(SkuInfo.VariableName)\r
Guid = GuidStructureStringToGuidString(Value)\r
if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:\r
HiiExPcds.append(Pcd)\r
\r
return True, ""\r
\r
-## Split command line option string to list\r
-#\r
-# subprocess.Popen needs the args to be a sequence. Otherwise there's problem\r
-# in non-windows platform to launch command\r
-#\r
-def SplitOption(OptionString):\r
- OptionList = []\r
- LastChar = " "\r
- OptionStart = 0\r
- QuotationMark = ""\r
- for Index in range(0, len(OptionString)):\r
- CurrentChar = OptionString[Index]\r
- if CurrentChar in ['"', "'"]:\r
- if QuotationMark == CurrentChar:\r
- QuotationMark = ""\r
- elif QuotationMark == "":\r
- QuotationMark = CurrentChar\r
- continue\r
- elif QuotationMark:\r
- continue\r
-\r
- if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:\r
- if Index > OptionStart:\r
- OptionList.append(OptionString[OptionStart:Index - 1])\r
- OptionStart = Index\r
- LastChar = CurrentChar\r
- OptionList.append(OptionString[OptionStart:])\r
- return OptionList\r
-\r
def CommonPath(PathList):\r
P1 = min(PathList).split(os.path.sep)\r
P2 = max(PathList).split(os.path.sep)\r
return os.path.sep.join(P1[:Index])\r
return os.path.sep.join(P1)\r
\r
-#\r
-# Convert string to C format array\r
-#\r
-def ConvertStringToByteArray(Value):\r
- Value = Value.strip()\r
- if not Value:\r
- return None\r
- if Value[0] == '{':\r
- if not Value.endswith('}'):\r
- return None\r
- Value = Value.replace(' ', '').replace('{', '').replace('}', '')\r
- ValFields = Value.split(',')\r
- try:\r
- for Index in range(len(ValFields)):\r
- ValFields[Index] = str(int(ValFields[Index], 0))\r
- except ValueError:\r
- return None\r
- Value = '{' + ','.join(ValFields) + '}'\r
- return Value\r
-\r
- Unicode = False\r
- if Value.startswith('L"'):\r
- if not Value.endswith('"'):\r
- return None\r
- Value = Value[1:]\r
- Unicode = True\r
- elif not Value.startswith('"') or not Value.endswith('"'):\r
- return None\r
-\r
- Value = eval(Value) # translate escape character\r
- NewValue = '{'\r
- for Index in range(0, len(Value)):\r
- if Unicode:\r
- NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','\r
- else:\r
- NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','\r
- Value = NewValue + '0}'\r
- return Value\r
-\r
class PathClass(object):\r
def __init__(self, File='', Root='', AlterRoot='', Type='', IsBinary=False,\r
Arch='COMMON', ToolChainFamily='', Target='', TagName='', ToolCode=''):\r