Make EXTRAS work for relative directories.

Also print a little feedback when processing EXTRAS.

--HG--
extra : convert_revision : 9cb324b0d5bc60a3c98af6495f16415b529e4af2
This commit is contained in:
Steve Reinhardt 2007-11-16 20:10:33 -08:00
parent 21a99af009
commit 785eb13190
2 changed files with 13 additions and 6 deletions

View file

@ -68,6 +68,8 @@ import os
from os.path import isdir, join as joinpath from os.path import isdir, join as joinpath
import SCons
# Check for recent-enough Python and SCons versions. If your system's # Check for recent-enough Python and SCons versions. If your system's
# default installation of Python is not recent enough, you can use a # default installation of Python is not recent enough, you can use a
# non-default installation of the Python interpreter by either (1) # non-default installation of the Python interpreter by either (1)
@ -472,14 +474,19 @@ all_isa_list.sort()
all_cpu_list.sort() all_cpu_list.sort()
default_cpus.sort() default_cpus.sort()
def ExtraPathValidator(key, val, env): def PathListMakeAbsolute(val):
if not val:
return val
f = lambda p: os.path.abspath(os.path.expanduser(p))
return ':'.join(map(f, val.split(':')))
def PathListAllExist(key, val, env):
if not val: if not val:
return return
paths = val.split(':') paths = val.split(':')
for path in paths: for path in paths:
path = os.path.expanduser(path)
if not isdir(path): if not isdir(path):
raise AttributeError, "Invalid path: '%s'" % path raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
sticky_opts.AddOptions( sticky_opts.AddOptions(
EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list), EnumOption('TARGET_ISA', 'Target ISA', 'alpha', all_isa_list),
@ -509,7 +516,7 @@ sticky_opts.AddOptions(
'Override the default PYTHONHOME for this system (use with caution)', 'Override the default PYTHONHOME for this system (use with caution)',
'%s:%s' % (sys.prefix, sys.exec_prefix)), '%s:%s' % (sys.prefix, sys.exec_prefix)),
('EXTRAS', 'Add Extra directories to the compilation', '', ('EXTRAS', 'Add Extra directories to the compilation', '',
ExtraPathValidator) PathListAllExist, PathListMakeAbsolute)
) )
nonsticky_opts.AddOptions( nonsticky_opts.AddOptions(

View file

@ -198,12 +198,12 @@ for root, dirs, files in os.walk(srcdir, topdown=True):
extra_string = env['EXTRAS'] extra_string = env['EXTRAS']
if extra_string and extra_string != '' and not extra_string.isspace(): if extra_string and extra_string != '' and not extra_string.isspace():
for extra in extra_string.split(':'): for extra in extra_string.split(':'):
extra = os.path.expanduser(extra) print 'Adding', extra, 'to source directory list'
extra = os.path.normpath(extra)
env.Append(CPPPATH=[Dir(extra)]) env.Append(CPPPATH=[Dir(extra)])
for root, dirs, files in os.walk(extra, topdown=True): for root, dirs, files in os.walk(extra, topdown=True):
if 'SConscript' in files: if 'SConscript' in files:
subdir = root[len(os.path.dirname(extra))+1:] subdir = root[len(os.path.dirname(extra))+1:]
print ' Found SConscript in', subdir
build_dir = joinpath(env['BUILDDIR'], subdir) build_dir = joinpath(env['BUILDDIR'], subdir)
SConscript(joinpath(root, 'SConscript'), build_dir=build_dir) SConscript(joinpath(root, 'SConscript'), build_dir=build_dir)