a
    ú)±g  ã                   @   sŽ   d dl Z d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 e e e¡¡Zdd„ Zeddd	„ƒZd
d„ Zeddd„ƒZeddd„ƒZdS )é    N)Úto_list)Úconf)Údebugc                 C   s   |   d¡} | jdd dd� d S )NzROOT Optionsz--with-rootzgive ROOT installation location)ÚdefaultÚhelp)Úadd_option_groupÚ
add_option)Úopt© r
   ú7/home/yuhw/wc/larsoft925/src/wct-latest/waft/rootsys.pyÚoptions   s
    
ÿr   Fc                 C   s   | j j}|r0| ¡ dv r0|r$tdƒ‚tdƒ d S | j jdg7  _tƒ }t| j dd ƒt	 
dd ¡fD ]}|rb| t |d¡¡ qbt|d�}| jdd
|dœ|¤Ž d
| jvrÀ|r´tdƒ‚tdƒ d S | j| jd
 ddd|d� | jdd||d� | jdd|d� d S )N)ÚnoÚoffÚfalsez/ROOT is mandatory but disabled via command linez7root: optional ROOT dependency disabled by command linez-fPICÚ	with_rootÚROOTSYSÚbin)Ú	path_listúroot-configZROOT_CONFIG)ÚvarÚ	mandatoryz'root-config not found but ROOT requiredz;root: skipping non mandatory ROOT, use --with-root to forcez--cflags --libs --ldflagsÚ )ÚpathÚuselib_storeÚargsÚpackager   Z	rootclingZ	ROOTCLING)r   r   r   zRtypes.h)Úheader_nameÚuser   )r   )r   r   ÚlowerÚRuntimeErrorr   ÚenvÚCXXFLAGSÚlistÚgetattrÚosÚgetenvÚappendÚospÚjoinÚdictÚfind_programÚ	check_cfgÚ	check_cxx)Úcfgr   Úinstdirr   ZtopdirÚkwargsr
   r
   r   Ú
check_root   s4    

ÿÿr0   c                 C   s   |   ¡  d S )N)r0   )r-   r
   r
   r   Ú	configure9   s    r1   r   c                 C   sL  t |ƒdg }t |ƒ}tƒ }|D ]R}td|› d|› �ƒ | d¡rLd| }nd| j |¡ ¡  }||vr | |¡ q d |¡}td|t	|ƒf ƒ |d }	d	| d
 }
d	| d }|d }t
|ƒt
dƒkrÖ| j |¡}t |ƒ|g }d dd„ |D ƒ¡}td|› d|› �ƒ d|
||f }| ||	||g||d� |  d|¡ |  d|¡ dS )zn
    rootcling -f NAMEDict.cxx -rml libNAME.so -rmf libNAME.rootmap myHeader1.h myHeader2.h ... LinkDef.h
    r   z
root: INC(z): ú/ú-I%sú zroot: INCS(%s): %súDict.cxxÚlibz.soz.rootmapzDict_rdict.pcmr   c                 S   s   g | ]}|  ¡ ‘qS r
   )Úabspath©Ú.0Úxr
   r
   r   Ú
<listcomp>`   ó    z&gen_rootcling_dict.<locals>.<listcomp>zroot: SOURCES(zJ${ROOTCLING} -f ${TGT[0].abspath()} -rml %s -rmf ${TGT[1].abspath()} %s %s)ÚsourceÚtargetÚruler   ú${PREFIX}/lib/N)r   r"   r   Ú
startswithr   Úfind_dirr7   r&   r(   ÚstrÚtypeÚfind_resourceÚinstall_files)ÚbldÚnameÚlinkdefÚheadersÚincludesr   ÚincsÚincZnewincÚdict_srcZdict_libZdict_mapZdict_pcmZsource_nodesZsourcesr?   r
   r
   r   Úgen_rootcling_dict<   s8    


þ	rO   c                    sŽ   t |ƒ}‡ fdd„t |ƒD ƒ}d |¡}|d }ˆ ||g |d| d� ˆ j||d |dd	� d
| }ˆ |g|d||f d� ˆ  d|¡ dS )zqGenerate a rootcint dictionary, compile it to a shared lib,
    produce its rootmap file and install it all.
    c                    s    g | ]}d ˆ j  |¡ ¡  ‘qS )r3   )r   rB   r7   r8   ©rG   r
   r   r;   v   r<   z%gen_rootcint_dict.<locals>.<listcomp>r4   r5   z"${ROOTCINT} -f ${TGT} -c %s ${SRC})r=   r>   r?   ÚDictr   )r=   r>   rK   r   zlib%sDict.rootmapz:${RLIBMAP} -o ${TGT} -l lib%sDict.so -d lib%s.so -c ${SRC}r@   N)r   r(   ÚshlibrF   )rG   rH   rI   rJ   rK   rL   rN   Zrootmapr
   rP   r   Úgen_rootcint_dictp   s$    

þý
ÿrS   )F)r   r   r   )r   r   )r$   Zos.pathr   r'   ÚwaflibZwaflib.Utilsr   Zwaflib.Configurer   Zwaflib.Logsr   Údirnamer7   Ú__file__Ú_tooldirr   r0   r1   rO   rS   r
   r
   r
   r   Ú<module>   s   '3