a
    n^e                     @   sj   d Z ddlZddlZddlZddlZddlmZ ejG dd dej	Z
G dd dZG dd	 d	eZdS )
zThis module contains the class Config, which knows about the
platform (the current one by default) and a set of directories,
for example where to store downloaded files.
    N)Optionalc                   @   s4   e Zd ZdZdZdZdZdZee	d dddZ
d	S )
Platformz"An enum of all supported platformsZfreebsdZlinuxdarwinmingw)platform_systemreturnc                 C   s>   |  }| j D ]}|j|kr|  S qtd| ddS )z:Find the platform for the given value of platform.system()z
Platform 'z' not foundN)lower__members__valuesvalueKeyError)clsr   member r   B/home/jjbenham/public_html/lilypond/release/binaries/lib/config.pyget_platform)   s
    

zPlatform.get_platformN)__name__
__module____qualname____doc__FREEBSDLINUXMACOSMINGWclassmethodstrr   r   r   r   r   r      s   r   c                
   @   s>  e Zd ZU dZeed< eed< eed< eed< eed< eed< d ed< eed	< d)eee eee ee ee ed  edddZ	e
edddZe
edddZe
edddZe
edddZe
edddZedddZedddZeddd Zedd!d"Ze
edd#d$Zd%d& Zedd'd(Zd
S )*Configz8A class to store the configuration for a given platform.base_dirdownloads_dirjobsplatformarchitecturetriplenative_configprogram_suffixN    r   r   r   r    r!   r"   r#   r$   c	           	      C   s   t j|| _|du r$t j|d}|| _|| _|p@tt	
 | _|pNt	 | _|du rptd}|duspJ || _|p|| | _|| _dS )z>Create a new Config instance, optionally for a given platform.NZ	downloadsZHOST_GNU_TYPE)ospathrealpathr   joinr   r   r   r   py_platformsystemr    machiner!   	sysconfigZget_config_varr"   r#   r$   )	selfr   r   r   r    r!   r"   r#   r$   r   r   r   __init__A   s    

zConfig.__init__)r   c                 C   s   t j| jdS )z#Return the path to the dependenciesdependencies)r(   r)   r+   r   r0   r   r   r   dependencies_dir`   s    zConfig.dependencies_dirc                 C   s   t j| jdS )z,Return the path to the dependencies' sourcessrcr(   r)   r+   r4   r3   r   r   r   dependencies_src_dire   s    zConfig.dependencies_src_dirc                 C   s   t j| jdS )z6Return the path to the dependencies' build directoriesbuildr6   r3   r   r   r   dependencies_build_dirj   s    zConfig.dependencies_build_dirc                 C   s   t j| jdS )zBReturn the path to the dependencies' temporary install directoriesinstallr6   r3   r   r   r   dependencies_install_diro   s    zConfig.dependencies_install_dirc                 C   s   t j| jdS )z<Return the path to the directory with the dependencies' logslogr6   r3   r   r   r   dependencies_log_dirt   s    zConfig.dependencies_log_dirc                 C   s   | j tjkS )z2Return True if this config is for platform FreeBSD)r    r   r   r3   r   r   r   
is_freebsdy   s    zConfig.is_freebsdc                 C   s   | j tjkS )z0Return True if this config is for platform Linux)r    r   r   r3   r   r   r   is_linux}   s    zConfig.is_linuxc                 C   s   | j tjkS )z0Return True if this config is for platform macOS)r    r   r   r3   r   r   r   is_macos   s    zConfig.is_macosc                 C   s   | j tjkS )z0Return True if this config is for platform mingw)r    r   r   r3   r   r   r   is_mingw   s    zConfig.is_mingwc                 C   s   |   rdS dS )z,Return the command for the make build systemZgmakeZmake)r>   r3   r   r   r   make_command   s    zConfig.make_commandc                 C   sd   t j| jdd t j| jdd t j| jdd t j| jdd t j| jdd t j| jdd dS )z8Create all necessary directories for this configuration.T)exist_okN)r(   makedirsr   r4   r7   r9   r;   r=   r3   r   r   r   create_directories   s    zConfig.create_directoriesc                 C   s   d| j  dS )Nz<Config for >)r    r3   r   r   r   __repr__   s    zConfig.__repr__)Nr%   NNNNr&   )r   r   r   r   r   __annotations__intr   r   r1   propertyr4   r7   r9   r;   r=   boolr>   r?   r@   rA   rB   rE   rG   r   r   r   r   r   3   sX   
       	r   c                       s(   e Zd ZdZeed fddZ  ZS )MingwConfigz'A class for cross-compilation to mingw.)r   r#   c              
      s&   t  j||j|jtjdd|dd d S )NZx86_64zx86_64-w64-mingw32z.exer'   )superr1   r   r   r   r   )r0   r   r#   	__class__r   r   r1      s    zMingwConfig.__init__)r   r   r   r   r   r   r1   __classcell__r   r   rN   r   rL      s   rL   )r   enumr(   r    r,   r/   typingr   uniqueEnumr   r   rL   r   r   r   r   <module>   s   k