mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1045783 - Move OS_LIBS from a passthrough to a more fully supported variable. r=gps
This commit is contained in:
parent
0f1191f02f
commit
8abd4db10f
@ -158,6 +158,33 @@ Similar to ``SIMPLE_PROGRAMS``, is ``CPP_UNIT_TESTS``, which defines, with the
|
||||
same rules, C++ unit tests programs.
|
||||
|
||||
|
||||
Linking with system libraries
|
||||
=============================
|
||||
|
||||
Programs and libraries usually need to link with system libraries, such as a
|
||||
widget toolkit, etc. Those required dependencies can be given with the
|
||||
``OS_LIBS`` variable.
|
||||
|
||||
OS_LIBS += [
|
||||
'foo',
|
||||
'bar',
|
||||
]
|
||||
|
||||
This expands to ``foo.lib bar.lib`` when building with MSVC, and
|
||||
``-lfoo -lbar`` otherwise.
|
||||
|
||||
For convenience with ``pkg-config``, ``OS_LIBS`` can also take linker flags
|
||||
such as ``-L/some/path`` and ``-llib``, such that it is possible to directly
|
||||
assign ``LIBS`` variables from ``CONFIG``, such as:
|
||||
|
||||
OS_LIBS += CONFIG['MOZ_PANGO_LIBS']
|
||||
|
||||
(assuming ``CONFIG['MOZ_PANGO_LIBS']`` is a list, not a string)
|
||||
|
||||
Like ``USE_LIBS``, this variable applies to static and shared libraries, as
|
||||
well as programs.
|
||||
|
||||
|
||||
Building both static and shared libraries
|
||||
=========================================
|
||||
|
||||
|
@ -14,7 +14,11 @@ GENERATED_INCLUDES += [
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
OS_LIBS += [ '$(call EXPAND_LIBNAME,psapi shell32 dbghelp)' ]
|
||||
OS_LIBS += [
|
||||
'psapi',
|
||||
'shell32',
|
||||
'dbghelp',
|
||||
]
|
||||
|
||||
DEFINES.update({
|
||||
'UNICODE': True,
|
||||
|
@ -1196,13 +1196,15 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
self.environment.topobjdir), obj.KIND)
|
||||
|
||||
def _process_linked_libraries(self, obj, backend_file):
|
||||
def recursive_get_shared_libs(lib):
|
||||
def write_shared_and_system_libs(lib):
|
||||
for l in lib.linked_libraries:
|
||||
if isinstance(l, StaticLibrary):
|
||||
for q in recursive_get_shared_libs(l):
|
||||
yield q
|
||||
write_shared_and_system_libs(l)
|
||||
else:
|
||||
yield l
|
||||
backend_file.write_once('SHARED_LIBS += %s/%s\n'
|
||||
% (pretty_relpath(l), l.import_name))
|
||||
for l in lib.linked_system_libs:
|
||||
backend_file.write_once('OS_LIBS += %s\n' % l)
|
||||
|
||||
def pretty_relpath(lib):
|
||||
return '$(DEPTH)/%s' % mozpath.relpath(lib.objdir, topobjdir)
|
||||
@ -1238,9 +1240,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
backend_file.write_once('STATIC_LIBS += %s/%s\n'
|
||||
% (relpath, lib.import_name))
|
||||
if isinstance(obj, SharedLibrary):
|
||||
for l in recursive_get_shared_libs(lib):
|
||||
backend_file.write_once('SHARED_LIBS += %s/%s\n'
|
||||
% (pretty_relpath(l), l.import_name))
|
||||
write_shared_and_system_libs(lib)
|
||||
elif isinstance(obj, SharedLibrary):
|
||||
assert lib.variant != lib.COMPONENT
|
||||
backend_file.write_once('SHARED_LIBS += %s/%s\n'
|
||||
@ -1249,9 +1249,7 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
if isinstance(lib, StaticLibrary):
|
||||
backend_file.write_once('STATIC_LIBS += %s/%s\n'
|
||||
% (relpath, lib.import_name))
|
||||
for l in recursive_get_shared_libs(lib):
|
||||
backend_file.write_once('SHARED_LIBS += %s/%s\n'
|
||||
% (pretty_relpath(l), l.import_name))
|
||||
write_shared_and_system_libs(lib)
|
||||
else:
|
||||
assert lib.variant != lib.COMPONENT
|
||||
backend_file.write_once('SHARED_LIBS += %s/%s\n'
|
||||
@ -1261,6 +1259,12 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
backend_file.write_once('HOST_LIBS += %s/%s\n'
|
||||
% (relpath, lib.import_name))
|
||||
|
||||
for lib in obj.linked_system_libs:
|
||||
if obj.KIND == 'target':
|
||||
backend_file.write_once('OS_LIBS += %s\n' % lib)
|
||||
else:
|
||||
backend_file.write_once('HOST_EXTRA_LIBS += %s\n' % lib)
|
||||
|
||||
def _write_manifests(self, dest, manifests):
|
||||
man_dir = mozpath.join(self.environment.topobjdir, '_build_manifests',
|
||||
dest)
|
||||
|
@ -328,11 +328,15 @@ class LinkageWrongKindError(Exception):
|
||||
|
||||
class Linkable(SandboxDerived):
|
||||
"""Generic sandbox container object for programs and libraries"""
|
||||
__slots__ = ('linked_libraries')
|
||||
__slots__ = (
|
||||
'linked_libraries',
|
||||
'linked_system_libs',
|
||||
)
|
||||
|
||||
def __init__(self, sandbox):
|
||||
SandboxDerived.__init__(self, sandbox)
|
||||
self.linked_libraries = []
|
||||
self.linked_system_libs = []
|
||||
|
||||
def link_library(self, obj):
|
||||
assert isinstance(obj, BaseLibrary)
|
||||
@ -344,6 +348,20 @@ class Linkable(SandboxDerived):
|
||||
self.linked_libraries.append(obj)
|
||||
obj.refs.append(self)
|
||||
|
||||
def link_system_library(self, lib):
|
||||
# The '$' check is here as a special temporary rule, allowing the
|
||||
# inherited use of make variables, most notably in TK_LIBS.
|
||||
if not lib.startswith('$') and not lib.startswith('-'):
|
||||
if self.config.substs.get('GNU_CC'):
|
||||
lib = '-l%s' % lib
|
||||
else:
|
||||
lib = '%s%s%s' % (
|
||||
self.config.import_prefix,
|
||||
lib,
|
||||
self.config.import_suffix,
|
||||
)
|
||||
self.linked_system_libs.append(lib)
|
||||
|
||||
|
||||
class BaseProgram(Linkable):
|
||||
"""Sandbox container object for programs, which is a unicode string.
|
||||
|
@ -314,6 +314,10 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
self._static_linking_shared.add(obj)
|
||||
obj.link_library(candidates[0])
|
||||
|
||||
# Link system libraries from OS_LIBS/HOST_OS_LIBS.
|
||||
for lib in sandbox.get(variable.replace('USE', 'OS'), []):
|
||||
obj.link_system_library(lib)
|
||||
|
||||
def emit_from_sandbox(self, sandbox):
|
||||
"""Convert a MozbuildSandbox to tree metadata objects.
|
||||
|
||||
@ -381,7 +385,6 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'IS_GYP_DIR',
|
||||
'MSVC_ENABLE_PGO',
|
||||
'NO_DIST_INSTALL',
|
||||
'OS_LIBS',
|
||||
'PYTHON_UNIT_TESTS',
|
||||
'RCFILE',
|
||||
'RESFILE',
|
||||
|
@ -332,6 +332,10 @@ VARIABLES = {
|
||||
"""List of libraries to link to host programs and libraries.
|
||||
""", None),
|
||||
|
||||
'HOST_OS_LIBS': (List, list,
|
||||
"""List of system libraries for host programs and libraries.
|
||||
""", None),
|
||||
|
||||
'LOCAL_INCLUDES': (StrictOrderingOnAppendList, list,
|
||||
"""Additional directories to be searched for include files by the compiler.
|
||||
""", None),
|
||||
|
@ -10,8 +10,6 @@ EXTRA_PP_COMPONENTS = ['bar.pp.js', 'foo.pp.js']
|
||||
HOST_SOURCES += ['bar.cpp', 'foo.cpp']
|
||||
HOST_SOURCES += ['bar.c', 'foo.c']
|
||||
|
||||
OS_LIBS = ['foo.so', '-l123', 'bar.a']
|
||||
|
||||
SOURCES += ['bar.c', 'foo.c']
|
||||
|
||||
SOURCES += ['bar.mm', 'foo.mm']
|
||||
|
@ -290,11 +290,6 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
'MSVC_ENABLE_PGO': [
|
||||
'MSVC_ENABLE_PGO := 1',
|
||||
],
|
||||
'OS_LIBS': [
|
||||
'OS_LIBS += foo.so',
|
||||
'OS_LIBS += -l123',
|
||||
'OS_LIBS += bar.a',
|
||||
],
|
||||
'SSRCS': [
|
||||
'SSRCS += baz.S',
|
||||
'SSRCS += foo.S',
|
||||
|
@ -10,8 +10,6 @@ EXTRA_PP_COMPONENTS=['fans.pp.js', 'tans.pp.js']
|
||||
HOST_SOURCES += ['fans.cpp', 'tans.cpp']
|
||||
HOST_SOURCES += ['fans.c', 'tans.c']
|
||||
|
||||
OS_LIBS += ['foo.so', '-l123', 'aaa.a']
|
||||
|
||||
SOURCES += ['fans.c', 'tans.c']
|
||||
|
||||
SOURCES += ['fans.mm', 'tans.mm']
|
||||
|
@ -159,7 +159,6 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
HOST_CSRCS=['fans.c', 'tans.c'],
|
||||
MSVC_ENABLE_PGO=True,
|
||||
NO_DIST_INSTALL=True,
|
||||
OS_LIBS=['foo.so', '-l123', 'aaa.a'],
|
||||
SSRCS=['bans.S', 'fans.S'],
|
||||
VISIBILITY_FLAGS='',
|
||||
DELAYLOAD_LDFLAGS=['-DELAYLOAD:foo.dll', '-DELAYLOAD:bar.dll'],
|
||||
|
Loading…
Reference in New Issue
Block a user