lfZddlZddlZddlZddlmZdZejfdZdZdS)N)PkgConfigErrorc0|D]\}}||vr|||<t||tstd|dt|tstd|d||||S)zMerge values from cffi config flags cfg2 to cf1 Example: merge_flags({"libraries": ["one"]}, {"libraries": ["two"]}) {"libraries": ["one", "two"]} zcfg1[z] should be a list of stringszcfg2[)items isinstancelist TypeErrorextend)cfg1cfg2keyvalues p/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/cffi/pkgconfig.py merge_flagsrsjjll$$ U d??DIId3i.. Qi### OPPPeT** Qi### OPPP I  U # # # # Kc 8ddg}|||| tj|tjtj}nC#t$r6}t dt |d}~wwxYw|\}}|j dkrH | |}n#t$rYnwxYwt |tj dkrUt|t s@ | |}n)#t$rt d|d |d |d |wxYwt jd krd |vrt d|d |d ||S)z5Calls pkg-config and returns the output if found z pkg-configz--print-errors)stdoutstderrzcannot run pkg-config: Nr)z pkg-config  z5 returned bytes that cannot be decoded with encoding z: \z3 returned an unsupported backslash-escaped output: )append subprocessPopenPIPEEnvironmentErrorrstrstrip communicate returncodedecode Exceptionsys version_inforUnicodeDecodeErrorosaltsep)libnameflagencodingapceboutberrs rcallr0s '(AHHTNNNHHWN  a   P P P NNNnCFFLLNNNLMMMN!!JD$ } ;;x((DD    D TZZ\\*** 4 4(=(= B;;x((DD! B B B ."&$$44"ABB B B  yDTT\\n"ddGGGTT344 4 Ks5+A B&1BBC C%$C%/E&E+c ddddd d  fd}i}|D]}||}t|||S)aReturn compiler line flags for FFI.set_source based on pkg-config output Usage ... ffibuilder.set_source("_foo", pkgconfig = ["libfoo", "libbar >= 1.8.3"]) If pkg-config is installed on build machine, then arguments include_dirs, library_dirs, libraries, define_macros, extra_compile_args and extra_link_args are extended with an output of pkg-config for libfoo and libbar. Raises PkgConfigError in case the pkg-config call fails. c>d|DS)NcLg|]!}|d|dd"S)-IN startswith.0xs r zBflags_from_pkgconfig..get_include_dirs..L1DDD!d1C1CD!""DDDrsplitstrings rget_include_dirsz.flags_from_pkgconfig..get_include_dirsKDDv||~~DDDDrc>d|DS)NcLg|]!}|d|dd"S)-Lr5Nr6r8s rr;zBflags_from_pkgconfig..get_library_dirs..Or<rr=r?s rget_library_dirsz.flags_from_pkgconfig..get_library_dirsNrBrc>d|DS)NcLg|]!}|d|dd"S)-lr5Nr6r8s rr;z?flags_from_pkgconfig..get_libraries..Rr<rr=r?s r get_librariesz+flags_from_pkgconfig..get_librariesQrBrcJdfd|DS)Ncl|dd}d|vr#t|ddS|dfS)Nr5=r)tupler>)r:s r_macroz8flags_from_pkgconfig..get_macros.._macroVs<!""AaxxQWWS!__---4y rcPg|]"}|d|#S)-Dr6)r9r:rOs rr;z.get_macros..\s2HHHaQ\\$5G5GHq HHHrr=)r@rOs @r get_macrosz(flags_from_pkgconfig..get_macrosUs7 ! ! ! IHHH6<<>>HHHHrc>d|DS)Ncfg|].}|d|d,|/S)r4rQr6r8s rr;zBflags_from_pkgconfig..get_other_cflags.._SEEEad1C1CE12d1C1CEEEErr=r?s rget_other_cflagsz.flags_from_pkgconfig..get_other_cflags^0EE6<<>>EEE Erc>d|DS)Ncfg|].}|d|d,|/S)rErIr6r8s rr;z@flags_from_pkgconfig..get_other_libs..crUrr=r?s rget_other_libsz,flags_from_pkgconfig..get_other_libsbrWrctj}t|d}t|d}||||| |dS)Nz--cflagsz--libs) include_dirs library_dirs libraries define_macrosextra_compile_argsextra_link_args)r#getfilesystemencodingr0) r(fse all_cflagsall_libsrArJrFrRrVrZs rkwargsz$flags_from_pkgconfig..kwargsgs'))':.. **,,Z88,,X66&x00'Z 33"2"2:">">-~h77  r)r) libsrfretr( lib_flagsrArJrFrRrVrZs @@@@@@rflags_from_pkgconfigrj<sEEEEEEEEEIIIEEEEEE           C$$F7OO C#### Jr) r#r&rerrorrrrbr0rjrrrms!!!!!!&";!:!