From f8c2a438f82eddd270dbe29a637fd3c76a0f9263 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Thu, 23 Feb 2023 15:30:59 -0800 Subject: move qt -> qt3 tool, adjust testing as well --- SCons/Tool/qt.py | 371 --------------------------------- SCons/Tool/qt.xml | 447 ---------------------------------------- SCons/Tool/qt3.py | 375 +++++++++++++++++++++++++++++++++ SCons/Tool/qt3.xml | 447 ++++++++++++++++++++++++++++++++++++++++ test/QT/CPPPATH-appended.py | 80 ------- test/QT/CPPPATH.py | 70 ------- test/QT/QTFLAGS.py | 219 -------------------- test/QT/Tool.py | 156 -------------- test/QT/copied-env.py | 83 -------- test/QT/empty-env.py | 79 ------- test/QT/generated-ui.py | 136 ------------ test/QT/installed.py | 220 -------------------- test/QT/manual.py | 148 ------------- test/QT/moc-from-cpp.py | 114 ---------- test/QT/moc-from-header.py | 109 ---------- test/QT/qt3/CPPPATH-appended.py | 80 +++++++ test/QT/qt3/CPPPATH.py | 70 +++++++ test/QT/qt3/QTFLAGS.py | 219 ++++++++++++++++++++ test/QT/qt3/Tool.py | 156 ++++++++++++++ test/QT/qt3/copied-env.py | 83 ++++++++ test/QT/qt3/empty-env.py | 79 +++++++ test/QT/qt3/generated-ui.py | 136 ++++++++++++ test/QT/qt3/installed.py | 220 ++++++++++++++++++++ test/QT/qt3/manual.py | 148 +++++++++++++ test/QT/qt3/moc-from-cpp.py | 114 ++++++++++ test/QT/qt3/moc-from-header.py | 109 ++++++++++ test/QT/qt3/qt_warnings.py | 104 ++++++++++ test/QT/qt3/reentrant.py | 74 +++++++ test/QT/qt3/source-from-ui.py | 161 +++++++++++++++ test/QT/qt3/up-to-date.py | 144 +++++++++++++ test/QT/qt_warnings.py | 104 ---------- test/QT/reentrant.py | 74 ------- test/QT/source-from-ui.py | 161 --------------- test/QT/up-to-date.py | 144 ------------- testing/framework/TestSCons.py | 10 +- 35 files changed, 2724 insertions(+), 2720 deletions(-) delete mode 100644 SCons/Tool/qt.py delete mode 100644 SCons/Tool/qt.xml create mode 100644 SCons/Tool/qt3.py create mode 100644 SCons/Tool/qt3.xml delete mode 100644 test/QT/CPPPATH-appended.py delete mode 100644 test/QT/CPPPATH.py delete mode 100644 test/QT/QTFLAGS.py delete mode 100644 test/QT/Tool.py delete mode 100644 test/QT/copied-env.py delete mode 100644 test/QT/empty-env.py delete mode 100644 test/QT/generated-ui.py delete mode 100644 test/QT/installed.py delete mode 100644 test/QT/manual.py delete mode 100644 test/QT/moc-from-cpp.py delete mode 100644 test/QT/moc-from-header.py create mode 100644 test/QT/qt3/CPPPATH-appended.py create mode 100644 test/QT/qt3/CPPPATH.py create mode 100644 test/QT/qt3/QTFLAGS.py create mode 100644 test/QT/qt3/Tool.py create mode 100644 test/QT/qt3/copied-env.py create mode 100644 test/QT/qt3/empty-env.py create mode 100644 test/QT/qt3/generated-ui.py create mode 100644 test/QT/qt3/installed.py create mode 100644 test/QT/qt3/manual.py create mode 100644 test/QT/qt3/moc-from-cpp.py create mode 100644 test/QT/qt3/moc-from-header.py create mode 100644 test/QT/qt3/qt_warnings.py create mode 100644 test/QT/qt3/reentrant.py create mode 100644 test/QT/qt3/source-from-ui.py create mode 100644 test/QT/qt3/up-to-date.py delete mode 100644 test/QT/qt_warnings.py delete mode 100644 test/QT/reentrant.py delete mode 100644 test/QT/source-from-ui.py delete mode 100644 test/QT/up-to-date.py diff --git a/SCons/Tool/qt.py b/SCons/Tool/qt.py deleted file mode 100644 index ff995657d..000000000 --- a/SCons/Tool/qt.py +++ /dev/null @@ -1,371 +0,0 @@ -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -"""Tool-specific initialization for Qt. - -There normally shouldn't be any need to import this module directly. -It will usually be imported through the generic SCons.Tool.Tool() -selection method. -""" - -import os.path -import re - -import SCons.Action -import SCons.Builder -import SCons.Defaults -import SCons.Scanner -import SCons.Tool -import SCons.Util -import SCons.Tool.cxx -import SCons.Warnings -cplusplus = SCons.Tool.cxx - -class ToolQtWarning(SCons.Warnings.SConsWarning): - pass - -class GeneratedMocFileNotIncluded(ToolQtWarning): - pass - -class QtdirNotFound(ToolQtWarning): - pass - -SCons.Warnings.enableWarningClass(ToolQtWarning) - -header_extensions = [".h", ".hxx", ".hpp", ".hh"] -if SCons.Util.case_sensitive_suffixes('.h', '.H'): - header_extensions.append('.H') - -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] - # looks like cpp.includes is cleared before the build stage :-( - # 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 moc not in includes: - SCons.Warnings.warn( - GeneratedMocFileNotIncluded, - "Generated moc file '%s' is not included by '%s'" % - (str(moc), str(cpp))) - -def find_file(filename, paths, node_factory): - for dir in paths: - node = node_factory(filename, dir) - if node.rexists(): - return node - return None - -class _Automoc: - """ - Callable class, which works as an emitter for Programs, SharedLibraries and - StaticLibraries. - """ - - def __init__(self, objBuilderName): - self.objBuilderName = objBuilderName - - def __call__(self, target, source, env): - """ - Smart autoscan function. Gets the list of objects for the Program - or Lib. Adds objects and builders for the special qt files. - """ - try: - if int(env.subst('$QT_AUTOSCAN')) == 0: - return target, source - except ValueError: - pass - try: - 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]') - # 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[:] - - for obj in source: - if not obj.has_builder(): - # binary obj file provided - if debug: - print("scons: qt: '%s' seems to be a binary. Discarded." % str(obj)) - continue - 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)) - # c or fortran source - continue - #cpp_contents = comment.sub('', cpp.get_text_contents()) - if debug: - print("scons: qt: Getting contents of %s" % cpp) - cpp_contents = cpp.get_text_contents() - h=None - for h_ext in header_extensions: - # try to find the header file in the corresponding source - # directory - hname = splitext(cpp.name)[0] + h_ext - h = find_file(hname, (cpp.get_dir(),), env.File) - if h: - if debug: - print("scons: qt: Scanning '%s' (header of '%s')" % (str(h), str(cpp))) - #h_contents = comment.sub('', h.get_text_contents()) - h_contents = h.get_text_contents() - break - if not h and debug: - print("scons: qt: no header for '%s'." % (str(cpp))) - if h and q_object_search.search(h_contents): - # h file with the Q_OBJECT macro found -> add moc_cpp - moc_cpp = env.Moc(h) - moc_o = objBuilder(moc_cpp) - out_sources.append(moc_o) - #moc_cpp.target_scanner = SCons.Defaults.CScan - if debug: - print("scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))) - if cpp and q_object_search.search(cpp_contents): - # cpp file with Q_OBJECT macro found -> add moc - # (to be included in cpp) - moc = env.Moc(cpp) - env.Ignore(moc, moc) - if debug: - print("scons: qt: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))) - #moc.source_scanner = SCons.Defaults.CScan - # restore the original env attributes (FIXME) - objBuilder.env = objBuilderEnv - env.Moc.env = mocBuilderEnv - - return (target, out_sources) - -AutomocShared = _Automoc('SharedObject') -AutomocStatic = _Automoc('StaticObject') - -def _detect(env): - """Not really safe, but fast method to detect the QT library""" - - QTDIR = env.get('QTDIR',None) - if not QTDIR: - QTDIR = os.environ.get('QTDIR',None) - if not QTDIR: - moc = env.WhereIs('moc') or env.WhereIs('moc',QT_BIN_DIR) - if moc: - QTDIR = os.path.dirname(os.path.dirname(moc)) - SCons.Warnings.warn( - QtdirNotFound, - "Could not detect qt, using moc executable as a hint (QTDIR=%s)" % QTDIR) - else: - QTDIR = None - SCons.Warnings.warn( - QtdirNotFound, - "Could not detect qt, using empty QTDIR") - return QTDIR - -def uicEmitter(target, source, env): - adjustixes = SCons.Util.adjustixes - bs = SCons.Util.splitext(str(source[0].name))[0] - bs = os.path.join(str(target[0].get_dir()),bs) - # first target (header) is automatically added by builder - if len(target) < 2: - # second target is implementation - target.append(adjustixes(bs, - env.subst('$QT_UICIMPLPREFIX'), - env.subst('$QT_UICIMPLSUFFIX'))) - if len(target) < 3: - # third target is moc file - target.append(adjustixes(bs, - env.subst('$QT_MOCHPREFIX'), - env.subst('$QT_MOCHSUFFIX'))) - return target, source - -def uicScannerFunc(node, env, path): - lookout = [] - lookout.extend(env['CPPPATH']) - lookout.append(str(node.rfile().dir)) - includes = re.findall("(.*?)", node.get_text_contents()) - result = [] - for incFile in includes: - dep = env.FindFile(incFile,lookout) - if dep: - result.append(dep) - return result - -uicScanner = SCons.Scanner.ScannerBase(uicScannerFunc, - name = "UicScanner", - node_class = SCons.Node.FS.File, - node_factory = SCons.Node.FS.File, - recursive = 0) - -def generate(env): - """Add Builders and construction variables for qt to an Environment.""" - CLVar = SCons.Util.CLVar - Action = SCons.Action.Action - Builder = SCons.Builder.Builder - - SCons.Warnings.warn( - SCons.Warnings.ToolQtDeprecatedWarning, "Tool module for Qt version 3 is deprecated" - ) - - env.SetDefault(QTDIR = _detect(env), - QT_BINPATH = os.path.join('$QTDIR', 'bin'), - QT_CPPPATH = os.path.join('$QTDIR', 'include'), - QT_LIBPATH = os.path.join('$QTDIR', 'lib'), - QT_MOC = os.path.join('$QT_BINPATH','moc'), - QT_UIC = os.path.join('$QT_BINPATH','uic'), - QT_LIB = 'qt', # may be set to qt-mt - - QT_AUTOSCAN = 1, # scan for moc'able sources - - # Some QT specific flags. I don't expect someone wants to - # manipulate those ... - QT_UICIMPLFLAGS = CLVar(''), - QT_UICDECLFLAGS = CLVar(''), - QT_MOCFROMHFLAGS = CLVar(''), - QT_MOCFROMCXXFLAGS = CLVar('-i'), - - # suffixes/prefixes for the headers / sources to generate - QT_UICDECLPREFIX = '', - QT_UICDECLSUFFIX = '.h', - QT_UICIMPLPREFIX = 'uic_', - QT_UICIMPLSUFFIX = '$CXXFILESUFFIX', - QT_MOCHPREFIX = 'moc_', - QT_MOCHSUFFIX = '$CXXFILESUFFIX', - QT_MOCCXXPREFIX = '', - QT_MOCCXXSUFFIX = '.moc', - QT_UISUFFIX = '.ui', - - # Commands for the qt support ... - # command to generate header, implementation and moc-file - # from a .ui file - QT_UICCOM = [ - CLVar('$QT_UIC $QT_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'), - CLVar('$QT_UIC $QT_UICIMPLFLAGS -impl ${TARGETS[0].file} ' - '-o ${TARGETS[1]} $SOURCE'), - CLVar('$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}')], - # command to generate meta object information for a class - # declarated in a header - QT_MOCFROMHCOM = ( - '$QT_MOC $QT_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE'), - # command to generate meta object information for a class - # declarated in a cpp file - QT_MOCFROMCXXCOM = [ - CLVar('$QT_MOC $QT_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'), - Action(checkMocIncluded,None)]) - - # ... and the corresponding builders - uicBld = Builder(action=SCons.Action.Action('$QT_UICCOM', '$QT_UICCOMSTR'), - emitter=uicEmitter, - src_suffix='$QT_UISUFFIX', - suffix='$QT_UICDECLSUFFIX', - prefix='$QT_UICDECLPREFIX', - source_scanner=uicScanner) - mocBld = Builder(action={}, prefix={}, suffix={}) - for h in header_extensions: - act = SCons.Action.Action('$QT_MOCFROMHCOM', '$QT_MOCFROMHCOMSTR') - mocBld.add_action(h, act) - mocBld.prefix[h] = '$QT_MOCHPREFIX' - mocBld.suffix[h] = '$QT_MOCHSUFFIX' - for cxx in cxx_suffixes: - act = SCons.Action.Action('$QT_MOCFROMCXXCOM', '$QT_MOCFROMCXXCOMSTR') - mocBld.add_action(cxx, act) - mocBld.prefix[cxx] = '$QT_MOCCXXPREFIX' - mocBld.suffix[cxx] = '$QT_MOCCXXSUFFIX' - - # register the builders - env['BUILDERS']['Uic'] = uicBld - env['BUILDERS']['Moc'] = mocBld - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - static_obj.add_src_builder('Uic') - shared_obj.add_src_builder('Uic') - - # We use the emitters of Program / StaticLibrary / SharedLibrary - # to scan for moc'able files - # We can't refer to the builders directly, we have to fetch them - # as Environment attributes because that sets them up to be called - # correctly later by our emitter. - env.AppendUnique(PROGEMITTER =[AutomocStatic], - SHLIBEMITTER=[AutomocShared], - LDMODULEEMITTER=[AutomocShared], - LIBEMITTER =[AutomocStatic], - # Of course, we need to link against the qt libraries - CPPPATH=["$QT_CPPPATH"], - LIBPATH=["$QT_LIBPATH"], - LIBS=['$QT_LIB']) - -def exists(env): - return _detect(env) - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/SCons/Tool/qt.xml b/SCons/Tool/qt.xml deleted file mode 100644 index 5298a82c4..000000000 --- a/SCons/Tool/qt.xml +++ /dev/null @@ -1,447 +0,0 @@ - - - - -%scons; - -%builders-mod; - -%functions-mod; - -%tools-mod; - -%variables-mod; -]> - - - - - - -Sets &consvars; for building Qt3 applications. - - - -This tool is only suitable for building targeted to Qt3, -which is obsolete -(the tool is deprecated since 4.3). -There are contributed tools for Qt4 and Qt5, see - -https://github.com/SCons/scons-contrib. -Qt4 has also passed end of life for standard support (in Dec 2015). - - - -Note paths for these &consvars; are assembled -using the os.path.join method -so they will have the appropriate separator at runtime, -but are listed here in the various -entries only with the '/' separator -for simplicity. - - - -In addition, the &consvars; -&cv-link-CPPPATH;, -&cv-link-LIBPATH; and -&cv-link-LIBS; may be modified -and the variables -&cv-link-PROGEMITTER;, &cv-link-SHLIBEMITTER; and &cv-link-LIBEMITTER; -are modified. Because the build-performance is affected when using this tool, -you have to explicitly specify it at Environment creation: - - - -Environment(tools=['default','qt']) - - - -The &t-qt; tool supports the following operations: - - - -Automatic moc file generation from header files. -You do not have to specify moc files explicitly, the tool does it for you. -However, there are a few preconditions to do so: Your header file must have -the same filebase as your implementation file and must stay in the same -directory. It must have one of the suffixes -.h, -.hpp, -.H, -.hxx, -.hh. -You can turn off automatic moc file generation by setting -&cv-link-QT_AUTOSCAN; to False. -See also the corresponding -&b-link-Moc; Builder. - - - -Automatic moc file generation from C++ files. -As described in the Qt documentation, include the moc file at the end of -the C++ file. Note that you have to include the file, which is generated -by the transformation -${QT_MOCCXXPREFIX}<basename>${QT_MOCCXXSUFFIX}, by default -<basename>.mo. A warning is generated after building the moc file if you -do not include the correct file. If you are using &f-link-VariantDir;, you may -need to specify duplicate=True. -You can turn off automatic moc file generation by setting &cv-QT_AUTOSCAN; to -False. See also the corresponding -&b-link-Moc; Builder. - - - -Automatic handling of .ui files. -The implementation files generated from .ui -files are handled much the same as yacc or lex files. -Each .ui file given as a source of &b-link-Program;, -&b-link-Library; or &b-link-SharedLibrary; -will generate three files: the declaration file, the -implementation file and a moc file. Because there are also generated headers, -you may need to specify duplicate=True in calls to -&f-link-VariantDir;. -See also the corresponding -&b-link-Uic; Builder. - - - -QTDIR -QT_BINPATH -QT_CPPPATH -QT_LIBPATH -QT_MOC -QT_UIC -QT_LIB -QT_AUTOSCAN -QT_UICIMPLFLAGS -QT_UICDECLFLAGS -QT_MOCFROMHFLAGS -QT_MOCFROMCXXFLAGS -QT_UICDECLPREFIX -QT_UICDECLSUFFIX -QT_UICIMPLPREFIX -QT_UICIMPLSUFFIX -QT_MOCHPREFIX -QT_MOCHSUFFIX -QT_MOCCXXPREFIX -QT_MOCCXXSUFFIX -QT_UISUFFIX -QT_UICCOM -QT_MOCFROMHCOM -QT_MOCFROMCXXCOM - - -QTDIR - - - - - - -Builds an output file from a moc input file. -moc input files are either header files or C++ files. -This builder is only available after using the -tool &t-link-qt;. See the &cv-link-QTDIR; variable for more information. -Example: - - - -env.Moc('foo.h') # generates moc_foo.cc -env.Moc('foo.cpp') # generates foo.moc - - - - - - - -Builds a header file, an implementation file and a moc file from an ui file. -and returns the corresponding nodes in the that order. -This builder is only available after using the tool &t-link-qt;. -Note: you can specify .ui files directly as source -files to the &b-link-Program;, -&b-link-Library; and &b-link-SharedLibrary; builders -without using this builder. Using this builder lets you override the standard -naming conventions (be careful: prefixes are always prepended to names of -built files; if you don't want prefixes, you may set them to ``). -See the &cv-link-QTDIR; variable for more information. -Example: - - - -env.Uic('foo.ui') # -> ['foo.h', 'uic_foo.cc', 'moc_foo.cc'] -env.Uic( - target=Split('include/foo.h gen/uicfoo.cc gen/mocfoo.cc'), - source='foo.ui' -) # -> ['include/foo.h', 'gen/uicfoo.cc', 'gen/mocfoo.cc'] - - - - - - - -The path to the Qt installation to build against. -If not already set, -&t-link-qt; tool tries to obtain this from -os.environ; -if not found there, it tries to make a guess. - - - - - - - -Turn off scanning for mocable files. Use the &b-link-Moc; Builder to explicitly -specify files to run moc on. - - - - - - - -The path where the Qt binaries are installed. -The default value is '&cv-link-QTDIR;/bin'. - - - - - - - -The path where the Qt header files are installed. -The default value is '&cv-link-QTDIR;/include'. -Note: If you set this variable to None, -the tool won't change the &cv-link-CPPPATH; -construction variable. - - - - - - - -Prints lots of debugging information while scanning for moc files. - - - - - - - -Default value is 'qt'. -You may want to set this to 'qt-mt'. -Note: If you set this variable to None, -the tool won't change the &cv-link-LIBS; variable. - - - - - - - -The path where the Qt libraries are installed. -The default value is '&cv-link-QTDIR;/lib'. -Note: If you set this variable to None, -the tool won't change the &cv-link-LIBPATH; -construction variable. - - - - - - - -Default value is '&cv-link-QT_BINPATH;/moc'. - - - - - - - -Default value is ''. -Prefix for moc output files when source is a C++ file. - - - - - - - -Default value is '.moc'. -Suffix for moc output files when source is a C++ file. - - - - - - - -Default value is '-i'. -These flags are passed to moc when moccing a C++ file. - - - - - - - -Command to generate a moc file from a C++ file. - - - - - - - -The string displayed when generating a moc file from a C++ file. -If this is not set, then &cv-link-QT_MOCFROMCXXCOM; (the command line) is displayed. - - - - - - - -Command to generate a moc file from a header. - - - - - - - -The string displayed when generating a moc file from a C++ file. -If this is not set, then &cv-link-QT_MOCFROMHCOM; (the command line) is displayed. - - - - - - - -Default value is ''. These flags are passed to moc -when moccing a header file. - - - - - - - -Default value is 'moc_'. -Prefix for moc output files when source is a header. - - - - - - - -Default value is '&cv-link-CXXFILESUFFIX;'. -Suffix for moc output files when source is a header. - - - - - - - -Default value is '&cv-link-QT_BINPATH;/uic'. - - - - - - - -Command to generate header files from .ui files. - - - - - - - -The string displayed when generating header files from .ui files. -If this is not set, then &cv-link-QT_UICCOM; (the command line) is displayed. - - - - - - - -Default value is ''. These flags are passed to uic -when creating a header file from a .ui file. - - - - - - - -Default value is ''. -Prefix for uic generated header files. - - - - - - - -Default value is '.h'. -Suffix for uic generated header files. - - - - - - - -Default value is ''. -These flags are passed to uic when creating a C++ -file from a .ui file. - - - - - - - -Default value is 'uic_'. -Prefix for uic generated implementation files. - - - - - - - -Default value is '&cv-link-CXXFILESUFFIX;'. Suffix for uic generated implementation -files. - - - - - - - -Default value is '.ui'. -Suffix of designer input files. - - - - - diff --git a/SCons/Tool/qt3.py b/SCons/Tool/qt3.py new file mode 100644 index 000000000..2b315548e --- /dev/null +++ b/SCons/Tool/qt3.py @@ -0,0 +1,375 @@ +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +"""Tool-specific initialization for Qt. + +There normally shouldn't be any need to import this module directly. +It will usually be imported through the generic SCons.Tool.Tool() +selection method. +""" + +import os.path +import re + +import SCons.Action +import SCons.Builder +import SCons.Defaults +import SCons.Scanner +import SCons.Tool +import SCons.Util +import SCons.Tool.cxx +import SCons.Warnings +cplusplus = SCons.Tool.cxx + +class ToolQtWarning(SCons.Warnings.SConsWarning): + pass + +class GeneratedMocFileNotIncluded(ToolQtWarning): + pass + +class QtdirNotFound(ToolQtWarning): + pass + +SCons.Warnings.enableWarningClass(ToolQtWarning) + +header_extensions = [".h", ".hxx", ".hpp", ".hh"] +if SCons.Util.case_sensitive_suffixes('.h', '.H'): + header_extensions.append('.H') + +cxx_suffixes = cplusplus.CXXSuffixes + + +def find_platform_specific_qt3_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 QT3DIR. 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 QT3DIR is unset, so we need to try to make a guess. + + :return: a guess at a path + """ + + # qt3_bin_dirs = [] + qt3_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 + # qt3_bin_dirs = glob.glob('/usr/lib64/qt*/bin') + # TODO: all current Fedoras do the same, need to look deeper here. + qt3_bin_dir = '/usr/lib64/qt-3.3/bin' + + return qt3_bin_dir + + +QT3_BIN_DIR = find_platform_specific_qt3_paths() + +def checkMocIncluded(target, source, env): + moc = target[0] + cpp = source[0] + # looks like cpp.includes is cleared before the build stage :-( + # 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 moc not in includes: + SCons.Warnings.warn( + GeneratedMocFileNotIncluded, + "Generated moc file '%s' is not included by '%s'" % + (str(moc), str(cpp))) + +def find_file(filename, paths, node_factory): + for dir in paths: + node = node_factory(filename, dir) + if node.rexists(): + return node + return None + +class _Automoc: + """ + Callable class, which works as an emitter for Programs, SharedLibraries and + StaticLibraries. + """ + + def __init__(self, objBuilderName): + self.objBuilderName = objBuilderName + + def __call__(self, target, source, env): + """ + Smart autoscan function. Gets the list of objects for the Program + or Lib. Adds objects and builders for the special qt3 files. + """ + try: + if int(env.subst('$QT3_AUTOSCAN')) == 0: + return target, source + except ValueError: + pass + try: + debug = int(env.subst('$QT3_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]') + # 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[:] + + for obj in source: + if not obj.has_builder(): + # binary obj file provided + if debug: + print("scons: qt3: '%s' seems to be a binary. Discarded." % str(obj)) + continue + cpp = obj.sources[0] + if not splitext(str(cpp))[1] in cxx_suffixes: + if debug: + print("scons: qt3: '%s' is no cxx file. Discarded." % str(cpp)) + # c or fortran source + continue + #cpp_contents = comment.sub('', cpp.get_text_contents()) + if debug: + print("scons: qt3: Getting contents of %s" % cpp) + cpp_contents = cpp.get_text_contents() + h=None + for h_ext in header_extensions: + # try to find the header file in the corresponding source + # directory + hname = splitext(cpp.name)[0] + h_ext + h = find_file(hname, (cpp.get_dir(),), env.File) + if h: + if debug: + print("scons: qt3: Scanning '%s' (header of '%s')" % (str(h), str(cpp))) + #h_contents = comment.sub('', h.get_text_contents()) + h_contents = h.get_text_contents() + break + if not h and debug: + print("scons: qt3: no header for '%s'." % (str(cpp))) + if h and q_object_search.search(h_contents): + # h file with the Q_OBJECT macro found -> add moc_cpp + moc_cpp = env.Moc(h) + moc_o = objBuilder(moc_cpp) + out_sources.append(moc_o) + #moc_cpp.target_scanner = SCons.Defaults.CScan + if debug: + print("scons: qt3: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(h), str(moc_cpp))) + if cpp and q_object_search.search(cpp_contents): + # cpp file with Q_OBJECT macro found -> add moc + # (to be included in cpp) + moc = env.Moc(cpp) + env.Ignore(moc, moc) + if debug: + print("scons: qt3: found Q_OBJECT macro in '%s', moc'ing to '%s'" % (str(cpp), str(moc))) + #moc.source_scanner = SCons.Defaults.CScan + # restore the original env attributes (FIXME) + objBuilder.env = objBuilderEnv + env.Moc.env = mocBuilderEnv + + return (target, out_sources) + +AutomocShared = _Automoc('SharedObject') +AutomocStatic = _Automoc('StaticObject') + +def _detect_qt3(env): + """Not really safe, but fast method to detect the QT library""" + + QT3DIR = env.get('QT3DIR',None) + if not QT3DIR: + QT3DIR = os.environ.get('QTDIR',None) + if not QT3DIR: + moc = env.WhereIs('moc') or env.WhereIs('moc',QT3_BIN_DIR) + if moc: + QT3DIR = os.path.dirname(os.path.dirname(moc)) + SCons.Warnings.warn( + QtdirNotFound, + "Could not detect qt3, using moc executable as a hint (QT3DIR=%s)" % QT3DIR) + else: + QT3DIR = None + SCons.Warnings.warn( + QtdirNotFound, + "Could not detect qt3, using empty QT3DIR") + return QT3DIR + +def uicEmitter(target, source, env): + adjustixes = SCons.Util.adjustixes + bs = SCons.Util.splitext(str(source[0].name))[0] + bs = os.path.join(str(target[0].get_dir()),bs) + # first target (header) is automatically added by builder + if len(target) < 2: + # second target is implementation + target.append(adjustixes(bs, + env.subst('$QT3_UICIMPLPREFIX'), + env.subst('$QT3_UICIMPLSUFFIX'))) + if len(target) < 3: + # third target is moc file + target.append(adjustixes(bs, + env.subst('$QT3_MOCHPREFIX'), + env.subst('$QT3_MOCHSUFFIX'))) + return target, source + +def uicScannerFunc(node, env, path): + lookout = [] + lookout.extend(env['CPPPATH']) + lookout.append(str(node.rfile().dir)) + includes = re.findall("(.*?)", node.get_text_contents()) + result = [] + for incFile in includes: + dep = env.FindFile(incFile,lookout) + if dep: + result.append(dep) + return result + +uicScanner = SCons.Scanner.ScannerBase(uicScannerFunc, + name = "UicScanner", + node_class = SCons.Node.FS.File, + node_factory = SCons.Node.FS.File, + recursive = 0) + +def generate(env): + """Add Builders and construction variables for qt3 to an Environment.""" + CLVar = SCons.Util.CLVar + Action = SCons.Action.Action + Builder = SCons.Builder.Builder + + SCons.Warnings.warn( + SCons.Warnings.ToolQtDeprecatedWarning, "Tool module for Qt version 3 is deprecated" + ) + + qt3path = _detect_qt3(env) + if qt3path is None: + return None + + env.SetDefault(QT3DIR = qt3path, + QT3_BINPATH = os.path.join('$QT3DIR', 'bin'), + QT3_CPPPATH = os.path.join('$QT3DIR', 'include'), + QT3_LIBPATH = os.path.join('$QT3DIR', 'lib'), + QT3_MOC = os.path.join('$QT3_BINPATH','moc'), + QT3_UIC = os.path.join('$QT3_BINPATH','uic'), + QT3_LIB = 'qt', # may be set to qt-mt + + QT3_AUTOSCAN = 1, # scan for moc'able sources + + # Some QT specific flags. I don't expect someone wants to + # manipulate those ... + QT3_UICIMPLFLAGS = CLVar(''), + QT3_UICDECLFLAGS = CLVar(''), + QT3_MOCFROMHFLAGS = CLVar(''), + QT3_MOCFROMCXXFLAGS = CLVar('-i'), + + # suffixes/prefixes for the headers / sources to generate + QT3_UICDECLPREFIX = '', + QT3_UICDECLSUFFIX = '.h', + QT3_UICIMPLPREFIX = 'uic_', + QT3_UICIMPLSUFFIX = '$CXXFILESUFFIX', + QT3_MOCHPREFIX = 'moc_', + QT3_MOCHSUFFIX = '$CXXFILESUFFIX', + QT3_MOCCXXPREFIX = '', + QT3_MOCCXXSUFFIX = '.moc', + QT3_UISUFFIX = '.ui', + + # Commands for the qt3 support ... + # command to generate header, implementation and moc-file + # from a .ui file + QT3_UICCOM = [ + CLVar('$QT3_UIC $QT3_UICDECLFLAGS -o ${TARGETS[0]} $SOURCE'), + CLVar('$QT3_UIC $QT3_UICIMPLFLAGS -impl ${TARGETS[0].file} ' + '-o ${TARGETS[1]} $SOURCE'), + CLVar('$QT3_MOC $QT3_MOCFROMHFLAGS -o ${TARGETS[2]} ${TARGETS[0]}')], + # command to generate meta object information for a class + # declarated in a header + QT3_MOCFROMHCOM = ( + '$QT3_MOC $QT3_MOCFROMHFLAGS -o ${TARGETS[0]} $SOURCE'), + # command to generate meta object information for a class + # declarated in a cpp file + QT3_MOCFROMCXXCOM = [ + CLVar('$QT3_MOC $QT3_MOCFROMCXXFLAGS -o ${TARGETS[0]} $SOURCE'), + Action(checkMocIncluded,None)]) + + # ... and the corresponding builders + uicBld = Builder(action=SCons.Action.Action('$QT3_UICCOM', '$QT3_UICCOMSTR'), + emitter=uicEmitter, + src_suffix='$QT3_UISUFFIX', + suffix='$QT3_UICDECLSUFFIX', + prefix='$QT3_UICDECLPREFIX', + source_scanner=uicScanner) + mocBld = Builder(action={}, prefix={}, suffix={}) + for h in header_extensions: + act = SCons.Action.Action('$QT3_MOCFROMHCOM', '$QT3_MOCFROMHCOMSTR') + mocBld.add_action(h, act) + mocBld.prefix[h] = '$QT3_MOCHPREFIX' + mocBld.suffix[h] = '$QT3_MOCHSUFFIX' + for cxx in cxx_suffixes: + act = SCons.Action.Action('$QT3_MOCFROMCXXCOM', '$QT3_MOCFROMCXXCOMSTR') + mocBld.add_action(cxx, act) + mocBld.prefix[cxx] = '$QT3_MOCCXXPREFIX' + mocBld.suffix[cxx] = '$QT3_MOCCXXSUFFIX' + + # register the builders + env['BUILDERS']['Uic'] = uicBld + env['BUILDERS']['Moc'] = mocBld + static_obj, shared_obj = SCons.Tool.createObjBuilders(env) + static_obj.add_src_builder('Uic') + shared_obj.add_src_builder('Uic') + + # We use the emitters of Program / StaticLibrary / SharedLibrary + # to scan for moc'able files + # We can't refer to the builders directly, we have to fetch them + # as Environment attributes because that sets them up to be called + # correctly later by our emitter. + env.AppendUnique(PROGEMITTER =[AutomocStatic], + SHLIBEMITTER=[AutomocShared], + LDMODULEEMITTER=[AutomocShared], + LIBEMITTER =[AutomocStatic], + # Of course, we need to link against the qt3 libraries + CPPPATH=["$QT3_CPPPATH"], + LIBPATH=["$QT3_LIBPATH"], + LIBS=['$QT3_LIB']) + +def exists(env): + return _detect(env) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/SCons/Tool/qt3.xml b/SCons/Tool/qt3.xml new file mode 100644 index 000000000..88df2e8f2 --- /dev/null +++ b/SCons/Tool/qt3.xml @@ -0,0 +1,447 @@ + + + + +%scons; + +%builders-mod; + +%functions-mod; + +%tools-mod; + +%variables-mod; +]> + + + + + + +Sets &consvars; for building Qt3 applications. + + + +This tool is only suitable for building targeted to Qt3, +which is obsolete +(the tool is deprecated since 4.3). +There are contributed tools for Qt4 and Qt5, see + +https://github.com/SCons/scons-contrib. +Qt4 has also passed end of life for standard support (in Dec 2015). + + + +Note paths for these &consvars; are assembled +using the os.path.join method +so they will have the appropriate separator at runtime, +but are listed here in the various +entries only with the '/' separator +for simplicity. + + + +In addition, the &consvars; +&cv-link-CPPPATH;, +&cv-link-LIBPATH; and +&cv-link-LIBS; may be modified +and the variables +&cv-link-PROGEMITTER;, &cv-link-SHLIBEMITTER; and &cv-link-LIBEMITTER; +are modified. Because the build-performance is affected when using this tool, +you have to explicitly specify it at Environment creation: + + + +Environment(tools=['default','qt3']) + + + +The &t-qt3; tool supports the following operations: + + + +Automatic moc file generation from header files. +You do not have to specify moc files explicitly, the tool does it for you. +However, there are a few preconditions to do so: Your header file must have +the same filebase as your implementation file and must stay in the same +directory. It must have one of the suffixes +.h, +.hpp, +.H, +.hxx, +.hh. +You can turn off automatic moc file generation by setting +&cv-link-qt3_AUTOSCAN; to False. +See also the corresponding +&b-link-Moc; Builder. + + + +Automatic moc file generation from C++ files. +As described in the Qt documentation, include the moc file at the end of +the C++ file. Note that you have to include the file, which is generated +by the transformation +${qt3_MOCCXXPREFIX}<basename>${QT3_MOCCXXSUFFIX}, by default +<basename>.mo. A warning is generated after building the moc file if you +do not include the correct file. If you are using &f-link-VariantDir;, you may +need to specify duplicate=True. +You can turn off automatic moc file generation by setting &cv-QT3_AUTOSCAN; to +False. See also the corresponding +&b-link-Moc; Builder. + + + +Automatic handling of .ui files. +The implementation files generated from .ui +files are handled much the same as yacc or lex files. +Each .ui file given as a source of &b-link-Program;, +&b-link-Library; or &b-link-SharedLibrary; +will generate three files: the declaration file, the +implementation file and a moc file. Because there are also generated headers, +you may need to specify duplicate=True in calls to +&f-link-VariantDir;. +See also the corresponding +&b-link-Uic; Builder. + + + +QT3DIR +QT3_BINPATH +QT3_CPPPATH +QT3_LIBPATH +QT3_MOC +QT3_UIC +QT3_LIB +QT3_AUTOSCAN +QT3_UICIMPLFLAGS +QT3_UICDECLFLAGS +QT3_MOCFROMHFLAGS +QT3_MOCFROMCXXFLAGS +QT3_UICDECLPREFIX +QT3_UICDECLSUFFIX +QT3_UICIMPLPREFIX +QT3_UICIMPLSUFFIX +QT3_MOCHPREFIX +QT3_MOCHSUFFIX +QT3_MOCCXXPREFIX +QT3_MOCCXXSUFFIX +QT3_UISUFFIX +QT3_UICCOM +QT3_MOCFROMHCOM +QT3_MOCFROMCXXCOM + + +QT3DIR + + + + + + +Builds an output file from a moc input file. +moc input files are either header files or C++ files. +This builder is only available after using the +tool &t-link-qt;. See the &cv-link-QT3DIR; variable for more information. +Example: + + + +env.Moc('foo.h') # generates moc_foo.cc +env.Moc('foo.cpp') # generates foo.moc + + + + + + + +Builds a header file, an implementation file and a moc file from an ui file. +and returns the corresponding nodes in the that order. +This builder is only available after using the tool &t-link-qt;. +Note: you can specify .ui files directly as source +files to the &b-link-Program;, +&b-link-Library; and &b-link-SharedLibrary; builders +without using this builder. Using this builder lets you override the standard +naming conventions (be careful: prefixes are always prepended to names of +built files; if you don't want prefixes, you may set them to ``). +See the &cv-link-QT3DIR; variable for more information. +Example: + + + +env.Uic('foo.ui') # -> ['foo.h', 'uic_foo.cc', 'moc_foo.cc'] +env.Uic( + target=Split('include/foo.h gen/uicfoo.cc gen/mocfoo.cc'), + source='foo.ui' +) # -> ['include/foo.h', 'gen/uicfoo.cc', 'gen/mocfoo.cc'] + + + + + + + +The path to the Qt installation to build against. +If not already set, +&t-link-qt; tool tries to obtain this from +os.environ; +if not found there, it tries to make a guess. + + + + + + + +Turn off scanning for mocable files. Use the &b-link-Moc; Builder to explicitly +specify files to run moc on. + + + + + + + +The path where the Qt binaries are installed. +The default value is '&cv-link-QT3DIR;/bin'. + + + + + + + +The path where the Qt header files are installed. +The default value is '&cv-link-QT3DIR;/include'. +Note: If you set this variable to None, +the tool won't change the &cv-link-CPPPATH; +construction variable. + + + + + + + +Prints lots of debugging information while scanning for moc files. + + + + + + + +Default value is 'qt'. +You may want to set this to 'qt-mt'. +Note: If you set this variable to None, +the tool won't change the &cv-link-LIBS; variable. + + + + + + + +The path where the Qt libraries are installed. +The default value is '&cv-link-QT3DIR;/lib'. +Note: If you set this variable to None, +the tool won't change the &cv-link-LIBPATH; +construction variable. + + + + + + + +Default value is '&cv-link-QT3_BINPATH;/moc'. + + + + + + + +Default value is ''. +Prefix for moc output files when source is a C++ file. + + + + + + + +Default value is '.moc'. +Suffix for moc output files when source is a C++ file. + + + + + + + +Default value is '-i'. +These flags are passed to moc when moccing a C++ file. + + + + + + + +Command to generate a moc file from a C++ file. + + + + + + + +The string displayed when generating a moc file from a C++ file. +If this is not set, then &cv-link-QT3_MOCFROMCXXCOM; (the command line) is displayed. + + + + + + + +Command to generate a moc file from a header. + + + + + + + +The string displayed when generating a moc file from a C++ file. +If this is not set, then &cv-link-QT3_MOCFROMHCOM; (the command line) is displayed. + + + + + + + +Default value is ''. These flags are passed to moc +when moccing a header file. + + + + + + + +Default value is 'moc_'. +Prefix for moc output files when source is a header. + + + + + + + +Default value is '&cv-link-CXXFILESUFFIX;'. +Suffix for moc output files when source is a header. + + + + + + + +Default value is '&cv-link-QT3_BINPATH;/uic'. + + + + + + + +Command to generate header files from .ui files. + + + + + + + +The string displayed when generating header files from .ui files. +If this is not set, then &cv-link-QT3_UICCOM; (the command line) is displayed. + + + + + + + +Default value is ''. These flags are passed to uic +when creating a header file from a .ui file. + + + + + + + +Default value is ''. +Prefix for uic generated header files. + + + + + + + +Default value is '.h'. +Suffix for uic generated header files. + + + + + + + +Default value is ''. +These flags are passed to uic when creating a C++ +file from a .ui file. + + + + + + + +Default value is 'uic_'. +Prefix for uic generated implementation files. + + + + + + + +Default value is '&cv-link-CXXFILESUFFIX;'. Suffix for uic generated implementation +files. + + + + + + + +Default value is '.ui'. +Suffix of designer input files. + + + + + diff --git a/test/QT/CPPPATH-appended.py b/test/QT/CPPPATH-appended.py deleted file mode 100644 index ee1808faf..000000000 --- a/test/QT/CPPPATH-appended.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test that an appended relative CPPPATH works with generated files. - -This is basically the same as CPPPATH.py, but the include path -is env.Append-ed and everything goes into sub directory "sub". -""" - -import os.path - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('sub', ['sub', 'local_include']) - -test.Qt_dummy_installation() - -aaa_exe = os.path.join('sub', 'aaa' + TestSCons._exe) - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', r""" -SConscript('sub/SConscript') -""") - -test.write(['sub', 'SConscript'], r""" -Import("env") -env.Append(CPPPATH=['./local_include']) -env.Program(target = 'aaa', source = 'aaa.cpp') -""") - -test.write(['sub', 'aaa.cpp'], r""" -#include "aaa.h" -int main(void) { aaa(); return 0; } -""") - -test.write(['sub', 'aaa.h'], r""" -#include "my_qobject.h" -#include "local_include.h" -void aaa(void) Q_OBJECT; -""") - -test.write(['sub', 'local_include', 'local_include.h'], r""" -/* empty; just needs to be found */ -""") - -test.run(arguments='--warn=no-tool-qt-deprecated ' + aaa_exe) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/CPPPATH.py b/test/QT/CPPPATH.py deleted file mode 100644 index b56efad44..000000000 --- a/test/QT/CPPPATH.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test that an overwritten CPPPATH works with generated files. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('local_include') - -test.Qt_dummy_installation() - -aaa_exe = 'aaa' + TestSCons._exe - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """\ -Import("env") -env.Program(target = 'aaa', source = 'aaa.cpp', CPPPATH=['$CPPPATH', './local_include']) -""") - -test.write('aaa.cpp', r""" -#include "aaa.h" -int main(void) { aaa(); return 0; } -""") - -test.write('aaa.h', r""" -#include "my_qobject.h" -#include "local_include.h" -void aaa(void) Q_OBJECT; -""") - -test.write(['local_include', 'local_include.h'], r""" -/* empty; just needs to be found */ -""") - -test.run(arguments='--warn=no-tool-qt-deprecated ' + aaa_exe) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py deleted file mode 100644 index c759c2a4a..000000000 --- a/test/QT/QTFLAGS.py +++ /dev/null @@ -1,219 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Testing the configuration mechanisms of the 'qt' tool. -""" - -import TestSCons - -_python_ = TestSCons._python_ -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation() -test.subdir('work1', 'work2') - -test.run( - chdir=test.workpath('qt', 'lib'), - arguments="--warn=no-tool-qt-deprecated .", - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall, -) - -QT = test.workpath('qt') -QT_LIB = 'myqt' -QT_MOC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'mymoc.py')) -QT_UIC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'myuic.py')) - -def createSConstruct(test, place, overrides): - test.write(place, """\ -env = Environment( - tools=['default','qt'], - QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', - %s # last because 'overrides' may add comma -) -if ARGUMENTS.get('variant_dir', 0): - if ARGUMENTS.get('chdir', 0): - SConscriptChdir(1) - else: - SConscriptChdir(0) - VariantDir('build', '.', duplicate=1) - sconscript = Dir('build').File('SConscript') -else: - sconscript = File('SConscript') -Export("env") -SConscript(sconscript) -""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides)) - - -createSConstruct(test, ['work1', 'SConstruct'], - """QT_UICIMPLFLAGS='-x', - QT_UICDECLFLAGS='-y', - QT_MOCFROMHFLAGS='-z', - QT_MOCFROMCXXFLAGS='-i -w', - QT_UICDECLPREFIX='uic-', - QT_UICDECLSUFFIX='.hpp', - QT_UICIMPLPREFIX='', - QT_UICIMPLSUFFIX='.cxx', - QT_MOCHPREFIX='mmm', - QT_MOCHSUFFIX='.cxx', - QT_MOCCXXPREFIX='moc', - QT_MOCCXXSUFFIX='.inl', - QT_UISUFFIX='.myui',""") -test.write(['work1', 'SConscript'],""" -Import("env") -env.Program('mytest', ['mocFromH.cpp', - 'mocFromCpp.cpp', - 'an_ui_file.myui', - 'another_ui_file.myui', - 'main.cpp']) -""") - -test.write(['work1', 'mocFromH.hpp'], """ -#include "my_qobject.h" -void mocFromH() Q_OBJECT -""") - -test.write(['work1', 'mocFromH.cpp'], """ -#include "mocFromH.hpp" -""") - -test.write(['work1', 'mocFromCpp.cpp'], """ -#include "my_qobject.h" -void mocFromCpp() Q_OBJECT -#include "mocmocFromCpp.inl" -""") - -test.write(['work1', 'an_ui_file.myui'], """ -void an_ui_file() -""") - -test.write(['work1', 'another_ui_file.myui'], """ -void another_ui_file() -""") - -test.write(['work1', 'another_ui_file.desc.hpp'], """ -/* just a dependency checker */ -""") - -test.write(['work1', 'main.cpp'], """ -#include "mocFromH.hpp" -#include "uic-an_ui_file.hpp" -#include "uic-another_ui_file.hpp" -void mocFromCpp(); - -int main(void) { - mocFromH(); - mocFromCpp(); - an_ui_file(); - another_ui_file(); -} -""") - -test.run(chdir='work1', arguments="--warn=no-tool-qt-deprecated mytest" + _exe) - -test.must_exist( - ['work1', 'mmmmocFromH.cxx'], - ['work1', 'mocmocFromCpp.inl'], - ['work1', 'an_ui_file.cxx'], - ['work1', 'uic-an_ui_file.hpp'], - ['work1', 'mmman_ui_file.cxx'], - ['work1', 'another_ui_file.cxx'], - ['work1', 'uic-another_ui_file.hpp'], - ['work1', 'mmmanother_ui_file.cxx'], -) - -def _flagTest(test,fileToContentsStart): - for f,c in fileToContentsStart.items(): - if test.read(test.workpath('work1', f), mode='r').find(c) != 0: - return 1 - return 0 - -test.fail_test( - _flagTest( - test, - { - 'mmmmocFromH.cxx': '/* mymoc.py -z */', - 'mocmocFromCpp.inl': '/* mymoc.py -w */', - 'an_ui_file.cxx': '/* myuic.py -x */', - 'uic-an_ui_file.hpp': '/* myuic.py -y */', - 'mmman_ui_file.cxx': '/* mymoc.py -z */', - }, - ) -) - -test.write(['work2', 'SConstruct'], """ -import os.path - -env1 = Environment( - tools=['qt'], - QTDIR=r'%(QTDIR)s', - QT_BINPATH='$QTDIR/bin64', - QT_LIBPATH='$QTDIR/lib64', - QT_CPPPATH='$QTDIR/h64', -) - -cpppath = env1.subst('$CPPPATH') -if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): - print(cpppath) - Exit(1) -libpath = env1.subst('$LIBPATH') -if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): - print(libpath) - Exit(2) -qt_moc = env1.subst('$QT_MOC') -if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): - print(qt_moc) - Exit(3) - -env2 = Environment( - tools=['default', 'qt'], QTDIR=None, QT_LIB=None, QT_CPPPATH=None, QT_LIBPATH=None -) - -env2.Program('main.cpp') -""" % {'QTDIR':QT}) - -test.write(['work2', 'main.cpp'], """ -int main(void) { return 0; } -""") - -# Ignore stderr, because if Qt is not installed, -# there may be a warning about an empty QTDIR on stderr. -test.run(arguments="--warn=no-tool-qt-deprecated", chdir='work2', stderr=None) - -test.must_exist(['work2', 'main' + _exe]) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/Tool.py b/test/QT/Tool.py deleted file mode 100644 index 122e7f413..000000000 --- a/test/QT/Tool.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Verify that applying env.Tool('qt') after running Configure checks -works properly. This was broken in 0.96.95. - -The configuration here is a moderately stripped-down version of the -real-world configuration for lprof (lprof.sourceforge.net). It's probably -not completely minimal, but we're leaving it as-is since it represents a -good real-world sanity check on the interaction of some key subsystems. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -if not os.environ.get('QTDIR', None): - x ="External environment variable $QTDIR not set; skipping test(s).\n" - test.skip_test(x) - -test.write('SConstruct', """ -import os - -def DoWithVariables(variables, prefix, what): - saved_variables = { } - for name in variables.keys(): - saved_variables[ name ] = env[ name ][:] - env[ name ].append(variables[ name ]) - - result = what() - - for name in saved_variables.keys(): - env[ name ] = saved_variables[ name ] - env[ prefix+name ] = variables[ name ] - - return result - -def CheckForQtAt(context, qtdir): - context.Message('Checking for Qt at %s... ' % qtdir) - libp = os.path.join(qtdir, 'lib') - cppp = os.path.join(qtdir, 'include') - result = AttemptLinkWithVariables(context, - { "LIBS": "qt-mt", "LIBPATH": libp , "CPPPATH": cppp }, - ''' -#include -int main(int argc, char **argv) { - QApplication qapp(argc, argv); - return 0; -} -''',".cpp","QT_") - context.Result(result) - return result - -def CheckForQt(context): - # list is currently POSIX centric - what happens with Windows? - potential_qt_dirs = [ - "/usr/share/qt3", # Debian unstable - "/usr/share/qt", - "/usr", - "/usr/local", - "/usr/lib/qt3", # Suse - "/usr/lib/qt", - "/usr/qt/3", # Gentoo - "/usr/pkg/qt3" # pkgsrc (NetBSD) - ] - - if 'QTDIR' in os.environ: - potential_qt_dirs.insert(0, os.environ[ 'QTDIR' ]) - - if env[ 'qt_directory' ] != "/": - uic_path = os.path.join(env['qt_directory'], 'bin', 'uic') - if os.path.isfile(uic_path): - potential_qt_dirs.insert(0, env[ 'qt_directory' ]) - else: - print("QT not found. Invalid qt_directory value - failed to find uic.") - return 0 - - for i in potential_qt_dirs: - context.env.Replace(QTDIR = i) - if CheckForQtAt(context, i): - # additional checks to validate QT installation - if not os.path.isfile(os.path.join(i, 'bin', 'uic')): - print("QT - failed to find uic.") - return 0 - if not os.path.isfile(os.path.join(i, 'bin', 'moc')): - print("QT - failed to find moc.") - return 0 - if not os.path.exists(os.path.join(i, 'lib')): - print("QT - failed to find QT lib path.") - return 0 - if not os.path.exists(os.path.join(i, 'include')): - print("QT - failed to find QT include path.") - return 0 - return 1 - else: - if i==env['qt_directory']: - print("QT directory not valid. Failed QT test build.") - return 0 - return 0 - -def AttemptLinkWithVariables(context, variables, code, extension, prefix): - return DoWithVariables(variables, prefix, - lambda: context.TryLink(code, extension)) - -env = Environment(CPPPATH=['.'], LIBPATH=['.'], LIBS=[]) - -opts = Variables('lprof.conf') -opts.Add(PathVariable("qt_directory", "Path to Qt directory", "/")) -opts.Update(env) - -env['QT_LIB'] = 'qt-mt' -config = env.Configure(custom_tests = { - 'CheckForQt' : CheckForQt, -}) - -if not config.CheckForQt(): - print("Failed to find valid QT environment.") - Exit(1) - -env.Tool('qt', ['$TOOL_PATH']) -""") - -test.run(arguments='--warn=no-tool-qt-deprecated .') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py deleted file mode 100644 index 74f59b7fc..000000000 --- a/test/QT/copied-env.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test Qt with a copied construction environment. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation() - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """\ -Import("env") -env.Append(CPPDEFINES = ['FOOBAZ']) - -copy = env.Clone() -copy.Append(CPPDEFINES = ['MYLIB_IMPL']) - -copy.SharedLibrary( - target = 'MyLib', - source = ['MyFile.cpp','MyForm.ui'] -) -""") - -test.write('MyFile.h', r""" -void aaa(void); -""") - -test.write('MyFile.cpp', r""" -#include "MyFile.h" -void useit() { - aaa(); -} -""") - -test.write('MyForm.ui', r""" -void aaa(void) -""") - -test.run(arguments="--warn=no-tool-qt-deprecated") - -moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1] - -MYLIB_IMPL = [x for x in moc_MyForm if x.find('MYLIB_IMPL') != -1] - -if not MYLIB_IMPL: - print("Did not find MYLIB_IMPL on moc_MyForm compilation line:") - print(test.stdout()) - test.fail_test() - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/empty-env.py b/test/QT/empty-env.py deleted file mode 100644 index e9dfc81b1..000000000 --- a/test/QT/empty-env.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test Qt creation from a copied empty environment. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation('qt') - -test.write('SConstruct', """\ -orig = Environment() -env = orig.Clone(QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', - tools=['qt']) -env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) -""" % (test.QT, test.QT_LIB, test.QT_MOC, test.QT_UIC)) - -test.write('main.cpp', r""" -#include "foo6.h" -int main(void) { foo6(); return 0; } -""") - -test.write(['qt', 'include', 'foo6.h'], """\ -#include -void -foo6(void) -{ -#ifdef FOO - printf("qt/include/foo6.h\\n"); -#endif -} -""") - -# we can receive warnings about a non detected qt (empty QTDIR) -# these are not critical, but may be annoying. -test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated') - -test.run( - program=test.workpath('main' + TestSCons._exe), - arguments='--warn=no-tool-qt-deprecated', - stderr=None, - stdout='qt/include/foo6.h\n', -) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/generated-ui.py b/test/QT/generated-ui.py deleted file mode 100644 index fd368b34d..000000000 --- a/test/QT/generated-ui.py +++ /dev/null @@ -1,136 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test that the UI scanning logic correctly picks up scansG -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -if not os.environ.get('QTDIR', None): - x ="External environment variable $QTDIR not set; skipping test(s).\n" - test.skip_test(x) - -test.subdir(['layer'], - ['layer', 'aclock'], - ['layer', 'aclock', 'qt_bug']) - -test.write(['SConstruct'], """\ -import os -aa=os.getcwd() - -env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) -if 'HOME' in os.environ: - env['ENV']['HOME'] = os.environ['HOME'] -env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') -if not os.access(env["EXP_HEADER_ABS"],os.F_OK): - os.mkdir (env["EXP_HEADER_ABS"]) -Export('env') -env.SConscript('layer/aclock/qt_bug/SConscript') -""") - -test.write(['expheaders.py'], """\ -import SCons.Defaults -def ExpHeaderScanner(node, env, path): - return [] -def generate(env): - HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0o755)]) - HeaderBuilder= SCons.Builder.Builder(action=HeaderAction) - env['BUILDERS']['ExportHeaders'] = HeaderBuilder -def exists(env): - return 0 -""") - -test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\ -import os - -Import ("env") -#src=os.path.join(env.Dir('.').srcnode().abspath, 'testfile.h') -env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h') -env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h') -env.Append(CPPPATH=env["EXP_HEADER_ABS"]) -env.StaticLibrary('all',['main.ui','migraform.ui']) -""") - -test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\ - -Main - - - Main - - - - 0 - 0 - 600 - 385 - - - - - migraform.h - - -""") - -test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ - -MigrateForm - - - MigrateForm - - - - 0 - 0 - %s - 385 - - - - -""") - -test.run( - arguments='--warn=no-tool-qt-deprecated', - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall, -) - -test.up_to_date(options="--warn=no-tool-qt-deprecated", arguments=".") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/installed.py b/test/QT/installed.py deleted file mode 100644 index 9e8693e3f..000000000 --- a/test/QT/installed.py +++ /dev/null @@ -1,220 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Look if qt is installed, and try out all builders. -""" - -import os -import sys - -import TestSCons - -test = TestSCons.TestSCons() - -if not os.environ.get('QTDIR', None): - x ="External environment variable $QTDIR not set; skipping test(s).\n" - test.skip_test(x) - -test.Qt_dummy_installation() - -QTDIR=os.environ['QTDIR'] - - -test.write('SConstruct', """\ -import os -dummy_env = Environment() -ENV = dummy_env['ENV'] -try: - PATH=ARGUMENTS['PATH'] - if 'PATH' in ENV: - ENV_PATH = PATH + os.pathsep + ENV['PATH'] - else: - Exit(0) # this is certainly a weird system :-) -except KeyError: - ENV_PATH=ENV.get('PATH', '') - -env = Environment(tools=['default','qt'], - ENV={'PATH':ENV_PATH, - 'PATHEXT':os.environ.get('PATHEXT'), - 'HOME':os.getcwd(), - 'SystemRoot':ENV.get('SystemRoot')}, - # moc / uic want to write stuff in ~/.qt - CXXFILESUFFIX=".cpp") - -conf = env.Configure() -if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): - conf.env['QT_LIB'] = 'qt-mt' - if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): - Exit(0) -env = conf.Finish() -VariantDir('bld', '.') -env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp', - 'bld/mocFromH.cpp', - 'bld/anUiFile.ui', - 'bld/main.cpp']) -""") - -test.write('mocFromCpp.h', """\ -void mocFromCpp(); -""") - -test.write('mocFromCpp.cpp', """\ -#include -#include "mocFromCpp.h" -class MyClass1 : public QObject { - Q_OBJECT - public: - MyClass1() : QObject() {}; - public slots: - void myslot() {}; -}; -void mocFromCpp() { - MyClass1 myclass; -} -#include "mocFromCpp.moc" -""") - -test.write('mocFromH.h', """\ -#include -class MyClass2 : public QObject { - Q_OBJECT; - public: - MyClass2(); - public slots: - void myslot(); -}; -void mocFromH(); -""") - -test.write('mocFromH.cpp', """\ -#include "mocFromH.h" - -MyClass2::MyClass2() : QObject() {} -void MyClass2::myslot() {} -void mocFromH() { - MyClass2 myclass; -} -""") - -test.write('anUiFile.ui', """\ - -MyWidget - - QWidget - - MyWidget - - - MyWidget - - - - anUiFile.ui.h - - - testSlot() - - - -""") - -test.write('anUiFile.ui.h', r""" -#include -#if QT_VERSION >= 0x030100 -void MyWidget::testSlot() -{ - printf("Hello World\n"); -} -#endif -""") - -test.write('main.cpp', r""" -#include -#include "mocFromCpp.h" -#include "mocFromH.h" -#include "anUiFile.h" -#include - -int main(int argc, char **argv) { - QApplication app(argc, argv); - mocFromCpp(); - mocFromH(); - MyWidget mywidget; -#if QT_VERSION >= 0x030100 - mywidget.testSlot(); -#else - printf("Hello World\n"); -#endif - return 0; -} -""") - -test.run(arguments="--warn=no-tool-qt-deprecated bld/test_realqt" + TestSCons._exe) - -test.run( - program=test.workpath("bld", "test_realqt"), - arguments="--warn=no-tool-qt-deprecated", - stdout=None, - status=None, - stderr=None, -) - -if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status: - sys.stdout.write(test.stdout()) - sys.stderr.write(test.stderr()) - # The test might be run on a system that doesn't have an X server - # running, or may be run by an ID that can't connect to the server. - # If so, then print whatever it showed us (which is in and of itself - # an indication that it built correctly) but don't fail the test. - expect = 'cannot connect to X server' - test.fail_test(test.stdout()) - test.fail_test(expect not in test.stderr()) - if test.status != 1 and (test.status >> 8) != 1: - sys.stdout.write('test_realqt returned status %s\n' % test.status) - test.fail_test() - -QTDIR = os.environ['QTDIR'] -PATH = os.environ['PATH'] -os.environ['QTDIR'] = '' -os.environ['PATH'] = '.' - -test.run( - stderr=None, - arguments="--warn=no-tool-qt-deprecated -c bld/test_realqt" + TestSCons._exe, -) - -expect1 = "scons: warning: Could not detect qt, using empty QTDIR" -expect2 = "scons: warning: Could not detect qt, using moc executable as a hint" - -test.fail_test(expect1 not in test.stderr() and expect2 not in test.stderr()) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/manual.py b/test/QT/manual.py deleted file mode 100644 index 84c6df8e0..000000000 --- a/test/QT/manual.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test the manual QT builder calls. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('include', 'ui') - -test.Qt_dummy_installation() - -aaa_exe = 'aaa' + TestSCons._exe - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', r""" -Import("env") -sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp'] - -# normal invocation -sources.append(env.Moc('include/aaa.h')) -moc = env.Moc('bbb.cpp') -env.Ignore( moc, moc ) -sources.extend(env.Uic('ui/ccc.ui')[1:]) - -# manual target specification -sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', - QT_MOCHPREFIX='')) # Watch out ! -moc = env.Moc('moc_eee.cpp', 'eee.cpp') -env.Ignore( moc, moc ) -sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], - 'ui/fff.ui')[1:]) - -print(list(map(str,sources))) -env.Program(target='aaa', - source=sources, - CPPPATH=['$CPPPATH', './include'], - QT_AUTOSCAN=0) -""") - -test.write('aaa.cpp', r""" -#include "aaa.h" -""") - -test.write(['include', 'aaa.h'], r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") - -test.write('bbb.h', r""" -void bbb(void); -""") - -test.write('bbb.cpp', r""" -#include "my_qobject.h" -void bbb(void) Q_OBJECT -#include "bbb.moc" -""") - -test.write(['ui', 'ccc.ui'], r""" -void ccc(void) -""") - -test.write('ddd.cpp', r""" -#include "ddd.h" -""") - -test.write(['include', 'ddd.h'], r""" -#include "my_qobject.h" -void ddd(void) Q_OBJECT; -""") - -test.write('eee.h', r""" -void eee(void); -""") - -test.write('eee.cpp', r""" -#include "my_qobject.h" -void eee(void) Q_OBJECT -#include "moc_eee.cpp" -""") - -test.write(['ui', 'fff.ui'], r""" -void fff(void) -""") - -test.write('main.cpp', r""" -#include "aaa.h" -#include "bbb.h" -#include "ui/ccc.h" -#include "ddd.h" -#include "eee.h" -#include "uic_fff.hpp" - -int main(void) { - aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0; -} -""") - -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_exe) - -# normal invocation -test.must_exist(test.workpath('include', 'moc_aaa.cc')) -test.must_exist(test.workpath('bbb.moc')) -test.must_exist(test.workpath('ui', 'ccc.h')) -test.must_exist(test.workpath('ui', 'uic_ccc.cc')) -test.must_exist(test.workpath('ui', 'moc_ccc.cc')) - -# manual target spec. -test.must_exist(test.workpath('moc-ddd.cpp')) -test.must_exist(test.workpath('moc_eee.cpp')) -test.must_exist(test.workpath('include', 'uic_fff.hpp')) -test.must_exist(test.workpath('fff.cpp')) -test.must_exist(test.workpath('fff.moc.cpp')) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/moc-from-cpp.py b/test/QT/moc-from-cpp.py deleted file mode 100644 index bbab8cab8..000000000 --- a/test/QT/moc-from-cpp.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Create a moc file from a cpp file. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation() - -############################################################################## - -lib_aaa = TestSCons.lib_ + 'aaa' + TestSCons._lib -moc = 'aaa.moc' - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """ -Import("env dup") -if dup == 0: env.Append(CPPPATH=['.']) -env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp']) -""" % lib_aaa) - -test.write('aaa.h', r""" -void aaa(void); -""") - -test.write('aaa.cpp', r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT -#include "%s" -""" % moc) - -test.write('useit.cpp', r""" -#include "aaa.h" -void useit() { - aaa(); -} -""") - -test.run( - arguments="--warn=no-tool-qt-deprecated " + lib_aaa, - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall, -) - -test.up_to_date(options='-n --warn=no-tool-qt-deprecated', arguments=lib_aaa) - -test.write('aaa.cpp', r""" -#include "my_qobject.h" -/* a change */ -void aaa(void) Q_OBJECT -#include "%s" -""" % moc) - -test.not_up_to_date(options='-n --warn=no-tool-qt-deprecated', arguments=moc) - -test.run(options="--warn=no-tool-qt-deprecated -c", arguments=lib_aaa) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 " - + test.workpath('build', lib_aaa), - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall, -) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " - + test.workpath('build', lib_aaa) -) - -test.must_exist(test.workpath('build', moc)) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 dup=0 " - + test.workpath('build_dup0', lib_aaa), - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall, -) - -test.must_exist(test.workpath('build_dup0', moc)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/moc-from-header.py b/test/QT/moc-from-header.py deleted file mode 100644 index 65a12e1ed..000000000 --- a/test/QT/moc-from-header.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Create a moc file from a header file. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -env = Environment() -""") - -test.Qt_dummy_installation() - -# We'll run some test programs later that need to find our dummy -# Qt library. -os.environ['LD_LIBRARY_PATH'] = test.QT_LIB_DIR - -############################################################################## - -aaa_exe = 'aaa' + TestSCons._exe -build_aaa_exe = test.workpath('build', aaa_exe) -moc = 'moc_aaa.cc' - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """\ -Import("env") -env.Program(target = 'aaa', source = 'aaa.cpp') -if env['PLATFORM'] == 'darwin': - env.Install('.', 'qt/lib/libmyqt.dylib') -""") - -test.write('aaa.cpp', r""" -#include "aaa.h" -int main(void) { aaa(); return 0; } -""") - -test.write('aaa.h', r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") - -test.run(arguments="--warn=no-tool-qt-deprecated") -test.up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=aaa_exe) - -test.write('aaa.h', r""" -/* a change */ -#include "my_qobject.h" -void aaa(void) Q_OBJECT; -""") - -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) - -test.run( - arguments="--warn=no-tool-qt-deprecated", - program=test.workpath(aaa_exe), - stdout='aaa.h\n', -) - -test.run(arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + build_aaa_exe) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + build_aaa_exe -) - -test.must_exist(test.workpath('build', moc)) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 dup=0 " - + test.workpath('build_dup0', aaa_exe) -) - -test.must_exist(['build_dup0', moc]) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/CPPPATH-appended.py b/test/QT/qt3/CPPPATH-appended.py new file mode 100644 index 000000000..ee1808faf --- /dev/null +++ b/test/QT/qt3/CPPPATH-appended.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test that an appended relative CPPPATH works with generated files. + +This is basically the same as CPPPATH.py, but the include path +is env.Append-ed and everything goes into sub directory "sub". +""" + +import os.path + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub', ['sub', 'local_include']) + +test.Qt_dummy_installation() + +aaa_exe = os.path.join('sub', 'aaa' + TestSCons._exe) + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', r""" +SConscript('sub/SConscript') +""") + +test.write(['sub', 'SConscript'], r""" +Import("env") +env.Append(CPPPATH=['./local_include']) +env.Program(target = 'aaa', source = 'aaa.cpp') +""") + +test.write(['sub', 'aaa.cpp'], r""" +#include "aaa.h" +int main(void) { aaa(); return 0; } +""") + +test.write(['sub', 'aaa.h'], r""" +#include "my_qobject.h" +#include "local_include.h" +void aaa(void) Q_OBJECT; +""") + +test.write(['sub', 'local_include', 'local_include.h'], r""" +/* empty; just needs to be found */ +""") + +test.run(arguments='--warn=no-tool-qt-deprecated ' + aaa_exe) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/CPPPATH.py b/test/QT/qt3/CPPPATH.py new file mode 100644 index 000000000..b56efad44 --- /dev/null +++ b/test/QT/qt3/CPPPATH.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test that an overwritten CPPPATH works with generated files. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('local_include') + +test.Qt_dummy_installation() + +aaa_exe = 'aaa' + TestSCons._exe + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', """\ +Import("env") +env.Program(target = 'aaa', source = 'aaa.cpp', CPPPATH=['$CPPPATH', './local_include']) +""") + +test.write('aaa.cpp', r""" +#include "aaa.h" +int main(void) { aaa(); return 0; } +""") + +test.write('aaa.h', r""" +#include "my_qobject.h" +#include "local_include.h" +void aaa(void) Q_OBJECT; +""") + +test.write(['local_include', 'local_include.h'], r""" +/* empty; just needs to be found */ +""") + +test.run(arguments='--warn=no-tool-qt-deprecated ' + aaa_exe) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/QTFLAGS.py b/test/QT/qt3/QTFLAGS.py new file mode 100644 index 000000000..c759c2a4a --- /dev/null +++ b/test/QT/qt3/QTFLAGS.py @@ -0,0 +1,219 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Testing the configuration mechanisms of the 'qt' tool. +""" + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation() +test.subdir('work1', 'work2') + +test.run( + chdir=test.workpath('qt', 'lib'), + arguments="--warn=no-tool-qt-deprecated .", + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall, +) + +QT = test.workpath('qt') +QT_LIB = 'myqt' +QT_MOC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'mymoc.py')) +QT_UIC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'myuic.py')) + +def createSConstruct(test, place, overrides): + test.write(place, """\ +env = Environment( + tools=['default','qt'], + QTDIR = r'%s', + QT_LIB = r'%s', + QT_MOC = r'%s', + QT_UIC = r'%s', + %s # last because 'overrides' may add comma +) +if ARGUMENTS.get('variant_dir', 0): + if ARGUMENTS.get('chdir', 0): + SConscriptChdir(1) + else: + SConscriptChdir(0) + VariantDir('build', '.', duplicate=1) + sconscript = Dir('build').File('SConscript') +else: + sconscript = File('SConscript') +Export("env") +SConscript(sconscript) +""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides)) + + +createSConstruct(test, ['work1', 'SConstruct'], + """QT_UICIMPLFLAGS='-x', + QT_UICDECLFLAGS='-y', + QT_MOCFROMHFLAGS='-z', + QT_MOCFROMCXXFLAGS='-i -w', + QT_UICDECLPREFIX='uic-', + QT_UICDECLSUFFIX='.hpp', + QT_UICIMPLPREFIX='', + QT_UICIMPLSUFFIX='.cxx', + QT_MOCHPREFIX='mmm', + QT_MOCHSUFFIX='.cxx', + QT_MOCCXXPREFIX='moc', + QT_MOCCXXSUFFIX='.inl', + QT_UISUFFIX='.myui',""") +test.write(['work1', 'SConscript'],""" +Import("env") +env.Program('mytest', ['mocFromH.cpp', + 'mocFromCpp.cpp', + 'an_ui_file.myui', + 'another_ui_file.myui', + 'main.cpp']) +""") + +test.write(['work1', 'mocFromH.hpp'], """ +#include "my_qobject.h" +void mocFromH() Q_OBJECT +""") + +test.write(['work1', 'mocFromH.cpp'], """ +#include "mocFromH.hpp" +""") + +test.write(['work1', 'mocFromCpp.cpp'], """ +#include "my_qobject.h" +void mocFromCpp() Q_OBJECT +#include "mocmocFromCpp.inl" +""") + +test.write(['work1', 'an_ui_file.myui'], """ +void an_ui_file() +""") + +test.write(['work1', 'another_ui_file.myui'], """ +void another_ui_file() +""") + +test.write(['work1', 'another_ui_file.desc.hpp'], """ +/* just a dependency checker */ +""") + +test.write(['work1', 'main.cpp'], """ +#include "mocFromH.hpp" +#include "uic-an_ui_file.hpp" +#include "uic-another_ui_file.hpp" +void mocFromCpp(); + +int main(void) { + mocFromH(); + mocFromCpp(); + an_ui_file(); + another_ui_file(); +} +""") + +test.run(chdir='work1', arguments="--warn=no-tool-qt-deprecated mytest" + _exe) + +test.must_exist( + ['work1', 'mmmmocFromH.cxx'], + ['work1', 'mocmocFromCpp.inl'], + ['work1', 'an_ui_file.cxx'], + ['work1', 'uic-an_ui_file.hpp'], + ['work1', 'mmman_ui_file.cxx'], + ['work1', 'another_ui_file.cxx'], + ['work1', 'uic-another_ui_file.hpp'], + ['work1', 'mmmanother_ui_file.cxx'], +) + +def _flagTest(test,fileToContentsStart): + for f,c in fileToContentsStart.items(): + if test.read(test.workpath('work1', f), mode='r').find(c) != 0: + return 1 + return 0 + +test.fail_test( + _flagTest( + test, + { + 'mmmmocFromH.cxx': '/* mymoc.py -z */', + 'mocmocFromCpp.inl': '/* mymoc.py -w */', + 'an_ui_file.cxx': '/* myuic.py -x */', + 'uic-an_ui_file.hpp': '/* myuic.py -y */', + 'mmman_ui_file.cxx': '/* mymoc.py -z */', + }, + ) +) + +test.write(['work2', 'SConstruct'], """ +import os.path + +env1 = Environment( + tools=['qt'], + QTDIR=r'%(QTDIR)s', + QT_BINPATH='$QTDIR/bin64', + QT_LIBPATH='$QTDIR/lib64', + QT_CPPPATH='$QTDIR/h64', +) + +cpppath = env1.subst('$CPPPATH') +if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): + print(cpppath) + Exit(1) +libpath = env1.subst('$LIBPATH') +if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): + print(libpath) + Exit(2) +qt_moc = env1.subst('$QT_MOC') +if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): + print(qt_moc) + Exit(3) + +env2 = Environment( + tools=['default', 'qt'], QTDIR=None, QT_LIB=None, QT_CPPPATH=None, QT_LIBPATH=None +) + +env2.Program('main.cpp') +""" % {'QTDIR':QT}) + +test.write(['work2', 'main.cpp'], """ +int main(void) { return 0; } +""") + +# Ignore stderr, because if Qt is not installed, +# there may be a warning about an empty QTDIR on stderr. +test.run(arguments="--warn=no-tool-qt-deprecated", chdir='work2', stderr=None) + +test.must_exist(['work2', 'main' + _exe]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/Tool.py b/test/QT/qt3/Tool.py new file mode 100644 index 000000000..122e7f413 --- /dev/null +++ b/test/QT/qt3/Tool.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Verify that applying env.Tool('qt') after running Configure checks +works properly. This was broken in 0.96.95. + +The configuration here is a moderately stripped-down version of the +real-world configuration for lprof (lprof.sourceforge.net). It's probably +not completely minimal, but we're leaving it as-is since it represents a +good real-world sanity check on the interaction of some key subsystems. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +if not os.environ.get('QTDIR', None): + x ="External environment variable $QTDIR not set; skipping test(s).\n" + test.skip_test(x) + +test.write('SConstruct', """ +import os + +def DoWithVariables(variables, prefix, what): + saved_variables = { } + for name in variables.keys(): + saved_variables[ name ] = env[ name ][:] + env[ name ].append(variables[ name ]) + + result = what() + + for name in saved_variables.keys(): + env[ name ] = saved_variables[ name ] + env[ prefix+name ] = variables[ name ] + + return result + +def CheckForQtAt(context, qtdir): + context.Message('Checking for Qt at %s... ' % qtdir) + libp = os.path.join(qtdir, 'lib') + cppp = os.path.join(qtdir, 'include') + result = AttemptLinkWithVariables(context, + { "LIBS": "qt-mt", "LIBPATH": libp , "CPPPATH": cppp }, + ''' +#include +int main(int argc, char **argv) { + QApplication qapp(argc, argv); + return 0; +} +''',".cpp","QT_") + context.Result(result) + return result + +def CheckForQt(context): + # list is currently POSIX centric - what happens with Windows? + potential_qt_dirs = [ + "/usr/share/qt3", # Debian unstable + "/usr/share/qt", + "/usr", + "/usr/local", + "/usr/lib/qt3", # Suse + "/usr/lib/qt", + "/usr/qt/3", # Gentoo + "/usr/pkg/qt3" # pkgsrc (NetBSD) + ] + + if 'QTDIR' in os.environ: + potential_qt_dirs.insert(0, os.environ[ 'QTDIR' ]) + + if env[ 'qt_directory' ] != "/": + uic_path = os.path.join(env['qt_directory'], 'bin', 'uic') + if os.path.isfile(uic_path): + potential_qt_dirs.insert(0, env[ 'qt_directory' ]) + else: + print("QT not found. Invalid qt_directory value - failed to find uic.") + return 0 + + for i in potential_qt_dirs: + context.env.Replace(QTDIR = i) + if CheckForQtAt(context, i): + # additional checks to validate QT installation + if not os.path.isfile(os.path.join(i, 'bin', 'uic')): + print("QT - failed to find uic.") + return 0 + if not os.path.isfile(os.path.join(i, 'bin', 'moc')): + print("QT - failed to find moc.") + return 0 + if not os.path.exists(os.path.join(i, 'lib')): + print("QT - failed to find QT lib path.") + return 0 + if not os.path.exists(os.path.join(i, 'include')): + print("QT - failed to find QT include path.") + return 0 + return 1 + else: + if i==env['qt_directory']: + print("QT directory not valid. Failed QT test build.") + return 0 + return 0 + +def AttemptLinkWithVariables(context, variables, code, extension, prefix): + return DoWithVariables(variables, prefix, + lambda: context.TryLink(code, extension)) + +env = Environment(CPPPATH=['.'], LIBPATH=['.'], LIBS=[]) + +opts = Variables('lprof.conf') +opts.Add(PathVariable("qt_directory", "Path to Qt directory", "/")) +opts.Update(env) + +env['QT_LIB'] = 'qt-mt' +config = env.Configure(custom_tests = { + 'CheckForQt' : CheckForQt, +}) + +if not config.CheckForQt(): + print("Failed to find valid QT environment.") + Exit(1) + +env.Tool('qt', ['$TOOL_PATH']) +""") + +test.run(arguments='--warn=no-tool-qt-deprecated .') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/copied-env.py b/test/QT/qt3/copied-env.py new file mode 100644 index 000000000..3b2a83ed7 --- /dev/null +++ b/test/QT/qt3/copied-env.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test Qt with a copied construction environment. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation() + +test.Qt_create_SConstruct('SConstruct', qt_tool='qt3') + +test.write('SConscript', """\ +Import("env") +env.Append(CPPDEFINES = ['FOOBAZ']) + +copy = env.Clone() +copy.Append(CPPDEFINES = ['MYLIB_IMPL']) + +copy.SharedLibrary( + target = 'MyLib', + source = ['MyFile.cpp','MyForm.ui'] +) +""") + +test.write('MyFile.h', r""" +void aaa(void); +""") + +test.write('MyFile.cpp', r""" +#include "MyFile.h" +void useit() { + aaa(); +} +""") + +test.write('MyForm.ui', r""" +void aaa(void) +""") + +test.run(arguments="--warn=no-tool-qt-deprecated") + +moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1] + +MYLIB_IMPL = [x for x in moc_MyForm if x.find('MYLIB_IMPL') != -1] + +if not MYLIB_IMPL: + print("Did not find MYLIB_IMPL on moc_MyForm compilation line:") + print(test.stdout()) + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/empty-env.py b/test/QT/qt3/empty-env.py new file mode 100644 index 000000000..e9dfc81b1 --- /dev/null +++ b/test/QT/qt3/empty-env.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test Qt creation from a copied empty environment. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation('qt') + +test.write('SConstruct', """\ +orig = Environment() +env = orig.Clone(QTDIR = r'%s', + QT_LIB = r'%s', + QT_MOC = r'%s', + QT_UIC = r'%s', + tools=['qt']) +env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) +""" % (test.QT, test.QT_LIB, test.QT_MOC, test.QT_UIC)) + +test.write('main.cpp', r""" +#include "foo6.h" +int main(void) { foo6(); return 0; } +""") + +test.write(['qt', 'include', 'foo6.h'], """\ +#include +void +foo6(void) +{ +#ifdef FOO + printf("qt/include/foo6.h\\n"); +#endif +} +""") + +# we can receive warnings about a non detected qt (empty QTDIR) +# these are not critical, but may be annoying. +test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated') + +test.run( + program=test.workpath('main' + TestSCons._exe), + arguments='--warn=no-tool-qt-deprecated', + stderr=None, + stdout='qt/include/foo6.h\n', +) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/generated-ui.py b/test/QT/qt3/generated-ui.py new file mode 100644 index 000000000..fd368b34d --- /dev/null +++ b/test/QT/qt3/generated-ui.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test that the UI scanning logic correctly picks up scansG +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +if not os.environ.get('QTDIR', None): + x ="External environment variable $QTDIR not set; skipping test(s).\n" + test.skip_test(x) + +test.subdir(['layer'], + ['layer', 'aclock'], + ['layer', 'aclock', 'qt_bug']) + +test.write(['SConstruct'], """\ +import os +aa=os.getcwd() + +env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) +if 'HOME' in os.environ: + env['ENV']['HOME'] = os.environ['HOME'] +env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') +if not os.access(env["EXP_HEADER_ABS"],os.F_OK): + os.mkdir (env["EXP_HEADER_ABS"]) +Export('env') +env.SConscript('layer/aclock/qt_bug/SConscript') +""") + +test.write(['expheaders.py'], """\ +import SCons.Defaults +def ExpHeaderScanner(node, env, path): + return [] +def generate(env): + HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0o755)]) + HeaderBuilder= SCons.Builder.Builder(action=HeaderAction) + env['BUILDERS']['ExportHeaders'] = HeaderBuilder +def exists(env): + return 0 +""") + +test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\ +import os + +Import ("env") +#src=os.path.join(env.Dir('.').srcnode().abspath, 'testfile.h') +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h') +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h') +env.Append(CPPPATH=env["EXP_HEADER_ABS"]) +env.StaticLibrary('all',['main.ui','migraform.ui']) +""") + +test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\ + +Main + + + Main + + + + 0 + 0 + 600 + 385 + + + + + migraform.h + + +""") + +test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ + +MigrateForm + + + MigrateForm + + + + 0 + 0 + %s + 385 + + + + +""") + +test.run( + arguments='--warn=no-tool-qt-deprecated', + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall, +) + +test.up_to_date(options="--warn=no-tool-qt-deprecated", arguments=".") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/installed.py b/test/QT/qt3/installed.py new file mode 100644 index 000000000..9e8693e3f --- /dev/null +++ b/test/QT/qt3/installed.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Look if qt is installed, and try out all builders. +""" + +import os +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +if not os.environ.get('QTDIR', None): + x ="External environment variable $QTDIR not set; skipping test(s).\n" + test.skip_test(x) + +test.Qt_dummy_installation() + +QTDIR=os.environ['QTDIR'] + + +test.write('SConstruct', """\ +import os +dummy_env = Environment() +ENV = dummy_env['ENV'] +try: + PATH=ARGUMENTS['PATH'] + if 'PATH' in ENV: + ENV_PATH = PATH + os.pathsep + ENV['PATH'] + else: + Exit(0) # this is certainly a weird system :-) +except KeyError: + ENV_PATH=ENV.get('PATH', '') + +env = Environment(tools=['default','qt'], + ENV={'PATH':ENV_PATH, + 'PATHEXT':os.environ.get('PATHEXT'), + 'HOME':os.getcwd(), + 'SystemRoot':ENV.get('SystemRoot')}, + # moc / uic want to write stuff in ~/.qt + CXXFILESUFFIX=".cpp") + +conf = env.Configure() +if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): + conf.env['QT_LIB'] = 'qt-mt' + if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): + Exit(0) +env = conf.Finish() +VariantDir('bld', '.') +env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp', + 'bld/mocFromH.cpp', + 'bld/anUiFile.ui', + 'bld/main.cpp']) +""") + +test.write('mocFromCpp.h', """\ +void mocFromCpp(); +""") + +test.write('mocFromCpp.cpp', """\ +#include +#include "mocFromCpp.h" +class MyClass1 : public QObject { + Q_OBJECT + public: + MyClass1() : QObject() {}; + public slots: + void myslot() {}; +}; +void mocFromCpp() { + MyClass1 myclass; +} +#include "mocFromCpp.moc" +""") + +test.write('mocFromH.h', """\ +#include +class MyClass2 : public QObject { + Q_OBJECT; + public: + MyClass2(); + public slots: + void myslot(); +}; +void mocFromH(); +""") + +test.write('mocFromH.cpp', """\ +#include "mocFromH.h" + +MyClass2::MyClass2() : QObject() {} +void MyClass2::myslot() {} +void mocFromH() { + MyClass2 myclass; +} +""") + +test.write('anUiFile.ui', """\ + +MyWidget + + QWidget + + MyWidget + + + MyWidget + + + + anUiFile.ui.h + + + testSlot() + + + +""") + +test.write('anUiFile.ui.h', r""" +#include +#if QT_VERSION >= 0x030100 +void MyWidget::testSlot() +{ + printf("Hello World\n"); +} +#endif +""") + +test.write('main.cpp', r""" +#include +#include "mocFromCpp.h" +#include "mocFromH.h" +#include "anUiFile.h" +#include + +int main(int argc, char **argv) { + QApplication app(argc, argv); + mocFromCpp(); + mocFromH(); + MyWidget mywidget; +#if QT_VERSION >= 0x030100 + mywidget.testSlot(); +#else + printf("Hello World\n"); +#endif + return 0; +} +""") + +test.run(arguments="--warn=no-tool-qt-deprecated bld/test_realqt" + TestSCons._exe) + +test.run( + program=test.workpath("bld", "test_realqt"), + arguments="--warn=no-tool-qt-deprecated", + stdout=None, + status=None, + stderr=None, +) + +if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status: + sys.stdout.write(test.stdout()) + sys.stderr.write(test.stderr()) + # The test might be run on a system that doesn't have an X server + # running, or may be run by an ID that can't connect to the server. + # If so, then print whatever it showed us (which is in and of itself + # an indication that it built correctly) but don't fail the test. + expect = 'cannot connect to X server' + test.fail_test(test.stdout()) + test.fail_test(expect not in test.stderr()) + if test.status != 1 and (test.status >> 8) != 1: + sys.stdout.write('test_realqt returned status %s\n' % test.status) + test.fail_test() + +QTDIR = os.environ['QTDIR'] +PATH = os.environ['PATH'] +os.environ['QTDIR'] = '' +os.environ['PATH'] = '.' + +test.run( + stderr=None, + arguments="--warn=no-tool-qt-deprecated -c bld/test_realqt" + TestSCons._exe, +) + +expect1 = "scons: warning: Could not detect qt, using empty QTDIR" +expect2 = "scons: warning: Could not detect qt, using moc executable as a hint" + +test.fail_test(expect1 not in test.stderr() and expect2 not in test.stderr()) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/manual.py b/test/QT/qt3/manual.py new file mode 100644 index 000000000..84c6df8e0 --- /dev/null +++ b/test/QT/qt3/manual.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test the manual QT builder calls. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('include', 'ui') + +test.Qt_dummy_installation() + +aaa_exe = 'aaa' + TestSCons._exe + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', r""" +Import("env") +sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp'] + +# normal invocation +sources.append(env.Moc('include/aaa.h')) +moc = env.Moc('bbb.cpp') +env.Ignore( moc, moc ) +sources.extend(env.Uic('ui/ccc.ui')[1:]) + +# manual target specification +sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', + QT_MOCHPREFIX='')) # Watch out ! +moc = env.Moc('moc_eee.cpp', 'eee.cpp') +env.Ignore( moc, moc ) +sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], + 'ui/fff.ui')[1:]) + +print(list(map(str,sources))) +env.Program(target='aaa', + source=sources, + CPPPATH=['$CPPPATH', './include'], + QT_AUTOSCAN=0) +""") + +test.write('aaa.cpp', r""" +#include "aaa.h" +""") + +test.write(['include', 'aaa.h'], r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") + +test.write('bbb.h', r""" +void bbb(void); +""") + +test.write('bbb.cpp', r""" +#include "my_qobject.h" +void bbb(void) Q_OBJECT +#include "bbb.moc" +""") + +test.write(['ui', 'ccc.ui'], r""" +void ccc(void) +""") + +test.write('ddd.cpp', r""" +#include "ddd.h" +""") + +test.write(['include', 'ddd.h'], r""" +#include "my_qobject.h" +void ddd(void) Q_OBJECT; +""") + +test.write('eee.h', r""" +void eee(void); +""") + +test.write('eee.cpp', r""" +#include "my_qobject.h" +void eee(void) Q_OBJECT +#include "moc_eee.cpp" +""") + +test.write(['ui', 'fff.ui'], r""" +void fff(void) +""") + +test.write('main.cpp', r""" +#include "aaa.h" +#include "bbb.h" +#include "ui/ccc.h" +#include "ddd.h" +#include "eee.h" +#include "uic_fff.hpp" + +int main(void) { + aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0; +} +""") + +test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_exe) + +# normal invocation +test.must_exist(test.workpath('include', 'moc_aaa.cc')) +test.must_exist(test.workpath('bbb.moc')) +test.must_exist(test.workpath('ui', 'ccc.h')) +test.must_exist(test.workpath('ui', 'uic_ccc.cc')) +test.must_exist(test.workpath('ui', 'moc_ccc.cc')) + +# manual target spec. +test.must_exist(test.workpath('moc-ddd.cpp')) +test.must_exist(test.workpath('moc_eee.cpp')) +test.must_exist(test.workpath('include', 'uic_fff.hpp')) +test.must_exist(test.workpath('fff.cpp')) +test.must_exist(test.workpath('fff.moc.cpp')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/moc-from-cpp.py b/test/QT/qt3/moc-from-cpp.py new file mode 100644 index 000000000..bbab8cab8 --- /dev/null +++ b/test/QT/qt3/moc-from-cpp.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Create a moc file from a cpp file. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation() + +############################################################################## + +lib_aaa = TestSCons.lib_ + 'aaa' + TestSCons._lib +moc = 'aaa.moc' + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', """ +Import("env dup") +if dup == 0: env.Append(CPPPATH=['.']) +env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp']) +""" % lib_aaa) + +test.write('aaa.h', r""" +void aaa(void); +""") + +test.write('aaa.cpp', r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT +#include "%s" +""" % moc) + +test.write('useit.cpp', r""" +#include "aaa.h" +void useit() { + aaa(); +} +""") + +test.run( + arguments="--warn=no-tool-qt-deprecated " + lib_aaa, + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall, +) + +test.up_to_date(options='-n --warn=no-tool-qt-deprecated', arguments=lib_aaa) + +test.write('aaa.cpp', r""" +#include "my_qobject.h" +/* a change */ +void aaa(void) Q_OBJECT +#include "%s" +""" % moc) + +test.not_up_to_date(options='-n --warn=no-tool-qt-deprecated', arguments=moc) + +test.run(options="--warn=no-tool-qt-deprecated -c", arguments=lib_aaa) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + + test.workpath('build', lib_aaa), + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall, +) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + + test.workpath('build', lib_aaa) +) + +test.must_exist(test.workpath('build', moc)) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 dup=0 " + + test.workpath('build_dup0', lib_aaa), + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall, +) + +test.must_exist(test.workpath('build_dup0', moc)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/moc-from-header.py b/test/QT/qt3/moc-from-header.py new file mode 100644 index 000000000..65a12e1ed --- /dev/null +++ b/test/QT/qt3/moc-from-header.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Create a moc file from a header file. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +env = Environment() +""") + +test.Qt_dummy_installation() + +# We'll run some test programs later that need to find our dummy +# Qt library. +os.environ['LD_LIBRARY_PATH'] = test.QT_LIB_DIR + +############################################################################## + +aaa_exe = 'aaa' + TestSCons._exe +build_aaa_exe = test.workpath('build', aaa_exe) +moc = 'moc_aaa.cc' + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', """\ +Import("env") +env.Program(target = 'aaa', source = 'aaa.cpp') +if env['PLATFORM'] == 'darwin': + env.Install('.', 'qt/lib/libmyqt.dylib') +""") + +test.write('aaa.cpp', r""" +#include "aaa.h" +int main(void) { aaa(); return 0; } +""") + +test.write('aaa.h', r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") + +test.run(arguments="--warn=no-tool-qt-deprecated") +test.up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=aaa_exe) + +test.write('aaa.h', r""" +/* a change */ +#include "my_qobject.h" +void aaa(void) Q_OBJECT; +""") + +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) + +test.run( + arguments="--warn=no-tool-qt-deprecated", + program=test.workpath(aaa_exe), + stdout='aaa.h\n', +) + +test.run(arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + build_aaa_exe) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + build_aaa_exe +) + +test.must_exist(test.workpath('build', moc)) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 dup=0 " + + test.workpath('build_dup0', aaa_exe) +) + +test.must_exist(['build_dup0', moc]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/qt_warnings.py b/test/QT/qt3/qt_warnings.py new file mode 100644 index 000000000..fb23a7151 --- /dev/null +++ b/test/QT/qt3/qt_warnings.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test the Qt tool warnings. +""" + +import os +import re + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +test.Qt_dummy_installation() + +test.Qt_create_SConstruct(SConstruct_path) + +test.write('aaa.cpp', r""" +#include "my_qobject.h" +void aaa(void) Q_OBJECT +""") + +test.write('SConscript', r""" +Import("env") +import os +env.StaticLibrary('aaa.cpp') +""") + +test.run(arguments="--warn=no-tool-qt-deprecated", stderr=None) + +match12 = r""" +scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' +""" + TestSCons.file_expr + +if not re.search(match12, test.stderr()): + print("Did not find expected regular expression in stderr:") + print(test.stderr()) + test.fail_test() + +os.environ['QTDIR'] = test.QT + +test.run(arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') + +# We'd like to eliminate $QTDIR from the environment as follows: +# del os.environ['QTDIR'] +# But unfortunately, in at least some versions of Python, the Environment +# class doesn't implement a __delitem__() method to make the library +# call to actually remove the deleted variable from the *external* +# environment, so it only gets removed from the Python dictionary. +# Consequently, we need to just wipe out its value as follows> +os.environ['QTDIR'] = '' +test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') + +moc = test.where_is('moc') +if moc: + import os.path + qtdir = os.path.dirname(os.path.dirname(moc)) + qtdir = qtdir.replace('\\', '\\\\' ) + + expect = r""" +scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) +File "%s", line \d+, in (\?|) +""" % (qtdir, re.escape(SConstruct_path)) +else: + + expect = r""" +scons: warning: Could not detect qt, using empty QTDIR +File "%s", line \d+, in (\?|) +""" % re.escape(SConstruct_path) + +test.fail_test(not test.match_re(test.stderr(), expect)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/reentrant.py b/test/QT/qt3/reentrant.py new file mode 100644 index 000000000..40fb1f19a --- /dev/null +++ b/test/QT/qt3/reentrant.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test creation from a copied environment that already has QT variables. +This makes sure the tool initialization is re-entrant. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation('qt') + +test.write(['qt', 'include', 'foo5.h'], """\ +#include +void +foo5(void) +{ +#ifdef FOO + printf("qt/include/foo5.h\\n"); +#endif +} +""") + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', """\ +Import("env") +env = env.Clone(tools=['qt']) +env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) +""") + +test.write('main.cpp', r""" +#include "foo5.h" +int main(void) { foo5(); return 0; } +""") + +test.run(arguments="--warn=no-tool-qt-deprecated") + +test.run( + arguments='--warn=no-tool-qt-deprecated', + program=test.workpath('main' + TestSCons._exe), + stdout='qt/include/foo5.h\n', +) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/source-from-ui.py b/test/QT/qt3/source-from-ui.py new file mode 100644 index 000000000..569fbab2c --- /dev/null +++ b/test/QT/qt3/source-from-ui.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Create .cpp, .h, moc_....cpp from a .ui file. +""" + +import os.path + +import TestSCons + +test = TestSCons.TestSCons() + +test.Qt_dummy_installation() + +############################################################################## + +aaa_dll = TestSCons.dll_ + 'aaa' + TestSCons._dll +moc = 'moc_aaa.cc' +cpp = 'uic_aaa.cc' +obj = TestSCons.shobj_ + os.path.splitext(cpp)[0] + TestSCons._shobj +h = 'aaa.h' + +test.Qt_create_SConstruct('SConstruct') + +test.write('SConscript', """\ +Import("env dup") +if dup == 0: env.Append(CPPPATH=['#', '.']) +env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) +""") + +test.write('aaa.ui', r""" +#if defined (_WIN32) || defined(__CYGWIN__) +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif +DLLEXPORT void aaa(void) +""") + +test.write('useit.cpp', r""" +#include "aaa.h" +void useit() { + aaa(); +} +""") + +test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) + +test.up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=aaa_dll) + +test.write('aaa.ui', r""" +/* a change */ +#if defined (_WIN32) || defined(__CYGWIN__) +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif +DLLEXPORT void aaa(void) +""") + +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) + +test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) + +test.write('aaa.ui', r""" +void aaa(void) +//aaa.ui.h +""") + +# test that non-existant ui.h files are ignored (as uic does) +test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) + +test.write('aaa.ui.h', r""" +/* test dependency to .ui.h */ +""") + +test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) + +test.write('aaa.ui.h', r""" +/* changed */ +""") + +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=obj) +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) +test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) + +# clean up +test.run(arguments="--warn=no-tool-qt-deprecated -c " + aaa_dll) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + + test.workpath('build', aaa_dll) +) + +test.must_exist(test.workpath('build', moc)) +test.must_exist(test.workpath('build', cpp)) +test.must_exist(test.workpath('build', h)) +test.must_not_exist(test.workpath(moc)) +test.must_not_exist(test.workpath(cpp)) +test.must_not_exist(test.workpath(h)) + +cppContents = test.read(test.workpath('build', cpp), mode='r') +test.fail_test(cppContents.find('#include "aaa.ui.h"') == -1) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + + test.workpath('build', aaa_dll) +) + +test.must_exist(test.workpath('build', moc)) +test.must_exist(test.workpath('build', cpp)) +test.must_exist(test.workpath('build', h)) +test.must_not_exist(test.workpath(moc)) +test.must_not_exist(test.workpath(cpp)) +test.must_not_exist(test.workpath(h)) + +test.run( + arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 dup=0 " + + test.workpath('build_dup0', aaa_dll) +) + +test.must_exist(test.workpath('build_dup0', moc)) +test.must_exist(test.workpath('build_dup0', cpp)) +test.must_exist(test.workpath('build_dup0', h)) +test.must_not_exist(test.workpath(moc)) +test.must_not_exist(test.workpath(cpp)) +test.must_not_exist(test.workpath(h)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt3/up-to-date.py b/test/QT/qt3/up-to-date.py new file mode 100644 index 000000000..06fb5590e --- /dev/null +++ b/test/QT/qt3/up-to-date.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Validate that a stripped-down real-world Qt configuation (thanks +to Leanid Nazdrynau) with a generated .h file is correctly +up-to-date after a build. + +(This catches a bug that was introduced during a signature refactoring +ca. September 2005.) +""" + +import os + +import TestSCons + +_obj = TestSCons._obj + +test = TestSCons.TestSCons() + +if not os.environ.get('QTDIR', None): + x ="External environment variable $QTDIR not set; skipping test(s).\n" + test.skip_test(x) + +test.subdir('layer', + ['layer', 'aclock'], + ['layer', 'aclock', 'qt_bug']) + +test.write('SConstruct', """\ +import os +aa=os.getcwd() + +env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) +env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') +if not os.access(env["EXP_HEADER_ABS"],os.F_OK): + os.mkdir (env["EXP_HEADER_ABS"]) +Export('env') +env.SConscript('layer/aclock/qt_bug/SConscript') +""") + +test.write('expheaders.py', """\ +import SCons.Defaults +def ExpHeaderScanner(node, env, path): + return [] +def generate(env): + HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0o755)]) + HeaderBuilder= SCons.Builder.Builder(action=HeaderAction) + env['BUILDERS']['ExportHeaders'] = HeaderBuilder +def exists(env): + return 0 +""") + +test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\ +import os + +Import ("env") +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h') +env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h') +env.Append(CPPPATH=env["EXP_HEADER_ABS"]) +env.StaticLibrary('all',['main.ui','migraform.ui','my.cc']) +""") + +test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\ + +Main + + + Main + + + + 0 + 0 + 600 + 385 + + + + + migraform.h + + +""") + +test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ + +MigrateForm + + + MigrateForm + + + + 0 + 0 + 600 + 385 + + + + +""") + +test.write(['layer', 'aclock', 'qt_bug', 'my.cc'], """\ +#include +""") + +my_obj = 'layer/aclock/qt_bug/my' + _obj + +test.run(arguments='--warn=no-tool-qt-deprecated ' + my_obj, stderr=None) + +expect = my_obj.replace('/', os.sep) +test.up_to_date(options='--debug=explain', arguments=expect, stderr=None) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/qt_warnings.py b/test/QT/qt_warnings.py deleted file mode 100644 index fb23a7151..000000000 --- a/test/QT/qt_warnings.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test the Qt tool warnings. -""" - -import os -import re - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct_path = test.workpath('SConstruct') - -test.Qt_dummy_installation() - -test.Qt_create_SConstruct(SConstruct_path) - -test.write('aaa.cpp', r""" -#include "my_qobject.h" -void aaa(void) Q_OBJECT -""") - -test.write('SConscript', r""" -Import("env") -import os -env.StaticLibrary('aaa.cpp') -""") - -test.run(arguments="--warn=no-tool-qt-deprecated", stderr=None) - -match12 = r""" -scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' -""" + TestSCons.file_expr - -if not re.search(match12, test.stderr()): - print("Did not find expected regular expression in stderr:") - print(test.stderr()) - test.fail_test() - -os.environ['QTDIR'] = test.QT - -test.run(arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') - -# We'd like to eliminate $QTDIR from the environment as follows: -# del os.environ['QTDIR'] -# But unfortunately, in at least some versions of Python, the Environment -# class doesn't implement a __delitem__() method to make the library -# call to actually remove the deleted variable from the *external* -# environment, so it only gets removed from the Python dictionary. -# Consequently, we need to just wipe out its value as follows> -os.environ['QTDIR'] = '' -test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') - -moc = test.where_is('moc') -if moc: - import os.path - qtdir = os.path.dirname(os.path.dirname(moc)) - qtdir = qtdir.replace('\\', '\\\\' ) - - expect = r""" -scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) -File "%s", line \d+, in (\?|) -""" % (qtdir, re.escape(SConstruct_path)) -else: - - expect = r""" -scons: warning: Could not detect qt, using empty QTDIR -File "%s", line \d+, in (\?|) -""" % re.escape(SConstruct_path) - -test.fail_test(not test.match_re(test.stderr(), expect)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/reentrant.py b/test/QT/reentrant.py deleted file mode 100644 index 40fb1f19a..000000000 --- a/test/QT/reentrant.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Test creation from a copied environment that already has QT variables. -This makes sure the tool initialization is re-entrant. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation('qt') - -test.write(['qt', 'include', 'foo5.h'], """\ -#include -void -foo5(void) -{ -#ifdef FOO - printf("qt/include/foo5.h\\n"); -#endif -} -""") - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """\ -Import("env") -env = env.Clone(tools=['qt']) -env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) -""") - -test.write('main.cpp', r""" -#include "foo5.h" -int main(void) { foo5(); return 0; } -""") - -test.run(arguments="--warn=no-tool-qt-deprecated") - -test.run( - arguments='--warn=no-tool-qt-deprecated', - program=test.workpath('main' + TestSCons._exe), - stdout='qt/include/foo5.h\n', -) -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/source-from-ui.py b/test/QT/source-from-ui.py deleted file mode 100644 index 569fbab2c..000000000 --- a/test/QT/source-from-ui.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -""" -Create .cpp, .h, moc_....cpp from a .ui file. -""" - -import os.path - -import TestSCons - -test = TestSCons.TestSCons() - -test.Qt_dummy_installation() - -############################################################################## - -aaa_dll = TestSCons.dll_ + 'aaa' + TestSCons._dll -moc = 'moc_aaa.cc' -cpp = 'uic_aaa.cc' -obj = TestSCons.shobj_ + os.path.splitext(cpp)[0] + TestSCons._shobj -h = 'aaa.h' - -test.Qt_create_SConstruct('SConstruct') - -test.write('SConscript', """\ -Import("env dup") -if dup == 0: env.Append(CPPPATH=['#', '.']) -env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp']) -""") - -test.write('aaa.ui', r""" -#if defined (_WIN32) || defined(__CYGWIN__) -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT -#endif -DLLEXPORT void aaa(void) -""") - -test.write('useit.cpp', r""" -#include "aaa.h" -void useit() { - aaa(); -} -""") - -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) - -test.up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=aaa_dll) - -test.write('aaa.ui', r""" -/* a change */ -#if defined (_WIN32) || defined(__CYGWIN__) -#define DLLEXPORT __declspec(dllexport) -#else -#define DLLEXPORT -#endif -DLLEXPORT void aaa(void) -""") - -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) - -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) - -test.write('aaa.ui', r""" -void aaa(void) -//aaa.ui.h -""") - -# test that non-existant ui.h files are ignored (as uic does) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) - -test.write('aaa.ui.h', r""" -/* test dependency to .ui.h */ -""") - -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) - -test.write('aaa.ui.h', r""" -/* changed */ -""") - -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=obj) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) - -# clean up -test.run(arguments="--warn=no-tool-qt-deprecated -c " + aaa_dll) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 " - + test.workpath('build', aaa_dll) -) - -test.must_exist(test.workpath('build', moc)) -test.must_exist(test.workpath('build', cpp)) -test.must_exist(test.workpath('build', h)) -test.must_not_exist(test.workpath(moc)) -test.must_not_exist(test.workpath(cpp)) -test.must_not_exist(test.workpath(h)) - -cppContents = test.read(test.workpath('build', cpp), mode='r') -test.fail_test(cppContents.find('#include "aaa.ui.h"') == -1) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " - + test.workpath('build', aaa_dll) -) - -test.must_exist(test.workpath('build', moc)) -test.must_exist(test.workpath('build', cpp)) -test.must_exist(test.workpath('build', h)) -test.must_not_exist(test.workpath(moc)) -test.must_not_exist(test.workpath(cpp)) -test.must_not_exist(test.workpath(h)) - -test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 dup=0 " - + test.workpath('build_dup0', aaa_dll) -) - -test.must_exist(test.workpath('build_dup0', moc)) -test.must_exist(test.workpath('build_dup0', cpp)) -test.must_exist(test.workpath('build_dup0', h)) -test.must_not_exist(test.workpath(moc)) -test.must_not_exist(test.workpath(cpp)) -test.must_not_exist(test.workpath(h)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/QT/up-to-date.py b/test/QT/up-to-date.py deleted file mode 100644 index 06fb5590e..000000000 --- a/test/QT/up-to-date.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python -# -# MIT License -# -# Copyright The SCons Foundation -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -""" -Validate that a stripped-down real-world Qt configuation (thanks -to Leanid Nazdrynau) with a generated .h file is correctly -up-to-date after a build. - -(This catches a bug that was introduced during a signature refactoring -ca. September 2005.) -""" - -import os - -import TestSCons - -_obj = TestSCons._obj - -test = TestSCons.TestSCons() - -if not os.environ.get('QTDIR', None): - x ="External environment variable $QTDIR not set; skipping test(s).\n" - test.skip_test(x) - -test.subdir('layer', - ['layer', 'aclock'], - ['layer', 'aclock', 'qt_bug']) - -test.write('SConstruct', """\ -import os -aa=os.getcwd() - -env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) -env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') -if not os.access(env["EXP_HEADER_ABS"],os.F_OK): - os.mkdir (env["EXP_HEADER_ABS"]) -Export('env') -env.SConscript('layer/aclock/qt_bug/SConscript') -""") - -test.write('expheaders.py', """\ -import SCons.Defaults -def ExpHeaderScanner(node, env, path): - return [] -def generate(env): - HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0o755)]) - HeaderBuilder= SCons.Builder.Builder(action=HeaderAction) - env['BUILDERS']['ExportHeaders'] = HeaderBuilder -def exists(env): - return 0 -""") - -test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\ -import os - -Import ("env") -env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h') -env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h') -env.Append(CPPPATH=env["EXP_HEADER_ABS"]) -env.StaticLibrary('all',['main.ui','migraform.ui','my.cc']) -""") - -test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\ - -Main - - - Main - - - - 0 - 0 - 600 - 385 - - - - - migraform.h - - -""") - -test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ - -MigrateForm - - - MigrateForm - - - - 0 - 0 - 600 - 385 - - - - -""") - -test.write(['layer', 'aclock', 'qt_bug', 'my.cc'], """\ -#include -""") - -my_obj = 'layer/aclock/qt_bug/my' + _obj - -test.run(arguments='--warn=no-tool-qt-deprecated ' + my_obj, stderr=None) - -expect = my_obj.replace('/', os.sep) -test.up_to_date(options='--debug=explain', arguments=expect, stderr=None) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 469f6c1c5..b6c9f094b 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -1172,17 +1172,17 @@ else: self.QT_UIC = f"{_python_} {self.workpath(dir, 'bin', 'myuic.py')}" self.QT_LIB_DIR = self.workpath(dir, 'lib') - def Qt_create_SConstruct(self, place): + def Qt_create_SConstruct(self, place, qt_tool='qt3'): if isinstance(place, list): place = test.workpath(*place) - self.write(place, """\ + self.write(place, f"""\ if ARGUMENTS.get('noqtdir', 0): QTDIR = None else: - QTDIR = r'%s' + QTDIR = r'{self.QT}' DefaultEnvironment(tools=[]) # test speedup env = Environment( - QTDIR=QTDIR, QT_LIB=r'%s', QT_MOC=r'%s', QT_UIC=r'%s', tools=['default', 'qt'] + QTDIR=QTDIR, QT_LIB=r'{self.QT_LIB}', QT_MOC=r'{self.QT_MOC}', QT_UIC=r'{self.QT_UIC}', tools=['default', '{qt_tool}'] ) dup = 1 if ARGUMENTS.get('variant_dir', 0): @@ -1203,7 +1203,7 @@ else: sconscript = File('SConscript') Export("env dup") SConscript(sconscript) -""" % (self.QT, self.QT_LIB, self.QT_MOC, self.QT_UIC)) +""") NCR = 0 # non-cached rebuild CR = 1 # cached rebuild (up to date) -- cgit v1.2.1 From 181ce80cf3df9a8f6ba7efd3dee77d8e92158337 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 24 Feb 2023 01:31:21 +0000 Subject: moved the qt tool to qt3. Changed all QT envvars to be now prefixed with QT3 --- CHANGES.txt | 3 ++ RELEASE.txt | 5 +++ SCons/Tool/qt3.py | 6 +--- SCons/Warnings.py | 2 +- test/QT/qt3/QTFLAGS.py | 76 +++++++++++++++++++++--------------------- test/QT/qt3/Tool.py | 12 +++---- test/QT/qt3/copied-env.py | 2 +- test/QT/qt3/empty-env.py | 13 ++++---- test/QT/qt3/generated-ui.py | 5 ++- test/QT/qt3/installed.py | 18 +++++----- test/QT/qt3/manual.py | 8 ++--- test/QT/qt3/qt_warnings.py | 10 +++--- test/QT/qt3/reentrant.py | 2 +- test/QT/qt3/source-from-ui.py | 32 +++++++++--------- test/QT/qt3/up-to-date.py | 2 +- testing/framework/TestSCons.py | 9 +++-- 16 files changed, 105 insertions(+), 100 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6052a21a3..df06c2fd7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -41,6 +41,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fixed Issue #4275 - when outputting compilation db and TEMPFILE was in use, the compilation db would have command lines using the generated tempfile for long command lines, instead of the full command line for the compilation step for the source/target pair. + - Renamed the qt tools to qt3 since the logic in that tool is only for QT version 3. Renamed all env vars + which affect qt3 from QT_ to QT3_. If you are still using SCons to build QT 3 code, you'll need to update + your SConscripts. Note that using 'qt' tool has been deprecated for some time. From David H: - Added JAVAPROCESSORPATH construction variable which populates -processorpath. diff --git a/RELEASE.txt b/RELEASE.txt index 91dbb862c..32bb94537 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -65,6 +65,11 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY always emitted in the order entered. Sorting is no longer required after Python interpreter improvements. There might be a one-time rebuild of targets that involved such sorted keys in their actions. +- Renamed the 'qt' tools to 'qt3' since the logic in that tool is only for QT version 3. + Renamed all env vars which affect qt3 from QT_ to QT3_. If you are still using SCons + to build QT 3 code, you'll need to update your SConscripts. Note that using 'qt' tool + has been deprecated for some time. + FIXES ----- diff --git a/SCons/Tool/qt3.py b/SCons/Tool/qt3.py index 2b315548e..4e6975648 100644 --- a/SCons/Tool/qt3.py +++ b/SCons/Tool/qt3.py @@ -271,10 +271,6 @@ def generate(env): Action = SCons.Action.Action Builder = SCons.Builder.Builder - SCons.Warnings.warn( - SCons.Warnings.ToolQtDeprecatedWarning, "Tool module for Qt version 3 is deprecated" - ) - qt3path = _detect_qt3(env) if qt3path is None: return None @@ -366,7 +362,7 @@ def generate(env): LIBS=['$QT3_LIB']) def exists(env): - return _detect(env) + return _detect_qt3(env) # Local Variables: # tab-width:4 diff --git a/SCons/Warnings.py b/SCons/Warnings.py index 754f05d86..f77a24a2d 100644 --- a/SCons/Warnings.py +++ b/SCons/Warnings.py @@ -131,7 +131,7 @@ class DeprecatedDebugOptionsWarning(MandatoryDeprecatedWarning): class DeprecatedMissingSConscriptWarning(DeprecatedWarning): pass -class ToolQtDeprecatedWarning(FutureDeprecatedWarning): +class ToolQtDeprecatedWarning(DeprecatedWarning): pass # The below is a list of 2-tuples. The first element is a class object. diff --git a/test/QT/qt3/QTFLAGS.py b/test/QT/qt3/QTFLAGS.py index c759c2a4a..56536845f 100644 --- a/test/QT/qt3/QTFLAGS.py +++ b/test/QT/qt3/QTFLAGS.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -Testing the configuration mechanisms of the 'qt' tool. +Testing the configuration mechanisms of the 'qt3' tool. """ import TestSCons @@ -39,24 +39,24 @@ test.subdir('work1', 'work2') test.run( chdir=test.workpath('qt', 'lib'), - arguments="--warn=no-tool-qt-deprecated .", + arguments=".", stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall, ) -QT = test.workpath('qt') -QT_LIB = 'myqt' -QT_MOC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'mymoc.py')) -QT_UIC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'myuic.py')) +QT3 = test.workpath('qt') +QT3_LIB = 'myqt' +QT3_MOC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'mymoc.py')) +QT3_UIC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'myuic.py')) def createSConstruct(test, place, overrides): test.write(place, """\ env = Environment( - tools=['default','qt'], - QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', + tools=['default','qt3'], + QT3DIR = r'%s', + QT3_LIB = r'%s', + QT3_MOC = r'%s', + QT3_UIC = r'%s', %s # last because 'overrides' may add comma ) if ARGUMENTS.get('variant_dir', 0): @@ -70,23 +70,23 @@ else: sconscript = File('SConscript') Export("env") SConscript(sconscript) -""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides)) +""" % (QT3, QT3_LIB, QT3_MOC, QT3_UIC, overrides)) createSConstruct(test, ['work1', 'SConstruct'], - """QT_UICIMPLFLAGS='-x', - QT_UICDECLFLAGS='-y', - QT_MOCFROMHFLAGS='-z', - QT_MOCFROMCXXFLAGS='-i -w', - QT_UICDECLPREFIX='uic-', - QT_UICDECLSUFFIX='.hpp', - QT_UICIMPLPREFIX='', - QT_UICIMPLSUFFIX='.cxx', - QT_MOCHPREFIX='mmm', - QT_MOCHSUFFIX='.cxx', - QT_MOCCXXPREFIX='moc', - QT_MOCCXXSUFFIX='.inl', - QT_UISUFFIX='.myui',""") + """QT3_UICIMPLFLAGS='-x', + QT3_UICDECLFLAGS='-y', + QT3_MOCFROMHFLAGS='-z', + QT3_MOCFROMCXXFLAGS='-i -w', + QT3_UICDECLPREFIX='uic-', + QT3_UICDECLSUFFIX='.hpp', + QT3_UICIMPLPREFIX='', + QT3_UICIMPLSUFFIX='.cxx', + QT3_MOCHPREFIX='mmm', + QT3_MOCHSUFFIX='.cxx', + QT3_MOCCXXPREFIX='moc', + QT3_MOCCXXSUFFIX='.inl', + QT3_UISUFFIX='.myui',""") test.write(['work1', 'SConscript'],""" Import("env") env.Program('mytest', ['mocFromH.cpp', @@ -137,7 +137,7 @@ int main(void) { } """) -test.run(chdir='work1', arguments="--warn=no-tool-qt-deprecated mytest" + _exe) +test.run(chdir='work1', arguments="mytest" + _exe) test.must_exist( ['work1', 'mmmmocFromH.cxx'], @@ -173,32 +173,32 @@ test.write(['work2', 'SConstruct'], """ import os.path env1 = Environment( - tools=['qt'], - QTDIR=r'%(QTDIR)s', - QT_BINPATH='$QTDIR/bin64', - QT_LIBPATH='$QTDIR/lib64', - QT_CPPPATH='$QTDIR/h64', + tools=['qt3'], + QT3DIR=r'%(QT3DIR)s', + QT3_BINPATH='$QT3DIR/bin64', + QT3_LIBPATH='$QT3DIR/lib64', + QT3_CPPPATH='$QT3DIR/h64', ) cpppath = env1.subst('$CPPPATH') -if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): +if os.path.normpath(cpppath) != os.path.join(r'%(QT3DIR)s', 'h64'): print(cpppath) Exit(1) libpath = env1.subst('$LIBPATH') -if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): +if os.path.normpath(libpath) != os.path.join(r'%(QT3DIR)s', 'lib64'): print(libpath) Exit(2) -qt_moc = env1.subst('$QT_MOC') -if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): +qt_moc = env1.subst('$QT3_MOC') +if os.path.normpath(qt_moc) != os.path.join(r'%(QT3DIR)s', 'bin64', 'moc'): print(qt_moc) Exit(3) env2 = Environment( - tools=['default', 'qt'], QTDIR=None, QT_LIB=None, QT_CPPPATH=None, QT_LIBPATH=None + tools=['default', 'qt3'], QT3DIR=None, QT3_LIB=None, QT3_CPPPATH=None, QT3_LIBPATH=None ) env2.Program('main.cpp') -""" % {'QTDIR':QT}) +""" % {'QT3DIR':QT3}) test.write(['work2', 'main.cpp'], """ int main(void) { return 0; } @@ -206,7 +206,7 @@ int main(void) { return 0; } # Ignore stderr, because if Qt is not installed, # there may be a warning about an empty QTDIR on stderr. -test.run(arguments="--warn=no-tool-qt-deprecated", chdir='work2', stderr=None) +test.run(chdir='work2', stderr=None) test.must_exist(['work2', 'main' + _exe]) diff --git a/test/QT/qt3/Tool.py b/test/QT/qt3/Tool.py index 122e7f413..1b34ea2ab 100644 --- a/test/QT/qt3/Tool.py +++ b/test/QT/qt3/Tool.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -Verify that applying env.Tool('qt') after running Configure checks +Verify that applying env.Tool('qt3') after running Configure checks works properly. This was broken in 0.96.95. The configuration here is a moderately stripped-down version of the @@ -90,7 +90,7 @@ def CheckForQt(context): ] if 'QTDIR' in os.environ: - potential_qt_dirs.insert(0, os.environ[ 'QTDIR' ]) + potential_qt_dirs.insert(0, os.environ['QTDIR']) if env[ 'qt_directory' ] != "/": uic_path = os.path.join(env['qt_directory'], 'bin', 'uic') @@ -101,7 +101,7 @@ def CheckForQt(context): return 0 for i in potential_qt_dirs: - context.env.Replace(QTDIR = i) + context.env.Replace(QT3DIR = i) if CheckForQtAt(context, i): # additional checks to validate QT installation if not os.path.isfile(os.path.join(i, 'bin', 'uic')): @@ -133,7 +133,7 @@ opts = Variables('lprof.conf') opts.Add(PathVariable("qt_directory", "Path to Qt directory", "/")) opts.Update(env) -env['QT_LIB'] = 'qt-mt' +env['QT3_LIB'] = 'qt-mt' config = env.Configure(custom_tests = { 'CheckForQt' : CheckForQt, }) @@ -142,10 +142,10 @@ if not config.CheckForQt(): print("Failed to find valid QT environment.") Exit(1) -env.Tool('qt', ['$TOOL_PATH']) +env.Tool('qt3', ['$TOOL_PATH']) """) -test.run(arguments='--warn=no-tool-qt-deprecated .') +test.run(arguments='.') test.pass_test() diff --git a/test/QT/qt3/copied-env.py b/test/QT/qt3/copied-env.py index 3b2a83ed7..9bcb95b68 100644 --- a/test/QT/qt3/copied-env.py +++ b/test/QT/qt3/copied-env.py @@ -63,7 +63,7 @@ test.write('MyForm.ui', r""" void aaa(void) """) -test.run(arguments="--warn=no-tool-qt-deprecated") +test.run() moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1] diff --git a/test/QT/qt3/empty-env.py b/test/QT/qt3/empty-env.py index e9dfc81b1..cd1434080 100644 --- a/test/QT/qt3/empty-env.py +++ b/test/QT/qt3/empty-env.py @@ -35,11 +35,11 @@ test.Qt_dummy_installation('qt') test.write('SConstruct', """\ orig = Environment() -env = orig.Clone(QTDIR = r'%s', - QT_LIB = r'%s', - QT_MOC = r'%s', - QT_UIC = r'%s', - tools=['qt']) +env = orig.Clone(QT3DIR = r'%s', + QT3_LIB = r'%s', + QT3_MOC = r'%s', + QT3_UIC = r'%s', + tools=['qt3']) env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) """ % (test.QT, test.QT_LIB, test.QT_MOC, test.QT_UIC)) @@ -61,11 +61,10 @@ foo6(void) # we can receive warnings about a non detected qt (empty QTDIR) # these are not critical, but may be annoying. -test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated') +test.run(stderr=None) test.run( program=test.workpath('main' + TestSCons._exe), - arguments='--warn=no-tool-qt-deprecated', stderr=None, stdout='qt/include/foo6.h\n', ) diff --git a/test/QT/qt3/generated-ui.py b/test/QT/qt3/generated-ui.py index fd368b34d..d43b21b00 100644 --- a/test/QT/qt3/generated-ui.py +++ b/test/QT/qt3/generated-ui.py @@ -45,7 +45,7 @@ test.write(['SConstruct'], """\ import os aa=os.getcwd() -env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) +env=Environment(tools=['default','expheaders','qt3'],toolpath=[aa]) if 'HOME' in os.environ: env['ENV']['HOME'] = os.environ['HOME'] env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') @@ -120,12 +120,11 @@ test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\ """) test.run( - arguments='--warn=no-tool-qt-deprecated', stderr=TestSCons.noisy_ar, match=TestSCons.match_re_dotall, ) -test.up_to_date(options="--warn=no-tool-qt-deprecated", arguments=".") +test.up_to_date(arguments=".") test.pass_test() diff --git a/test/QT/qt3/installed.py b/test/QT/qt3/installed.py index 9e8693e3f..71ff98fb7 100644 --- a/test/QT/qt3/installed.py +++ b/test/QT/qt3/installed.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -Look if qt is installed, and try out all builders. +Look if qt3 is installed, and try out all builders. """ import os @@ -56,7 +56,7 @@ try: except KeyError: ENV_PATH=ENV.get('PATH', '') -env = Environment(tools=['default','qt'], +env = Environment(tools=['default','qt3'], ENV={'PATH':ENV_PATH, 'PATHEXT':os.environ.get('PATHEXT'), 'HOME':os.getcwd(), @@ -65,9 +65,9 @@ env = Environment(tools=['default','qt'], CXXFILESUFFIX=".cpp") conf = env.Configure() -if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): - conf.env['QT_LIB'] = 'qt-mt' - if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0): +if not conf.CheckLib(env.subst("$QT3_LIB"), autoadd=0): + conf.env['QT3_LIB'] = 'qt-mt' + if not conf.CheckLib(env.subst("$QT3_LIB"), autoadd=0): Exit(0) env = conf.Finish() VariantDir('bld', '.') @@ -196,18 +196,18 @@ if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status: sys.stdout.write('test_realqt returned status %s\n' % test.status) test.fail_test() -QTDIR = os.environ['QTDIR'] +QT3DIR = os.environ['QTDIR'] PATH = os.environ['PATH'] os.environ['QTDIR'] = '' os.environ['PATH'] = '.' test.run( stderr=None, - arguments="--warn=no-tool-qt-deprecated -c bld/test_realqt" + TestSCons._exe, + arguments="-c bld/test_realqt" + TestSCons._exe, ) -expect1 = "scons: warning: Could not detect qt, using empty QTDIR" -expect2 = "scons: warning: Could not detect qt, using moc executable as a hint" +expect1 = "scons: warning: Could not detect qt3, using empty QT3DIR" +expect2 = "scons: warning: Could not detect qt3, using moc executable as a hint" test.fail_test(expect1 not in test.stderr() and expect2 not in test.stderr()) diff --git a/test/QT/qt3/manual.py b/test/QT/qt3/manual.py index 84c6df8e0..f467b5ae2 100644 --- a/test/QT/qt3/manual.py +++ b/test/QT/qt3/manual.py @@ -24,7 +24,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -Test the manual QT builder calls. +Test the manual QT3 builder calls. """ import TestSCons @@ -51,7 +51,7 @@ sources.extend(env.Uic('ui/ccc.ui')[1:]) # manual target specification sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h', - QT_MOCHPREFIX='')) # Watch out ! + QT3_MOCHPREFIX='')) # Watch out ! moc = env.Moc('moc_eee.cpp', 'eee.cpp') env.Ignore( moc, moc ) sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], @@ -61,7 +61,7 @@ print(list(map(str,sources))) env.Program(target='aaa', source=sources, CPPPATH=['$CPPPATH', './include'], - QT_AUTOSCAN=0) + QT3_AUTOSCAN=0) """) test.write('aaa.cpp', r""" @@ -123,7 +123,7 @@ int main(void) { } """) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_exe) +test.run(arguments=aaa_exe) # normal invocation test.must_exist(test.workpath('include', 'moc_aaa.cc')) diff --git a/test/QT/qt3/qt_warnings.py b/test/QT/qt3/qt_warnings.py index fb23a7151..1cbf2b013 100644 --- a/test/QT/qt3/qt_warnings.py +++ b/test/QT/qt3/qt_warnings.py @@ -51,7 +51,7 @@ import os env.StaticLibrary('aaa.cpp') """) -test.run(arguments="--warn=no-tool-qt-deprecated", stderr=None) +test.run(stderr=None) match12 = r""" scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' @@ -64,7 +64,7 @@ if not re.search(match12, test.stderr()): os.environ['QTDIR'] = test.QT -test.run(arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') +test.run(arguments='-n noqtdir=1') # We'd like to eliminate $QTDIR from the environment as follows: # del os.environ['QTDIR'] @@ -74,7 +74,7 @@ test.run(arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') # environment, so it only gets removed from the Python dictionary. # Consequently, we need to just wipe out its value as follows> os.environ['QTDIR'] = '' -test.run(stderr=None, arguments='--warn=no-tool-qt-deprecated -n noqtdir=1') +test.run(stderr=None, arguments='-n noqtdir=1') moc = test.where_is('moc') if moc: @@ -83,13 +83,13 @@ if moc: qtdir = qtdir.replace('\\', '\\\\' ) expect = r""" -scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\) +scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR=%s\) File "%s", line \d+, in (\?|) """ % (qtdir, re.escape(SConstruct_path)) else: expect = r""" -scons: warning: Could not detect qt, using empty QTDIR +scons: warning: Could not detect qt3, using empty QT3DIR File "%s", line \d+, in (\?|) """ % re.escape(SConstruct_path) diff --git a/test/QT/qt3/reentrant.py b/test/QT/qt3/reentrant.py index 40fb1f19a..be6d8a62f 100644 --- a/test/QT/qt3/reentrant.py +++ b/test/QT/qt3/reentrant.py @@ -49,7 +49,7 @@ test.Qt_create_SConstruct('SConstruct') test.write('SConscript', """\ Import("env") -env = env.Clone(tools=['qt']) +env = env.Clone(tools=['qt3']) env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[]) """) diff --git a/test/QT/qt3/source-from-ui.py b/test/QT/qt3/source-from-ui.py index 569fbab2c..1404f7532 100644 --- a/test/QT/qt3/source-from-ui.py +++ b/test/QT/qt3/source-from-ui.py @@ -67,9 +67,9 @@ void useit() { } """) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) +test.run(arguments=aaa_dll) -test.up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=aaa_dll) +test.up_to_date(options='-n', arguments=aaa_dll) test.write('aaa.ui', r""" /* a change */ @@ -81,11 +81,11 @@ test.write('aaa.ui', r""" DLLEXPORT void aaa(void) """) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) +test.not_up_to_date(options='-n', arguments=moc) +test.not_up_to_date(options='-n', arguments=cpp) +test.not_up_to_date(options='-n', arguments=h) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) +test.run(arguments=" " + aaa_dll) test.write('aaa.ui', r""" void aaa(void) @@ -93,28 +93,28 @@ void aaa(void) """) # test that non-existant ui.h files are ignored (as uic does) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) +test.run(arguments=" " + aaa_dll) test.write('aaa.ui.h', r""" /* test dependency to .ui.h */ """) -test.run(arguments="--warn=no-tool-qt-deprecated " + aaa_dll) +test.run(arguments=" " + aaa_dll) test.write('aaa.ui.h', r""" /* changed */ """) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=obj) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=cpp) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=h) -test.not_up_to_date(options='--warn=no-tool-qt-deprecated -n', arguments=moc) +test.not_up_to_date(options='-n', arguments=obj) +test.not_up_to_date(options='-n', arguments=cpp) +test.not_up_to_date(options='-n', arguments=h) +test.not_up_to_date(options='-n', arguments=moc) # clean up -test.run(arguments="--warn=no-tool-qt-deprecated -c " + aaa_dll) +test.run(arguments=" -c " + aaa_dll) test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + arguments="variant_dir=1 " + test.workpath('build', aaa_dll) ) @@ -129,7 +129,7 @@ cppContents = test.read(test.workpath('build', cpp), mode='r') test.fail_test(cppContents.find('#include "aaa.ui.h"') == -1) test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + arguments="variant_dir=1 chdir=1 " + test.workpath('build', aaa_dll) ) @@ -141,7 +141,7 @@ test.must_not_exist(test.workpath(cpp)) test.must_not_exist(test.workpath(h)) test.run( - arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 dup=0 " + arguments=" variant_dir=1 chdir=1 dup=0 " + test.workpath('build_dup0', aaa_dll) ) diff --git a/test/QT/qt3/up-to-date.py b/test/QT/qt3/up-to-date.py index 06fb5590e..ec5123827 100644 --- a/test/QT/qt3/up-to-date.py +++ b/test/QT/qt3/up-to-date.py @@ -53,7 +53,7 @@ test.write('SConstruct', """\ import os aa=os.getcwd() -env=Environment(tools=['default','expheaders','qt'],toolpath=[aa]) +env=Environment(tools=['default','expheaders','qt3'],toolpath=[aa]) env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include') if not os.access(env["EXP_HEADER_ABS"],os.F_OK): os.mkdir (env["EXP_HEADER_ABS"]) diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index b6c9f094b..224a8cf9d 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -1175,14 +1175,17 @@ else: def Qt_create_SConstruct(self, place, qt_tool='qt3'): if isinstance(place, list): place = test.workpath(*place) + + var_prefix=qt_tool.upper() self.write(place, f"""\ if ARGUMENTS.get('noqtdir', 0): - QTDIR = None + {var_prefix}DIR = None else: - QTDIR = r'{self.QT}' + {var_prefix}DIR = r'{self.QT}' DefaultEnvironment(tools=[]) # test speedup env = Environment( - QTDIR=QTDIR, QT_LIB=r'{self.QT_LIB}', QT_MOC=r'{self.QT_MOC}', QT_UIC=r'{self.QT_UIC}', tools=['default', '{qt_tool}'] + {var_prefix}DIR={var_prefix}DIR, {var_prefix}_LIB=r'{self.QT_LIB}', {var_prefix}_MOC=r'{self.QT_MOC}', + {var_prefix}_UIC=r'{self.QT_UIC}', tools=['default', '{qt_tool}'] ) dup = 1 if ARGUMENTS.get('variant_dir', 0): -- cgit v1.2.1 From 6df636f3a3a6058dd720f6ce301a0db368fea8e2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 24 Feb 2023 03:49:33 +0000 Subject: fix test/import.py for qt3 changes --- test/import.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/import.py b/test/import.py index 55a40cc43..997e6c4e6 100644 --- a/test/import.py +++ b/test/import.py @@ -130,13 +130,13 @@ if moc: qtdir = os.path.dirname(os.path.dirname(moc)) qt_err = r""" -scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%(qtdir)s\) +scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR=%(qtdir)s\) """ % locals() else: qt_err = """ -scons: warning: Could not detect qt, using empty QTDIR +scons: warning: Could not detect qt3, using empty QT3DIR """ qt_warnings = [ re.compile(qt_err + TestSCons.file_expr) ] @@ -144,7 +144,7 @@ qt_warnings = [ re.compile(qt_err + TestSCons.file_expr) ] error_output = { 'icl' : intel_warnings, 'intelc' : intel_warnings, - 'qt' : qt_warnings, + 'qt3' : qt_warnings, } # An SConstruct for importing Tool names that have illegal characters -- cgit v1.2.1 From ea8c3ee4c644c0e30fdefea4cac1f8c7e18a9375 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 24 Feb 2023 05:28:32 +0000 Subject: add placeholder tool qt to instruct users to switch to qt3 --- SCons/Tool/qt.py | 35 +++++++++++++++++++++++++++++++++++ SCons/Tool/qt.xml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 SCons/Tool/qt.py create mode 100644 SCons/Tool/qt.xml diff --git a/SCons/Tool/qt.py b/SCons/Tool/qt.py new file mode 100644 index 000000000..8e34eb7cd --- /dev/null +++ b/SCons/Tool/qt.py @@ -0,0 +1,35 @@ +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +This is a fake tool to instruct any builds still referencing 'qt' instead +of the new 'qt3' or a newer QT builder how to fix their now broken build. +""" +import SCons.Warnings + +def generate(env): + pass + +def exists(env): + return False + diff --git a/SCons/Tool/qt.xml b/SCons/Tool/qt.xml new file mode 100644 index 000000000..3ba71b92c --- /dev/null +++ b/SCons/Tool/qt.xml @@ -0,0 +1,34 @@ + + + + +%scons; + +%builders-mod; + +%functions-mod; + +%tools-mod; + +%variables-mod; +]> + + + + + + +Placeholder tool to alert anyone still using qt tools to switch to qt3 or newer tool. + + + + + -- cgit v1.2.1 From cc77c4bfe5130ddeed0bf176b0b733abb25eadea Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 24 Feb 2023 05:33:22 +0000 Subject: Fix qt3 -> QT3 typos --- SCons/Tool/qt3.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SCons/Tool/qt3.xml b/SCons/Tool/qt3.xml index 88df2e8f2..306b53c07 100644 --- a/SCons/Tool/qt3.xml +++ b/SCons/Tool/qt3.xml @@ -79,7 +79,7 @@ directory. It must have one of the suffixes .hxx, .hh. You can turn off automatic moc file generation by setting -&cv-link-qt3_AUTOSCAN; to False. +&cv-link-QT3_AUTOSCAN; to False. See also the corresponding &b-link-Moc; Builder. @@ -89,7 +89,7 @@ See also the corresponding As described in the Qt documentation, include the moc file at the end of the C++ file. Note that you have to include the file, which is generated by the transformation -${qt3_MOCCXXPREFIX}<basename>${QT3_MOCCXXSUFFIX}, by default +${QT3_MOCCXXPREFIX}<basename>${QT3_MOCCXXSUFFIX}, by default <basename>.mo. A warning is generated after building the moc file if you do not include the correct file. If you are using &f-link-VariantDir;, you may need to specify duplicate=True. @@ -149,7 +149,7 @@ See also the corresponding Builds an output file from a moc input file. moc input files are either header files or C++ files. This builder is only available after using the -tool &t-link-qt;. See the &cv-link-QT3DIR; variable for more information. +tool &t-link-qt3;. See the &cv-link-QT3DIR; variable for more information. Example: @@ -165,7 +165,7 @@ env.Moc('foo.cpp') # generates foo.moc Builds a header file, an implementation file and a moc file from an ui file. and returns the corresponding nodes in the that order. -This builder is only available after using the tool &t-link-qt;. +This builder is only available after using the tool &t-link-qt3;. Note: you can specify .ui files directly as source files to the &b-link-Program;, &b-link-Library; and &b-link-SharedLibrary; builders @@ -191,7 +191,7 @@ env.Uic( The path to the Qt installation to build against. If not already set, -&t-link-qt; tool tries to obtain this from +&t-link-qt3; tool tries to obtain this from os.environ; if not found there, it tries to make a guess. -- cgit v1.2.1 From a4c586aaf7d453c6f202ec1c026fdacb4f9eb9c8 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 1 Mar 2023 07:51:25 -0700 Subject: Update PR 4305: failing stub qt tool Proposed addition of code to cause stub qt to fail, and test/import.py to detect this situation. Unfortunately, it doesn't seem to work... needs adjustment. Doc updates to record rename version. Signed-off-by: Mats Wichmann --- SCons/Tool/qt.py | 9 ++++-- SCons/Tool/qt3.xml | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++- test/import.py | 27 ++++++++++-------- 3 files changed, 102 insertions(+), 16 deletions(-) diff --git a/SCons/Tool/qt.py b/SCons/Tool/qt.py index 8e34eb7cd..607b58d83 100644 --- a/SCons/Tool/qt.py +++ b/SCons/Tool/qt.py @@ -25,11 +25,14 @@ This is a fake tool to instruct any builds still referencing 'qt' instead of the new 'qt3' or a newer QT builder how to fix their now broken build. """ -import SCons.Warnings +import SCons.Errors def generate(env): - pass + raise SCons.Errors.UserError( + "Deprecated tool 'qt' renamed to 'qt3'. " + "Please update your build accordingly. " + "'qt3' will be removed entirely in a future release." + ) def exists(env): return False - diff --git a/SCons/Tool/qt3.xml b/SCons/Tool/qt3.xml index 306b53c07..445751b5e 100644 --- a/SCons/Tool/qt3.xml +++ b/SCons/Tool/qt3.xml @@ -32,7 +32,9 @@ Sets &consvars; for building Qt3 applications. This tool is only suitable for building targeted to Qt3, which is obsolete -(the tool is deprecated since 4.3). +(the tool is deprecated since 4.3, +and was renamed to qt3 in 4.5.0. +). There are contributed tools for Qt4 and Qt5, see https://github.com/SCons/scons-contrib. @@ -195,6 +197,9 @@ If not already set, os.environ; if not found there, it tries to make a guess. + +Changed in 4.5.0: renamed from QTDIR. + @@ -204,6 +209,9 @@ if not found there, it tries to make a guess. Turn off scanning for mocable files. Use the &b-link-Moc; Builder to explicitly specify files to run moc on. + +Changed in 4.5.0: renamed from QT_AUTOSCAN. + @@ -213,6 +221,9 @@ specify files to run moc on. The path where the Qt binaries are installed. The default value is '&cv-link-QT3DIR;/bin'. + +Changed in 4.5.0: renamed from QT_BINPATH. + @@ -225,6 +236,9 @@ Note: If you set this variable to None, the tool won't change the &cv-link-CPPPATH; construction variable. + +Changed in 4.5.0: renamed from QT_CPPPATH. + @@ -233,6 +247,9 @@ construction variable. Prints lots of debugging information while scanning for moc files. + +Changed in 4.5.0: renamed from QT_DEBUG. + @@ -244,6 +261,9 @@ You may want to set this to 'qt-mt'. Note: If you set this variable to None, the tool won't change the &cv-link-LIBS; variable. + +Changed in 4.5.0: renamed from QT_LIB. + @@ -256,6 +276,9 @@ Note: If you set this variable to None, the tool won't change the &cv-link-LIBPATH; construction variable. + +Changed in 4.5.0: renamed from QT_LIBPATH. + @@ -282,6 +305,9 @@ Prefix for moc output files when source is a C++ file. Default value is '.moc'. Suffix for moc output files when source is a C++ file. + +Changed in 4.5.0: renamed from QT_MOCCXXSUFFIX. + @@ -291,6 +317,9 @@ Suffix for moc output files when source is a C++ file. Default value is '-i'. These flags are passed to moc when moccing a C++ file. + +Changed in 4.5.0: renamed from QT_MOCFROMCXXFLAGS. + @@ -299,6 +328,9 @@ These flags are passed to moc when moccing a C++ file. Command to generate a moc file from a C++ file. + +Changed in 4.5.0: renamed from QT_MOCFROMCXXCOM. + @@ -308,6 +340,9 @@ Command to generate a moc file from a C++ file. The string displayed when generating a moc file from a C++ file. If this is not set, then &cv-link-QT3_MOCFROMCXXCOM; (the command line) is displayed. + +Changed in 4.5.0: renamed from QT_MOCFROMCXXCOMSTR. + @@ -316,6 +351,9 @@ If this is not set, then &cv-link-QT3_MOCFROMCXXCOM; (the command line) is displ Command to generate a moc file from a header. + +Changed in 4.5.0: renamed from QT_MOCFROMSHCOM. + @@ -325,6 +363,9 @@ Command to generate a moc file from a header. The string displayed when generating a moc file from a C++ file. If this is not set, then &cv-link-QT3_MOCFROMHCOM; (the command line) is displayed. + +Changed in 4.5.0: renamed from QT_MOCFROMSHCOMSTR. + @@ -334,6 +375,9 @@ If this is not set, then &cv-link-QT3_MOCFROMHCOM; (the command line) is display Default value is ''. These flags are passed to moc when moccing a header file. + +Changed in 4.5.0: renamed from QT_MOCFROMSHFLAGS. + @@ -343,6 +387,9 @@ when moccing a header file. Default value is 'moc_'. Prefix for moc output files when source is a header. + +Changed in 4.5.0: renamed from QT_MOCHPREFIX. + @@ -352,6 +399,9 @@ Prefix for moc output files when source is a header. Default value is '&cv-link-CXXFILESUFFIX;'. Suffix for moc output files when source is a header. + +Changed in 4.5.0: renamed from QT_MOCHSUFFIX. + @@ -360,6 +410,9 @@ Suffix for moc output files when source is a header. Default value is '&cv-link-QT3_BINPATH;/uic'. + +Changed in 4.5.0: renamed from QT_UIC. + @@ -368,6 +421,9 @@ Default value is '&cv-link-QT3_BINPATH;/uic'. Command to generate header files from .ui files. + +Changed in 4.5.0: renamed from QT_UICCOM. + @@ -377,6 +433,9 @@ Command to generate header files from .ui files. The string displayed when generating header files from .ui files. If this is not set, then &cv-link-QT3_UICCOM; (the command line) is displayed. + +Changed in 4.5.0: renamed from QT_UICCOMSTR. + @@ -386,6 +445,9 @@ If this is not set, then &cv-link-QT3_UICCOM; (the command line) is displayed. Default value is ''. These flags are passed to uic when creating a header file from a .ui file. + +Changed in 4.5.0: renamed from QT_UICDECLFLAGS. + @@ -395,6 +457,9 @@ when creating a header file from a .ui file. Default value is ''. Prefix for uic generated header files. + +Changed in 4.5.0: renamed from QT_UICDECLPREFIX. + @@ -404,6 +469,9 @@ Prefix for uic generated header files. Default value is '.h'. Suffix for uic generated header files. + +Changed in 4.5.0: renamed from QT_UICDECLSUFFIX. + @@ -414,6 +482,9 @@ Default value is ''. These flags are passed to uic when creating a C++ file from a .ui file. + +Changed in 4.5.0: renamed from QT_UICIMPFLAGS. + @@ -423,6 +494,9 @@ file from a .ui file. Default value is 'uic_'. Prefix for uic generated implementation files. + +Changed in 4.5.0: renamed from QT_UICIMPLPREFIX. + @@ -432,6 +506,9 @@ Prefix for uic generated implementation files. Default value is '&cv-link-CXXFILESUFFIX;'. Suffix for uic generated implementation files. + +Changed in 4.5.0: renamed from QT_UICIMPLSUFFIX. + @@ -441,6 +518,9 @@ files. Default value is '.ui'. Suffix of designer input files. + +Changed in 4.5.0: renamed from QT_UISUFFIX. + diff --git a/test/import.py b/test/import.py index 997e6c4e6..037508dd9 100644 --- a/test/import.py +++ b/test/import.py @@ -128,23 +128,26 @@ if moc: import os.path qtdir = os.path.dirname(os.path.dirname(moc)) - - qt_err = r""" -scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR=%(qtdir)s\) -""" % locals() - + qt3_err = fr""" +scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR={qtdir}\) +""" else: - - qt_err = """ + qt3_err = r""" scons: warning: Could not detect qt3, using empty QT3DIR """ -qt_warnings = [ re.compile(qt_err + TestSCons.file_expr) ] +qt_moved = r""" +scons: \*\*\* Deprecated tool 'qt' has moved to 'qt3'. Please update your build accordingly. 'qt3' will be removed entirely in a future release. +""" + +qt3_warnings = [re.compile(qt3_err + TestSCons.file_expr)] +qt_error = [re.compile(qt_moved + TestSCons.file_expr)] error_output = { - 'icl' : intel_warnings, - 'intelc' : intel_warnings, - 'qt3' : qt_warnings, + 'icl': intel_warnings, + 'intelc': intel_warnings, + 'qt3': qt3_warnings, + 'qt': qt_error, } # An SConstruct for importing Tool names that have illegal characters @@ -187,7 +190,7 @@ for tool in tools: matched = 1 break if not matched: - print("Failed importing '%s', stderr:" % tool) + print(f"Failed importing '{tool}', stderr:") print(stderr) failures.append(tool) -- cgit v1.2.1 From 5e9e2eb6fced85e8cc59d1fcaa9ecb10b2d8f5aa Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 1 Mar 2023 14:00:43 -0700 Subject: test/import works on dummy qt tool now Signed-off-by: Mats Wichmann --- test/import.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/import.py b/test/import.py index 037508dd9..50d7b2178 100644 --- a/test/import.py +++ b/test/import.py @@ -137,7 +137,7 @@ scons: warning: Could not detect qt3, using empty QT3DIR """ qt_moved = r""" -scons: \*\*\* Deprecated tool 'qt' has moved to 'qt3'. Please update your build accordingly. 'qt3' will be removed entirely in a future release. +scons: \*\*\* Deprecated tool 'qt' renamed to 'qt3'. Please update your build accordingly. 'qt3' will be removed entirely in a future release. """ qt3_warnings = [re.compile(qt3_err + TestSCons.file_expr)] @@ -181,9 +181,9 @@ for tool in tools: test.write('SConstruct', indirect_import % locals()) else: test.write('SConstruct', direct_import % locals()) - test.run(stderr=None) + test.run(stderr=None, status=None) stderr = test.stderr() - if stderr: + if stderr or test.status: matched = None for expression in error_output.get(tool, []): if expression.match(stderr): -- cgit v1.2.1