<s> '''<STR_LIT>''' <EOL> from . . import build <EOL> import os , sys <EOL> import subprocess <EOL> from . . mesonlib import MesonException <EOL> from . . import mlog <EOL> from . . import mesonlib <EOL> girwarning_printed = False <EOL> gresource_warning_printed = False <EOL> class GnomeModule : <EOL> def __print_gresources_warning ( self ) : <EOL> global gresource_warning_printed <EOL> if not gresource_warning_printed : <EOL> mlog . log ( '<STR_LIT>' , <EOL> mlog . bold ( '<STR_LIT>' ) ) <EOL> gresource_warning_printed = True <EOL> return [ ] <EOL> def compile_resources ( self , state , args , kwargs ) : <EOL> self . __print_gresources_warning ( ) <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> source_dirs = kwargs . pop ( '<STR_LIT>' , [ ] ) <EOL> if not isinstance ( source_dirs , list ) : <EOL> source_dirs = [ source_dirs ] <EOL> ifile = args [ <NUM_LIT:1> ] <EOL> if isinstance ( ifile , mesonlib . File ) : <EOL> ifile = os . path . join ( ifile . subdir , ifile . fname ) <EOL> elif isinstance ( ifile , str ) : <EOL> ifile = os . path . join ( state . subdir , ifile ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> kwargs [ '<STR_LIT>' ] = self . get_gresource_dependencies ( state , ifile , source_dirs ) <EOL> for source_dir in source_dirs : <EOL> sourcedir = os . path . join ( state . build_to_src , state . subdir , source_dir ) <EOL> cmd += [ '<STR_LIT>' , sourcedir ] <EOL> if '<STR_LIT>' in kwargs : <EOL> cmd += [ '<STR_LIT>' , kwargs . pop ( '<STR_LIT>' ) ] <EOL> cmd += [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> kwargs [ '<STR_LIT>' ] = cmd <EOL> kwargs [ '<STR_LIT:input>' ] = args [ <NUM_LIT:1> ] <EOL> kwargs [ '<STR_LIT>' ] = args [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> target_c = build . CustomTarget ( args [ <NUM_LIT:0> ] + '<STR_LIT>' , state . subdir , kwargs ) <EOL> kwargs [ '<STR_LIT>' ] = args [ <NUM_LIT:0> ] + '<STR_LIT>' <EOL> target_h = build . CustomTarget ( args [ <NUM_LIT:0> ] + '<STR_LIT>' , state . subdir , kwargs ) <EOL> return [ target_c , target_h ] <EOL> def get_gresource_dependencies ( self , state , input_file , source_dirs ) : <EOL> self . __print_gresources_warning ( ) <EOL> cmd = [ '<STR_LIT>' , <EOL> input_file , <EOL> '<STR_LIT>' ] <EOL> for source_dir in source_dirs : <EOL> cmd += [ '<STR_LIT>' , os . path . join ( state . subdir , source_dir ) ] <EOL> pc = subprocess . Popen ( cmd , stdout = subprocess . PIPE , universal_newlines = True , <EOL> cwd = state . environment . get_source_dir ( ) ) <EOL> ( stdout , _ ) = pc . communicate ( ) <EOL> if pc . returncode != <NUM_LIT:0> : <EOL> mlog . log ( mlog . bold ( '<STR_LIT>' ) , '<STR_LIT>' . format ( cmd [ <NUM_LIT:1> ] ) ) <EOL> raise subprocess . CalledProcessError ( pc . returncode , cmd ) <EOL> return stdout . split ( '<STR_LIT:\n>' ) [ : - <NUM_LIT:1> ] <EOL> def generate_gir ( self , state , args , kwargs ) : <EOL> if len ( args ) != <NUM_LIT:1> : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> girtarget = args [ <NUM_LIT:0> ] <EOL> while hasattr ( girtarget , '<STR_LIT>' ) : <EOL> girtarget = girtarget . held_object <EOL> if not isinstance ( girtarget , ( build . Executable , build . SharedLibrary ) ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> try : <EOL> pkgstr = subprocess . check_output ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> except Exception : <EOL> global girwarning_printed <EOL> if not girwarning_printed : <EOL> mlog . log ( mlog . bold ( '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> girwarning_printed = True <EOL> return [ ] <EOL> pkgargs = pkgstr . decode ( ) . strip ( ) . split ( ) <EOL> ns = kwargs . pop ( '<STR_LIT>' ) <EOL> nsversion = kwargs . pop ( '<STR_LIT>' ) <EOL> libsources = kwargs . pop ( '<STR_LIT>' ) <EOL> girfile = '<STR_LIT>' % ( ns , nsversion ) <EOL> depends = [ girtarget ] <EOL> scan_command = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> scan_command += pkgargs <EOL> scan_command += [ '<STR_LIT>' , '<STR_LIT>' + ns , '<STR_LIT>' + nsversion , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> extra_args = kwargs . pop ( '<STR_LIT>' , [ ] ) <EOL> if not isinstance ( extra_args , list ) : <EOL> extra_args = [ extra_args ] <EOL> scan_command += extra_args <EOL> for incdirs in girtarget . include_dirs : <EOL> for incdir in incdirs . get_incdirs ( ) : <EOL> scan_command += [ '<STR_LIT>' % os . path . join ( state . environment . get_source_dir ( ) , incdir ) ] <EOL> if '<STR_LIT>' in kwargs : <EOL> link_with = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( link_with , list ) : <EOL> link_with = [ link_with ] <EOL> for link in link_with : <EOL> lib = link . held_object <EOL> scan_command += [ '<STR_LIT>' % lib . name ] <EOL> if isinstance ( lib , build . SharedLibrary ) : <EOL> scan_command += [ '<STR_LIT>' % <EOL> os . path . join ( state . environment . get_build_dir ( ) , <EOL> lib . subdir ) ] <EOL> depends . append ( lib ) <EOL> if '<STR_LIT>' in kwargs : <EOL> includes = kwargs . pop ( '<STR_LIT>' ) <EOL> if isinstance ( includes , str ) : <EOL> scan_command += [ '<STR_LIT>' % includes ] <EOL> elif isinstance ( includes , list ) : <EOL> scan_command += [ '<STR_LIT>' % inc for inc in includes ] <EOL> else : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> if state . global_args . get ( '<STR_LIT:c>' ) : <EOL> scan_command += [ '<STR_LIT>' ] <EOL> scan_command += state . global_args [ '<STR_LIT:c>' ] <EOL> scan_command += [ '<STR_LIT>' ] <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> sym_prefix = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( sym_prefix , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> scan_command += [ '<STR_LIT>' % sym_prefix ] <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> identifier_prefix = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( identifier_prefix , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> scan_command += [ '<STR_LIT>' % identifier_prefix ] <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> pkgs = kwargs . pop ( '<STR_LIT>' ) <EOL> if isinstance ( pkgs , str ) : <EOL> scan_command += [ '<STR_LIT>' % pkgs ] <EOL> elif isinstance ( pkgs , list ) : <EOL> scan_command += [ '<STR_LIT>' % pkg for pkg in pkgs ] <EOL> else : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> deps = None <EOL> if '<STR_LIT>' in kwargs : <EOL> deps = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( deps , list ) : <EOL> deps = [ deps ] <EOL> for dep in deps : <EOL> girdir = dep . held_object . get_variable ( "<STR_LIT>" ) <EOL> if girdir : <EOL> scan_command += [ "<STR_LIT>" % girdir ] <EOL> for lib in dep . held_object . libs : <EOL> if os . path . isabs ( lib ) and dep . held_object . is_libtool : <EOL> scan_command += [ "<STR_LIT>" % os . path . dirname ( lib ) ] <EOL> libname = os . path . basename ( lib ) <EOL> if libname . startswith ( "<STR_LIT>" ) : <EOL> libname = libname [ <NUM_LIT:3> : ] <EOL> libname = libname . split ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> lib = "<STR_LIT>" % libname <EOL> scan_command += [ lib ] <EOL> inc_dirs = None <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> inc_dirs = kwargs . pop ( '<STR_LIT>' ) <EOL> if not isinstance ( inc_dirs , list ) : <EOL> inc_dirs = [ inc_dirs ] <EOL> for ind in inc_dirs : <EOL> if isinstance ( ind . held_object , build . IncludeDirs ) : <EOL> scan_command += [ '<STR_LIT>' % inc for inc in ind . held_object . get_incdirs ( ) ] <EOL> else : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> if isinstance ( girtarget , build . Executable ) : <EOL> scan_command += [ '<STR_LIT>' , girtarget ] <EOL> elif isinstance ( girtarget , build . SharedLibrary ) : <EOL> scan_command += [ "<STR_LIT>" % girtarget . get_id ( ) ] <EOL> libname = girtarget . get_basename ( ) <EOL> scan_command += [ '<STR_LIT>' , libname ] <EOL> scankwargs = { '<STR_LIT>' : girfile , <EOL> '<STR_LIT:input>' : libsources , <EOL> '<STR_LIT>' : scan_command , <EOL> '<STR_LIT>' : depends , <EOL> } <EOL> if kwargs . get ( '<STR_LIT>' ) : <EOL> scankwargs [ '<STR_LIT>' ] = kwargs [ '<STR_LIT>' ] <EOL> scankwargs [ '<STR_LIT>' ] = os . path . join ( state . environment . get_datadir ( ) , '<STR_LIT>' ) <EOL> scan_target = GirTarget ( girfile , state . subdir , scankwargs ) <EOL> typelib_output = '<STR_LIT>' % ( ns , nsversion ) <EOL> typelib_cmd = [ '<STR_LIT>' , scan_target , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if inc_dirs : <EOL> for incd in inc_dirs : <EOL> typelib_cmd += [ '<STR_LIT>' % inc for inc in <EOL> incd . held_object . get_incdirs ( ) ] <EOL> if deps : <EOL> for dep in deps : <EOL> girdir = dep . held_object . get_variable ( "<STR_LIT>" ) <EOL> if girdir : <EOL> typelib_cmd += [ "<STR_LIT>" % girdir ] <EOL> kwargs [ '<STR_LIT>' ] = typelib_output <EOL> kwargs [ '<STR_LIT>' ] = typelib_cmd <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> typelib_target = TypelibTarget ( typelib_output , state . subdir , kwargs ) <EOL> return [ scan_target , typelib_target ] <EOL> def compile_schemas ( self , state , args , kwargs ) : <EOL> if len ( args ) != <NUM_LIT:0> : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> srcdir = os . path . join ( state . build_to_src , state . subdir ) <EOL> outdir = state . subdir <EOL> cmd = [ '<STR_LIT>' , '<STR_LIT>' , outdir , srcdir ] <EOL> kwargs [ '<STR_LIT>' ] = cmd <EOL> kwargs [ '<STR_LIT:input>' ] = [ ] <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if state . subdir == '<STR_LIT>' : <EOL> targetname = '<STR_LIT>' <EOL> else : <EOL> targetname = '<STR_LIT>' + state . subdir <EOL> target_g = build . CustomTarget ( targetname , state . subdir , kwargs ) <EOL> return target_g <EOL> def gtkdoc ( self , state , args , kwargs ) : <EOL> if len ( args ) != <NUM_LIT:1> : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> modulename = args [ <NUM_LIT:0> ] <EOL> if not isinstance ( modulename , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> if not '<STR_LIT>' in kwargs : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> main_file = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if not isinstance ( main_file , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> main_xml = kwargs . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if not isinstance ( main_xml , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> if main_xml != '<STR_LIT>' : <EOL> if main_file != '<STR_LIT>' : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> main_file = main_xml <EOL> src_dir = kwargs [ '<STR_LIT>' ] <EOL> targetname = modulename + '<STR_LIT>' <EOL> command = [ state . environment . get_build_command ( ) , '<STR_LIT>' , '<STR_LIT>' ] <EOL> if hasattr ( src_dir , '<STR_LIT>' ) : <EOL> src_dir = src_dir . held_object <EOL> if not isinstance ( src_dir , build . IncludeDirs ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> incdirs = src_dir . get_incdirs ( ) <EOL> if len ( incdirs ) != <NUM_LIT:1> : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> header_dir = os . path . join ( state . environment . get_source_dir ( ) , src_dir . get_curdir ( ) , incdirs [ <NUM_LIT:0> ] ) <EOL> else : <EOL> header_dir = os . path . normpath ( os . path . join ( state . subdir , src_dir ) ) <EOL> args = [ '<STR_LIT>' + state . environment . get_source_dir ( ) , <EOL> '<STR_LIT>' + state . environment . get_build_dir ( ) , <EOL> '<STR_LIT>' + state . subdir , <EOL> '<STR_LIT>' + header_dir , <EOL> '<STR_LIT>' + main_file , <EOL> '<STR_LIT>' + modulename ] <EOL> args += self . unpack_args ( '<STR_LIT>' , '<STR_LIT>' , kwargs ) <EOL> args += self . unpack_args ( '<STR_LIT>' , '<STR_LIT>' , kwargs ) <EOL> res = [ build . RunTarget ( targetname , command [ <NUM_LIT:0> ] , command [ <NUM_LIT:1> : ] + args , state . subdir ) ] <EOL> if kwargs . get ( '<STR_LIT>' , True ) : <EOL> res . append ( build . InstallScript ( command + args ) ) <EOL> return res <EOL> def unpack_args ( self , arg , kwarg_name , kwargs ) : <EOL> try : <EOL> new_args = kwargs [ kwarg_name ] <EOL> if not isinstance ( new_args , list ) : <EOL> new_args = [ new_args ] <EOL> for i in new_args : <EOL> if not isinstance ( i , str ) : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> return [ ] <EOL> if len ( new_args ) > <NUM_LIT:0> : <EOL> return [ arg + '<STR_LIT>' . join ( new_args ) ] <EOL> return [ ] <EOL> def gdbus_codegen ( self , state , args , kwargs ) : <EOL> if len ( args ) != <NUM_LIT:2> : <EOL> raise MesonException ( '<STR_LIT>' ) <EOL> namebase = args [ <NUM_LIT:0> ] <EOL> xml_file = args [ <NUM_LIT:1> ] <EOL> cmd = [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in kwargs : <EOL> cmd += [ '<STR_LIT>' , kwargs . pop ( '<STR_LIT>' ) ] <EOL> if '<STR_LIT>' in kwargs : <EOL> cmd += [ '<STR_LIT>' , kwargs . pop ( '<STR_LIT>' ) ] <EOL> cmd += [ '<STR_LIT>' , '<STR_LIT>' + namebase , '<STR_LIT>' ] <EOL> outputs = [ namebase + '<STR_LIT>' , namebase + '<STR_LIT>' ] <EOL> custom_kwargs = { '<STR_LIT:input>' : xml_file , <EOL> '<STR_LIT>' : outputs , <EOL> '<STR_LIT>' : cmd <EOL> } <EOL> return build . CustomTarget ( namebase + '<STR_LIT>' , state . subdir , custom_kwargs ) <EOL> def initialize ( ) : <EOL> return GnomeModule ( ) <EOL> class GirTarget ( build . CustomTarget ) : <EOL> def __init__ ( self , name , subdir , kwargs ) : <EOL> super ( ) . __init__ ( name , subdir , kwargs ) <EOL> class TypelibTarget ( build . CustomTarget ) : <EOL> def __init__ ( self , name , subdir , kwargs ) : <EOL> super ( ) . __init__ ( name , subdir , kwargs ) </s>
