B
    ›³ëbÐ  ã               @   sb   d Z ddlmZmZ ddlZdgZdZdZdd„ Z	dd	œd
d„Z
deeeeeef d	œdd„ZdS )aí  Variable type for package Variables.

To be used whenever a 'package' may be enabled/disabled and the
package path may be specified.

Given these options ::

   x11=no   (disables X11 support)
   x11=yes  (will search for the package installation dir)
   x11=/usr/local/X11 (will check this path for existence)

Can be used as a replacement for autoconf's ``--with-xxx=yyy`` ::

    opts = Variables()
    opts.Add(
        PackageVariable(
            key='x11',
            help='use X11 installed here (yes = search some places)',
            default='yes'
        )
    )
    ...
    if env['x11'] == True:
        dir = ...  # search X11 in some standard places ...
        env['x11'] = dir
    if env['x11']:
        ...  # build with x11 ...
é    )ÚTupleÚCallableNÚPackageVariable)Ú1ZyesÚtrueZonÚenableÚsearch)Ú0ZnoZfalseZoffÚdisablec             C   s$   |   ¡ }|tkrdS |tkr dS | S )ú TF)ÚlowerÚENABLE_STRINGSÚDISABLE_STRINGS)ÚvalZlval© r   ú>lib/python3.7/site-packages/SCons/Variables/PackageVariable.pyÚ
_converter>   s    r   )Úreturnc             C   sT   ddl }||  dkr(|rP|| |ƒ|| < n(||  rP|j |¡sPtj d| |f ¡‚dS )r   r   NTz%Path does not exist for option %s: %s)ÚosÚpathÚexistsÚSConsZErrorsZ	UserError)Úkeyr   ÚenvÚ
searchfuncr   r   r   r   Ú
_validatorH   s    r   c                s(   d  |d|  f¡}| ||‡ fdd„tfS )as  Return a tuple describing a package list SCons Variable.

    The input parameters describe a 'package list' option. Returns
    a tuple including the correct converter and validator appended.
    The result is usable as input to :meth:`Add` .

    A 'package list' option may either be 'all', 'none' or a pathname
    string. This information is appended to *help*.
    z
    z( yes | no | /path/to/%s )c                s   t | ||ˆ ƒS )N)r   )ÚkÚvÚe)r   r   r   Ú<lambda>d   ó    z!PackageVariable.<locals>.<lambda>)Újoinr   )r   ÚhelpÚdefaultr   r   )r   r   r   V   s
    
)N)Ú__doc__Útypingr   r   ZSCons.Errorsr   Ú__all__r   r   r   r   Ústrr   r   r   r   r   Ú<module>3   s   
