mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 11:26:09 +00:00
e0bbb4aa9e
Bug 1256642 introduced magic at the emitter level to determine whether a binary contains C++ sources and should be linked with the C compiler or the C++ compiler. Unfortunately, the Binary() moz.build template always adds C++ OS libraries on Android (through STLPORT_LIBS), and C++ libraries on Linux (stdc++compat). The latter only ends up forcing every Binary() to be linked with the C++ linker, which is unfortunate, but doesn't cause much problems. The former, however, involving OS libraries, the magic from bug 1256642 doesn't kick in, so we end up trying to link C++ OS libraries with the C linker. Which ends up failing, because the libraries in STLPORT_LIBS require -lm, which, while it's added by the C++ compiler when linking, is not when the linkage is driven by the C compiler. Because the fallible library, linked to all GeckoBinary()s is a C++ library, we still ended up linking with the C++ compiler on Android, so this wasn't actually causing any problem... until I tried to remove that fallible library in bug 1423803. Anyways, the core problem is that moz.build evaluation is happening too early to know whether any C++ sources are being linked together, so there is no way the Binary() template can do the right thing. So this change moves the logic to the emitter. This also changes the type of STLPORT_LIBS to a list. --HG-- extra : rebase_source : a70ddf7a132f94dc10e7e1db94ae80fb8d7a269f
142 lines
3.1 KiB
Python
142 lines
3.1 KiB
Python
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
|
# vim: set filetype=python:
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
@template
|
|
def Binary():
|
|
'''Generic template for target binaries. Meant to be used by other
|
|
templates.'''
|
|
|
|
# Add -llog by default, since we use it all over the place.
|
|
if CONFIG['OS_TARGET'] == 'Android':
|
|
OS_LIBS += ['log']
|
|
|
|
|
|
@template
|
|
def Program(name):
|
|
'''Template for program executables.'''
|
|
PROGRAM = name
|
|
|
|
Binary()
|
|
|
|
|
|
@template
|
|
def SimplePrograms(names, ext='.cpp'):
|
|
'''Template for simple program executables.
|
|
|
|
Those have a single source with the same base name as the executable.
|
|
'''
|
|
SIMPLE_PROGRAMS += names
|
|
SOURCES += ['%s%s' % (name, ext) for name in names]
|
|
|
|
Binary()
|
|
|
|
|
|
@template
|
|
def CppUnitTests(names, ext='.cpp'):
|
|
'''Template for C++ unit tests.
|
|
|
|
Those have a single source with the same base name as the executable.
|
|
'''
|
|
COMPILE_FLAGS['EXTRA_INCLUDES'] = ['-I%s/dist/include' % TOPOBJDIR,
|
|
'-I%s/dist/include/testing' % TOPOBJDIR]
|
|
CPP_UNIT_TESTS += names
|
|
SOURCES += ['%s%s' % (name, ext) for name in names]
|
|
|
|
Binary()
|
|
|
|
|
|
@template
|
|
def Library(name):
|
|
'''Template for libraries.'''
|
|
LIBRARY_NAME = name
|
|
|
|
|
|
@template
|
|
def RustLibrary(name, features=None, target_dir=None):
|
|
'''Template for Rust libraries.'''
|
|
Library(name)
|
|
|
|
IS_RUST_LIBRARY = True
|
|
|
|
if features:
|
|
RUST_LIBRARY_FEATURES = features
|
|
|
|
if target_dir:
|
|
RUST_LIBRARY_TARGET_DIR = target_dir
|
|
|
|
|
|
@template
|
|
def SharedLibrary(name):
|
|
'''Template for shared libraries.'''
|
|
Library(name)
|
|
|
|
FORCE_SHARED_LIB = True
|
|
|
|
Binary()
|
|
|
|
|
|
@template
|
|
def Framework(name):
|
|
'''Template for OSX Frameworks.'''
|
|
SharedLibrary(name)
|
|
|
|
IS_FRAMEWORK = True
|
|
|
|
|
|
@template
|
|
def HostProgram(name):
|
|
'''Template for build tools executables.'''
|
|
HOST_PROGRAM = name
|
|
|
|
|
|
@template
|
|
def HostSimplePrograms(names, ext='.cpp'):
|
|
'''Template for simple build tools executables.
|
|
|
|
Those have a single source with the same base name as the executable.
|
|
'''
|
|
HOST_SIMPLE_PROGRAMS += names
|
|
HOST_SOURCES += ['%s%s' % (name.replace('host_', ''), ext)
|
|
for name in names]
|
|
|
|
|
|
@template
|
|
def HostLibrary(name):
|
|
'''Template for build tools libraries.'''
|
|
HOST_LIBRARY_NAME = name
|
|
|
|
@template
|
|
def HostRustLibrary(name, features=None):
|
|
'''Template for host Rust libraries.'''
|
|
HostLibrary(name)
|
|
|
|
IS_RUST_LIBRARY = True
|
|
|
|
if features:
|
|
HOST_RUST_LIBRARY_FEATURES = features
|
|
|
|
@template
|
|
def DisableStlWrapping():
|
|
COMPILE_FLAGS['STL'] = []
|
|
|
|
@template
|
|
def NoVisibilityFlags():
|
|
COMPILE_FLAGS['VISIBILITY'] = []
|
|
|
|
@template
|
|
def AllowCompilerWarnings():
|
|
COMPILE_FLAGS['WARNINGS_AS_ERRORS'] = []
|
|
|
|
@template
|
|
def RustTest(name, features=None):
|
|
RUST_TEST = name
|
|
|
|
if features:
|
|
RUST_TEST_FEATURES = features
|
|
|
|
include('gecko_templates.mozbuild')
|
|
include('test_templates.mozbuild')
|