ó
)Ù¸Vc           @   sƒ  d  Z  d d l Z d d l Z d d l Z d d l Ty e j d a Wn e k
 r` Z d a n Xt d a y& e j d d k rŠ e	 a
 n e a
 Wn e k
 r¬ Z e	 a
 n Xy& e j d	 d k rÌ e	 a n e a Wn e k
 rî Z e a n Xi  Z d
 „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d Z d „  Z d d „ Z d „  Z d „  Z d S(   s"   Misc utilities used at build time
iÿÿÿÿN(   t   *t   srcdirt   .t   /t   do_makefilet   0t
   do_sourcesc         C   sE   t  j j |  ƒ \ } } | d } t j | g  ƒ } | j |  ƒ d  S(   Ni   (   t   ost   patht   splitextt	   name_dictt
   setdefaultt   append(   t   namet   baset   extt   entry(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   log_output_name8   s    
c         C   s,   t  r t |  | ƒ } n d  } t |  ƒ | S(   N(   R   t   opent   NoneR   (   R   t   dirt   f(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   open_and_log_name?   s
    
t    c         C   s{   t  | ƒ } t | d ƒ } |  d | d | } t | ƒ t rm t | d ƒ } t |  | | ƒ | j ƒ  n  | j ƒ  d S(   sS   Given a dictionary D and a TEMPLATE_FILENAME, expand template into output file
    t   rt   NAMER   t   wN(   t   extract_extensiont   open_srcR   R   R   t   do_substitutiont   close(   t   dt   template_filenamet   extrat   output_extensiont   templatet   output_namet   output(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   expand_templateH   s    
c         C   s   t  ƒ  t |  ƒ d  S(   N(   t   output_makefile_fragmentt   output_ifile_include(   t   dirname(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   output_glueV   s    c          C   sˆ   t  s
 d  St t j j t j j d t j j d d ƒ ƒ d ƒ d ƒ }  |  j d ƒ t |  d ƒ t |  d ƒ t |  d	 ƒ |  j	 ƒ  d  S(
   Nt   gendirR   R   s   Makefile.genR   sE   #
# This file is machine generated.  All edits will be overwritten
#
t   ht   it   cc(
   R   R   R   R   t   joint   environt   gett   writet   output_subfragR   (   R   (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR'   Z   s    <c         C   s»   t  r· t d |  f d ƒ } | j d ƒ t j d g  ƒ } | j ƒ  | j d ƒ x- | D]% } | j d | d d !d	 f ƒ qY W| j d
 ƒ x% | D] } | j d | f ƒ q– Wn  d  S(   Ns   %s_generated.iR   sH   //
// This file is machine generated.  All edits will be overwritten
//
R-   s   %{
s   #include <%s>
i    iÿÿÿÿR,   s   %}

s   %%include <%s>
(   R   R   R2   R
   R   t   sort(   R)   R   t   filest   file(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR(   g   s    
#c         C   si   t  j | g  ƒ } | j ƒ  |  j d | j ƒ  ƒ x" | D] } |  j d | f ƒ q: W|  j d ƒ d  S(   Ns   GENERATED_%s =s    \
	%ss   

(   R
   R   R4   R2   t   upper(   R   R   R5   R6   (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR3   u   s    
c         C   s8   t  j d |  ƒ } | s+ t d |  f ‚ n  | j d ƒ S(   Ns   \.([a-z]+)\.t$s%   Incorrectly formed template_name '%s'i   (   t   ret   searcht
   ValueErrort   group(   t   template_namet   mo(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR   }   s    c         C   s   t  t j j t |  ƒ | ƒ S(   N(   R   R   R   R/   R   (   R   t   mode(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR   …   s    c            sA   ‡  f d †  } | j  ƒ  } t j d | | ƒ } | j | ƒ d  S(   Nc            s   |  j  d ƒ } ˆ  | S(   Ni   (   R;   (   t	   match_objt   key(   R   (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   replŠ   s    s   @([a-zA-Z0-9_]+)@(   t   readR8   t   subR2   (   R   t   in_filet   out_fileRA   t   inpt   out(    (   R   s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyR   ‰   s    s:  /* -*- c++ -*- */
/*
 * Copyright 2003,2004 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * GNU Radio is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * GNU Radio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU Radio; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */
c         C   s0   t  |  ƒ d k s$ t |  ƒ d k r( d Sd Sd  S(   Nt   ct   1R   (   t   i_codet   o_code(   t   code3(    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt
   is_complex¬   s    $t   grc         C   sõ   i  } |  | d <|  d | d <d | j  ƒ  |  j  ƒ  f | d <d | j  ƒ  |  j  ƒ  f | d <t j d | d	 d
 |  ƒ | d <d |  | d <d | d <t | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <| S(   NR   t   _implt	   NAME_IMPLs   INCLUDED_%s_%s_Ht
   GUARD_NAMEs   INCLUDED_%s_%s_IMPL_Ht   GUARD_NAME_IMPLt   ^t   _R   t	   BASE_NAMEs   %s_sptrt	   SPTR_NAMEsB   WARNING: this file is machine generated. Edits will be overwrittent   WARNINGt	   COPYRIGHTt   TYPEt   I_TYPEt   O_TYPEt   TAP_TYPEt
   IS_COMPLEX(   R7   R8   RC   t	   copyrightt   i_typet   o_typet   tap_typeRM   (   R   RL   t   packageR   (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   standard_dict³   s    
  !

c         C   s¢   i  } |  | d <|  | d <d | j  ƒ  |  j  ƒ  f | d <d | d <t | d <t | ƒ | d <t | ƒ | d	 <t | ƒ | d
 <t | ƒ | d <t | ƒ | d <| S(   NR   RU   s   INCLUDED_%s_%s_HRQ   sB   WARNING: this file is machine generated. Edits will be overwrittenRW   RX   RY   RZ   R[   R\   R]   (   R7   R^   R_   R`   Ra   RM   (   R   RL   Rb   R   (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   standard_dict2Å   s    

 

c         C   så   i  } |  | d <|  | d <|  j  d ƒ j  d ƒ | d <d | j ƒ  |  j ƒ  f | d <d | d	 <t | d
 <d | | d <d | d d !d | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <t | ƒ | d <| S(   NR   t	   IMPL_NAMEt   implRT   RU   s   INCLUDED_%s_%s_HRQ   sB   WARNING: this file is machine generated. Edits will be overwrittenRW   RX   t   fir_filter_t   FIR_TYPEi    i   RH   t	   CFIR_TYPERY   RZ   R[   R\   R]   (   t   rstripR7   R^   R_   R`   Ra   RM   (   R   RL   Rb   R   (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   standard_impl_dict2Ó   s    

 

(   t   __doc__R8   R   t   os.patht   build_utils_codesR0   R   t   KeyErrort   et   FalseR   t   TrueR   R
   R   R   R&   R*   R'   R(   R3   R   R   R   R^   RM   Rc   Rd   Rk   (    (    (    s;   /usr/share/gnuradio/modtool/gr-newmod/python/build_utils.pyt   <module>   sF   $


	

	

										!		