CMake: pro2cmake.py: Fix library mapping
Fix library substitution again which broke when I merged all the library related pieces of information. Keep Qt and 3rdparty libraries separate so that dbus does not get mapped into Qt::DBus (or the other way around). Make names in helper.py more consistent while at it. Change-Id: I5e5bf02bdabf8bafe991c5701deca76bde4df2c3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
f26a156dd3
commit
059f4ade7f
@ -33,7 +33,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from typing import Set, Union, List, Dict
|
from typing import Set, Union, List, Dict
|
||||||
|
|
||||||
from helper import map_qt_library, featureName, substitute_platform, find_library_mapping
|
from helper import map_qt_library, featureName, map_platform, find_3rd_party_library_mapping
|
||||||
|
|
||||||
knownTests = set() # type: Set[str]
|
knownTests = set() # type: Set[str]
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ def processFiles(ctx, data):
|
|||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
||||||
newlib = find_library_mapping(lib)
|
newlib = find_3rd_party_library_mapping(lib)
|
||||||
if not newlib:
|
if not newlib:
|
||||||
print(' XXXX Unknown library "{}".'.format(lib))
|
print(' XXXX Unknown library "{}".'.format(lib))
|
||||||
return
|
return
|
||||||
@ -174,7 +174,7 @@ def parseLib(ctx, lib, data, cm_fh, cmake_find_packages_set):
|
|||||||
print(' **** Skipping library "{}" -- was masked.'.format(lib))
|
print(' **** Skipping library "{}" -- was masked.'.format(lib))
|
||||||
return
|
return
|
||||||
|
|
||||||
print(' mapped library {} to {}.'.format(lib, newlib))
|
print(' mapped library {} to {}.'.format(lib, newlib.targetName))
|
||||||
|
|
||||||
# Avoid duplicate find_package calls.
|
# Avoid duplicate find_package calls.
|
||||||
if newlib.targetName in cmake_find_packages_set:
|
if newlib.targetName in cmake_find_packages_set:
|
||||||
@ -251,7 +251,7 @@ def map_condition(condition):
|
|||||||
substitution = None
|
substitution = None
|
||||||
appendFoundSuffix = True
|
appendFoundSuffix = True
|
||||||
if match.group(1) == 'libs':
|
if match.group(1) == 'libs':
|
||||||
libmapping = find_library_mapping(match.group(2))
|
libmapping = find_3rd_party_library_mapping(match.group(2))
|
||||||
|
|
||||||
if libmapping and libmapping.packageName:
|
if libmapping and libmapping.packageName:
|
||||||
substitution = libmapping.packageName
|
substitution = libmapping.packageName
|
||||||
@ -282,7 +282,7 @@ def map_condition(condition):
|
|||||||
substitution = 'INPUT_{}'.format(featureName(match.group(2)))
|
substitution = 'INPUT_{}'.format(featureName(match.group(2)))
|
||||||
|
|
||||||
elif match.group(1) == 'config':
|
elif match.group(1) == 'config':
|
||||||
substitution = substitute_platform(match.group(2))
|
substitution = map_platform(match.group(2))
|
||||||
|
|
||||||
elif match.group(1) == 'arch':
|
elif match.group(1) == 'arch':
|
||||||
if match.group(2) == 'i386':
|
if match.group(2) == 'i386':
|
||||||
|
@ -67,7 +67,7 @@ _qt_library_map = [
|
|||||||
LibraryMapping('core', 'Qt5', 'Qt::Core', extra = ['COMPONENTS', 'Core']),
|
LibraryMapping('core', 'Qt5', 'Qt::Core', extra = ['COMPONENTS', 'Core']),
|
||||||
LibraryMapping('coretest', 'Qt5', 'Qt::3DCoreTest', extra = ['COMPONENTS', '3DCoreTest']),
|
LibraryMapping('coretest', 'Qt5', 'Qt::3DCoreTest', extra = ['COMPONENTS', '3DCoreTest']),
|
||||||
LibraryMapping('crypto-lib', 'Qt5', 'Qt::AppManCrypto', extra = ['COMPONENTS', 'AppManCrypto']),
|
LibraryMapping('crypto-lib', 'Qt5', 'Qt::AppManCrypto', extra = ['COMPONENTS', 'AppManCrypto']),
|
||||||
LibraryMapping('dbus', 'Qt5', 'Qt::Dbus', extra = ['COMPONENTS', 'DBus']),
|
LibraryMapping('dbus', 'Qt5', 'Qt::DBus', extra = ['COMPONENTS', 'DBus']),
|
||||||
LibraryMapping('devicediscovery', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
|
LibraryMapping('devicediscovery', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
|
||||||
LibraryMapping('devicediscovery_support', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
|
LibraryMapping('devicediscovery_support', 'Qt5', 'Qt::DeviceDiscoverySupport', extra = ['COMPONENTS', 'DeviceDiscoverySupport']),
|
||||||
LibraryMapping('edid', 'Qt5', 'Qt::EdidSupport', extra = ['COMPONENTS', 'EdidSupport']),
|
LibraryMapping('edid', 'Qt5', 'Qt::EdidSupport', extra = ['COMPONENTS', 'EdidSupport']),
|
||||||
@ -189,10 +189,11 @@ _library_map = [
|
|||||||
LibraryMapping('host_dbus', None, None),
|
LibraryMapping('host_dbus', None, None),
|
||||||
LibraryMapping('icu', 'ICU', 'ICU::i18n ICU::uc ICU::data', extra=['COMPONENTS', 'i18n', 'uc', 'data']),
|
LibraryMapping('icu', 'ICU', 'ICU::i18n ICU::uc ICU::data', extra=['COMPONENTS', 'i18n', 'uc', 'data']),
|
||||||
LibraryMapping('journald', 'Libsystemd', 'PkgConfig::Libsystemd'),
|
LibraryMapping('journald', 'Libsystemd', 'PkgConfig::Libsystemd'),
|
||||||
|
LibraryMapping('jpeg', 'JPEG', 'JPEG::JPEG'), # see also libjpeg
|
||||||
LibraryMapping('libatomic', 'Atomic', 'Atomic'),
|
LibraryMapping('libatomic', 'Atomic', 'Atomic'),
|
||||||
LibraryMapping('libdl', None, None),
|
LibraryMapping('libdl', None, '${CMAKE_DL_LIBS}'),
|
||||||
LibraryMapping('libinput', 'Libinput', 'Libinput::Libinput'),
|
LibraryMapping('libinput', 'Libinput', 'Libinput::Libinput'),
|
||||||
LibraryMapping('libjpeg', 'JPEG', 'JPEG::JPEG'),
|
LibraryMapping('libjpeg', 'JPEG', 'JPEG::JPEG'), # see also jpeg
|
||||||
LibraryMapping('libpng', 'PNG', 'PNG::PNG'),
|
LibraryMapping('libpng', 'PNG', 'PNG::PNG'),
|
||||||
LibraryMapping('libproxy', 'Libproxy', 'PkgConfig::Libproxy'),
|
LibraryMapping('libproxy', 'Libproxy', 'PkgConfig::Libproxy'),
|
||||||
LibraryMapping('librt', 'WrapRt','WrapRt'),
|
LibraryMapping('librt', 'WrapRt','WrapRt'),
|
||||||
@ -246,7 +247,7 @@ _library_map = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def find_library_mapping(soName: str) -> typing.Optional[LibraryMapping]:
|
def find_3rd_party_library_mapping(soName: str) -> typing.Optional[LibraryMapping]:
|
||||||
for i in _library_map:
|
for i in _library_map:
|
||||||
if i.soName == soName:
|
if i.soName == soName:
|
||||||
return i
|
return i
|
||||||
@ -272,6 +273,7 @@ def map_qt_library(lib: str) -> str:
|
|||||||
mapped = find_qt_library_mapping(lib)
|
mapped = find_qt_library_mapping(lib)
|
||||||
qt_name = lib
|
qt_name = lib
|
||||||
if mapped:
|
if mapped:
|
||||||
|
assert mapped.targetName # Qt libs must have a target name set
|
||||||
qt_name = mapped.targetName
|
qt_name = mapped.targetName
|
||||||
if private:
|
if private:
|
||||||
qt_name += 'Private'
|
qt_name += 'Private'
|
||||||
@ -314,19 +316,25 @@ platform_mapping = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def substitute_platform(platform: str) -> str:
|
def map_platform(platform: str) -> str:
|
||||||
""" Return the qmake platform as cmake platform or the unchanged string. """
|
""" Return the qmake platform as cmake platform or the unchanged string. """
|
||||||
return platform_mapping.get(platform, platform)
|
return platform_mapping.get(platform, platform)
|
||||||
|
|
||||||
|
|
||||||
def substitute_libs(lib: str) -> str:
|
def is_known_3rd_party_library(lib: str) -> bool:
|
||||||
|
if lib.endswith('/nolink') or lib.endswith('_nolink'):
|
||||||
|
lib = lib[:-7]
|
||||||
|
mapping = find_3rd_party_library_mapping(lib)
|
||||||
|
|
||||||
|
return mapping is not None and mapping.targetName is not None
|
||||||
|
|
||||||
|
|
||||||
|
def map_3rd_party_library(lib: str) -> str:
|
||||||
libpostfix = ''
|
libpostfix = ''
|
||||||
if lib.endswith('/nolink'):
|
if lib.endswith('/nolink'):
|
||||||
lib = lib[:-7]
|
lib = lib[:-7]
|
||||||
libpostfix = '_nolink'
|
libpostfix = '_nolink'
|
||||||
mapping = find_qt_library_mapping(lib)
|
mapping = find_3rd_party_library_mapping(lib)
|
||||||
if not mapping:
|
if not mapping or not mapping.targetName:
|
||||||
mapping = find_library_mapping(lib)
|
return lib
|
||||||
if not mapping:
|
|
||||||
return lib + libpostfix
|
|
||||||
return mapping.targetName + libpostfix
|
return mapping.targetName + libpostfix
|
||||||
|
@ -42,8 +42,8 @@ import typing
|
|||||||
from sympy.logic import (simplify_logic, And, Or, Not,)
|
from sympy.logic import (simplify_logic, And, Or, Not,)
|
||||||
import pyparsing as pp
|
import pyparsing as pp
|
||||||
|
|
||||||
from helper import map_qt_library, featureName, \
|
from helper import map_qt_library, map_3rd_party_library, is_known_3rd_party_library, \
|
||||||
substitute_platform, substitute_libs
|
featureName, map_platform
|
||||||
|
|
||||||
|
|
||||||
def _parse_commandline():
|
def _parse_commandline():
|
||||||
@ -810,15 +810,14 @@ def map_condition(condition: str) -> str:
|
|||||||
part = 'TARGET {}'.format(map_qt_library(feature.group(2)))
|
part = 'TARGET {}'.format(map_qt_library(feature.group(2)))
|
||||||
else:
|
else:
|
||||||
feature = featureName(feature.group(2))
|
feature = featureName(feature.group(2))
|
||||||
if feature.startswith('system_') and substitute_libs(feature[7:]) != feature[7:]:
|
if feature.startswith('system_') and is_known_3rd_party_library(feature[7:]):
|
||||||
# Qt6 always uses system libraries!
|
|
||||||
part = 'ON'
|
part = 'ON'
|
||||||
elif feature == 'dlopen':
|
elif feature == 'dlopen':
|
||||||
part = 'ON'
|
part = 'ON'
|
||||||
else:
|
else:
|
||||||
part = 'QT_FEATURE_' + feature
|
part = 'QT_FEATURE_' + feature
|
||||||
else:
|
else:
|
||||||
part = substitute_platform(part)
|
part = map_platform(part)
|
||||||
|
|
||||||
part = part.replace('true', 'ON')
|
part = part.replace('true', 'ON')
|
||||||
part = part.replace('false', 'OFF')
|
part = part.replace('false', 'OFF')
|
||||||
@ -939,7 +938,9 @@ def write_library_list(cm_fh: typing.IO[str], cmake_keyword: str,
|
|||||||
if d.startswith('-'):
|
if d.startswith('-'):
|
||||||
d = '# Remove: {}'.format(d[1:])
|
d = '# Remove: {}'.format(d[1:])
|
||||||
else:
|
else:
|
||||||
d = substitute_libs(d)
|
d = map_3rd_party_library(d)
|
||||||
|
if not d or d in dependencies_to_print:
|
||||||
|
continue
|
||||||
dependencies_to_print.append(d)
|
dependencies_to_print.append(d)
|
||||||
is_framework = False
|
is_framework = False
|
||||||
|
|
||||||
@ -954,18 +955,24 @@ def write_library_list(cm_fh: typing.IO[str], cmake_keyword: str,
|
|||||||
def write_library_section(cm_fh: typing.IO[str], scope: Scope,
|
def write_library_section(cm_fh: typing.IO[str], scope: Scope,
|
||||||
public: typing.List[str],
|
public: typing.List[str],
|
||||||
private: typing.List[str],
|
private: typing.List[str],
|
||||||
mixed: typing.List[str], *,
|
qt_private: typing.List[str],
|
||||||
|
qt_mixed: typing.List[str], *,
|
||||||
indent: int = 0, known_libraries=set()):
|
indent: int = 0, known_libraries=set()):
|
||||||
public_dependencies = [] # typing.List[str]
|
public_dependencies = [] # type: typing.List[str]
|
||||||
private_dependencies = [] # typing.List[str]
|
private_dependencies = [] # type: typing.List[str]
|
||||||
|
|
||||||
for key in public:
|
for key in public:
|
||||||
public_dependencies += [map_qt_library(q) for q in scope.expand(key)
|
public_dependencies += [q for q in scope.expand(key)
|
||||||
if map_qt_library(q) not in known_libraries]
|
if q not in known_libraries]
|
||||||
for key in private:
|
for key in private:
|
||||||
|
private_dependencies += [q for q in scope.expand(key)
|
||||||
|
if q not in known_libraries]
|
||||||
|
|
||||||
|
for key in qt_private:
|
||||||
private_dependencies += [map_qt_library(q) for q in scope.expand(key)
|
private_dependencies += [map_qt_library(q) for q in scope.expand(key)
|
||||||
if map_qt_library(q) not in known_libraries]
|
if map_qt_library(q) not in known_libraries]
|
||||||
for key in mixed:
|
|
||||||
|
for key in qt_mixed:
|
||||||
for lib in scope.expand(key):
|
for lib in scope.expand(key):
|
||||||
mapped_lib = map_qt_library(lib)
|
mapped_lib = map_qt_library(lib)
|
||||||
if mapped_lib in known_libraries:
|
if mapped_lib in known_libraries:
|
||||||
@ -1028,7 +1035,8 @@ def write_sources_section(cm_fh: typing.IO[str], scope: Scope, *,
|
|||||||
|
|
||||||
write_library_section(cm_fh, scope,
|
write_library_section(cm_fh, scope,
|
||||||
['QMAKE_USE', 'LIBS'],
|
['QMAKE_USE', 'LIBS'],
|
||||||
['QT_FOR_PRIVATE', 'QMAKE_USE_PRIVATE', 'QMAKE_USE_FOR_PRIVATE', 'LIBS_PRIVATE'],
|
['QMAKE_USE_PRIVATE', 'QMAKE_USE_FOR_PRIVATE', 'LIBS_PRIVATE'],
|
||||||
|
['QT_FOR_PRIVATE',],
|
||||||
['QT',],
|
['QT',],
|
||||||
indent=indent, known_libraries=known_libraries)
|
indent=indent, known_libraries=known_libraries)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user