X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=scripts%2Fbuild%2Fmacosx_DeployApp.py;h=a7aae571baec7e127c97420b923684cf6b60fb48;hp=a46b5dca4184d59fe792d782761b121b7f810a48;hb=5745311bc102bf2361cee0f3a5c4d442a05ac64e;hpb=cf17ae38dd425697d0d8e22d50fb16f2bc821df6 diff --git a/scripts/build/macosx_DeployApp.py b/scripts/build/macosx_DeployApp.py index a46b5dca..a7aae571 100755 --- a/scripts/build/macosx_DeployApp.py +++ b/scripts/build/macosx_DeployApp.py @@ -31,27 +31,34 @@ class InstallQt(object): else: self.frameworkDir = self.executableDir + "/Frameworks" - self.needFrameworks = [] + self.installedFrameworks = set() self.findFrameworkPath() executables = [self.executableDir + "/" + executable for executable in os.listdir(self.executableDir)] - for executable in executables: - for framework,lib in self.determineDependancies(executable): - if framework not in self.needFrameworks: - self.needFrameworks.append(framework) - self.installFramework(framework) - self.changeDylPath(executable) + self.resolveDependancies(executable) def findFrameworkPath(self): - otoolProcess = Popen('qmake -query QT_INSTALL_LIBS', shell=True, stdout=PIPE, stderr=PIPE) - self.sourceFrameworkPath = otoolProcess.stdout.read().strip() - otoolProcess.stdout.close() - otoolProcess.wait() + qmakeProcess = Popen('qmake -query QT_INSTALL_LIBS', shell=True, stdout=PIPE, stderr=PIPE) + self.sourceFrameworkPath = qmakeProcess.stdout.read().strip() + qmakeProcess.stdout.close() + qmakeProcess.wait() + def resolveDependancies(self, obj): + # obj must be either an application binary or a framework library + for framework, lib in self.determineDependancies(obj): + self.installFramework(framework) + self.changeDylPath(obj, lib) def installFramework(self, framework): + # skip if framework is already installed. + if framework in self.installedFrameworks: + return + + self.installedFrameworks.add(framework) + + # ensure that the framework directory exists try: os.mkdir(self.frameworkDir) except: @@ -88,27 +95,28 @@ class InstallQt(object): newlibname = "@executable_path/%s%s" % (frameworkname, libpath) #print 'install_name_tool -id "%s" "%s"' % (newlibname, lib) os.system('install_name_tool -id "%s" "%s"' % (newlibname, lib)) - self.changeDylPath(lib) - + + self.resolveDependancies(lib) + def determineDependancies(self, app): otoolPipe = Popen('otool -L "%s"' % app, shell=True, stdout=PIPE).stdout otoolOutput = [line for line in otoolPipe] otoolPipe.close() - libs = [line.split()[0] for line in otoolOutput[1:] if "Qt" in line and not "@executable_path" in line] + libs = [line.split()[0] for line in otoolOutput[1:] if ("Qt" in line + or "phonon" in line) + and not "@executable_path" in line] frameworks = [lib[:lib.find(".framework")+len(".framework")] for lib in libs] return zip(frameworks, libs) - def changeDylPath(self, obj): - for framework, lib in self.determineDependancies(obj): - frameworkname = framework.split('/')[-1] - frameworkpath, libpath = lib.split(frameworkname) - if self.bundle: - newlibname = "@executable_path/../Frameworks/%s%s" % (frameworkname, libpath) - else: - newlibname = "@executable_path/Frameworks/%s%s" % (frameworkname, libpath) - #print 'install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj) - os.system('install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj)) + def changeDylPath(self, obj, lib): + if self.bundle: + newlibname = "@executable_path/../Frameworks/%s" % lib + else: + newlibname = "@executable_path/Frameworks/%s" % lib + + #print 'install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj) + os.system('install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj)) if __name__ == "__main__": if len(sys.argv) < 2: @@ -128,5 +136,3 @@ if __name__ == "__main__": targetDir += "/Contents" InstallQt(targetDir, bundle) - -