X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=scripts%2Fbuild%2Fmacosx_qt.py;fp=scripts%2Fbuild%2Fmacosx_qt.py;h=3955364e4aa81357fbdba0b80eaf5740976ac731;hp=0000000000000000000000000000000000000000;hb=528af0d9d853d40c6ab5b2b753cc4644b6ddcdd1;hpb=c144bdee0d8ab0c195b3088f5c6e57e372e526f7 diff --git a/scripts/build/macosx_qt.py b/scripts/build/macosx_qt.py new file mode 100755 index 00000000..3955364e --- /dev/null +++ b/scripts/build/macosx_qt.py @@ -0,0 +1,108 @@ +#!/usr/bin/python +# -*- coding: iso-8859-1 -*- + +################################################################################ +# # +# 2008 June 27th by Marcus 'EgS' Eggenberger # +# # +# The author disclaims copyright to this source code. # +# This Python Script is in the PUBLIC DOMAIN. # +# # +################################################################################ + +# ============================== +# Imports +# ============================== +import os +from subprocess import Popen, PIPE + +# ============================== +# Global Functions +# ============================== +def qtProperty(qtProperty): + """ + Query persistent property of Qt via qmake + """ + VALID_PROPERTIES = ['QT_INSTALL_PREFIX', + 'QT_INSTALL_DATA', + 'QT_INSTALL_DOCS', + 'QT_INSTALL_HEADERS', + 'QT_INSTALL_LIBS', + 'QT_INSTALL_BINS', + 'QT_INSTALL_PLUGINS', + 'QT_INSTALL_IMPORTS', + 'QT_INSTALL_TRANSLATIONS', + 'QT_INSTALL_CONFIGURATION', + 'QT_INSTALL_EXAMPLES', + 'QT_INSTALL_DEMOS', + 'QMAKE_MKSPECS', + 'QMAKE_VERSION', + 'QT_VERSION' + ] + if qtProperty not in VALID_PROPERTIES: + return None + + qmakeProcess = Popen('qmake -query %s' % qtProperty, shell=True, stdout=PIPE, stderr=PIPE) + result = qmakeProcess.stdout.read().strip() + qmakeProcess.stdout.close() + qmakeProcess.wait() + return result + +def qtMakespec(qtMakespec): + """ + Query a Makespec value of Qt via qmake + """ + + VALID_PROPERTIES = ['QMAKE_MACOSX_DEPLOYMENT_TARGET', + ] + if qtMakespec not in VALID_PROPERTIES: + return None + + # QMAKE_MACOSX_DEPLOYMENT_TARGET sadly cannot be queried in the traditional way + # + # Inspired by https://code.qt.io/cgit/pyside/pyside-setup.git/tree/qtinfo.py?h=5.6 + # Simplified, no caching, etc, as we're just looking for the macOS version. + # If a cleaner solution is desired, look into license compatibility in + # order to simply copy the above code. + + current_dir = os.getcwd() + qmakeFakeProjectFile = os.path.join(current_dir, "qmake_empty_project.txt") + qmakeStashFile = os.path.join(current_dir, ".qmake.stash") + # Make an empty file + open(qmakeFakeProjectFile, 'a').close() + + qmakeProcess = Popen('qmake -E %s' % qmakeFakeProjectFile, shell=True, stdout=PIPE, stderr=PIPE) + result = qmakeProcess.stdout.read().strip() + qmakeProcess.stdout.close() + qmakeProcess.wait() + + # Clean up temporary files + try: + os.remove(qmakeFakeProjectFile) + except OSError: + pass + try: + os.remove(qmakeStashFile) + except OSError: + pass + + # Result should be like this: + # PROPERTY = VALUE\n + result_list = result.splitlines() + # Clear result so if nothing matches, nothing is returned + result = None + # Search keys + for line in result_list: + if not '=' in line: + # Ignore lines without '=' + continue + + # Find property = value + parts = line.split('=', 1) + prop = parts[0].strip() + value = parts[1].strip() + if (prop == qtMakespec): + result = value + break + + return result