diff options
Diffstat (limited to 'BaseTools/Source/Python/Common')
18 files changed, 224 insertions, 29 deletions
diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py index 5c0a79f291..a81a44731f 100644 --- a/BaseTools/Source/Python/Common/Database.py +++ b/BaseTools/Source/Python/Common/Database.py @@ -1,7 +1,7 @@ ## @file
# This file is used to create a database used by ECC tool
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -15,7 +15,7 @@ # Import Modules
#
import sqlite3
-import os
+import Common.LongFilePathOs as os
import EdkLogger as EdkLogger
from CommonDataClass.DataClass import *
diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py index 5b39bcd4ce..d7c70a7336 100644 --- a/BaseTools/Source/Python/Common/DecClassObject.py +++ b/BaseTools/Source/Python/Common/DecClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of DEC file
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
from String import *
from DataType import *
from Identification import *
@@ -26,6 +26,7 @@ from Table.TableDec import TableDec import Database
from Parsing import *
import GlobalData
+from Common.LongFilePathSupport import OpenLongFilePath as open
#
# Global variable
diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py index de3556b892..5300a5456c 100644 --- a/BaseTools/Source/Python/Common/Dictionary.py +++ b/BaseTools/Source/Python/Common/Dictionary.py @@ -1,7 +1,7 @@ ## @file
# Define a dictionary structure
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -16,6 +16,7 @@ #
import EdkLogger
from DataType import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
## Convert a text file to a dictionary
#
diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py index 3d06288e9a..788a75e267 100644 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ b/BaseTools/Source/Python/Common/DscClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of DSC file
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import EdkLogger as EdkLogger
import Database
from String import *
@@ -28,6 +28,7 @@ from BuildToolError import * from Misc import sdict
import GlobalData
from Table.TableDsc import TableDsc
+from Common.LongFilePathSupport import OpenLongFilePath as open
#
# Global variable
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/Python/Common/EdkIIWorkspace.py index d041b35411..84d89b6c2e 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py @@ -1,7 +1,7 @@ ## @file
# This is the base class for applications that operate on an EDK II Workspace
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,8 +14,9 @@ ##
# Import Modules
#
-import os, sys, time
+import Common.LongFilePathOs as os, sys, time
from DataType import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
## EdkIIWorkspace
#
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py index 2b5990ebe7..d6df01d4ce 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of the build database
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ ##
# Import Modules
#
-import os, string, copy, pdb, copy
+import Common.LongFilePathOs as os, string, copy, pdb, copy
import EdkLogger
import DataType
from InfClassObject import *
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py index 10e7222b3d..f048b619e4 100644 --- a/BaseTools/Source/Python/Common/EdkLogger.py +++ b/BaseTools/Source/Python/Common/EdkLogger.py @@ -1,7 +1,7 @@ ## @file
# This file implements the log mechanism for Python tools.
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -12,7 +12,7 @@ #
## Import modules
-import sys, os, logging
+import Common.LongFilePathOs as os, sys, logging
import traceback
from BuildToolError import *
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index 031dc15bc7..54a60a7e8f 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -1,7 +1,7 @@ ## @file
# parse FDF file
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -16,9 +16,10 @@ # Import Modules
#
import re
-import os
+import Common.LongFilePathOs as os
import CommonDataClass.FdfClass
+from Common.LongFilePathSupport import OpenLongFilePath as open
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py index 7ea0c39297..f24e4e41a0 100644 --- a/BaseTools/Source/Python/Common/InfClassObject.py +++ b/BaseTools/Source/Python/Common/InfClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of INF file
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import re
import EdkLogger
from CommonDataClass.CommonClass import LibraryClassClass
@@ -29,6 +29,7 @@ import GlobalData from Table.TableInf import TableInf
import Database
from Parsing import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
#
# Global variable
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py new file mode 100644 index 0000000000..66d93d25f3 --- /dev/null +++ b/BaseTools/Source/Python/Common/LongFilePathOs.py @@ -0,0 +1,73 @@ +## @file
+# Override built in module os to provide support for long file path
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+import os
+import LongFilePathOsPath
+from Common.LongFilePathSupport import LongFilePath
+from Common.LongFilePathSupport import UniToStr
+
+path = LongFilePathOsPath
+
+def access(path, mode):
+ return os.access(LongFilePath(path), mode)
+
+def remove(path):
+ return os.remove(LongFilePath(path))
+
+def removedirs(name):
+ return os.removedirs(LongFilePath(name))
+
+def rmdir(path):
+ return os.rmdir(LongFilePath(path))
+
+def mkdir(path):
+ return os.mkdir(LongFilePath(path))
+
+def makedirs(name, mode=0777):
+ return os.makedirs(LongFilePath(name), mode)
+
+def rename(old, new):
+ return os.rename(LongFilePath(old), LongFilePath(new))
+
+def chdir(path):
+ return os.chdir(LongFilePath(path))
+
+def chmod(path, mode):
+ return os.chmod(LongFilePath(path), mode)
+
+def stat(path):
+ return os.stat(LongFilePath(path))
+
+def utime(path):
+ return os.utime(LongFilePath(path), None)
+
+def listdir(path):
+ List = []
+ uList = os.listdir(u"%s" % LongFilePath(path))
+ for Item in uList:
+ List.append(UniToStr(Item))
+ return List
+
+environ = os.environ
+getcwd = os.getcwd
+chdir = os.chdir
+walk = os.walk
+W_OK = os.W_OK
+F_OK = os.F_OK
+sep = os.sep
+linesep = os.linesep
+getenv = os.getenv
+pathsep = os.pathsep
+name = os.name
+SEEK_SET = os.SEEK_SET
+SEEK_END = os.SEEK_END
diff --git a/BaseTools/Source/Python/Common/LongFilePathOsPath.py b/BaseTools/Source/Python/Common/LongFilePathOsPath.py new file mode 100644 index 0000000000..cb89b1b813 --- /dev/null +++ b/BaseTools/Source/Python/Common/LongFilePathOsPath.py @@ -0,0 +1,51 @@ +## @file
+# Override built in module os.path to provide support for long file path
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+import os
+from Common.LongFilePathSupport import LongFilePath
+
+def isfile(path):
+ return os.path.isfile(LongFilePath(path))
+
+def isdir(path):
+ return os.path.isdir(LongFilePath(path))
+
+def exists(path):
+ return os.path.exists(LongFilePath(path))
+
+def getsize(filename):
+ return os.path.getsize(LongFilePath(filename))
+
+def getmtime(filename):
+ return os.path.getmtime(LongFilePath(filename))
+
+def getatime(filename):
+ return os.path.getatime(LongFilePath(filename))
+
+def getctime(filename):
+ return os.path.getctime(LongFilePath(filename))
+
+join = os.path.join
+splitext = os.path.splitext
+splitdrive = os.path.splitdrive
+split = os.path.split
+abspath = os.path.abspath
+basename = os.path.basename
+commonprefix = os.path.commonprefix
+sep = os.path.sep
+normpath = os.path.normpath
+normcase = os.path.normcase
+dirname = os.path.dirname
+islink = os.path.islink
+isabs = os.path.isabs
+realpath = os.path.realpath
diff --git a/BaseTools/Source/Python/Common/LongFilePathSupport.py b/BaseTools/Source/Python/Common/LongFilePathSupport.py new file mode 100644 index 0000000000..72dde20503 --- /dev/null +++ b/BaseTools/Source/Python/Common/LongFilePathSupport.py @@ -0,0 +1,59 @@ +## @file
+# Override built in function file.open to provide support for long file path
+#
+# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+import os
+import platform
+import shutil
+
+##
+# OpenLongPath
+# Convert a file path to a long file path
+#
+def LongFilePath(FileName):
+ FileName = os.path.normpath(FileName)
+ if platform.system() == 'Windows':
+ if FileName.startswith('\\\\?\\'):
+ return FileName
+ if FileName.startswith('\\\\'):
+ return '\\\\?\\UNC\\' + FileName[2:]
+ if os.path.isabs(FileName):
+ return '\\\\?\\' + FileName
+ return FileName
+
+##
+# OpenLongFilePath
+# wrap open to support opening a long file path
+#
+def OpenLongFilePath(FileName, Mode='r', Buffer= -1):
+ return open(LongFilePath(FileName), Mode, Buffer)
+
+##
+# CopyLongFilePath
+# wrap copyfile to support copy a long file path
+#
+def CopyLongFilePath(src, dst):
+ with open(LongFilePath(src), 'rb') as fsrc:
+ with open(LongFilePath(dst), 'wb') as fdst:
+ shutil.copyfileobj(fsrc, fdst)
+
+## Convert a python unicode string to a normal string
+#
+# Convert a python unicode string to a normal string
+# UniToStr(u'I am a string') is 'I am a string'
+#
+# @param Uni: The python unicode string
+#
+# @retval: The formatted normal string
+#
+def UniToStr(Uni):
+ return repr(Uni)[2:-1]
diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py index 7c69704596..6d6669d7ae 100644 --- a/BaseTools/Source/Python/Common/MigrationUtilities.py +++ b/BaseTools/Source/Python/Common/MigrationUtilities.py @@ -1,7 +1,7 @@ ## @file
# Contains several utilitities shared by migration tools.
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,13 +14,14 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import re
import EdkLogger
from optparse import OptionParser
from Common.BuildToolError import *
from XmlRoutines import *
from CommonDataClass.CommonClass import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
## Set all fields of CommonClass object.
#
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 7b568dc3e5..e9e41de02e 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1,7 +1,7 @@ ## @file
# Common routines used by all tools
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,7 +14,7 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import sys
import string
import thread
@@ -32,6 +32,7 @@ from DataType import * from BuildToolError import *
from CommonDataClass.DataClass import *
from Parsing import GetSplitValueList
+from Common.LongFilePathSupport import OpenLongFilePath as open
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE)
diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index 04b45a0b83..4dc8e9b116 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define common string related functions used in parsing process
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -16,13 +16,14 @@ #
import re
import DataType
-import os.path
+import Common.LongFilePathOs as os
import string
import EdkLogger as EdkLogger
import GlobalData
from BuildToolError import *
from CommonDataClass.Exceptions import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
gHexVerPatt = re.compile('0x[a-f0-9]{4}[a-f0-9]{4}$', re.IGNORECASE)
gHumanReadableVerPatt = re.compile(r'([1-9][0-9]*|0)\.[0-9]{1,2}$')
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py index a7dec65a25..89e3937086 100644 --- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py +++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of Target.txt file
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,11 +14,12 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import EdkLogger
import DataType
from BuildToolError import *
import GlobalData
+from Common.LongFilePathSupport import OpenLongFilePath as open
gDefaultTargetTxtFile = "Conf/target.txt"
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index 0f49457449..583d51b513 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of tools_def.txt file
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -14,13 +14,14 @@ ##
# Import Modules
#
-import os
+import Common.LongFilePathOs as os
import re
import EdkLogger
from Dictionary import *
from BuildToolError import *
from TargetTxtClassObject import *
+from Common.LongFilePathSupport import OpenLongFilePath as open
##
# Static variables used for pattern
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index 18f6f5663c..1a68e9bee1 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -6,7 +6,7 @@ # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt
#
#
-# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -15,11 +15,12 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-import os
+import Common.LongFilePathOs as os
import re
import Common.EdkLogger as EdkLogger
import Common.BuildToolError as BuildToolError
import subprocess
+from Common.LongFilePathSupport import OpenLongFilePath as open
FILE_COMMENT_TEMPLATE = \
"""
|