File: build_files.py

package info (click to toggle)
obitools 1.2.13%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,652 kB
  • sloc: python: 18,199; ansic: 1,542; makefile: 98
file content (58 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''
Created on 20 oct. 2012

@author: coissac
'''

import os.path

from distutils.core import Command
from distutils.util import convert_path
from distutils import log, sysconfig
from distutils.dep_util import newer
from distutils import log



class build_files(Command):
            
    def initialize_options(self):
        self.files=None
        self.ctools=None
        self.build_temp=None
        self.build_cexe=None

    def finalize_options(self):
        
        self.set_undefined_options('build_ctools',
                                   ('ctools',  'ctools'),
                                   ('build_temp','build_temp'),
                                   ('build_cexe','build_cexe'),
                                   )
        
        self.files = {}
        
    def run(self):
        
        for dest,prog,command in self.distribution.files:
            destfile = os.path.join(self.build_temp,dest)
            if prog in self.ctools:
                progfile = os.path.join(self.build_cexe,prog)
            else:
                progfile = prog 
                
            log.info("Building file : %s" % dest)
            
            commandline = command % {'prog' : progfile,
                                     'dest' : destfile}

            log.info("    --> %s" % commandline)
            
            os.system(commandline)
            self.files[dest]=destfile
            
            log.info("Done.\n")