SCons: implement logic to find source trees, which than can be built as plugin
This commit is contained in:
parent
5f22118ff5
commit
bd6436e43b
1 changed files with 45 additions and 0 deletions
|
|
@ -91,6 +91,38 @@ def globRootdirs(roots):
|
|||
|
||||
|
||||
|
||||
def findSrcTrees(location, patterns=SRCPATTERNS):
|
||||
""" find possible source tree roots, starting with the given location.
|
||||
When delving down from the initial location(s), a source tree is defined
|
||||
as a directory containing source files and possibly further sub directories.
|
||||
After having initially expanded the given location with #globRootdirs, each
|
||||
directory is examined depth first, until encountering a directory containing
|
||||
source files, which then yields a result. Especially, this can be used to traverse
|
||||
an organisational directory structure and find out all possible source trees of
|
||||
to be built into packages, plugins, individual tool executables etc.
|
||||
@return: the relative path names of all source root dirs found (generator function).
|
||||
"""
|
||||
for dir in globRootdirs(location):
|
||||
if isSrcDir(dir,patterns):
|
||||
yield dir
|
||||
else:
|
||||
for result in findSrcTrees(str(dir)+'/*'):
|
||||
yield result
|
||||
|
||||
|
||||
def isSrcDir(path, patterns=SRCPATTERNS):
|
||||
""" helper: investigate the given (relative) path
|
||||
@param patterns: list of wildcards defining what counts as "source file"
|
||||
@return: True if it's a directory containing any source file
|
||||
"""
|
||||
if not os.path.isdir(path):
|
||||
return False
|
||||
else:
|
||||
for p in patterns:
|
||||
if glob.glob(path+'/'+p):
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def filterNodes(nlist, removeName=None):
|
||||
""" filter out scons build nodes using the given criteria.
|
||||
|
|
@ -115,6 +147,19 @@ def getDirname(dir):
|
|||
|
||||
|
||||
|
||||
def createPlugins(env, dir):
|
||||
""" investigate the given source directory to identify all contained source trees.
|
||||
@return: a list of build nodes defining a plugin for each of these source trees.
|
||||
"""
|
||||
return [env.LoadableModule( '$PLUGDIR/%s' % getDirname(tree)
|
||||
, srcSubtree(env, tree)
|
||||
, SHLIBPREFIX='', SHLIBSUFFIX='.lum'
|
||||
)
|
||||
for tree in findSrcTrees(dir)
|
||||
]
|
||||
|
||||
|
||||
|
||||
def checkCommandOption(env, optID, val=None, cmdName=None):
|
||||
""" evaluate and verify an option, which may point at a command.
|
||||
besides specifying a path, the option may read True, yes or 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue