2 # -*- coding: iso-8859-1 -*-
4 ################################################################################
6 # 2008 June 27th by Marcus 'EgS' Eggenberger <egs@quassel-irc.org> #
8 # The author disclaims copyright to this source code. #
9 # This Python Script is in the PUBLIC DOMAIN. #
11 ################################################################################
13 # ==============================
15 # ==============================
21 # Handling Qt properties
24 # ==============================
26 # ==============================
30 SOURCE_DIR = sys.argv[1]
33 BUNDLE_NAME = "Quassel Client"
34 EXE_NAME = "quasselclient"
36 EXE_NAME = sys.argv[3]
37 BUNDLE_NAME = sys.argv[2]
39 # make the dir of the exe the target dir
40 if(os.path.dirname(EXE_NAME)):
41 CONTENTS_DIR = os.path.dirname(EXE_NAME) + "/"
42 CONTENTS_DIR += BUNDLE_NAME + ".app/Contents/"
44 BUNDLE_VERSION = commands.getoutput("git --git-dir=" + SOURCE_DIR + "/.git/ describe")
45 ICONSET_FOLDER = "pics/iconset/"
50 os.makedirs(CONTENTS_DIR + "MacOS")
51 os.makedirs(CONTENTS_DIR + "Resources")
56 def copyFiles(exeFile, iconset):
57 os.system("cp %s %sMacOs/%s" % (exeFile, CONTENTS_DIR.replace(' ', '\ '), BUNDLE_NAME.replace(' ', '\ ')))
58 os.system("cp -r %s/%s %s/Resources/quassel.iconset/" % (SOURCE_DIR, iconset, CONTENTS_DIR.replace(' ', '\ ')))
61 def createPlist(bundleName, bundleVersion):
62 templateFile = file(SOURCE_DIR + "/scripts/build/Info.plist", 'r')
63 template = templateFile.read()
66 # Get the minimum macOS deployment version
67 QT_MACOSX_DEPLOYMENT_TARGET = macosx_qt.qtMakespec('QMAKE_MACOSX_DEPLOYMENT_TARGET')
68 # Keep in sync with QMAKE_MACOSX_DEPLOYMENT_TARGET
69 # See https://doc.qt.io/qt-5/macos.html
70 if QT_MACOSX_DEPLOYMENT_TARGET is None:
71 # Something went wrong
72 sys.exit("Could not determine 'QMAKE_MACOSX_DEPLOYMENT_TARGET', check build scripts")
73 print("Qt macOS deployment target (minimum version): %s" % QT_MACOSX_DEPLOYMENT_TARGET)
75 plistFile = file(CONTENTS_DIR + "Info.plist", 'w')
76 plistFile.write(template % {"BUNDLE_NAME": bundleName,
77 "ICON_FILE": "quassel.icns",
78 "BUNDLE_VERSION": bundleVersion,
79 "QT_MACOSX_DEPLOYMENT_TARGET": QT_MACOSX_DEPLOYMENT_TARGET})
83 os.system("iconutil -c icns %s/Resources/quassel.iconset" % CONTENTS_DIR.replace(' ', '\ '))
84 os.system("rm -R %s/Resources/quassel.iconset" % CONTENTS_DIR.replace(' ', '\ '))
86 if __name__ == "__main__":
88 createPlist(BUNDLE_NAME, BUNDLE_VERSION)
89 copyFiles(EXE_NAME, ICONSET_FOLDER)