a uf@sTddlZddlZddlZddlZddZddZddZdd Zd d Zd d Z dS)NcCs*tdt|dd|tddS)zm Print a configure.ac error message with the line number. :param line_i: the zero based line counter zERROR: configure.ac line z: N)printstrsysexit)line_imessager U/home/osmocom-build/jenkins/workspace/Osmocom-depcheck/scripts/osmo-depcheck/parse.pyerror sr cCs\tjD]8\}}||vr td|d|d|d|Sq td|d||S)aW Find the git repository that contains a certain library. Based on the information in config.py. :param library: the name as referenced in the PKG_CHECK_MODULES statement. For example: "libosmoabis" :param version: for example "0.5.0" :returns: the repository name, e.g. "libosmo-abis" z * :z (part of ))configrepositemsr)libraryversionrepoZ librariesr r r repositorys   rcCs"tjD]}t||rdSqdS)zl :returns: True when we would build the library in question from source, False otherwise. TF)rrelevant_library_patternsfnmatch)rpatternr r r library_is_relevant$s  rcCsVd|vr dStd|rdS|dddd}|dd}t|rR|SdS) aL Find the PKG_CHECK_MODULES conditions in any line from a configure.ac. Example lines: PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0) PKG_CHECK_MODULES(LIBSYSTEMD, libsystemd) :returns: * None when there's no condition in that line * a string like "libosmocore >= 0.1.0" ZPKG_CHECK_MODULESNz#.*PKG_CHECK_MODULES,rr r )researchsplitstripr)lineretrr r r parse_condition-s  r!cCsbttd|d}t|dkr2t|d|d|\}}}|dkrL||fSt|d|ddS)z Get the library and version strings from a condition. :param line_i: the zero based line counter :param condition: a condition like "libosmocore >= 0.1.0" NrzTinvalid condition format, expected something like 'libosmocore >= 0.10.0' but got: ''z>=z*invalid operator, expected '>=' but got: ')listfilterrlenr )r conditionrroperatorrr r r library_versionEs  r)c Cs|d|d}t|}|}Wdn1s60Yi}tdt|D]\}t||}|shqRt||\}} t|| } | |vr| || krt|d| d| || <qR|S)a\ Parse the PKG_CHECK_MODULES statements of a configure.ac file. :param workdir: path to where all data (git, build, install) is stored :param repo: the repository to look at (e.g. "osmo-bts") :returns: a dictionary like the following: {"libosmocore": "0.11.0", "libosmo-abis": "0.5.0"} z/git/z /configure.acNrz0found multiple PKG_CHECK_MODULES statements for z'.git, and they have different versions!)open readlinesranger&r!r)rr ) workdirrpathZhandlelinesr ir'rrZrepo_dependencyr r r configure_acZs$  &   r1) rrrrr rrr!r)r1r r r r s