summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool/qt.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Tool/qt.py')
-rw-r--r--src/engine/SCons/Tool/qt.py70
1 files changed, 50 insertions, 20 deletions
diff --git a/src/engine/SCons/Tool/qt.py b/src/engine/SCons/Tool/qt.py
index e7c1b95..a582e6f 100644
--- a/src/engine/SCons/Tool/qt.py
+++ b/src/engine/SCons/Tool/qt.py
@@ -10,7 +10,7 @@ selection method.
"""
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -33,10 +33,11 @@ selection method.
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/qt.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/qt.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os.path
import re
+import glob
import SCons.Action
import SCons.Builder
@@ -44,6 +45,8 @@ import SCons.Defaults
import SCons.Scanner
import SCons.Tool
import SCons.Util
+import SCons.Tool.cxx
+cplusplus = SCons.Tool.cxx
class ToolQtWarning(SCons.Warnings.Warning):
pass
@@ -60,12 +63,40 @@ header_extensions = [".h", ".hxx", ".hpp", ".hh"]
if SCons.Util.case_sensitive_suffixes('.h', '.H'):
header_extensions.append('.H')
-import SCons.Tool.cxx
-cplusplus = SCons.Tool.cxx
-#cplusplus = __import__('cxx', globals(), locals(), [])
-
cxx_suffixes = cplusplus.CXXSuffixes
+
+def find_platform_specific_qt_paths():
+ """
+ find non-standard QT paths
+
+ If the platform does not put QT tools in standard search paths,
+ the path is expected to be set using QTDIR. SCons violates
+ the normal rule of not pulling from the user's environment
+ in this case. However, some test cases try to validate what
+ happens when QTDIR is unset, so we need to try to make a guess.
+
+ :return: a guess at a path
+ """
+
+ # qt_bin_dirs = []
+ qt_bin_dir = None
+ if os.path.isfile('/etc/redhat-release'):
+ with open('/etc/redhat-release','r') as rr:
+ lines = rr.readlines()
+ distro = lines[0].split()[0]
+ if distro == 'CentOS':
+ # Centos installs QT under /usr/{lib,lib64}/qt{4,5,-3.3}/bin
+ # so we need to handle this differently
+ # qt_bin_dirs = glob.glob('/usr/lib64/qt*/bin')
+ # TODO: all current Fedoras do the same, need to look deeper here.
+ qt_bin_dir = '/usr/lib64/qt-3.3/bin'
+
+ return qt_bin_dir
+
+
+QT_BIN_DIR = find_platform_specific_qt_paths()
+
def checkMocIncluded(target, source, env):
moc = target[0]
cpp = source[0]
@@ -73,7 +104,7 @@ def checkMocIncluded(target, source, env):
# not really sure about the path transformations (moc.cwd? cpp.cwd?) :-/
path = SCons.Defaults.CScan.path(env, moc.cwd)
includes = SCons.Defaults.CScan(cpp, env, path)
- if not moc in includes:
+ if moc not in includes:
SCons.Warnings.warn(
GeneratedMocFileNotIncluded,
"Generated moc file '%s' is not included by '%s'" %
@@ -94,7 +125,7 @@ class _Automoc(object):
def __init__(self, objBuilderName):
self.objBuilderName = objBuilderName
-
+
def __call__(self, target, source, env):
"""
Smart autoscan function. Gets the list of objects for the Program
@@ -109,25 +140,25 @@ class _Automoc(object):
debug = int(env.subst('$QT_DEBUG'))
except ValueError:
debug = 0
-
+
# some shortcuts used in the scanner
splitext = SCons.Util.splitext
objBuilder = getattr(env, self.objBuilderName)
-
+
# some regular expressions:
# Q_OBJECT detection
- q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
+ q_object_search = re.compile(r'[^A-Za-z0-9]Q_OBJECT[^A-Za-z0-9]')
# cxx and c comment 'eater'
#comment = re.compile(r'(//.*)|(/\*(([^*])|(\*[^/]))*\*/)')
# CW: something must be wrong with the regexp. See also bug #998222
# CURRENTLY THERE IS NO TEST CASE FOR THAT
-
+
# The following is kind of hacky to get builders working properly (FIXME)
objBuilderEnv = objBuilder.env
objBuilder.env = env
mocBuilderEnv = env.Moc.env
env.Moc.env = env
-
+
# make a deep copy for the result; MocH objects will be appended
out_sources = source[:]
@@ -140,7 +171,7 @@ class _Automoc(object):
cpp = obj.sources[0]
if not splitext(str(cpp))[1] in cxx_suffixes:
if debug:
- print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
+ print("scons: qt: '%s' is no cxx file. Discarded." % str(cpp))
# c or fortran source
continue
#cpp_contents = comment.sub('', cpp.get_text_contents())
@@ -188,13 +219,12 @@ AutomocStatic = _Automoc('StaticObject')
def _detect(env):
"""Not really safe, but fast method to detect the QT library"""
- QTDIR = None
- if not QTDIR:
- QTDIR = env.get('QTDIR',None)
+
+ QTDIR = env.get('QTDIR',None)
if not QTDIR:
QTDIR = os.environ.get('QTDIR',None)
if not QTDIR:
- moc = env.WhereIs('moc')
+ moc = env.WhereIs('moc') or env.WhereIs('moc',QT_BIN_DIR)
if moc:
QTDIR = os.path.dirname(os.path.dirname(moc))
SCons.Warnings.warn(
@@ -237,7 +267,7 @@ def uicScannerFunc(node, env, path):
return result
uicScanner = SCons.Scanner.Base(uicScannerFunc,
- name = "UicScanner",
+ name = "UicScanner",
node_class = SCons.Node.FS.File,
node_factory = SCons.Node.FS.File,
recursive = 0)
@@ -313,7 +343,7 @@ def generate(env):
mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX'
mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX'
- # register the builders
+ # register the builders
env['BUILDERS']['Uic'] = uicBld
env['BUILDERS']['Moc'] = mocBld
static_obj, shared_obj = SCons.Tool.createObjBuilders(env)