a
    	$a                     @   s0   d dl Z d dlZdddZdd Zd	ddZdS )
    Nc                 C   s.   | durd| v r|  dS tjdr*dS dS )zFind the git binary.NGITz/usr/bin/git)get_flatospathexists)env r   j/home/jack/SDK/ZBT-AX3000-OpenWrt-21.02/build_dir/hostpkg/samba-4.14.12/./buildtools/wafsamba/samba_git.pyfind_git   s
    
r
   c                 C   s,   t jt j| do*t jt j| dS )z{Check whether a source directory is git-versioned and has submodules.

    :param path: Path to Samba source directory
    z.gitz.gitmodules)r   r   isdirjoinisfile)r   r   r   r	   has_submodules   s    r   c           	      c   s   t | sdS t|}|du r dS tj|ddgtj| d}|d\}}| D ]}| }|d }|dd }|d}t	|dkr|d	v r|d d
fV  qNt	|dkr|dkr|d dfV  qNt	|dkr|dkr|d dfV  qNt
d||f qNdS )aL  Check status of submodules.

    :param path: Path to git directory
    :param env: Optional waf environment
    :return: Yields tuples with submodule relpath and status
        (one of: 'out-of-date', 'not-checked-out', 'up-to-date')
    :raise RuntimeError: raised when parsing of 'git submodule status' output
        fails.
    N	submodulestatus)stdoutcwdr          )-+zout-of-dater   znot-checked-outz
up-to-datez(Unable to parse submodule status: %r, %r)r   r
   
subprocessPopenPIPEcommunicate
splitlinesrstripsplitlenRuntimeError)	r   r   gitpr   stderrlr   partsr   r   r	   read_submodule_status   s*    

r&   )N)N)r   r   r
   r   r&   r   r   r   r	   <module>   s   
	