@@ -32,19 +32,15 @@ function generate_single(target, sourcefile, opt)
3232 local fileconfig = target :fileconfig (sourcefile )
3333 local autogendir = path .join (target :autogendir (), " platform/windows/idl" )
3434
35- local enable_server = true
36- local enable_client = true
35+ local enable_server
36+ local enable_client
3737 local defs = table .wrap (target :get (" defines" ) or {})
3838 local incs = table .wrap (target :get (" includedirs" ) or {})
3939 local undefs = table .wrap (target :get (" undefines" ) or {})
4040
4141 if fileconfig then
42- if fileconfig .server then
43- enable_server = fileconfig .server
44- end
45- if fileconfig .client then
46- enable_client = fileconfig .client
47- end
42+ enable_server = fileconfig .server
43+ enable_client = fileconfig .client
4844 if fileconfig .includedirs then
4945 table .join2 (incs , fileconfig .includedirs )
5046 end
@@ -104,13 +100,13 @@ function generate_single(target, sourcefile, opt)
104100 path (sourcefile )
105101 })
106102
107- local dependfile = path .join (autogendir , path .basename (sourcefile ) .. " .idl.d" )
108103 depend .on_changed (function ()
109104 progress .show (opt .progress or 0 , " ${color.build.object}generating.idl %s" , sourcefile )
110105 os .vrunv (midl .program , flags , { envs = msvc :runenvs () })
111106 end , {
112107 files = sourcefile ,
113- dependfile = dependfile
108+ dependfile = target :dependfile (sourcefile ),
109+ changed = target :is_rebuilt ()
114110 })
115111end
116112
@@ -124,67 +120,37 @@ function configure(target)
124120end
125121
126122function generate_idl (target , jobgraph , sourcebatch , opt )
127- local idljob = target :fullname () .. " /generate/midl"
128- jobgraph :group (idljob , function ()
129- for _ , sourcefile in ipairs (sourcebatch .sourcefiles ) do
130- local midljob = target :fullname () .. " /generate/" .. sourcefile
131- jobgraph :add (midljob , function (index , total , opt )
132- generate_single (target , sourcefile , opt )
133- end )
134- end
135- end )
123+ for _ , sourcefile in ipairs (sourcebatch .sourcefiles ) do
124+ local midljob = target :fullname () .. " /generate/" .. sourcefile
125+ jobgraph :add (midljob , function (index , total , opt )
126+ generate_single (target , sourcefile , opt )
127+ end )
128+ end
136129end
137130
138131function build_idlfiles (target , jobgraph , sourcebatch , opt )
139132 local autogendir = path .join (target :autogendir (), " platform/windows/idl" )
140-
141- local function addsrc ( sourcename , suffix , mysources )
142- local fullfile = path . join ( autogendir , sourcename .. suffix )
143- if os . exists ( fullfile ) then
144- table.insert (mysources , fullfile )
133+ for _ , sourcefile in ipairs ( sourcebatch . sourcefiles ) do
134+ local fileconfig = target : fileconfig ( sourcefile )
135+ local files = { " _i.c " , " _c.c " , " _s.c " }
136+ if fileconfig and fileconfig . proxy then
137+ table.insert (files , " _p.c " )
145138 end
146- end
147-
148- local build_midl = target :fullname () .. " /obj/midl"
149- jobgraph :group (build_midl , function ()
150- for _ , sourcefile in ipairs (sourcebatch .sourcefiles ) do
151- local ccjob = target :fullname () .. " /obj/" .. sourcefile
152- jobgraph :add (ccjob , function (index , total , opt )
153- local fileconfig = target :fileconfig (sourcefile )
154- local enable_proxy = true
155- if fileconfig then
156- if fileconfig .proxy then
157- enable_proxy = fileconfig .proxy
158- end
159- end
160- local name = path .basename (sourcefile )
161- local mysources = {}
162139
140+ local name = path .basename (sourcefile )
141+ for _ , suffix in ipairs (files ) do
142+ local c_sourcefile = path .join (autogendir , name .. suffix )
143+ local objectfile = target :objectfile (c_sourcefile )
144+ local dependfile = target :dependfile (objectfile )
145+ local cc_job_name = path .join (target :fullname (), " /obj/" , c_sourcefile )
146+ jobgraph :add (cc_job_name , function (index , total , jobopt )
163147 -- we don't have a way to detect which midl files are generated
164- addsrc (name , " _i.c" , mysources )
165- if enable_proxy then
166- addsrc (name , " _p.c" , mysources )
148+ if os .exists (c_sourcefile ) then
149+ table.insert (target :objectfiles (), objectfile )
150+ local build_opt = table .join ({objectfile = objectfile , dependfile = dependfile , sourcekind = " cc" , progress = jobopt .progress }, opt )
151+ build_objectfiles .build_object (target , c_sourcefile , build_opt )
167152 end
168- addsrc (name , " _c.c" , mysources )
169- addsrc (name , " _s.c" , mysources )
170-
171- local batchcxx = {
172- rulename = " c.build" ,
173- sourcekind = " cc" ,
174- sourcefiles = mysources ,
175- objectfiles = {},
176- dependfiles = {}
177- }
178- for _ , sourcefile in ipairs (batchcxx .sourcefiles ) do
179- local objfile = target :objectfile (sourcefile )
180- local depfile = target :objectfile (objfile )
181- table.insert (target :objectfiles (), objfile )
182- table.insert (batchcxx .objectfiles , objfile )
183- table.insert (batchcxx .dependfiles , depfile )
184- table.insert (target :objectfiles (), objfile )
185- end
186- build_objectfiles .build (target , batchcxx , opt )
187- end )
153+ end , {distcc = opt .distcc })
188154 end
189- end )
155+ end
190156end
0 commit comments