mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 00:51:36 +08:00
More comments. Attempt to support forward/revert selection from command line
This commit is contained in:
parent
2defe9d7e0
commit
1e8830f013
@ -124,6 +124,12 @@ if FreeBSD_DIR == RTEMS_DIR:
|
||||
print "FreeBSD and RTEMS Directories are the same"
|
||||
sys.exit(2)
|
||||
|
||||
# Are we generating or reverting?
|
||||
if isForward == True:
|
||||
print "Generating into", RTEMS_DIR
|
||||
else:
|
||||
print "Reverting from", RTEMS_DIR
|
||||
|
||||
if isEarlyExit == True:
|
||||
print "Early exit at user request"
|
||||
sys.exit(0)
|
||||
@ -132,14 +138,13 @@ if isEarlyExit == True:
|
||||
# build tree.
|
||||
PREFIX = 'freebsd'
|
||||
|
||||
print "Generating into", RTEMS_DIR
|
||||
|
||||
def mapContribPath(path):
|
||||
m = re.match('(.*)(' + PREFIX + '/)(contrib/\\w+/)(.*)', path)
|
||||
if m:
|
||||
path = m.group(1) + m.group(3) + m.group(2) + m.group(4)
|
||||
return path
|
||||
|
||||
# generate an empty file as a place holder
|
||||
def installEmptyFile(src):
|
||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + src.replace('rtems/', '')
|
||||
if isVerbose == True:
|
||||
@ -154,6 +159,7 @@ def installEmptyFile(src):
|
||||
out.write('/* EMPTY */\n')
|
||||
out.close()
|
||||
|
||||
# fix include paths inside a C or .h file
|
||||
def fixIncludes(data):
|
||||
data = re.sub('#([ \t]*)include <', '#\\1include <' + PREFIX + '/', data)
|
||||
data = re.sub('#include <' + PREFIX + '/rtems', '#include <rtems', data)
|
||||
@ -162,12 +168,14 @@ def fixIncludes(data):
|
||||
data = re.sub('_H_', '_HH_', data)
|
||||
return data
|
||||
|
||||
# revert fixing the include paths inside a C or .h file
|
||||
def revertFixIncludes(data):
|
||||
data = re.sub('_HH_', '_H_', data)
|
||||
data = re.sub('#include <' + PREFIX + '/local/([^>]*)>', '#include "\\1"', data)
|
||||
data = re.sub('#([ \t]*)include <' + PREFIX + '/', '#\\1include <', data)
|
||||
return data
|
||||
|
||||
# Copy a header file from FreeBSD to the RTEMS BSD tree
|
||||
def installHeaderFile(org):
|
||||
src = FreeBSD_DIR + '/' + org
|
||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + org # + org.replace('rtems/', '')
|
||||
@ -187,6 +195,7 @@ def installHeaderFile(org):
|
||||
out.write(data)
|
||||
out.close()
|
||||
|
||||
# Copy a source file from FreeBSD to the RTEMS BSD tree
|
||||
def installSourceFile(org):
|
||||
src = FreeBSD_DIR + '/' + org
|
||||
dst = RTEMS_DIR + '/' + PREFIX + '/' + org
|
||||
@ -207,6 +216,7 @@ def installSourceFile(org):
|
||||
out.write(data)
|
||||
out.close()
|
||||
|
||||
# Revert a header file from the RTEMS BSD tree to the FreeBSD tree
|
||||
def revertHeaderFile(org):
|
||||
src = RTEMS_DIR + '/' + PREFIX + '/' + org.replace('rtems/', '')
|
||||
src = mapContribPath(src)
|
||||
@ -226,6 +236,7 @@ def revertHeaderFile(org):
|
||||
out.write(data)
|
||||
out.close()
|
||||
|
||||
# Revert a source file from the RTEMS BSD tree to the FreeBSD tree
|
||||
def revertSourceFile(org):
|
||||
src = RTEMS_DIR + '/' + PREFIX + '/' + org
|
||||
src = mapContribPath(src)
|
||||
@ -246,6 +257,7 @@ def revertSourceFile(org):
|
||||
out.write(data)
|
||||
out.close()
|
||||
|
||||
# Remove the output directory
|
||||
def deleteOutputDirectory():
|
||||
if isVerbose == True:
|
||||
print "Delete Directory - " + RTEMS_DIR
|
||||
@ -256,6 +268,7 @@ def deleteOutputDirectory():
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Module Manager - Collection of Modules
|
||||
class ModuleManager:
|
||||
def __init__(self):
|
||||
self.modules = []
|
||||
@ -343,6 +356,7 @@ class ModuleManager:
|
||||
out.write(data)
|
||||
out.close()
|
||||
|
||||
# Module - logical group of related files we can perform actions on
|
||||
class Module:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
@ -359,6 +373,8 @@ class Module:
|
||||
def addDependency(self, dep):
|
||||
self.dependencies.append(dep)
|
||||
|
||||
# Create Module Manager and supporting Modules
|
||||
# - initialize each module with set of files associated
|
||||
mm = ModuleManager()
|
||||
|
||||
rtems_headerFiles = [
|
||||
@ -1667,6 +1683,7 @@ mm.addEmptyFiles(
|
||||
]
|
||||
)
|
||||
|
||||
# Register all the Module instances with the Module Manager
|
||||
mm.addModule(netDeps)
|
||||
mm.addModule(net)
|
||||
mm.addModule(netinet)
|
||||
@ -1691,7 +1708,10 @@ mm.addModule(devUsbStorage)
|
||||
|
||||
#mm.addModule(devUsbNet)
|
||||
|
||||
#mm.revertFiles()
|
||||
# Perform the actual file manipulation
|
||||
if isForward == True:
|
||||
mm.copyFiles()
|
||||
mm.createMakefile()
|
||||
else:
|
||||
mm.revertFiles()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user