Skip to content

Commit

Permalink
fix order of found qt5 dep libs for linking if pkg-config/pkgconf was…
Browse files Browse the repository at this point in the history
… not used #31
  • Loading branch information
pustotnik committed Feb 21, 2022
1 parent 0124aff commit ce815b9
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/zenmake/zm/features/qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import re
from collections import Counter

from waflib import Errors as waferror
from waflib.Task import Task
Expand All @@ -25,6 +26,7 @@
from zm.constants import PLATFORM, HOST_OS
from zm import error, utils, log
from zm.features import precmd
from zm.pyutils import cached
from zm.pathutils import getNativePath, unfoldPath, getNodesFromPathsConf
from zm.waf import assist
from zm.waf import context
Expand Down Expand Up @@ -350,6 +352,9 @@ def _gatherQt5LibDepsFromHeaders(conf, qtIncludes):
It's not perfect but better than nothing.
"""

cacheReadModules = {}

@cached(cacheReadModules)
def readModulesFromFile(filepath):
modules = []
if not _pathexists(filepath):
Expand All @@ -362,26 +367,26 @@ def readModulesFromFile(filepath):
modules.append(qtmodname)
return utils.uniqueListWithOrder(modules)

def gatherModules(modules, seen):
def gatherModules(modules):

result = []
for module in modules:
if module in seen:
continue

seen.add(module)
result.append(module)

filepath = _joinpath(qtIncludes, module, '%sDepends' % module)
result.extend(gatherModules(readModulesFromFile(filepath), seen))
result.extend(gatherModules(readModulesFromFile(filepath)))

return result

deps = {}
for libname in conf.qt5libNames:
seen = set()
module = libname.replace('Qt5', 'Qt', 1)
deps[libname] = gatherModules([module], seen)
modules = gatherModules([module])

dmodules = modules[1:]
mcounter = Counter(dmodules)
modules[1:] = sorted(set(dmodules), key = mcounter.__getitem__)
deps[libname] = modules

return deps

Expand Down

0 comments on commit ce815b9

Please sign in to comment.