mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-16 04:46:27 +08:00
Move dry run check so more actions are performed during dry run
+ Output is now generated ANYTIME a file is transferred from one tree to the other. + Dry run means that all actions EXCEPT final overwrite of the destination file are performed. + Output message for file copy is in a single location
This commit is contained in:
@@ -156,12 +156,15 @@ def mapCPUDependentPath(path):
|
|||||||
return path.replace("include/", "include/freebsd/machine/")
|
return path.replace("include/", "include/freebsd/machine/")
|
||||||
|
|
||||||
# compare and overwrite destination file only if different
|
# compare and overwrite destination file only if different
|
||||||
def copyIfDifferent(new, old):
|
def copyIfDifferent(new, old, desc, src):
|
||||||
global filesChanged
|
global filesChanged
|
||||||
|
# print new + " " + old + " X" + desc + "X " + src
|
||||||
if not os.path.exists(old) or \
|
if not os.path.exists(old) or \
|
||||||
filecmp.cmp(new, old, shallow=False) == False:
|
filecmp.cmp(new, old, shallow=False) == False:
|
||||||
shutil.move(new, old)
|
|
||||||
filesChanged += 1
|
filesChanged += 1
|
||||||
|
print "Install " + desc + src + " => " + dst
|
||||||
|
if isDryRun == False:
|
||||||
|
shutil.move(new, old)
|
||||||
# print "Move " + new + " to " + old
|
# print "Move " + new + " to " + old
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -170,20 +173,15 @@ def copyIfDifferent(new, old):
|
|||||||
def installEmptyFile(src):
|
def installEmptyFile(src):
|
||||||
global tempFile
|
global tempFile
|
||||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + src.replace('rtems/', '')
|
dst = RTEMS_DIR + '/' + PREFIX + '/' + src.replace('rtems/', '')
|
||||||
if isDryRun == True:
|
|
||||||
if isVerbose == True:
|
|
||||||
print "Install empty - " + dst
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
if isDryRun == False:
|
||||||
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
out = open(tempFile, 'w')
|
out = open(tempFile, 'w')
|
||||||
out.write('/* EMPTY */\n')
|
out.write('/* EMPTY */\n')
|
||||||
out.close()
|
out.close()
|
||||||
if copyIfDifferent(tempFile, dst) == True:
|
copyIfDifferent(tempFile, dst, "empty file ", "" )
|
||||||
if isVerbose == True:
|
|
||||||
print "Install empty - " + dst
|
|
||||||
|
|
||||||
# fix include paths inside a C or .h file
|
# fix include paths inside a C or .h file
|
||||||
def fixIncludes(data):
|
def fixIncludes(data):
|
||||||
@@ -209,12 +207,9 @@ def installHeaderFile(org, target):
|
|||||||
dst = mapContribPath(dst)
|
dst = mapContribPath(dst)
|
||||||
if target != "generic":
|
if target != "generic":
|
||||||
dst = mapCPUDependentPath(dst)
|
dst = mapCPUDependentPath(dst)
|
||||||
if isDryRun == True:
|
|
||||||
if isVerbose == True:
|
|
||||||
print "Install Header - " + src + " => " + dst
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
if isDryRun == False:
|
||||||
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
@@ -223,9 +218,7 @@ def installHeaderFile(org, target):
|
|||||||
data = fixIncludes(data)
|
data = fixIncludes(data)
|
||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
out.close()
|
||||||
if copyIfDifferent(tempFile, dst) == True:
|
copyIfDifferent(tempFile, dst, "Header ", src)
|
||||||
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
|
||||||
@@ -234,12 +227,9 @@ def installSourceFile(org):
|
|||||||
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:
|
|
||||||
print "Install Source - " + src + " => " + dst
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
if isDryRun == False:
|
||||||
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
@@ -249,9 +239,7 @@ def installSourceFile(org):
|
|||||||
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:
|
copyIfDifferent(tempFile, dst, "Source ", src)
|
||||||
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, target):
|
def revertHeaderFile(org, target):
|
||||||
@@ -261,12 +249,9 @@ def revertHeaderFile(org, target):
|
|||||||
if target != "generic":
|
if target != "generic":
|
||||||
src = mapCPUDependentPath(src)
|
src = mapCPUDependentPath(src)
|
||||||
dst = FreeBSD_DIR + '/' + org
|
dst = FreeBSD_DIR + '/' + org
|
||||||
if isVerbose == True:
|
|
||||||
print "Revert Header - " + src + " => " + dst
|
|
||||||
if isDryRun == True:
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
if isDryRun == False:
|
||||||
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
@@ -275,9 +260,7 @@ def revertHeaderFile(org, target):
|
|||||||
data = revertFixIncludes(data)
|
data = revertFixIncludes(data)
|
||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
out.close()
|
||||||
if copyIfDifferent(tempFile, dst) == True:
|
copyIfDifferent(tempFile, dst, "Header ", src)
|
||||||
if isVerbose == True:
|
|
||||||
print "Revert Header - " + src + " => " + dst
|
|
||||||
|
|
||||||
# Revert a source file from the RTEMS BSD tree to the FreeBSD tree
|
# Revert a source file from the RTEMS BSD tree to the FreeBSD tree
|
||||||
def revertSourceFile(org, target):
|
def revertSourceFile(org, target):
|
||||||
@@ -286,12 +269,9 @@ def revertSourceFile(org, target):
|
|||||||
dst = FreeBSD_DIR + '/' + org
|
dst = FreeBSD_DIR + '/' + org
|
||||||
if target != "generic":
|
if target != "generic":
|
||||||
src = mapCPUDependentPath(src)
|
src = mapCPUDependentPath(src)
|
||||||
if isVerbose == True:
|
|
||||||
print "Revert Source - " + src + " => " + dst
|
|
||||||
if isDryRun == True:
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.dirname(dst))
|
if isDryRun == False:
|
||||||
|
os.makedirs(os.path.dirname(dst))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
data = open(src).read()
|
data = open(src).read()
|
||||||
@@ -301,19 +281,19 @@ def revertSourceFile(org, target):
|
|||||||
data = revertFixIncludes(data)
|
data = revertFixIncludes(data)
|
||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
out.close()
|
||||||
if copyIfDifferent(tempFile, dst) == True:
|
copyIfDifferent(tempFile, dst, "Source ", src)
|
||||||
if isVerbose == True:
|
|
||||||
print "Revert Source - " + src + " => " + dst
|
|
||||||
|
|
||||||
# Remove the output directory
|
# Remove the output directory
|
||||||
def deleteOutputDirectory():
|
def deleteOutputDirectory():
|
||||||
if isVerbose == True:
|
|
||||||
print "Delete Directory - " + RTEMS_DIR
|
|
||||||
if isDryRun == True:
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
print "Deleting output directory needs to be more precise"
|
if isVerbose == True:
|
||||||
#shutil.rmtree(RTEMS_DIR)
|
print "Delete Directory - " + RTEMS_DIR + "/freebsd"
|
||||||
|
if isVerbose == True:
|
||||||
|
print "Delete Directory - " + RTEMS_DIR + "/contrib"
|
||||||
|
if isDryRun == True:
|
||||||
|
return
|
||||||
|
shutil.rmtree(RTEMS_DIR + "/freebsd" )
|
||||||
|
shutil.rmtree(RTEMS_DIR + "/contrib" )
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -347,10 +327,6 @@ class ModuleManager:
|
|||||||
|
|
||||||
def createMakefile(self):
|
def createMakefile(self):
|
||||||
global tempFile
|
global tempFile
|
||||||
if isDryRun == True:
|
|
||||||
if isVerbose == True:
|
|
||||||
print "Create Makefile"
|
|
||||||
return
|
|
||||||
data = 'include config.inc\n' \
|
data = 'include config.inc\n' \
|
||||||
'\n' \
|
'\n' \
|
||||||
'include $(RTEMS_MAKEFILE_PATH)/Makefile.inc\n' \
|
'include $(RTEMS_MAKEFILE_PATH)/Makefile.inc\n' \
|
||||||
@@ -431,9 +407,7 @@ class ModuleManager:
|
|||||||
out.write(data)
|
out.write(data)
|
||||||
out.close()
|
out.close()
|
||||||
makefile = RTEMS_DIR + '/Makefile'
|
makefile = RTEMS_DIR + '/Makefile'
|
||||||
if copyIfDifferent(tempFile, makefile) == True:
|
copyIfDifferent(tempFile, makefile, "Makefile ", "")
|
||||||
if isVerbose == True:
|
|
||||||
print "Create Makefile"
|
|
||||||
|
|
||||||
# Module - logical group of related files we can perform actions on
|
# Module - logical group of related files we can perform actions on
|
||||||
class Module:
|
class Module:
|
||||||
|
Reference in New Issue
Block a user