#! /usr/bin/env python
# encoding: utf-8
# Thomas Keller, 2006
APPNAME='guitone'
VERSION='0.5'
srcdir = '.'
blddir = '_build_'
# path to an *.icns file created with the Icon Composer app
iconsfile = 'guitone/res/osx/guitone.icns'
# array of languages (ISO 639 code) for a localized application menu
languages = (['de'])
import os
import sys
import shutil
import Params
import Runner
import Utils
Utils.waf_version(mini="1.0.0", maxi="1.4.9")
app_info = '''
CFBundlePackageType
APPL
CFBundleGetInfoString
Created by waf
CFBundleSignature
????
NOTE
Do not change this file, it will be overwritten by waf.
'''
app_info_foot = '''
'''
locversion = '''
LprojCompatibleVersion
123
LprojLocale
%s
LprojRevisionLevel
1
LprojVersion
123
'''
def build(bld):
bld.add_subdirs("guitone")
def configure(conf):
Runner.set_exec("noredir")
conf.check_tool('g++ Qt4')
def set_options(opt):
opt.tool_options('Qt4')
opt.add_option('--exe', action='store_true', default=False, help='execute the application')
if sys.platform == "darwin":
opt.add_option('--bundle', action='store_true', default=False, help='create a MacOS X application bundle')
def shutdown():
global APPNAME,blddir,app_info,app_info_foot,iconsfile,locversion,languages
app_bundle = blddir + '/default/bundle/' + APPNAME + '.app'
prog_bin = blddir + '/default/' + APPNAME + '/' + APPNAME
if Params.g_options.exe:
if sys.platform == "darwin" and os.path.exists(app_bundle):
os.popen('open "' + app_bundle + '"')
else:
os.popen(prog_bin)
if Params.g_options.bundle:
try:
# remove any old application bundle
if os.path.exists(app_bundle):
shutil.rmtree(app_bundle)
os.makedirs(app_bundle + '/Contents/MacOS')
# create the semi-useful PkgInfo file
f = file(app_bundle + '/Contents/PkgInfo', 'w')
f.write('APPL????')
f.close()
# copy the binary in position
shutil.copy(prog_bin, app_bundle + '/Contents/MacOS/' + os.path.basename(prog_bin))
# write Info.plist
f = file(os.path.join(app_bundle, "Contents", "Info.plist"), "w")
f.write(app_info)
f.write("\tCFBundleExecutable\n\t%s\n" % os.path.basename(prog_bin))
# if there is an icon file, add it to the bundle
if iconsfile != "":
f.write("\tCFBundleIconFile\n\t%s\n" % os.path.basename(iconsfile))
os.makedirs(app_bundle + '/Contents/Resources')
shutil.copy(iconsfile, app_bundle + '/Contents/Resources')
f.write(app_info_foot)
f.close()
# write locversion.plist files for each given language
for lang in languages:
langdir = app_bundle + '/Contents/Resources/' + lang + '.lproj'
os.makedirs(langdir)
f = file(os.path.join(langdir, "locversion.plist"), "w")
f.write(locversion % lang)
f.close()
except IOError, arg:
print "IOError", arg