3 # WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
5 import os,shutil,sys,platform
6 from waflib import TaskGen,Task,Build,Options,Utils,Errors
7 from waflib.TaskGen import taskgen_method,feature,after_method,before_method
9 <?xml version="1.0" encoding="UTF-8"?>
10 <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
13 <key>CFBundlePackageType</key>
15 <key>CFBundleGetInfoString</key>
16 <string>Created by Waf</string>
17 <key>CFBundleSignature</key>
20 <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
21 <key>CFBundleExecutable</key>
27 def set_macosx_deployment_target(self):
28 if self.env['MACOSX_DEPLOYMENT_TARGET']:
29 os.environ['MACOSX_DEPLOYMENT_TARGET']=self.env['MACOSX_DEPLOYMENT_TARGET']
30 elif'MACOSX_DEPLOYMENT_TARGET'not in os.environ:
31 if Utils.unversioned_sys_platform()=='darwin':
32 os.environ['MACOSX_DEPLOYMENT_TARGET']='.'.join(platform.mac_ver()[0].split('.')[:2])
34 def create_bundle_dirs(self,name,out):
36 dir=out.parent.find_or_declare(name)
38 macos=dir.find_or_declare(['Contents','MacOS'])
41 def bundle_name_for_output(out):
49 @feature('cprogram','cxxprogram')
50 @after_method('apply_link')
51 def create_task_macapp(self):
52 if self.env['MACAPP']or getattr(self,'mac_app',False):
53 out=self.link_task.outputs[0]
54 name=bundle_name_for_output(out)
55 dir=self.create_bundle_dirs(name,out)
56 n1=dir.find_or_declare(['Contents','MacOS',out.name])
57 self.apptask=self.create_task('macapp',self.link_task.outputs,n1)
58 inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/MacOS/'%name
59 self.bld.install_files(inst_to,n1,chmod=Utils.O755)
60 if getattr(self,'mac_resources',None):
61 res_dir=n1.parent.parent.make_node('Resources')
62 inst_to=getattr(self,'install_path','/Applications')+'/%s/Resources'%name
63 for x in self.to_list(self.mac_resources):
64 node=self.path.find_node(x)
66 raise Errors.WafError('Missing mac_resource %r in %r'%(x,self))
68 if os.path.isdir(node.abspath()):
69 nodes=node.ant_glob('**')
73 rel=node.path_from(parent)
74 tsk=self.create_task('macapp',node,res_dir.make_node(rel))
75 self.bld.install_as(inst_to+'/%s'%rel,node)
76 if getattr(self.bld,'is_install',None):
77 self.install_task.hasrun=Task.SKIP_ME
78 @feature('cprogram','cxxprogram')
79 @after_method('apply_link')
80 def create_task_macplist(self):
81 if self.env['MACAPP']or getattr(self,'mac_app',False):
82 out=self.link_task.outputs[0]
83 name=bundle_name_for_output(out)
84 dir=self.create_bundle_dirs(name,out)
85 n1=dir.find_or_declare(['Contents','Info.plist'])
86 self.plisttask=plisttask=self.create_task('macplist',[],n1)
87 if getattr(self,'mac_plist',False):
88 node=self.path.find_resource(self.mac_plist)
90 plisttask.inputs.append(node)
92 plisttask.code=self.mac_plist
94 plisttask.code=app_info%self.link_task.outputs[0].name
95 inst_to=getattr(self,'install_path','/Applications')+'/%s/Contents/'%name
96 self.bld.install_files(inst_to,n1)
97 @feature('cshlib','cxxshlib')
98 @before_method('apply_link','propagate_uselib_vars')
99 def apply_bundle(self):
100 if self.env['MACBUNDLE']or getattr(self,'mac_bundle',False):
101 self.env['LINKFLAGS_cshlib']=self.env['LINKFLAGS_cxxshlib']=[]
102 self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['macbundle_PATTERN']
103 use=self.use=self.to_list(getattr(self,'use',[]))
104 if not'MACBUNDLE'in use:
105 use.append('MACBUNDLE')
106 app_dirs=['Contents','Contents/MacOS','Contents/Resources']
107 class macapp(Task.Task):
110 self.outputs[0].parent.mkdir()
111 shutil.copy2(self.inputs[0].srcpath(),self.outputs[0].abspath())
112 class macplist(Task.Task):
116 if getattr(self,'code',None):
119 txt=self.inputs[0].read()
120 self.outputs[0].write(txt)