o
    uJAfO                     @  sP   d dl mZ 	 d dlZd dlZddlmZ ddlmZ	 dgZ
G dd de	ZdS )    )annotationsN   )MesonException)BuildDirLockr   c                   @  s    e Zd Zd
ddZdddZd	S )r   returnNonec              
   C  s   t | jddd| _zt| jtjtjB  W d S  ttfy)   | j	  t
d tyA } z| j	  t
d|j d }~ww )Nwzutf-8)encodingzHSome other Meson process is already using this build directory. Exiting.z$Failed to lock the build directory: )openZlockfilenamelockfilefcntlflockLOCK_EXLOCK_NBBlockingIOErrorPermissionErrorcloser   OSErrorstrerror)selfe r   ;/usr/lib/python3.10/site-packages/mesonbuild/utils/posix.py	__enter__   s   

zBuildDirLock.__enter__argsT.Anyc                 G  s   t | jt j | j  d S )N)r   r   r   LOCK_UNr   )r   r   r   r   r   __exit__)   s   zBuildDirLock.__exit__N)r   r   )r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r   r      s    
)
__future__r   r   typingTcorer   platformr   ZBuildDirLockBase__all__r   r   r   r   <module>   s   