Changeset a84249d in rtems-source-builder


Ignore:
Timestamp:
Mar 3, 2015, 9:20:10 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, master
Children:
46ec6b5
Parents:
dbb78dc
git-author:
Chris Johns <chrisj@…> (03/03/15 09:20:10)
git-committer:
Chris Johns <chrisj@…> (03/06/15 22:24:51)
Message:

Windows fixes to build with MSYS2.

The path handling has been cleaned up and support for file names
longer than 256 characters.

Location:
source-builder/sb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source-builder/sb/path.py

    rdbb78dc ra84249d  
    2727import os
    2828import shutil
     29import stat
    2930import string
    3031
     
    3738        while '//' in path:
    3839            path = path.replace('//', '/')
    39         if windows and len(path) > 2:
    40             if path[0] == '/' and path[2] == '/' and \
    41                     (path[1] in string.ascii_lowercase or \
    42                          path[1] in string.ascii_uppercase):
    43                 path = ('%s:%s' % (path[1], path[2:])).replace('/', '\\')
     40        if windows:
     41            if len(path) > 2 and \
     42               path[0] == '/' and path[2] == '/' and \
     43               (path[1] in string.ascii_lowercase or \
     44                path[1] in string.ascii_uppercase):
     45                path = '%s:%s' % (path[1], path[2:])
     46            path = path.replace('/', '\\')
     47            if not path.startswith('\\\\?\\') and len(path) > 254:
     48                path = '\\\\?\\' + path
    4449    return path
    4550
    4651def shell(path):
    4752    if path is not None:
    48         if windows and len(path) > 1 and path[1] == ':':
    49             path = ('/%s%s' % (path[0], path[2:])).replace('\\', '/')
     53        if windows:
     54            if path.startswith('\\\\?\\'):
     55                path = path[4:]
     56            if len(path) > 1 and path[1] == ':':
     57                path = '/%s%s' % (path[0], path[2:])
     58            path = path.replace('\\', '/')
    5059        while '//' in path:
    5160            path = path.replace('//', '/')
     
    126135
    127136def removeall(path):
    128 
    129     def _onerror(function, path, excinfo):
    130         import stat
    131         if windows:
    132             path = "\\\\?\\" + path
    133         if not os.access(path, os.W_OK):
    134             # Is the error an access error ?
    135             os.chmod(path, stat.S_IWUSR)
    136             function(path)
    137         else:
    138             print 'removeall error: %s' % (path)
    139             raise
    140 
     137    #
     138    # Perform the removal of the directory tree manually so we can
     139    # make sure on Windows the files and correctly encoded to avoid
     140    # the size limit.
     141    #
    141142    path = host(path)
    142     shutil.rmtree(path, onerror = _onerror)
    143     return
     143    for root, dirs, files in os.walk(path, topdown = False):
     144        for name in files:
     145            file = host(os.path.join(root, name))
     146            if not os.access(file, os.W_OK):
     147                os.chmod(file, stat.S_IWUSR)
     148            os.unlink(file)
     149        for name in dirs:
     150            dir = host(os.path.join(root, name))
     151            if not os.access(dir, os.W_OK):
     152                os.chmod(dir, stat.S_IWUSR)
     153            os.rmdir(dir)
     154    if not os.access(path, os.W_OK):
     155        os.chmod(path, stat.S_IWUSR)
     156    os.rmdir(path)
    144157
    145158def expand(name, paths):
     
    174187
    175188    for name in names:
    176         srcname = os.path.join(hsrc, name)
    177         dstname = os.path.join(hdst, name)
     189        srcname = host(os.path.join(hsrc, name))
     190        dstname = host(os.path.join(hdst, name))
    178191        try:
    179192            if os.path.islink(srcname):
     
    183196                        dstlinkto = os.readlink(dstname)
    184197                        if linkto != dstlinkto:
    185                             log.warning('copying tree: update of link does not match: %s -> %s' % \
     198                            log.warning('copying tree: link does not match: %s -> %s' % \
    186199                                            (dstname, dstlinkto))
    187200                            os.remove(dstname)
     
    195208                copy_tree(srcname, dstname)
    196209            else:
    197                 if windows:
    198                     shutil.copy2("\\\\?\\" + srcname, dstname)
    199                 else:
    200                     shutil.copy2(srcname, dstname)
     210                    shutil.copy2(host(srcname), host(dstname))
    201211        except shutil.Error, err:
    202212            raise error.general('copying tree: %s -> %s: %s' % \
     
    228238    print basename('x:/sd/df/fg/me.txt')
    229239    print dirname('x:/sd/df/fg/me.txt')
    230     print join('s:/d/', '/g', '/tyty/fgfg')
     240    print join('s:/d/e\\f/g', '/h', '/tyty/zxzx', '\\mm\\nn/p')
  • source-builder/sb/windows.py

    rdbb78dc ra84249d  
    6868        ncpus = '1'
    6969
     70    if os.environ.has_key('MSYSTEM'):
     71        os.environ.pop('NUMBER_OF_PROCESSORS')
     72
    7073    version = uname[2]
    7174    defines = {
Note: See TracChangeset for help on using the changeset viewer.