@@ -30,32 +30,36 @@ class QtCreator(Exporter):
30
30
def generate (self ):
31
31
self .resources .win_to_unix ()
32
32
33
- with open ("%s.creator" % self .project_name , "w" ) as fd :
34
- fd .write ("[General]\n " )
33
+ defines = [] # list of tuples ('D'/'U', [key, value]) (value is optional)
34
+ forced_includes = [] # list of strings
35
+ sources = [] # list of strings
36
+ include_paths = [] # list of strings
35
37
36
38
next_is_include = False
37
- includes = []
38
- with open ("%s.config" % self .project_name , "w" ) as fd :
39
- for f in self .flags ['c_flags' ] + self .flags ['cxx_flags' ]:
40
- f = f .strip ()
41
- if next_is_include :
42
- includes .append (f )
43
- next_is_include = False
44
- continue
45
- if f .startswith ('-D' ):
46
- fd .write ("#define %s\n " % (f [2 :].replace ('=' , ' ' )))
47
- elif f .startswith ('-U' ):
48
- fd .write ("#undef %s\n " % f [2 :])
49
- elif f == "-include" :
50
- next_is_include = True
51
- for i in includes :
52
- fd .write ("#include \" %s\" \n " % i )
53
-
54
- with open ("%s.files" % self .project_name , "w" ) as fd :
55
- for r_type in ['headers' , 'c_sources' , 's_sources' , 'cpp_sources' ]:
56
- for f in getattr (self .resources , r_type ):
57
- fd .write (f + "\n " )
58
-
59
- with open ("%s.includes" % self .project_name , "w" ) as fd :
60
- for i in self .resources .inc_dirs :
61
- fd .write (i + "\n " )
39
+ for f in self .flags ['c_flags' ] + self .flags ['cxx_flags' ]:
40
+ f = f .strip ()
41
+ if next_is_include :
42
+ forced_includes .append (f )
43
+ next_is_include = False
44
+ continue
45
+ if f .startswith ('-D' ):
46
+ defines .append (('D' , f [2 :].split ('=' , 1 )))
47
+ elif f .startswith ('-U' ):
48
+ defines .append (('U' , [f [2 :]]))
49
+ elif f == "-include" :
50
+ next_is_include = True
51
+
52
+ for r_type in ['headers' , 'c_sources' , 's_sources' , 'cpp_sources' ]:
53
+ sources .extend (getattr (self .resources , r_type ))
54
+
55
+ include_paths = self .resources .inc_dirs
56
+
57
+ ctx = {
58
+ 'defines' : defines ,
59
+ 'forced_includes' : forced_includes ,
60
+ 'sources' : sources ,
61
+ 'include_paths' : self .resources .inc_dirs
62
+ }
63
+
64
+ for ext in ['creator' , 'files' , 'includes' , 'config' ]:
65
+ self .gen_file ('qtcreator/%s.tmpl' % ext , ctx , "%s.%s" % (self .project_name , ext ))
0 commit comments