summaryrefslogtreecommitdiffstats
path: root/freebsd-to-rtems.py
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-08 14:13:25 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-08 14:13:25 -0600
commit287453d759a1e823076c90a826290315fa3504eb (patch)
treedcde8067d8e7a27e8ed1a30333e18f4c299aa277 /freebsd-to-rtems.py
parentAll RTEMS files should now be under RTEMS (diff)
downloadrtems-libbsd-287453d759a1e823076c90a826290315fa3504eb.tar.bz2
freebsd-to-rtems.py - Only copy if new version of file is different
Diffstat (limited to 'freebsd-to-rtems.py')
-rwxr-xr-xfreebsd-to-rtems.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py
index abb2f08b..421b2444 100755
--- a/freebsd-to-rtems.py
+++ b/freebsd-to-rtems.py
@@ -8,6 +8,8 @@
# Germany
# <info@embedded-brains.de>
#
+# Copyright (c) 2012 OAR Corporation. All rights reserved.
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@@ -36,6 +38,7 @@ import os
import re
import sys
import getopt
+import filecmp
RTEMS_DIR = "not_set"
FreeBSD_DIR = "not_set"
@@ -44,6 +47,7 @@ isForward = True
isDryRun = False
isEarlyExit = False
isOnlyMakefile = False
+tempFile = "/tmp/tmp_FBRT"
def usage():
print "freebsd-to-rtems.py [args]"
@@ -177,46 +181,64 @@ def revertFixIncludes(data):
data = re.sub('#([ \t]*)include <' + PREFIX + '/', '#\\1include <', data)
return data
+# compare and overwrite destination file only if different
+def copyIfDifferent(new, old):
+ if filecmp.cmp(new, old, shallow=False) == False:
+ shutil.move(new, old)
+ # print "Move " + new + " to " + old
+ return True
+ return False
+
+
# Copy a header file from FreeBSD to the RTEMS BSD tree
def installHeaderFile(org):
+ global tempFile
src = FreeBSD_DIR + '/' + org
dst = RTEMS_DIR + '/' + PREFIX + '/' + org # + org.replace('rtems/', '')
dst = mapContribPath(dst)
- if isVerbose == True:
- print "Install Header - " + src + " => " + dst
if isDryRun == True:
+ if isVerbose == True:
+ print "Install Header - " + src + " => " + dst
return
try:
os.makedirs(os.path.dirname(dst))
except OSError:
pass
data = open(src).read()
- out = open(dst, 'w')
+ out = open(tempFile, 'w')
if src.find('rtems') == -1:
data = fixIncludes(data)
out.write(data)
out.close()
+ if copyIfDifferent(tempFile, dst) == True:
+ if isVerbose == True:
+ print "Install Header - " + src + " => " + dst
+
# Copy a source file from FreeBSD to the RTEMS BSD tree
def installSourceFile(org):
+ global tempFile
src = FreeBSD_DIR + '/' + org
dst = RTEMS_DIR + '/' + PREFIX + '/' + org
dst = mapContribPath(dst)
- if isVerbose == True:
- print "Install Source - " + src + " => " + dst
if isDryRun == True:
+ if isVerbose == True:
+ print "Install Source - " + src + " => " + dst
return
try:
os.makedirs(os.path.dirname(dst))
except OSError:
pass
data = open(src).read()
- out = open(dst, 'w')
+ out = open(tempFile, 'w')
if src.find('rtems') == -1:
data = fixIncludes(data)
out.write('#include <' + PREFIX + '/machine/rtems-bsd-config.h>\n\n')
out.write(data)
out.close()
+ if copyIfDifferent(tempFile, dst) == True:
+ if isVerbose == True:
+ print "Install Source - " + src + " => " + dst
# Revert a header file from the RTEMS BSD tree to the FreeBSD tree
def revertHeaderFile(org):