Skip to content

Commit

Permalink
Bug 991983 - Use objdir-relative SOURCES instead of GENERATED_SOURCES…
Browse files Browse the repository at this point in the history
…. r=gps
  • Loading branch information
glandium committed May 27, 2015
1 parent ea7750b commit 806e022
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 123 deletions.
16 changes: 8 additions & 8 deletions accessible/interfaces/msaa/moz.build
Expand Up @@ -6,14 +6,14 @@

GeckoSharedLibrary('AccessibleMarshal', linkage=None)

GENERATED_SOURCES += [
'dlldata.c',
'ISimpleDOMDocument_i.c',
'ISimpleDOMDocument_p.c',
'ISimpleDOMNode_i.c',
'ISimpleDOMNode_p.c',
'ISimpleDOMText_i.c',
'ISimpleDOMText_p.c',
SOURCES += [
'!dlldata.c',
'!ISimpleDOMDocument_i.c',
'!ISimpleDOMDocument_p.c',
'!ISimpleDOMNode_i.c',
'!ISimpleDOMNode_p.c',
'!ISimpleDOMText_i.c',
'!ISimpleDOMText_p.c',
]

DEFINES['REGISTER_PROXY_DLL'] = True
Expand Down
4 changes: 2 additions & 2 deletions accessible/xpcom/moz.build
Expand Up @@ -20,8 +20,8 @@ UNIFIED_SOURCES += [
'xpcAccessibleValue.cpp',
]

GENERATED_SOURCES += [
'xpcAccEvents.cpp',
SOURCES += [
'!xpcAccEvents.cpp',
]

LOCAL_INCLUDES += [
Expand Down
4 changes: 2 additions & 2 deletions build/unix/elfhack/inject/moz.build
Expand Up @@ -13,8 +13,8 @@ elif CONFIG['TARGET_CPU'].startswith('arm'):
else:
cpu = CONFIG['TARGET_CPU']

GENERATED_SOURCES += [
"%s.c" % cpu,
SOURCES += [
"!%s.c" % cpu,
]

NO_PGO = True
Expand Down
4 changes: 1 addition & 3 deletions dom/plugins/ipc/moz.build
Expand Up @@ -68,10 +68,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
]

if CONFIG['MOZ_ENABLE_QT']:
GENERATED_SOURCES += [
'moc_NestedLoopTimer.cpp',
]
SOURCES += [
'!moc_NestedLoopTimer.cpp',
'NestedLoopTimer.cpp',
'PluginHelperQt.cpp',
]
Expand Down
4 changes: 1 addition & 3 deletions dom/system/qt/moz.build
Expand Up @@ -5,10 +5,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

if CONFIG['MOZ_ENABLE_QT5GEOPOSITION']:
GENERATED_SOURCES += [
'moc_QTMLocationProvider.cpp',
]
SOURCES += [
'!moc_QTMLocationProvider.cpp',
'QTMLocationProvider.cpp',
]

Expand Down
8 changes: 2 additions & 6 deletions ipc/chromium/moz.build
Expand Up @@ -202,11 +202,9 @@ if os_linux:
]
if CONFIG['MOZ_ENABLE_QT']:
SOURCES += [
'!moc_message_pump_qt.cc',
'src/base/message_pump_qt.cc',
]
GENERATED_SOURCES += [
'moc_message_pump_qt.cc',
]
if not CONFIG['MOZ_NATIVE_LIBEVENT']:
if CONFIG['OS_TARGET'] != 'Android':
SOURCES += [
Expand Down Expand Up @@ -239,11 +237,9 @@ if os_bsd:
]
if CONFIG['MOZ_ENABLE_QT']:
SOURCES += [
'!moc_message_pump_qt.cc',
'src/base/message_pump_qt.cc',
]
GENERATED_SOURCES += [
'moc_message_pump_qt.cc',
]
if not CONFIG['MOZ_NATIVE_LIBEVENT']:
SOURCES += [
'src/third_party/libevent/kqueue.c',
Expand Down
5 changes: 1 addition & 4 deletions ipc/ipdl/test/cxx/moz.build
Expand Up @@ -55,14 +55,11 @@ if CONFIG['OS_ARCH'] == 'Linux':
]

SOURCES += [
'!IPDLUnitTests.cpp',
'IPDLUnitTestProcessChild.cpp',
'IPDLUnitTestSubprocess.cpp',
]

GENERATED_SOURCES += [
'IPDLUnitTests.cpp',
]

IPDL_SOURCES += [
'PTestActorPunning.ipdl',
'PTestActorPunningPunned.ipdl',
Expand Down
6 changes: 3 additions & 3 deletions media/libopus/moz.build
Expand Up @@ -89,9 +89,9 @@ else:

if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['GNU_AS']:
SOURCES += celt_sources_arm
GENERATED_SOURCES += [ '%s.%s' % (f, CONFIG['ASM_SUFFIX']) for f in [
'celt_pitch_xcorr_arm-gnu',
]]
SOURCES += [
'!celt_pitch_xcorr_arm-gnu.%s' % CONFIG['ASM_SUFFIX']
]
# -Os is significantly slower, enable -O3 unless optimization is disabled
if CONFIG['MOZ_OPTIMIZE']:
CFLAGS += [
Expand Down
2 changes: 1 addition & 1 deletion media/libtheora/moz.build
Expand Up @@ -86,7 +86,7 @@ if CONFIG['GNU_AS']:
if CONFIG['OS_TARGET'] == 'Android':
DEFINES['__linux__'] = True

GENERATED_SOURCES += [ '%s.%s' % (f, CONFIG['ASM_SUFFIX']) for f in [
SOURCES += [ '!%s.%s' % (f, CONFIG['ASM_SUFFIX']) for f in [
'armbits-gnu',
'armfrag-gnu',
'armidct-gnu',
Expand Down
11 changes: 5 additions & 6 deletions media/libvpx/moz.build
Expand Up @@ -53,12 +53,11 @@ if CONFIG['VPX_ARM_ASM']:
arm_asm_files += files['ARM_ASM']

if CONFIG['VPX_AS_CONVERSION']:
GENERATED_SOURCES += [ "%s.%s" % (f, CONFIG['VPX_ASM_SUFFIX'])
for f in sorted(arm_asm_files) if f.endswith('.asm')
]
SOURCES += [
f for f in sorted(arm_asm_files) if not f.endswith('.asm')
]
SOURCES += sorted([
"!%s.%s" % (f, CONFIG['VPX_ASM_SUFFIX'])
if f.endswith('.asm') else f
for f in sorted(arm_asm_files)
])
else:
SOURCES += sorted(arm_asm_files)

Expand Down
5 changes: 1 addition & 4 deletions netwerk/system/qt/moz.build
Expand Up @@ -5,14 +5,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

SOURCES += [
'!moc_nsQtNetworkManager.cpp',
'nsQtNetworkLinkService.cpp',
'nsQtNetworkManager.cpp',
]

GENERATED_SOURCES += [
'moc_nsQtNetworkManager.cpp',
]

FAIL_ON_WARNINGS = True

FINAL_LIBRARY = 'xul'
Expand Down
18 changes: 1 addition & 17 deletions python/mozbuild/mozbuild/frontend/context.py
Expand Up @@ -664,20 +664,13 @@ def asdict(self):
populated by calling add_android_eclipse{_library}_project().
""", 'export'),

'SOURCES': (ContextDerivedTypedListWithItems(SourcePath, StrictOrderingOnAppendListWithFlagsFactory({'no_pgo': bool, 'flags': List})), list,
'SOURCES': (ContextDerivedTypedListWithItems(Path, StrictOrderingOnAppendListWithFlagsFactory({'no_pgo': bool, 'flags': List})), list,
"""Source code files.
This variable contains a list of source code files to compile.
Accepts assembler, C, C++, Objective C/C++.
""", None),

'GENERATED_SOURCES': (StrictOrderingOnAppendList, list,
"""Generated source code files.
This variable contains a list of generated source code files to
compile. Accepts assembler, C, C++, Objective C/C++.
""", None),

'FILES_PER_UNIFIED_FILE': (int, int,
"""The number of source files to compile into each unified source file.
Expand All @@ -692,15 +685,6 @@ def asdict(self):
size.
""", None),

'GENERATED_UNIFIED_SOURCES': (StrictOrderingOnAppendList, list,
"""Generated source code files that can be compiled together.
This variable contains a list of generated source code files to
compile, that can be concatenated all together, with UNIFIED_SOURCES,
and built as a single source file. This can help make the build faster
and reduce the debug info size.
""", None),

'GENERATED_FILES': (StrictOrderingOnAppendListWithFlagsFactory({
'script': unicode,
'inputs': list }), list,
Expand Down
63 changes: 35 additions & 28 deletions python/mozbuild/mozbuild/frontend/emitter.py
Expand Up @@ -78,6 +78,8 @@

from .context import (
Context,
ObjDirPath,
SourcePath,
SubContext,
TemplateContext,
)
Expand Down Expand Up @@ -712,29 +714,33 @@ def _create_substitution(self, cls, context, path):
return sub

def _process_sources(self, context, passthru):
all_sources = {}
sources = defaultdict(list)
gen_sources = defaultdict(list)
all_flags = {}
for symbol in ('SOURCES', 'HOST_SOURCES', 'UNIFIED_SOURCES',
'GENERATED_SOURCES'):
srcs = all_sources[symbol] = []
for symbol in ('SOURCES', 'HOST_SOURCES', 'UNIFIED_SOURCES'):
srcs = sources[symbol]
gen_srcs = gen_sources[symbol]
context_srcs = context.get(symbol, [])
for f in context_srcs:
if symbol.startswith('GENERATED_'):
full_path = mozpath.normpath(
mozpath.join(context.objdir, f))
full_path = f.full_path
if isinstance(f, SourcePath):
srcs.append(full_path)
else:
full_path = f.full_path
srcs.append(full_path)
assert isinstance(f, ObjDirPath)
gen_srcs.append(full_path)
if symbol == 'SOURCES':
flags = context_srcs[f]
if flags:
all_flags[full_path] = flags

for symbol in ('SOURCES', 'HOST_SOURCES', 'UNIFIED_SOURCES'):
for src in all_sources[symbol]:
if not os.path.exists(src):
if isinstance(f, SourcePath) and not os.path.exists(full_path):
raise SandboxValidationError('File listed in %s does not '
'exist: \'%s\'' % (symbol, src), context)
'exist: \'%s\'' % (symbol, full_path), context)

# HOST_SOURCES and UNIFIED_SOURCES only take SourcePaths, so
# there should be no generated source in here
assert not gen_sources['HOST_SOURCES']
assert not gen_sources['UNIFIED_SOURCES']

no_pgo = context.get('NO_PGO')
no_pgo_sources = [f for f, flags in all_flags.iteritems()
Expand Down Expand Up @@ -777,32 +783,33 @@ def canonical_suffix_for_file(f):
# kinds that can be listed therein.
all_suffixes = list(suffix_map.keys())
varmap = dict(
SOURCES=(Sources, all_suffixes),
HOST_SOURCES=(HostSources, ['.c', '.mm', '.cpp']),
UNIFIED_SOURCES=(UnifiedSources, ['.c', '.mm', '.cpp']),
GENERATED_SOURCES=(GeneratedSources, all_suffixes),
SOURCES=(Sources, GeneratedSources, all_suffixes),
HOST_SOURCES=(HostSources, None, ['.c', '.mm', '.cpp']),
UNIFIED_SOURCES=(UnifiedSources, None, ['.c', '.mm', '.cpp']),
)

for variable, (klass, suffixes) in varmap.items():
for variable, (klass, gen_klass, suffixes) in varmap.items():
allowed_suffixes = set().union(*[suffix_map[s] for s in suffixes])

# First ensure that we haven't been given filetypes that we don't
# recognize.
for f in all_sources[variable]:
for f in itertools.chain(sources[variable], gen_sources[variable]):
ext = mozpath.splitext(f)[1]
if ext not in allowed_suffixes:
raise SandboxValidationError(
'%s has an unknown file type.' % f, context)

# Now sort the files to let groupby work.
sorted_files = sorted(all_sources[variable],
key=canonical_suffix_for_file)
for canonical_suffix, files in itertools.groupby(
sorted_files, canonical_suffix_for_file):
arglist = [context, list(files), canonical_suffix]
if variable.startswith('UNIFIED_') and 'FILES_PER_UNIFIED_FILE' in context:
arglist.append(context['FILES_PER_UNIFIED_FILE'])
yield klass(*arglist)
for srcs, cls in ((sources[variable], klass),
(gen_sources[variable], gen_klass)):
# Now sort the files to let groupby work.
sorted_files = sorted(srcs, key=canonical_suffix_for_file)
for canonical_suffix, files in itertools.groupby(
sorted_files, canonical_suffix_for_file):
arglist = [context, list(files), canonical_suffix]
if (variable.startswith('UNIFIED_') and
'FILES_PER_UNIFIED_FILE' in context):
arglist.append(context['FILES_PER_UNIFIED_FILE'])
yield cls(*arglist)

for f, flags in all_flags.iteritems():
if flags.flags:
Expand Down
Expand Up @@ -2,29 +2,29 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/

GENERATED_SOURCES += [
'a.cpp',
'b.cc',
'c.cxx',
SOURCES += [
'!a.cpp',
'!b.cc',
'!c.cxx',
]

GENERATED_SOURCES += [
'd.c',
SOURCES += [
'!d.c',
]

GENERATED_SOURCES += [
'e.m',
SOURCES += [
'!e.m',
]

GENERATED_SOURCES += [
'f.mm',
SOURCES += [
'!f.mm',
]

GENERATED_SOURCES += [
'g.S',
SOURCES += [
'!g.S',
]

GENERATED_SOURCES += [
'h.s',
'i.asm',
SOURCES += [
'!h.s',
'!i.asm',
]
4 changes: 1 addition & 3 deletions toolkit/xre/moz.build
Expand Up @@ -42,10 +42,8 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt':
EXPORTS += ['nsQAppInstance.h']
GENERATED_SOURCES += [
'moc_nsNativeAppSupportQt.cpp',
]
SOURCES += [
'!moc_nsNativeAppSupportQt.cpp',
'nsNativeAppSupportQt.cpp',
'nsQAppInstance.cpp',
]
Expand Down
8 changes: 4 additions & 4 deletions widget/android/bindings/moz.build
Expand Up @@ -11,21 +11,21 @@ generated = [
'SurfaceTexture',
]

GENERATED_SOURCES += [stem + '.cpp' for stem in generated]
SOURCES += ['!%s.cpp' % stem for stem in generated]

# We'd like to add these to a future GENERATED_EXPORTS list, but for now we mark
# them as generated here and manually install them in Makefile.in.
GENERATED_FILES += [stem + '.h' for stem in generated]

# There is an unfortunate race condition when using GENERATED_SOURCES and
# There is an unfortunate race condition when using generated SOURCES and
# pattern rules (see Makefile.in) that manifests itself as a VPATH resolution
# conflict: MediaCodec.o looks for MediaCodec.cpp and $(CURDIR)/MediaCodec.cpp,
# and the pattern rule is matched but doesn't resolve both sources, causing a
# failure. Adding the GENERATED_SOURCES to GENERATED_FILES causes the sources
# failure. Adding the SOURCES to GENERATED_FILES causes the sources
# to be built at export time, which is before MediaCodec.o needs them; and by
# the time MediaCodec.o is built, the source is in place and the VPATH
# resolution works as expected.
GENERATED_FILES += GENERATED_SOURCES
GENERATED_FILES += [f[1:] for f in SOURCES]

FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'
Expand Down

0 comments on commit 806e022

Please sign in to comment.