mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1221453 - Use SourcePaths for LOCAL_INCLUDES. r=gps
This commit is contained in:
parent
5b874069f1
commit
10276f39ee
@ -31,7 +31,7 @@ else:
|
||||
if os_posix and not CONFIG['MOZ_NATIVE_LIBEVENT']:
|
||||
DEFINES['HAVE_CONFIG_H'] = True
|
||||
LOCAL_INCLUDES += sorted([
|
||||
libevent_path_prefix + '/libevent',
|
||||
libevent_path_prefix + '/libevent/include',
|
||||
libevent_path_prefix + '/libevent/' + libevent_include_suffix,
|
||||
'libevent',
|
||||
'libevent/include',
|
||||
'libevent/' + libevent_include_suffix,
|
||||
])
|
||||
|
@ -24,6 +24,11 @@ from mozpack.manifests import (
|
||||
)
|
||||
import mozpack.path as mozpath
|
||||
|
||||
from mozbuild.frontend.context import (
|
||||
Path,
|
||||
SourcePath,
|
||||
ObjDirPath,
|
||||
)
|
||||
from .common import CommonBackend
|
||||
from ..frontend.data import (
|
||||
AndroidAssetsDirs,
|
||||
@ -868,6 +873,21 @@ class RecursiveMakeBackend(CommonBackend):
|
||||
|
||||
ensureParentDir(mozpath.join(self.environment.topobjdir, 'dist', 'foo'))
|
||||
|
||||
def _pretty_path(self, path, backend_file):
|
||||
assert isinstance(path, Path)
|
||||
if isinstance(path, SourcePath):
|
||||
if path.full_path.startswith(backend_file.srcdir):
|
||||
return '$(srcdir)' + path.full_path[len(backend_file.srcdir):]
|
||||
if path.full_path.startswith(self.environment.topsrcdir):
|
||||
return '$(topsrcdir)' + path.full_path[len(self.environment.topsrcdir):]
|
||||
elif isinstance(path, ObjDirPath):
|
||||
if path.full_path.startswith(backend_file.objdir):
|
||||
return path.full_path[len(backend_file.objdir) + 1:]
|
||||
if path.full_path.startswith(self.environment.topobjdir):
|
||||
return '$(DEPTH)' + path.full_path[len(self.environment.topobjdir):]
|
||||
|
||||
return path.full_path
|
||||
|
||||
def _process_unified_sources(self, obj):
|
||||
backend_file = self._get_backend_file_for(obj)
|
||||
|
||||
@ -1219,11 +1239,11 @@ INSTALL_TARGETS += %(prefix)s
|
||||
self.backend_input_files |= obj.manifest.manifests
|
||||
|
||||
def _process_local_include(self, local_include, backend_file):
|
||||
if local_include.startswith('/'):
|
||||
path = '$(topsrcdir)'
|
||||
path = self._pretty_path(local_include, backend_file)
|
||||
if ' ' in path:
|
||||
backend_file.write('LOCAL_INCLUDES += -I\'%s\'\n' % path)
|
||||
else:
|
||||
path = '$(srcdir)/'
|
||||
backend_file.write('LOCAL_INCLUDES += -I%s%s\n' % (path, local_include))
|
||||
backend_file.write('LOCAL_INCLUDES += -I%s\n' % path)
|
||||
|
||||
def _process_generated_include(self, generated_include, backend_file):
|
||||
if generated_include.startswith('/'):
|
||||
|
@ -136,13 +136,8 @@ class VisualStudioBackend(CommonBackend):
|
||||
self._paths_to_defines.setdefault(reldir, {}).update(obj.defines)
|
||||
|
||||
elif isinstance(obj, LocalInclude):
|
||||
p = obj.path
|
||||
includes = self._paths_to_includes.setdefault(reldir, [])
|
||||
|
||||
if p.startswith('/'):
|
||||
includes.append(os.path.join('$(TopSrcDir)', p[1:]))
|
||||
else:
|
||||
includes.append(os.path.join('$(TopSrcDir)', reldir, p))
|
||||
includes.append(obj.path.full_path)
|
||||
|
||||
# Just acknowledge everything.
|
||||
return True
|
||||
|
@ -1169,7 +1169,7 @@ VARIABLES = {
|
||||
"""List of system libraries for host programs and libraries.
|
||||
""", None),
|
||||
|
||||
'LOCAL_INCLUDES': (StrictOrderingOnAppendList, list,
|
||||
'LOCAL_INCLUDES': (ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList), list,
|
||||
"""Additional directories to be searched for include files by the compiler.
|
||||
""", None),
|
||||
|
||||
|
@ -671,17 +671,10 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
yield klass(context, name)
|
||||
|
||||
for local_include in context.get('LOCAL_INCLUDES', []):
|
||||
if local_include.startswith('/'):
|
||||
path = context.config.topsrcdir
|
||||
relative_include = local_include[1:]
|
||||
else:
|
||||
path = context.srcdir
|
||||
relative_include = local_include
|
||||
|
||||
actual_include = os.path.join(path, relative_include)
|
||||
if not os.path.exists(actual_include):
|
||||
if not os.path.exists(local_include.full_path):
|
||||
raise SandboxValidationError('Path specified in LOCAL_INCLUDES '
|
||||
'does not exist: %s (resolved to %s)' % (local_include, actual_include), context)
|
||||
'does not exist: %s (resolved to %s)' % (local_include,
|
||||
local_include.full_path), context)
|
||||
yield LocalInclude(context, local_include)
|
||||
|
||||
final_target_files = context.get('FINAL_TARGET_FILES')
|
||||
|
@ -610,7 +610,7 @@ class TestRecursiveMakeBackend(BackendTester):
|
||||
lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
|
||||
|
||||
expected = [
|
||||
'LOCAL_INCLUDES += -I$(topsrcdir)/bar/baz',
|
||||
'LOCAL_INCLUDES += -I$(srcdir)/bar/baz',
|
||||
'LOCAL_INCLUDES += -I$(srcdir)/foo',
|
||||
]
|
||||
|
||||
|
@ -647,6 +647,15 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
|
||||
self.assertEqual(local_includes, expected)
|
||||
|
||||
local_includes = [o.path.full_path
|
||||
for o in objs if isinstance(o, LocalInclude)]
|
||||
expected = [
|
||||
mozpath.join(reader.config.topsrcdir, 'bar/baz'),
|
||||
mozpath.join(reader.config.topsrcdir, 'foo'),
|
||||
]
|
||||
|
||||
self.assertEqual(local_includes, expected)
|
||||
|
||||
def test_generated_includes(self):
|
||||
"""Test that GENERATED_INCLUDES is emitted correctly."""
|
||||
reader = self.reader('generated_includes')
|
||||
|
Loading…
Reference in New Issue
Block a user