There is a limitation on WINDOWS OS for the length of entire file path can’t be larger than 255. There is an OS API provided by Microsoft to add “\\?\” before the path header to support the long file path. Enable this feature on basetools.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15809 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Hess Chen
2014-08-15 03:06:48 +00:00
committed by hchen30
parent b8a13d7369
commit 1be2ed90a2
109 changed files with 702 additions and 332 deletions

View File

@@ -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 *

View File

@@ -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

View File

@@ -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
#

View File

@@ -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

View File

@@ -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
#

View File

@@ -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 *

View File

@@ -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 *

View File

@@ -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'

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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]

View File

@@ -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.
#

View File

@@ -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)

View File

@@ -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}$')

View File

@@ -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"

View File

@@ -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

View File

@@ -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 = \
"""