Changeset 904702d for waflib/Tools/glib2.py
- Timestamp:
- Mar 14, 2015, 6:06:10 PM (10 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 6d7acc8
- Parents:
- 5525507
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waflib/Tools/glib2.py
r5525507 r904702d 4 4 5 5 import os 6 from waflib import Task,Utils,Options,Errors,Logs 7 from waflib.TaskGen import taskgen_method,before_method,after_method,feature 6 from waflib import Context,Task,Utils,Options,Errors,Logs 7 from waflib.TaskGen import taskgen_method,before_method,after_method,feature,extension 8 from waflib.Configure import conf 8 9 @taskgen_method 9 10 def add_marshal_file(self,filename,prefix): … … 99 100 filename_list=[filename_list] 100 101 self.settings_enum_files=filename_list 101 def r_change_ext(self,ext):102 name=self.name103 k=name.rfind('.')104 if k>=0:105 name=name[:k]+ext106 else:107 name=name+ext108 return self.parent.find_or_declare([name])109 102 @feature('glib2') 110 103 def process_settings(self): … … 137 130 schema_task.set_inputs(source_list) 138 131 schema_task.env['GLIB_COMPILE_SCHEMAS_OPTIONS']=[("--schema-file="+k.abspath())for k in source_list] 139 target_node= r_change_ext(schema_node,'.xml.valid')132 target_node=schema_node.change_ext('.xml.valid') 140 133 schema_task.set_outputs(target_node) 141 134 schema_task.env['GLIB_VALIDATE_SCHEMA_OUTPUT']=target_node.abspath() … … 156 149 run_str='rm -f ${GLIB_VALIDATE_SCHEMA_OUTPUT} && ${GLIB_COMPILE_SCHEMAS} --dry-run ${GLIB_COMPILE_SCHEMAS_OPTIONS} && touch ${GLIB_VALIDATE_SCHEMA_OUTPUT}' 157 150 color='PINK' 158 def configure(conf): 151 @extension('.gresource.xml') 152 def process_gresource_source(self,node): 153 if not self.env['GLIB_COMPILE_RESOURCES']: 154 raise Errors.WafError("Unable to process GResource file - glib-compile-resources was not found during configure") 155 if'gresource'in self.features: 156 return 157 h_node=node.change_ext('_xml.h') 158 c_node=node.change_ext('_xml.c') 159 self.create_task('glib_gresource_source',node,[h_node,c_node]) 160 self.source.append(c_node) 161 @feature('gresource') 162 def process_gresource_bundle(self): 163 for i in self.to_list(self.source): 164 node=self.path.find_resource(i) 165 task=self.create_task('glib_gresource_bundle',node,node.change_ext('')) 166 inst_to=getattr(self,'install_path',None) 167 if inst_to: 168 self.bld.install_files(inst_to,task.outputs) 169 class glib_gresource_base(Task.Task): 170 color='BLUE' 171 base_cmd='${GLIB_COMPILE_RESOURCES} --sourcedir=${SRC[0].parent.srcpath()} --sourcedir=${SRC[0].bld_dir()}' 172 def scan(self): 173 bld=self.generator.bld 174 kw={} 175 try: 176 if not kw.get('cwd',None): 177 kw['cwd']=bld.cwd 178 except AttributeError: 179 bld.cwd=kw['cwd']=bld.variant_dir 180 kw['quiet']=Context.BOTH 181 cmd=Utils.subst_vars('${GLIB_COMPILE_RESOURCES} --sourcedir=%s --sourcedir=%s --generate-dependencies %s'%(self.inputs[0].parent.srcpath(),self.inputs[0].bld_dir(),self.inputs[0].bldpath()),self.env) 182 output=bld.cmd_and_log(cmd,**kw) 183 nodes=[] 184 names=[] 185 for dep in output.splitlines(): 186 if dep: 187 node=bld.bldnode.find_node(dep) 188 if node: 189 nodes.append(node) 190 else: 191 names.append(dep) 192 return(nodes,names) 193 class glib_gresource_source(glib_gresource_base): 194 vars=['GLIB_COMPILE_RESOURCES'] 195 fun_h=Task.compile_fun_shell(glib_gresource_base.base_cmd+' --target=${TGT[0].abspath()} --generate-header ${SRC}') 196 fun_c=Task.compile_fun_shell(glib_gresource_base.base_cmd+' --target=${TGT[1].abspath()} --generate-source ${SRC}') 197 ext_out=['.h'] 198 def run(self): 199 return self.fun_h[0](self)or self.fun_c[0](self) 200 class glib_gresource_bundle(glib_gresource_base): 201 run_str=glib_gresource_base.base_cmd+' --target=${TGT} ${SRC}' 202 shell=True 203 @conf 204 def find_glib_genmarshal(conf): 159 205 conf.find_program('glib-genmarshal',var='GLIB_GENMARSHAL') 160 conf.find_perl_program('glib-mkenums',var='GLIB_MKENUMS') 161 conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS',mandatory=False) 206 @conf 207 def find_glib_mkenums(conf): 208 if not conf.env.PERL: 209 conf.find_program('perl',var='PERL') 210 conf.find_program('glib-mkenums',interpreter='PERL',var='GLIB_MKENUMS') 211 @conf 212 def find_glib_compile_schemas(conf): 213 conf.find_program('glib-compile-schemas',var='GLIB_COMPILE_SCHEMAS') 162 214 def getstr(varname): 163 215 return getattr(Options.options,varname,getattr(conf.env,varname,'')) … … 170 222 gsettingsschemadir=os.path.join(datadir,'glib-2.0','schemas') 171 223 conf.env['GSETTINGSSCHEMADIR']=gsettingsschemadir 224 @conf 225 def find_glib_compile_resources(conf): 226 conf.find_program('glib-compile-resources',var='GLIB_COMPILE_RESOURCES') 227 def configure(conf): 228 conf.find_glib_genmarshal() 229 conf.find_glib_mkenums() 230 conf.find_glib_compile_schemas(mandatory=False) 231 conf.find_glib_compile_resources(mandatory=False) 172 232 def options(opt): 173 opt.add_option('--gsettingsschemadir',help='GSettings schema location [Default: ${datadir}/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR') 233 gr=opt.add_option_group('Installation directories') 234 gr.add_option('--gsettingsschemadir',help='GSettings schema location [DATADIR/glib-2.0/schemas]',default='',dest='GSETTINGSSCHEMADIR')
Note: See TracChangeset
for help on using the changeset viewer.