Bug 1108750 - part 2 - move _write_unified_file to CommonBackend; r=mshal

Nothing about writing unified files is specific to the recursive make
backend, and if we want to write the unified files for IPDL and WebIDL
files, we'll need this functionality available in the common build
backend.
This commit is contained in:
Nathan Froyd
2015-01-19 14:45:32 -05:00
parent 86269471c0
commit b513767c2f
2 changed files with 26 additions and 27 deletions

View File

@@ -30,7 +30,6 @@ from ..frontend.data import (
from collections import defaultdict
class XPIDLManager(object):
"""Helps manage XPCOM IDLs in the context of the build system."""
def __init__(self, config):
@@ -269,6 +268,32 @@ class CommonBackend(BuildBackend):
s = json.dumps(self._test_manager.tests_by_path)
fh.write(s)
def _write_unified_file(self, unified_file, source_filenames,
output_directory, poison_windows_h=False):
with self._write_file(mozpath.join(output_directory, unified_file)) as f:
f.write('#define MOZ_UNIFIED_BUILD\n')
includeTemplate = '#include "%(cppfile)s"'
if poison_windows_h:
includeTemplate += (
'\n'
'#ifdef _WINDOWS_\n'
'#error "%(cppfile)s included windows.h"\n'
"#endif")
includeTemplate += (
'\n'
'#ifdef PL_ARENA_CONST_ALIGN_MASK\n'
'#error "%(cppfile)s uses PL_ARENA_CONST_ALIGN_MASK, '
'so it cannot be built in unified mode."\n'
'#undef PL_ARENA_CONST_ALIGN_MASK\n'
'#endif\n'
'#ifdef INITGUID\n'
'#error "%(cppfile)s defines INITGUID, '
'so it cannot be built in unified mode."\n'
'#undef INITGUID\n'
'#endif')
f.write('\n'.join(includeTemplate % { "cppfile": s } for
s in source_filenames))
def _create_config_header(self, obj):
'''Creates the given config header. A config header is generated by
taking the corresponding source file and replacing some #define/#undef

View File

@@ -609,32 +609,6 @@ class RecursiveMakeBackend(CommonBackend):
mozpath.join(self.environment.topobjdir, 'root-deps.mk')) as root_deps:
root_deps_mk.dump(root_deps, removal_guard=False)
def _write_unified_file(self, unified_file, source_filenames,
output_directory, poison_windows_h=False):
with self._write_file(mozpath.join(output_directory, unified_file)) as f:
f.write('#define MOZ_UNIFIED_BUILD\n')
includeTemplate = '#include "%(cppfile)s"'
if poison_windows_h:
includeTemplate += (
'\n'
'#ifdef _WINDOWS_\n'
'#error "%(cppfile)s included windows.h"\n'
"#endif")
includeTemplate += (
'\n'
'#ifdef PL_ARENA_CONST_ALIGN_MASK\n'
'#error "%(cppfile)s uses PL_ARENA_CONST_ALIGN_MASK, '
'so it cannot be built in unified mode."\n'
'#undef PL_ARENA_CONST_ALIGN_MASK\n'
'#endif\n'
'#ifdef INITGUID\n'
'#error "%(cppfile)s defines INITGUID, '
'so it cannot be built in unified mode."\n'
'#undef INITGUID\n'
'#endif')
f.write('\n'.join(includeTemplate % { "cppfile": s } for
s in source_filenames))
def _add_unified_build_rules(self, makefile, files, output_directory,
unified_prefix='Unified',
unified_suffix='cpp',