Changeset 287453d in rtems-libbsd for freebsd-to-rtems.py


Ignore:
Timestamp:
Mar 8, 2012, 8:13:25 PM (8 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, afaeccc05a556f6aa25ba044a7e49d6aa634a59e, freebsd-9.3, master
Children:
b55081a
Parents:
24600f2
Message:

freebsd-to-rtems.py - Only copy if new version of file is different

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freebsd-to-rtems.py

    r24600f2 r287453d  
    88#   Germany
    99#   <info@embedded-brains.de>
     10#
     11#  Copyright (c) 2012 OAR Corporation. All rights reserved.
    1012#
    1113#  Redistribution and use in source and binary forms, with or without
     
    3739import sys
    3840import getopt
     41import filecmp
    3942
    4043RTEMS_DIR = "not_set"
     
    4548isEarlyExit = False
    4649isOnlyMakefile = False
     50tempFile = "/tmp/tmp_FBRT"
    4751
    4852def usage():
     
    178182        return data
    179183
     184# compare and overwrite destination file only if different
     185def copyIfDifferent(new, old):
     186        if filecmp.cmp(new, old, shallow=False) == False:
     187                shutil.move(new, old)
     188                # print "Move " + new + " to " + old
     189                return True
     190        return False
     191       
     192   
    180193# Copy a header file from FreeBSD to the RTEMS BSD tree
    181194def installHeaderFile(org):
     195        global tempFile
    182196        src = FreeBSD_DIR + '/' + org
    183197        dst = RTEMS_DIR + '/' + PREFIX + '/' + org # + org.replace('rtems/', '')
    184198        dst = mapContribPath(dst)
    185         if isVerbose == True:
    186                 print "Install Header - " + src + " => " + dst
    187199        if isDryRun == True:
     200                if isVerbose == True:
     201                        print "Install Header - " + src + " => " + dst
    188202                return
    189203        try:
     
    192206                pass
    193207        data = open(src).read()
    194         out = open(dst, 'w')
     208        out = open(tempFile, 'w')
    195209        if src.find('rtems') == -1:
    196210                data = fixIncludes(data)
    197211        out.write(data)
    198212        out.close()
     213        if copyIfDifferent(tempFile, dst) == True:
     214                if isVerbose == True:
     215                        print "Install Header - " + src + " => " + dst
     216
    199217
    200218# Copy a source file from FreeBSD to the RTEMS BSD tree
    201219def installSourceFile(org):
     220        global tempFile
    202221        src = FreeBSD_DIR + '/' + org
    203222        dst = RTEMS_DIR + '/' + PREFIX + '/' + org
    204223        dst = mapContribPath(dst)
    205         if isVerbose == True:
    206                 print "Install Source - " + src + " => " + dst
    207224        if isDryRun == True:
     225                if isVerbose == True:
     226                        print "Install Source - " + src + " => " + dst
    208227                return
    209228        try:
     
    212231                pass
    213232        data = open(src).read()
    214         out = open(dst, 'w')
     233        out = open(tempFile, 'w')
    215234        if src.find('rtems') == -1:
    216235                data = fixIncludes(data)
     
    218237        out.write(data)
    219238        out.close()
     239        if copyIfDifferent(tempFile, dst) == True:
     240                if isVerbose == True:
     241                        print "Install Source - " + src + " => " + dst
    220242
    221243# Revert a header file from the RTEMS BSD tree to the FreeBSD tree
Note: See TracChangeset for help on using the changeset viewer.