Ñò
¶£Kc           @   sø  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z h d d 6d d 6d d 6Z	 g  Z
 d d	 d
 d d g Z d g Z d Z d Z y€ x? e d ƒ D]1 Z e i d ƒ o e e i ƒ  d ƒ Z Pq» q» We d j  o d Z d Z n e d j  o d Z d Z n Wn n Xd Z d Z d Z d. \ Z Z d e f d „  ƒ  YZ d  d/ d! „  ƒ  YZ d0 d" „ Z d# d1 d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' e f d( „  ƒ  YZ  d) „  Z! d* „  Z" d+ „  Z# d, „  Z$ d- „  Z% d S(2   iÿÿÿÿNs   /usr/bin/maket   makes   /usr/bin/gcjt   gcjs   /usr/bin/gcj-dbtoolt   dbtools   -gs   -O2s   -fPICs   -findirect-dispatchs   -fjnis   -Wl,-Bsymbolici   i   s   /proc/meminfos	   MemTotal:i   iÀ‘! i   i   iàÈ i   i   t   Makefiles§   GCJ = %(gcj)s
DBTOOL = %(dbtool)s
GCJFLAGS = %(gcjflags)s
LDFLAGS = %(ldflags)s

%%.o: %%.jar
	$(GCJ) -c $(GCJFLAGS) $< -o $@

TARGETS = \
%(targets)s

all: $(TARGETS)s;  
%(base)s_SOURCES = \
%(jars)s

%(base)s_OBJECTS = \
$(%(base)s_SOURCES:.jar=.o)

%(dso)s: $(%(base)s_OBJECTS)
	$(GCJ) -shared $(GCJFLAGS) $(LDFLAGS) $^ -o $@

%(db)s: $(%(base)s_SOURCES)
	$(DBTOOL) -n $@ 64
	for jar in $^; do \
            $(DBTOOL) -f $@ $$jar \
                %(libdir)s/%(dso)s; \
        dones   PKs   Êþº¾t   Errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /usr/lib/gcc/aotcompile.pyR   W   s   t   Compilerc           B   s/   e  Z d d  „ Z d „  Z d „  Z d „  Z RS(   c         C   s±   t  i i | ƒ |  _ t  i i | ƒ |  _ | d  j o |  i |  _ n( t  i i | |  i i t  i	 ƒ ƒ |  _ t
 i
 t ƒ |  _ t
 i
 t ƒ |  _ t
 i
 t ƒ |  _ g  |  _ d  S(   N(   t   ost   patht   abspatht   srcdirt   libdirt   Nonet   dstdirt   joint   lstript   sept   copyt   GCJFLAGSt   gcjflagst   LDFLAGSt   ldflagst	   MAKEFLAGSt	   makeflagst
   exclusions(   t   selfR   R   t   prefix(    (    s   /usr/lib/gcc/aotcompile.pyt   __init__[   s    'c      
   C   sê   t  i i |  i ƒ p t  i |  i ƒ n t  i ƒ  } t  i |  i ƒ z |  i ƒ  } | p t d ‚ n |  i	 t
 | ƒ x | D] } | i ƒ  q€ Wt t d g |  i ƒ x | D] } | i ƒ  q³ Wt  i t
 ƒ Wd t  i | ƒ Xd S(   ss   Search srcdir for classes and jarfiles, then generate
        solibs and mappings databases for them all in libdir.s   nothing to doR    N(   R   R	   t   isdirR   t   makedirst   getcwdt   chdirt
   getJobListR   t   writeMakefilet   MAKEFILEt	   writeJarst   systemt   PATHSR   t   cleant   unlink(   R   t   oldcwdt   jobst   job(    (    s   /usr/lib/gcc/aotcompile.pyt   compilei   s$      c         C   s)   t  t |  i |  i ƒ ƒ } t | ƒ | S(   s4   Return all jarfiles and class collections in srcdir.(   t	   weed_jobst	   find_jobsR   R   t   set_basenames(   R   R*   (    (    s   /usr/lib/gcc/aotcompile.pyR!   ~   s    
c         C   sè   t  | d ƒ } | t h t d d 6t d d 6d i |  i ƒ d 6d i |  i ƒ d 6d i t t i g  } | D] } | | i	 ƒ  | i
 ƒ  f qo ~ ƒ ƒ d 6IJx5 | D]- } | i ƒ  } |  i | d	 <| t | IJq© W| i ƒ  d
 S(   sf   Generate a makefile to build the solibs and mappings
        databases for the specified list of jobs.t   wR   R   t    R   R   s    \
t   targetsR   N(   t   opent   MAKEFILE_HEADERR&   R   R   R   t   reducet   operatort   addt   dsoNamet   dbNamet   ruleArgumentsR   t   MAKEFILE_JOBt   close(   R   R	   R*   t   fpt   _[1]R+   t   values(    (    s   /usr/lib/gcc/aotcompile.pyR"   „   s    
> N(   R   R   R   R   R,   R!   R"   (    (    (    s   /usr/lib/gcc/aotcompile.pyR   Z   s   		c   
      C   s^  d „  } g  g  } } t  i i |  | | | f ƒ xx | op | d t t  i t | d ƒ d ƒ  } | i | ƒ g  } | D]! } | i | ƒ p | | q~ q~ ~ } q5 Wx9 | D]1 } | | j o | i | ƒ q´ t	 d | ‚ q´ Wg  } | i
 ƒ  x^ | D]V } t  i i | ƒ o t | ƒ }	 n t | ƒ }	 t |	 i ƒ o | i |	 ƒ q q W| S(   s¢   Scan a directory and find things to compile: jarfiles (zips,
    wars, ears, rars, etc: we go by magic rather than file extension)
    and directories of classes.c         S   s¸   |  \ } } x¥ | D] } t  i i | | ƒ } t  i i | ƒ p t  i i | ƒ o q n t | d ƒ i d ƒ } | t j o | i | ƒ q | t	 j o | i | ƒ q q Wd  S(   Nt   ri   (
   R   R	   R   t   islinkt   isfileR3   t   readt   ZIPMAGICt   appendt
   CLASSMAGIC(   t   .0t   dirt   itemst   classest   zipst   itemR	   t   magic(    (    s   /usr/lib/gcc/aotcompile.pyt   visit™   s    	 'i    s   .classs'   %s: path does not exist or is not a job(   R   R	   t   walkt   lenR   t	   classnameRE   t
   startswitht   removeR   t   sortRB   t   JarJobt   DirJobRJ   (
   RH   R   RN   RJ   t   pathsR	   R>   t   clsR*   R+   (    (    s   /usr/lib/gcc/aotcompile.pyR.   •   s.    	
 *: 
 t   Jobc           B   sz   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z RS(   s8   A collection of classes that will be compiled as a unit.c         C   s*   | h  d  |  _ |  _ |  _ h  |  _ d  S(   N(   R   R	   RJ   t   blockst
   classnames(   R   R	   (    (    s   /usr/lib/gcc/aotcompile.pyR   Â   s    c         C   s3   t  i | ƒ i ƒ  } | |  i | <| |  i | <d S(   sR   Subclasses call this from their __init__ method for
        every class they find.N(   t   md5t   newt   digestRJ   R[   (   R   t   bytest   nameR^   (    (    s   /usr/lib/gcc/aotcompile.pyt   addClassÆ   s    c         C   sW  h  } x‡ |  i  i ƒ  D]v \ } } y t | ƒ } Wn( t d |  i |  i | f ƒ ‚  n X| i | ƒ p g  | | <n | | i | ƒ q W| i ƒ  } | i ƒ  g  g d |  _	 } x— | D] \ } } x€ | D]x } t
 |  i	 d ƒ t j p | t j o |  i	 i g  ƒ d } n |  i	 d i | | f ƒ | t
 |  i  | ƒ 7} qÓ WqÀ Wd S(   s3  Split self.classes into chunks that can be compiled to
        native code by gcj.  In the majority of cases this is not
        necessary -- the job will have come from a jarfile which will
        be equivalent to the one we generate -- but this only happens
        _if_ the job was a jarfile and _if_ the jarfile isn't too big
        and _if_ the jarfile has the correct extension and _if_ all
        classes are correctly named and _if_ the jarfile has no
        embedded jarfiles.  Fitting a special case around all these
        conditions is tricky to say the least.

        Note that this could be called at the end of each subclass's
        __init__ method.  The reason this is not done is because we
        need to parse every class file.  This is slow, and unnecessary
        if the job is subsetted.s4   job %s: class %s malformed or not a valid class filei    iÿÿÿÿN(   RJ   RI   RQ   t   warnR	   R[   t   has_keyRE   RT   RZ   RP   t   MAX_CLASSES_PER_JARt   MAX_BYTES_PER_JAR(   R   t   namest   hashR_   R`   t   hashes(    (    s   /usr/lib/gcc/aotcompile.pyt   __makeBlocksÍ   s0     
  
c         C   s6   x/ | i  i ƒ  D] } |  i  i | ƒ p t Sq Wt S(   s^   Returns True if identical copies of all classes in this
        collection exist in the other.(   RJ   t   keysRc   t   Falset   True(   R   t   otherRL   (    (    s   /usr/lib/gcc/aotcompile.pyt
   isSubsetOfÿ   s
     	c         C   s   |  i  | S(   N(   t   basename(   R   t   ext(    (    s   /usr/lib/gcc/aotcompile.pyt   __targetName  s    c         C   s   |  i  d | d ƒ S(   Ns   .%d.jari   (   t   _Job__targetName(   R   t   num(    (    s   /usr/lib/gcc/aotcompile.pyt   tempJarName
  s    c         C   s   |  i  d | d ƒ S(   Ns   .%d.oi   (   Rr   (   R   Rs   (    (    s   /usr/lib/gcc/aotcompile.pyt   tempObjName  s    c         C   s   |  i  d ƒ S(   sS   Return the filename of the shared library that will be
        built from this job.s   .so(   Rr   (   R   (    (    s   /usr/lib/gcc/aotcompile.pyR8     s    c         C   s   |  i  d ƒ S(   sU   Return the filename of the mapping database that will be
        built from this job.s   .db(   Rr   (   R   (    (    s   /usr/lib/gcc/aotcompile.pyR9     s    c      	   C   sÄ   |  i  d j o |  i ƒ  n h d i g  } |  i ƒ  D]! } | | i ƒ  o | p d q8 ~ ƒ d 6d i g  } t t |  i  ƒ ƒ D] } | |  i | ƒ q† ~ ƒ d 6|  i ƒ  d 6|  i	 ƒ  d 6S(	   s³   Return a dictionary of values that when substituted
        into MAKEFILE_JOB will create the rules required to build
        the shared library and mapping database for this job.t    t   _t   bases    \
t   jarst   dsot   dbN(
   RZ   R   t   _Job__makeBlocksR   R8   t   isalnumt   xrangeRP   Rt   R9   (   R   R>   t   ct   _[2]t   i(    (    s   /usr/lib/gcc/aotcompile.pyR:     s    ?=c         C   sº   |  i  d j o |  i ƒ  n x• t |  i  t t |  i  ƒ ƒ ƒ D]r \ } } t i |  i | ƒ d t i	 ƒ } x8 | D]0 \ } } | i
 t i d | ƒ |  i | ƒ qt W| i ƒ  q@ Wd S(   s5   Generate jarfiles that can be native compiled by gcj.R0   s   %s.classN(   RZ   R   R|   t   zipR~   RP   t   zipfilet   ZipFileRt   t
   ZIP_STOREDt   writestrt   ZipInfoRJ   R<   (   R   t   blockR   t   jarR`   Rg   (    (    s   /usr/lib/gcc/aotcompile.pyR$   (  s    " ! "c         C   sn   |  i  d j o |  i ƒ  n xI t t |  i  ƒ ƒ D]2 } t i |  i | ƒ ƒ t i |  i | ƒ ƒ q4 Wd S(   s;   Delete all temporary files created during this job's build.N(	   RZ   R   R|   R~   RP   R   R(   Rt   Ru   (   R   R   (    (    s   /usr/lib/gcc/aotcompile.pyR'   3  s     (   R   R   t   __doc__R   Ra   R|   Rn   Rr   Rt   Ru   R8   R9   R:   R$   R'   (    (    (    s   /usr/lib/gcc/aotcompile.pyRY   ¿   s   			2								RU   c           B   s    e  Z d  Z d „  Z d „  Z RS(   s!   A Job whose origin was a jarfile.c         C   s-   t  i |  | ƒ |  i t i | d ƒ ƒ d  S(   NR@   (   RY   R   t   _walkRƒ   R„   (   R   R	   (    (    s   /usr/lib/gcc/aotcompile.pyR   >  s    c         C   s   xz | i  ƒ  D]l } | i | ƒ } | i t ƒ o# |  i t i t i | ƒ ƒ ƒ q | i t ƒ o |  i	 | | ƒ q q Wd  S(   N(
   t   namelistRC   RR   RD   R‹   Rƒ   R„   t   StringIORF   Ra   (   R   t   zfR`   R_   (    (    s   /usr/lib/gcc/aotcompile.pyR‹   B  s     #(   R   R   RŠ   R   R‹   (    (    (    s   /usr/lib/gcc/aotcompile.pyRU   ;  s   	RV   c           B   s    e  Z d  Z d „  Z d „  Z RS(   s1   A Job whose origin was a directory of classfiles.c         C   s-   t  i |  | ƒ t i i | t i |  ƒ d  S(   N(   RY   R   R   R	   RO   RV   t   _visit(   R   R	   (    (    s   /usr/lib/gcc/aotcompile.pyR   M  s    c         C   s¡   xš | D]’ } t  i i | | ƒ } t  i i | ƒ p t  i i | ƒ o q n t | d ƒ } | i d ƒ } | t j o |  i | | i ƒ  t	 ƒ q q Wd  S(   NR@   i   (
   R   R	   R   RA   RB   R3   RC   RF   Ra   R`   (   R   RH   RI   RL   R	   R=   RM   (    (    s   /usr/lib/gcc/aotcompile.pyR   Q  s     '(   R   R   RŠ   R   R   (    (    (    s   /usr/lib/gcc/aotcompile.pyRV   J  s   	c         C   sÞ   t  i  |  ƒ }  xÈ t oÀ x¶ |  D]­ } x£ |  D]˜ } | | j o q- n | i | ƒ on d | i } | i | ƒ o5 t | t ƒ o t | t ƒ o q- n | d 7} n t | ƒ |  i | ƒ Pq- q- Wq  Pq  WPq q W|  S(   s®   Remove any jarfiles that are completely contained within
    another.  This is more common than you'd think, and we only
    need one nativified copy of each class after all.s   subsetted %ss    (identical)(	   R   Rl   Rn   R	   t
   isinstanceRV   RU   Rb   RS   (   R*   t   job1t   job2t   msg(    (    s   /usr/lib/gcc/aotcompile.pyR-   [  s0       
	c         C   s   h  } xR |  D]J } t  i i | i ƒ } | i | ƒ p g  | | <n | | i | ƒ q Wxó| i ƒ  D]å\ } } t | ƒ d j o | | d _ qh n g  } | D]" } | | i i t  i ƒ | f q¦ ~ } t	 g  } | D] \ } } | t | ƒ qß ~ ƒ } g  }	 | D] \ } } |	 | | | f q~	 } t
 t g  }
 | D] \ } } |
 | qG~
 ƒ } xL t oD | d } x2 | d D] } | | d j o Pq…q…W| d =qiPqiWt g  } t
 t | d ƒ D] } | d i | ƒ qÐ~ g  } | D] \ } } | | q÷~ ƒ } x4 | D], \ } } t d | i | f ƒ | | _ qWqh Wh  } xB |  D]: } | i } | i | ƒ o t d | ‚ n d | | <q^Wd S(   s2   Ensure that each jarfile has a different basename.i   i    iþÿÿÿRw   s   building %s as %ss   %s: duplicate jobnameN(   R   R	   Ro   Rc   RE   RI   RP   t   splitR   t   mint   applyR‚   Rl   R   Rb   R   (   R*   Rf   R+   R`   t   setR>   R€   t   bitst   minlent   _[3]t   _[4]t   rowt   bitt   _[5]t   _[6](    (    s   /usr/lib/gcc/aotcompile.pyR/   z  sP      6320 
 	4*  	c         C   sq   t  i t  i |  d |  ƒ } | d j o t d |  d | f ‚ n* | d j  o t d |  d | f ‚ n d S(   s   Execute a command.i    s   %s exited with code %ds   %s killed by signal %dN(   R   t   spawnvt   P_WAITR   (   t   commandt   status(    (    s   /usr/lib/gcc/aotcompile.pyR%   £  s
    c         C   s.   t  i d t i i t  i d ƒ |  f IJd S(   s   Print a warning message.s   %s: warning: %si    N(   t   syst   stderrR   R	   Ro   t   argv(   R“   (    (    s   /usr/lib/gcc/aotcompile.pyRb   «  s    
c         C   s,   t  i |  ƒ } | i | i | i d d S(   s6   Extract the class name from the bytes of a class file.i   (   t	   classfilet   Classt	   constantsR`   (   R_   t   klass(    (    s   /usr/lib/gcc/aotcompile.pyRQ   °  s    (   s   PKs   Êþº¾(    (    (    (&   R§   R   R\   R6   R   R¤   t	   cStringIOR   Rƒ   R&   R   R   R   Rd   Re   t   filet   lineRR   t   intR”   t   memtotalR#   R4   R;   RD   RF   t	   ExceptionR   R   R.   RY   RU   RV   R-   R/   R%   Rb   RQ   (    (    (    s   /usr/lib/gcc/aotcompile.pyt   <module>   sX   

	 	
;*|		)		