Add optional cpp output targets
This commit is contained in:
parent
309426e024
commit
927b14848f
34
SConstruct
34
SConstruct
|
@ -2430,6 +2430,7 @@ class DXXCommon(LazyObjectConstructor):
|
||||||
('use_tracker', True, 'enable Tracker support (requires UDP)'),
|
('use_tracker', True, 'enable Tracker support (requires UDP)'),
|
||||||
('verbosebuild', self.default_verbosebuild, 'print out all compiler/linker messages during building'),
|
('verbosebuild', self.default_verbosebuild, 'print out all compiler/linker messages during building'),
|
||||||
('register_compile_target', True, 'report compile targets to SCons core'),
|
('register_compile_target', True, 'report compile targets to SCons core'),
|
||||||
|
('register_cpp_output_targets', None, None),
|
||||||
# This is intentionally undocumented. If a bug
|
# This is intentionally undocumented. If a bug
|
||||||
# report includes a log with this set to False, the
|
# report includes a log with this set to False, the
|
||||||
# reporter will be asked to provide a log with the
|
# reporter will be asked to provide a log with the
|
||||||
|
@ -2682,12 +2683,31 @@ class DXXCommon(LazyObjectConstructor):
|
||||||
kwargs['CXXCOMSTR'] = "Checking %s %s %s" % (self.target, builddir, name)
|
kwargs['CXXCOMSTR'] = "Checking %s %s %s" % (self.target, builddir, name)
|
||||||
Depends(StaticObject(target=os.path.join('%s/chi/%s%s' % (dirname, name, OBJSUFFIX)), CPPFLAGS=CPPFLAGS, **kwargs), fs.File(name))
|
Depends(StaticObject(target=os.path.join('%s/chi/%s%s' % (dirname, name, OBJSUFFIX)), CPPFLAGS=CPPFLAGS, **kwargs), fs.File(name))
|
||||||
|
|
||||||
|
def _cpp_output_StaticObject(self,target=None,source=None,*args,**kwargs):
|
||||||
|
CXXFLAGS = kwargs.get('CXXFLAGS', None)
|
||||||
|
env = self.env
|
||||||
|
OBJSUFFIX = env['OBJSUFFIX']
|
||||||
|
StaticObject = env.__cpp_output_StaticObject
|
||||||
|
StaticObject(
|
||||||
|
target='%s.i' % (target[:-len(OBJSUFFIX)] if target.endswith(OBJSUFFIX) else target),
|
||||||
|
source=source, OBJSUFFIX='.i',
|
||||||
|
# Bypass ccache
|
||||||
|
CXXCOM=env._dxx_cxxcom_no_prefix,
|
||||||
|
CXXFLAGS=(env['CXXFLAGS'] if CXXFLAGS is None else CXXFLAGS) + ['-E'],
|
||||||
|
CXXCOMSTR=env.__generate_cpp_output_COMSTR,
|
||||||
|
)
|
||||||
|
return StaticObject(target=target, source=source, *args, **kwargs)
|
||||||
|
|
||||||
def create_pch_node(self,archive):
|
def create_pch_node(self,archive):
|
||||||
user_settings = self.user_settings
|
user_settings = self.user_settings
|
||||||
if user_settings.check_header_includes:
|
if user_settings.check_header_includes:
|
||||||
# Create header targets before creating the PCHManager, so that
|
# Create header targets before creating the PCHManager, so that
|
||||||
# create_header_targets() uses the stock env.StaticObject
|
# create_header_targets() uses the stock env.StaticObject
|
||||||
self.create_header_targets()
|
self.create_header_targets()
|
||||||
|
if user_settings.register_cpp_output_targets:
|
||||||
|
env = self.env
|
||||||
|
env.__cpp_output_StaticObject = env.StaticObject
|
||||||
|
env.StaticObject = self._cpp_output_StaticObject
|
||||||
configure_pch_flags = archive.configure_pch_flags
|
configure_pch_flags = archive.configure_pch_flags
|
||||||
if configure_pch_flags:
|
if configure_pch_flags:
|
||||||
self.pch_manager = PCHManager(self.user_settings, self.env, self.srcdir, configure_pch_flags, archive.pch_manager)
|
self.pch_manager = PCHManager(self.user_settings, self.env, self.srcdir, configure_pch_flags, archive.pch_manager)
|
||||||
|
@ -2749,10 +2769,16 @@ class DXXCommon(LazyObjectConstructor):
|
||||||
distcc_hosts = self.user_settings.distcc_hosts
|
distcc_hosts = self.user_settings.distcc_hosts
|
||||||
if distcc_hosts is not None:
|
if distcc_hosts is not None:
|
||||||
self.env['ENV']['DISTCC_HOSTS'] = distcc_hosts
|
self.env['ENV']['DISTCC_HOSTS'] = distcc_hosts
|
||||||
if (self.user_settings.verbosebuild == 0):
|
if self.user_settings.verbosebuild:
|
||||||
builddir = self.user_settings.builddir if self.user_settings.builddir != '' else '.'
|
self.env.__generate_cpp_output_COMSTR = None
|
||||||
self.env["CXXCOMSTR"] = "Compiling %s %s $SOURCE" % (self.target, builddir)
|
else:
|
||||||
self.env["LINKCOMSTR"] = "Linking %s $TARGET" % self.target
|
target = self.target[:3]
|
||||||
|
format_tuple = (target, self.user_settings.builddir or '.')
|
||||||
|
self.env.__generate_cpp_output_COMSTR = "CPP %s %s $SOURCE" % format_tuple
|
||||||
|
self.env["CXXCOMSTR"] = "CXX %s %s $SOURCE" % format_tuple
|
||||||
|
# `builddir` is implicit since $TARGET is the full path to
|
||||||
|
# the output
|
||||||
|
self.env["LINKCOMSTR"] = "LD %s $TARGET" % target
|
||||||
|
|
||||||
# Use -Wundef to catch when a shared source file includes a
|
# Use -Wundef to catch when a shared source file includes a
|
||||||
# shared header that misuses conditional compilation. Use
|
# shared header that misuses conditional compilation. Use
|
||||||
|
|
Loading…
Reference in a new issue