~ubuntu-branches/ubuntu/utopic/adios/utopic

« back to all changes in this revision

Viewing changes to .pc/python3.patch/utils/skel/lib/skel_makefile.py

  • Committer: Package Import Robot
  • Author(s): Alastair McKinstry
  • Date: 2013-12-09 15:21:31 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20131209152131-jtd4fpmdv3xnunnm
Tags: 1.5.0-1
* New upstream.
* Standards-Version: 3.9.5
* Include latest config.{sub,guess} 
* New watch file.
* Create libadios-bin for binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import argparse
 
4
import os
 
5
import sys
 
6
 
 
7
import adios
 
8
import skelconf
 
9
import skel_settings
 
10
 
 
11
 
 
12
 
 
13
def generate_makefiles (params, config):
 
14
    lang = config.get_host_language()
 
15
    if "C" == lang or "c" == lang:
 
16
        generate_makefiles_c (params)
 
17
    else:
 
18
        generate_makefiles_fortran (params)
 
19
 
 
20
 
 
21
 
 
22
def generate_makefiles_fortran (params):
 
23
 
 
24
    platform = params.get_target()
 
25
 
 
26
    settings = skel_settings.skel_settings()
 
27
 
 
28
    makefile = open ('Makefile', 'w')
 
29
 
 
30
    # Makefile generation no longer depends on the target, just using default here.
 
31
    #makefile_template_name = '~/.skel/templates/Makefile.' + platform + '.tpl'
 
32
    makefile_template_name = '~/.skel/templates/Makefile.default.tpl'
 
33
    makefile_template = open(os.path.expanduser(makefile_template_name), 'r')
 
34
 
 
35
    include_statement = "" + os.path.dirname (sys.argv[0]) + '/../etc/skel/compiler_fragment.mk'
 
36
 
 
37
    for template_line in makefile_template:
 
38
 
 
39
        # Fill in any replacement vars in this line...
 
40
        template_line = template_line.replace ('$$APP$$', params.get_application () )
 
41
        template_line = template_line.replace ('$$INCLUDE$$', include_statement)
 
42
        template_line = template_line.replace ('$$TARGET$$', platform)
 
43
        template_line = template_line.replace ('$$DEPLOY_DIR$$', settings.get_deploy_dir())
 
44
        template_line = template_line.replace ('$$CORES_USED$$', '%d'%params.get_batches()[0].get_cores())
 
45
 
 
46
        if '$$CTESTS$$' in template_line:
 
47
            template_line = template_line.replace ('$$CTESTS$$', '')
 
48
 
 
49
        if '$$FTESTS$$' in template_line:
 
50
            test_string = ''
 
51
            test_set = set()
 
52
            for batch in params.get_batches():
 
53
                for test in batch.get_tests():
 
54
                    test_set.add (params.get_application() + '_skel_' + test.get_group_name() + '_' + test.get_type() + ' ')
 
55
 
 
56
            for t in test_set:
 
57
                test_string = test_string + t
 
58
            template_line = template_line.replace ('$$FTESTS$$', test_string)
 
59
 
 
60
        makefile.write (template_line)
 
61
 
 
62
 
 
63
def generate_makefiles_c (params):
 
64
 
 
65
    platform = params.get_target()
 
66
 
 
67
    settings = skel_settings.skel_settings()
 
68
 
 
69
    makefile = open ('Makefile', 'w')
 
70
 
 
71
    # Makefile generation no longer depends on the target, just using default here.
 
72
    #makefile_template_name = os.path.dirname (sys.argv[0]) + '/../etc/skel/templates/Makefile.' + platform + '.tpl'
 
73
    makefile_template_name = os.path.dirname (sys.argv[0]) + '/../etc/skel/templates/Makefile.default.tpl'
 
74
    makefile_template = open(os.path.expanduser(makefile_template_name), 'r')
 
75
 
 
76
    include_statement = "" + os.path.dirname (sys.argv[0]) + '/../etc/skel/compiler_fragment.mk'
 
77
 
 
78
    for template_line in makefile_template:
 
79
 
 
80
        # Fill in any replacement vars in this line...
 
81
        template_line = template_line.replace ('$$APP$$', params.get_application () )
 
82
        template_line = template_line.replace ('$$INCLUDE$$', include_statement)
 
83
        template_line = template_line.replace ('$$TARGET$$', platform)
 
84
        template_line = template_line.replace ('$$DEPLOY_DIR$$', settings.get_deploy_dir())
 
85
 
 
86
        template_line = template_line.replace ('$$CORES_USED$$', '%d'%params.get_batches()[0].get_cores())
 
87
 
 
88
        if '$$FTESTS$$' in template_line:
 
89
            template_line = template_line.replace ('$$FTESTS$$', '')
 
90
 
 
91
        if '$$CTESTS$$' in template_line:
 
92
            test_string = ''
 
93
            test_set = set()
 
94
            for batch in params.get_batches():
 
95
                for test in batch.get_tests():
 
96
                    test_set.add (params.get_application() + '_skel_' + test.get_group_name() + '_' + test.get_type() + ' ')
 
97
 
 
98
            for t in test_set:
 
99
                test_string = test_string + t
 
100
            template_line = template_line.replace ('$$CTESTS$$', test_string)
 
101
 
 
102
        makefile.write (template_line)
 
103
 
 
104
 
 
105
def parse_command_line():
 
106
 
 
107
    parser = argparse.ArgumentParser (description='Create a Makefile for the given skel project')
 
108
    parser.add_argument ('project', metavar='project', help='Name of the skel project')
 
109
 
 
110
    return parser.parse_args()
 
111
 
 
112
 
 
113
def main(argv=None):
 
114
 
 
115
    skel_settings.create_settings_dir_if_needed()
 
116
 
 
117
    args = parse_command_line()
 
118
 
 
119
    config = adios.adiosConfig (args.project + '_skel.xml')
 
120
    params = skelconf.skelConfig (args.project + '_params.xml')
 
121
 
 
122
    lang = config.get_host_language ()
 
123
    if 'c' == lang or 'C' == lang:
 
124
        print 'generating C flavored Makefile'
 
125
        generate_makefiles_c (params)
 
126
    else:
 
127
        print 'generating fortran flavored Makefile'
 
128
        generate_makefiles_fortran (params)
 
129
 
 
130
 
 
131
 
 
132
if __name__ == "__main__":
 
133
    main()
 
134
 
 
135
 
 
136