mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-15 06:51:41 +08:00
freebsd-to-rtems.py - Only copy if new version of file is different
This commit is contained in:
@@ -8,6 +8,8 @@
|
|||||||
# Germany
|
# Germany
|
||||||
# <info@embedded-brains.de>
|
# <info@embedded-brains.de>
|
||||||
#
|
#
|
||||||
|
# Copyright (c) 2012 OAR Corporation. All rights reserved.
|
||||||
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
# are met:
|
# are met:
|
||||||
@@ -36,6 +38,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
|
import filecmp
|
||||||
|
|
||||||
RTEMS_DIR = "not_set"
|
RTEMS_DIR = "not_set"
|
||||||
FreeBSD_DIR = "not_set"
|
FreeBSD_DIR = "not_set"
|
||||||
@@ -44,6 +47,7 @@ isForward = True
|
|||||||
isDryRun = False
|
isDryRun = False
|
||||||
isEarlyExit = False
|
isEarlyExit = False
|
||||||
isOnlyMakefile = False
|
isOnlyMakefile = False
|
||||||
|
tempFile = "/tmp/tmp_FBRT"
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "freebsd-to-rtems.py [args]"
|
print "freebsd-to-rtems.py [args]"
|
||||||
@@ -177,46 +181,64 @@ def revertFixIncludes(data):
|
|||||||
data = re.sub('#([ \t]*)include <' + PREFIX + '/', '#\\1include <', data)
|
data = re.sub('#([ \t]*)include <' + PREFIX + '/', '#\\1include <', data)
|
||||||
return 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
|
# Copy a header file from FreeBSD to the RTEMS BSD tree
|
||||||
def installHeaderFile(org):
|
def installHeaderFile(org):
|
||||||
|
global tempFile
|
||||||
src = FreeBSD_DIR + '/' + org
|
src = FreeBSD_DIR + '/' + org
|
||||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + org # + org.replace('rtems/', '')
|
dst = RTEMS_DIR + '/' + PREFIX + '/' + org # + org.replace('rtems/', '')
|
||||||
dst = mapContribPath(dst)
|
dst = mapContribPath(dst)
|
||||||
|
if isDryRun == True:
|
||||||
if isVerbose == True:
|
if isVerbose == True:
|
||||||
print "Install Header - " + src + " => " + dst
|
print "Install Header - " + src + " => " + dst
|
||||||
if isDryRun == True:
|
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
out = open(dst, 'w')
|
out = open(tempFile, 'w')
|
||||||
if src.find('rtems') == -1:
|
if src.find('rtems') == -1:
|
||||||
data = fixIncludes(data)
|
data = fixIncludes(data)
|
||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
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
|
# Copy a source file from FreeBSD to the RTEMS BSD tree
|
||||||
def installSourceFile(org):
|
def installSourceFile(org):
|
||||||
|
global tempFile
|
||||||
src = FreeBSD_DIR + '/' + org
|
src = FreeBSD_DIR + '/' + org
|
||||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + org
|
dst = RTEMS_DIR + '/' + PREFIX + '/' + org
|
||||||
dst = mapContribPath(dst)
|
dst = mapContribPath(dst)
|
||||||
|
if isDryRun == True:
|
||||||
if isVerbose == True:
|
if isVerbose == True:
|
||||||
print "Install Source - " + src + " => " + dst
|
print "Install Source - " + src + " => " + dst
|
||||||
if isDryRun == True:
|
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
out = open(dst, 'w')
|
out = open(tempFile, 'w')
|
||||||
if src.find('rtems') == -1:
|
if src.find('rtems') == -1:
|
||||||
data = fixIncludes(data)
|
data = fixIncludes(data)
|
||||||
out.write('#include <' + PREFIX + '/machine/rtems-bsd-config.h>\n\n')
|
out.write('#include <' + PREFIX + '/machine/rtems-bsd-config.h>\n\n')
|
||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
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
|
# Revert a header file from the RTEMS BSD tree to the FreeBSD tree
|
||||||
def revertHeaderFile(org):
|
def revertHeaderFile(org):
|
||||||
|
Reference in New Issue
Block a user