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