PmDriver.icl 81.4 KB
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1
2
3
4
5
6
7
8
9
implementation module PmDriver

import StdArray, StdBool, StdList, StdMisc, StdEnum
import StdPSt, StdSystem, StdPStClass, StdTimer
import StdWindow

import UtilNewlinesFile, UtilIO

import IdeState
10

11
from typewin import updateTypeWindow, tw_safe_close, class Typer, :: TypeWinInfo
Diederik van Arkel's avatar
Diederik van Arkel committed
12
from typeatt import typeWinKeyboard, typeWinMouse
13
from errwin  import updateErrorWindow, ew_safe_close
Diederik van Arkel's avatar
Diederik van Arkel committed
14
from messwin import showInfo, :: InfoMessage(..)
Diederik van Arkel's avatar
Diederik van Arkel committed
15
from projwin import pm_update_project_window
16
17
18
19
20

import PmCleanSystem
import PmPath
import PmProject
from PmDialogues import doPathsDialog
21
import PmAbcMagic
Diederik van Arkel's avatar
Diederik van Arkel committed
22
23
import PmFileInfo
import PmDirCache
24

Diederik van Arkel's avatar
Diederik van Arkel committed
25
import interrupt,Platform
26
from Directory import :: Date`(..), :: Time`(..)
Diederik van Arkel's avatar
Diederik van Arkel committed
27
28

//from dodebug import trace_n`
29
import dodebug
Diederik van Arkel's avatar
Diederik van Arkel committed
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
trace_n _ g :== g

//--

verboseInfo verbose info ps :== verbi verbose info ps
where
	verbi verbose info ps
		| not verbose && level3 info
			= ps
			= showInfo info ps

	level3 (Level3 _) = True
	level3 _ = False

traceInfo _ ps :== ps
//traceInfo i ps :== showInfo i ps

//--

getFICache` ps
	# (_,ps)	= getFICache ps
	# fi		= FI_EmptyCache
	= (fi,ps)


/*--- TO DO:

system module dependancy analysis is possible...

	ie. when you encounter a system module that must be recompiled then check in done list
	and remove those that depend on this system module and put them back into the todo list

should also be possible to detect cycles... -> generate warning dialogue...

---*/

System			:== "_system"

//--- project manager routines

:: SetMadeProjectFun :== (Bool -> Bool -> Project -> (PSt General) -> PSt General)

//	Compile /Check Syntax of the designated module
CompileProjectModule ::	!CompileOrCheckSyntax !Pathname !Project !SetMadeProjectFun !*(PSt General) -> *(PSt General)
CompileProjectModule compilerOrCheckSyntax path project setproject ps
75
76
77
	# (ccstring,ps)			= getCurrentComp ps
	# (startupdir,ps)		= getStup ps
	#! (_,ps)				= ClearCompilerCache ccstring startupdir ps
Diederik van Arkel's avatar
Diederik van Arkel committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	# (syspaths,ps)			= getCurrentPaths ps
	# prjpaths				= PR_GetPaths project
	# srcpaths				= AppendLists prjpaths syspaths
	#! (abccache,ps)		= getABCCache ps
	#! (fileinfo,ps)		= getFICache` ps
	#! ((errs,warns,dircache),ps)
							= accFiles (DC_Setup srcpaths) ps
	# ({be_verbose},ps)		= getPrefs ps
	#! ps					= HandleDCErrors be_verbose errs warns ps
	#! (ps,fileinfo,_,abccache,project,ok,newpaths,_,_)
							= CompileTheProjectModule True compilerOrCheckSyntax path fileinfo dircache abccache project ps
	# ps					= setABCCache abccache ps
	# ps					= setFICache fileinfo ps
	= setproject ok newpaths project ps

GenAsmProjectModule :: !.Pathname !Project !SetMadeProjectFun !*(PSt General) -> *(PSt *General)
GenAsmProjectModule path project setproject ps
95
96
97
	# (ccstring,ps)			= getCurrentComp ps
	# (startupdir,ps)		= getStup ps
	#! (_,ps)				= ClearCompilerCache ccstring startupdir ps
Diederik van Arkel's avatar
Diederik van Arkel committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
	# (syspaths,ps)			= getCurrentPaths ps
	# prjpaths				= PR_GetPaths project
	# srcpaths				= AppendLists prjpaths syspaths
	# (abccache,ps)			= getABCCache ps
	#! (fileinfo,ps)		= getFICache` ps
	# ((errs,warns,dircache),ps)
							= accFiles (DC_Setup srcpaths) ps
	# ({be_verbose},ps)		= getPrefs ps
	# ps					= HandleDCErrors be_verbose errs warns ps
	# (ps,fileinfo,_,abccache,project,ok,newpaths,abcpath,_)
							= CompileTheProjectModule True Compilation path fileinfo dircache abccache project ps
	| not ok || newpaths
		# ps				= setABCCache abccache ps
		# ps				= setFICache fileinfo ps
		= setproject True False project ps
	#	(ps,abccache,fileinfo,project,ok,_)
							= GenCodeTheProjectModule True False AsmGeneration abcpath abccache fileinfo project ps
	# ps					= setABCCache abccache ps
	# ps					= setFICache fileinfo ps
	= setproject True ok project ps

119
:: CleanupCont :== Pathname Bool Bool *(PSt *General) -> *(PSt *General)
Diederik van Arkel's avatar
Diederik van Arkel committed
120
121
122
123
124
125
126
127
128
129
130

BringProjectUptoDate :: !Bool CleanupCont !*(PSt *General) -> *PSt *General
BringProjectUptoDate force continuation ps
	#  (project,ps)		= getProject ps

	#	ps				= ew_safe_close ps							// close error window
	#	ps				= tw_safe_close ps							// close types window

	#	ps				= PrecompileFase project ps

	#	ps				= showInfo (Level1 "Bring up to date...") ps
131
132
133
	# (ccstring,ps)		= getCurrentComp ps
	# (startupdir,ps)	= getStup ps
	#! (_,ps)			= ClearCompilerCache ccstring startupdir ps
Diederik van Arkel's avatar
Diederik van Arkel committed
134
135

	#!	(intr_info,ps) 	= getInterrupt ps
Diederik van Arkel's avatar
Diederik van Arkel committed
136
//		(interact,ps) 	= getInteract ps
Diederik van Arkel's avatar
Diederik van Arkel committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
		ini_step		= DInit force project cleanup
	#	ps				= StartIntr intr_info ini_step step ps
	= ps
where
	PrecompileFase project ps
		# (precompile,project)	= PR_GetPrecompile project
		| isJust precompile
			# ps				= showInfo (Level1 "Precompile...") ps
			# (ok,ec,ps)		= Execute` (fromJust precompile) ps
			// error handling???
			= trace_n ("PRE",ok,ec) ps
		= trace_n "NO-PRE" ps
	
	PostlinkFase project ps
		# (postlink,project)	= PR_GetPostlink project
		| isJust postlink
			# ps				= showInfo (Level1 "Postlink...") ps
			# (ok,ec,ps)		= Execute` (fromJust postlink) ps
			= ps
		= ps
	
	cleanup :: !Bool !Bool !Bool !FileInfoCache !StaticLibInfo !(List Modulename) !Project !Bool (!*ABCCache,!(PSt *General)) -> *(!*DriverState,!PSt *General)
	cleanup ok newpaths linked fileinfo libsinfo modpaths project intr (abccache,ps)
		| newpaths && not intr		// if paths have changed -> try again
			# ps			= showInfo (Level1 "Paths have changed: remaking.") ps
162
163
164
			# (ccstring,ps)			= getCurrentComp ps
			# (startupdir,ps)		= getStup ps
			#! (_,ps)		= ClearCompilerCache ccstring startupdir ps
Diederik van Arkel's avatar
Diederik van Arkel committed
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
			= MakeTheProject False fileinfo libsinfo abccache project cleanup` ps

		# ps				= PostlinkFase project ps
		
		# ps				= showInfo (Level1 "Finished making.") ps
		# ps				= setProject project ps
		# ps				= setABCCache abccache ps
		# ps				= setFICache fileinfo ps
		# ps				= pm_update_project_window ps
		# path				= PR_GetExecPath project
		= stop (DDone,continuation path linked ok ps)
	
	cleanup` :: MTPContinuation
	cleanup` = cleanup

//-- Private stuff

Diederik van Arkel's avatar
Diederik van Arkel committed
182
:: MTPContinuation :== Bool Bool Bool FileInfoCache StaticLibInfo (List Modulename) Project Bool *(*ABCCache,(PSt *General)) -> *(*DriverState,PSt *General)
Diederik van Arkel's avatar
Diederik van Arkel committed
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214

MakeTheProject :: !Bool !FileInfoCache !StaticLibInfo !*ABCCache !Project !MTPContinuation !(PSt General) -> (!*DriverState,!PSt General)
MakeTheProject force fileinfo libsinfo abccache project continue ps
	# (syspaths,ps)			= getCurrentPaths ps
	# prjpaths				= PR_GetPaths project
	# srcpaths				= AppendLists prjpaths syspaths
	# ((errs,warns,dircache),ps)
							= accFiles (DC_Setup srcpaths) ps
	# ({be_verbose},ps)		= getPrefs ps
	# ps					= HandleDCErrors be_verbose errs warns ps
	# (root,project)		= PR_GetRootPathName project
	# root					= MakeDefPathname root	// avoid double compilation...
	# inidone				= Nil
	# (env_static_libs,ps)	= getCurrentSlibs ps
	# sfiles				= (StrictListToList(Concat (SL_Libs libsinfo) env_static_libs))
	# (err,ps)				= check_exists sfiles ps
	| isJust err
		# line				= Level3 ["Error: Unable to find static library: '" +++ fromJust err +++ "'."]
		# ps				= showInfo line ps
		= continue False False False fileinfo libsinfo Nil project False (abccache, ps)
	# ((errs,slibs),ps)		= accFiles (getLibs sfiles) ps
	| not (isEmpty errs)
		# line				= Level3 ["Error: Failed reading static libraries: '" :errs]
		# ps				= showInfo line ps
		= continue False False False fileinfo libsinfo Nil project False (abccache, ps)
	# slibs					= ListToStrictList slibs
	# libsinfo				= SL_SetDcls slibs libsinfo
	# ps					= showInfo (Level1 "Compiling...") ps
	# rest					= root :! Nil
	# (method,ps)			= getCurrentMeth ps
	# compinfo = case method of
				CompileSync			-> Sync
215
216
217
				(CompileAsync cmax)	-> PlatformDependant
										(AsyncWin cmax [])								// win
										(Async [] cmax 0 NoUnknownFinishedProcessors)	// mac
Diederik van Arkel's avatar
Diederik van Arkel committed
218
				CompilePers			-> Pers InitCompilingInfo
219
	= step False (DComp force inidone compinfo rest fileinfo dircache abccache libsinfo project False continue) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
where
	check_exists [] ps = (Nothing,ps)
	check_exists [file:rest] ps
		# (ok,ps) = accFiles (FExists file) ps
		| ok = check_exists rest ps
		= (Just file,ps)

:: CurrentlyCompiled =
	{ iclModule	:: !String
	, options	:: CompilerOptions
	, slot		:: !Int
	}

//--

cont :: !*(.a,*(PSt *General)) -> *(.a,*(PSt *General));
cont (ls,ps)
	# (intr_info,ps) 	= getInterrupt ps
	# ps				= ContIntr intr_info ps
	= (ls,ps)

stop :: !*(.a,*(PSt *General)) -> *(.a,*(PSt *General));
stop (ls,ps)
	# (intr_info,ps) 	= getInterrupt ps
	# ps				= StopIntr intr_info ps
	= (ls,ps)

Diederik van Arkel's avatar
Diederik van Arkel committed
247
step :: !Bool !*DriverState !*(PSt General) -> (!*DriverState,!*(PSt General))
Diederik van Arkel's avatar
Diederik van Arkel committed
248
step intr (DInit force project setproject) ps
249
	# ps				= showInfo (Level1 "Make the project...") ps
Diederik van Arkel's avatar
Diederik van Arkel committed
250
251
252
253
254
	# libsinfo			= PR_GetStaticLibsInfo project
	# (abccache,ps)		= getABCCache ps
	# (fileinfo,ps)		= getFICache` ps
	= MakeTheProject force fileinfo libsinfo abccache project setproject ps

255
step True (DComp force done (Pers inf) rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
256
257
	// compile phase finished: kill clean compiler
	# (_,ps)				= ExitCleanCompiler (inf,ps)
258
	= step True (DGene False newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
259

260
step True (DComp force done compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
261
	// need async cocl shootdown as well..
262
	= step True (DGene False newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
263

264
step intr (DComp force done Sync Nil fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
265
	// compile phase finished: remove all modules not (indirectly) imported by main module
266
	# project				= PR_SetBuilt done project	// removes unused modules
Diederik van Arkel's avatar
Diederik van Arkel committed
267
268
	# (modpaths,project)	= PR_GetModulenames True IclMod project
	# ps					= showInfo (Level1 "Generating...") ps
269
	= step intr (DGene True newpaths fileinfo libsinfo modpaths modpaths SyncCodeGeneration abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
270

271
step intr (DComp force done compinfo=:Sync (next :! rest) fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
272
	// compile phase: check module 'next'
273
	| StringOccurs next done
Diederik van Arkel's avatar
Diederik van Arkel committed
274
		// if already done then skip
275
		= step intr (DComp force done compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
276
	# modname					= GetModuleName next
277
278
279
280
281
282
	| isProjLibraryModule modname libsinfo
		// kan ipv dit hier te testen deze ook meteen in done zetten?! ruzie met rest admi...
		= step intr (DComp force done compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
	# (ps,fileinfo,dircache,abccache,project,ok,newpaths`,rest,compinfo,done,_)
							= UpdateDependencies force next done rest compinfo fileinfo dircache abccache libsinfo project ps
	# newpaths = newpaths || newpaths`
Diederik van Arkel's avatar
Diederik van Arkel committed
283
	| not ok
284
285
286
//XXX		= step intr (DGene ok newpaths fileinfo libsinfo done done abccache project setproject) ps
		= step intr (DGene ok newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject) ps
	= cont (DComp force (next :! done) compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject,ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
287

288
step intr (DComp force done (Pers inf) Nil fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
289
290
291
	// compile phase finished: kill clean compiler
	# (_,ps)				= ExitCleanCompiler (inf,ps)
	// compile phase finished: remove all modules not (indirectly) imported by main module
292
	# project				= PR_SetBuilt done project	// removes unused modules
Diederik van Arkel's avatar
Diederik van Arkel committed
293
294
295
	# (modpaths,project)	= PR_GetModulenames True IclMod project
	# ps					= showInfo (Level1 "Generating...") ps
//XXX	= step intr (DGene True newpaths fileinfo libsinfo modpaths modpaths abccache project setproject) ps
296
	= step intr (DGene True newpaths fileinfo libsinfo modpaths modpaths SyncCodeGeneration abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
297

298
step intr (DComp force done compinfo=:(Pers inf) (next :! rest) fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
299
	// compile phase: check module 'next'
300
	| StringOccurs next done
Diederik van Arkel's avatar
Diederik van Arkel committed
301
		// if already done then skip
302
		= step intr (DComp force done compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
303
	# modname					= GetModuleName next
304
305
306
307
308
309
	| isProjLibraryModule modname libsinfo
		// kan ipv dit hier te testen deze ook meteen in done zetten?! ruzie met rest admi...
		= step intr (DComp force done compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
	# (ps,fileinfo,dircache,abccache,project,ok,newpaths`,rest,compinfo,done,_)
							= UpdateDependencies force next done rest compinfo fileinfo dircache abccache libsinfo project ps
	# newpaths = newpaths || newpaths`
Diederik van Arkel's avatar
Diederik van Arkel committed
310
	| not ok
311
312
313
314
315
316
317
318
319
320
321
322
323
//XXX		= step intr (DGene ok newpaths fileinfo libsinfo done done abccache project setproject) ps
		= step intr (DGene ok newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject) ps
	= cont (DComp force (next :! done) compinfo rest fileinfo dircache abccache libsinfo project newpaths setproject,ps)

/* DEBUG...
step intr (DComp force done current todo fileinfo dircache abccache libsinfo project newpaths setproject) ps
	# ((abccache,fileinfo,modinfo),ps)= FI_GetFileInfo CurrentProcessor "C:\\Clean\\StdEnv\\StdTuple.icl" abccache fileinfo ps
	# ps = showInfo (Level3 ["step <>"+++toString modinfo.abcdate+++" <-> "+++toString modinfo.objdate]) ps	// DEBUG
	# state = (DComp force done current todo fileinfo dircache abccache libsinfo project newpaths setproject)
 ...DEBUG */

//XXX step intr state=:(DComp force done (Async _ []) Nil fileinfo _ abccache libsinfo project newpaths setproject) ps
step intr (DComp force done (Async [] max_n_processes n_used_processors NoUnknownFinishedProcessors) Nil fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
324
	// compile phase finished: remove all modules not (indirectly) imported by main module
325
326
327
328
//	(DComp force done (Async cmax current) todo fileinfo dircache abccache libsinfo project newpaths setproject)
//	# state		= (DGene ok newpaths fileinfo libsinfo done done abccache project setproject, ps)
//	= cont (state, ps)
	# project				= PR_SetBuilt done project	// removes unused modules
Diederik van Arkel's avatar
Diederik van Arkel committed
329
	# (modpaths,project)	= PR_GetModulenames True IclMod project
330
331
332
//YYY	
	# (os_error,ps) = ClearCompilerCaches n_used_processors ps;
	
Diederik van Arkel's avatar
Diederik van Arkel committed
333
	# ps					= showInfo (Level1 "Generating...") ps
334
335
//XXX	= step intr (DGene True newpaths fileinfo libsinfo modpaths modpaths abccache project setproject) ps
	= step intr (DGene True newpaths fileinfo libsinfo modpaths modpaths (ASyncCodeGeneration [] max_n_processes NoUnknownFinishedProcessors) abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
336

337
338
//XXX step intr state=:(DComp force _ (Async _ _) _ fileinfo _ _ _ _ _ _) ps
step intr state=:(DComp force _ (Async _ _ _ _) _ fileinfo _ _ _ _ _ _) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
339
340
341
342
343
344
	# ps					= traceInfo (Level3 ["check_completed..."]) ps
	# (state, ps) = check_completed state ps
	# ps					= traceInfo (Level3 ["start_compilations..."]) ps
	# (state, ps) = start_compilations state ps
	= cont (state, ps)
	where
345
/*XXX
Diederik van Arkel's avatar
Diederik van Arkel committed
346
		check_completed :: !*DriverState !*(PSt General) -> !(!*DriverState,!*PSt General)
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
		check_completed state=:(DComp force _ (Async cmax current=:[_:_]) _ _ _ _ _ _ _ _)  ps
			=	case (CompilePollCompleted ps) of
					(Nothing, ps)
						-> (state, ps)
					(Just (completedSlot,exitcode), ps)
						#! (state,ps) = process_completed completedSlot exitcode state ps
						-> check_completed state ps
		check_completed state ps
			=	(state, ps)

		process_completed :: !Int !Int !*DriverState !*(PSt General) -> !(!*DriverState,!*PSt General)
		process_completed completedSlot exitcode (DComp force done (Async cmax current) todo fileinfo dircache abccache libsinfo project newpaths setproject) ps
			# (completed, current)	= removeFromCurrent completedSlot current
			# (startupdir,ps)		= getStup ps
			  typewin				= updateTypeWindow (GetModuleName completed.iclModule) [typeWinKeyboard, typeWinMouse]
			# ccstring				= "dummy ccstring for now.."
			# (ps,abcpath,res)		= CompileHandleExitCode exitcode ccstring startupdir completedSlot updateErrorWindow typewin 
										completed.iclModule completed.options.listTypes ps // types param
			# (ps,fileinfo,dircache,abccache,project,ok,newpaths`,_,deps)
									= ProcessCompilerMsg Compilation completed.options completed.iclModule abcpath res fileinfo dircache abccache project ps
			# newpaths				= newpaths || newpaths`
			| ok
				=	(DComp force (completed.iclModule :! done) (Async cmax current) (Concat deps todo) fileinfo dircache abccache libsinfo project newpaths setproject, ps)
			// not ok
				=	(DGene ok newpaths fileinfo libsinfo done done abccache project setproject, ps)
			where
				removeFromCurrent :: Int [CurrentlyCompiled] -> (CurrentlyCompiled, [CurrentlyCompiled])
				removeFromCurrent _ []
					=	abort "driver.icl: unknown threadId"
				removeFromCurrent completedSlot [current=:{slot} : rest]
					| completedSlot == slot
						=	(current, rest)
					// otherwise
						# (completed, rest) = removeFromCurrent completedSlot rest
						= (completed, [current : rest])

		start_compilations :: !*DriverState !*(PSt General) -> (!*DriverState,!*PSt General)
		start_compilations state=:(DComp force done (Async cmax current) (next :! rest) fileinfo dircache abccache libsinfo project newpaths setproject) ps
//			# (prefs,ps)	= getPrefs ps
//			| length current >= prefs.number_of_processes
			| length current >= cmax
				# ps	= traceInfo (Level3 ["start_compilations druk druk druk..." : [c.iclModule +++ " " +++ toString c.slot \\ c <- current]]) ps
				= (state, ps)
		// compile phase: check module 'next'
			| StringOccurs next done || currently_compiled next current
				# ps = traceInfo (Level3 ["start_compilations " +++ (if (StringOccurs next done) "al gedaan: "  "mee bezig: ") +++ next]) ps
				= start_compilations (DComp force done (Async cmax current) rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
			# modname = GetModuleName next
			# ps = traceInfo (Level3 [("start_compilations next... "
								+++ toString (LLength done)+++ " " 
								+++ toString (length current)+++ " " 
								+++ toString (LLength rest))]) ps
			| isProjLibraryModule modname libsinfo
				// kan ipv dit hier te testen deze ook meteen in done zetten!
				= (DComp force done (Async cmax current) rest fileinfo dircache abccache libsinfo project newpaths setproject, ps)
			# (ps,fileinfo,dircache,abccache,project,ok,_,rest,current,done,_)
				= UpdateDependencies force next done rest (Async cmax current) fileinfo dircache abccache libsinfo project ps
			| not ok
				= (DGene ok newpaths fileinfo libsinfo done done abccache project setproject, ps)
			= start_compilations (DComp force done current rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
		start_compilations state ps
			# ps = traceInfo (Level3 ["start_compilations no next..."]) ps
			= (state, ps)
*/
		check_completed :: !*DriverState !*(PSt General) -> (!*DriverState,!*PSt General)
		check_completed state=:(DComp force _ (Async current=:[_:_] cmax _ _) _ _ _ _ _ _ _ _)  ps
Diederik van Arkel's avatar
Diederik van Arkel committed
413
414
415
416
417
			= case (CompilePollCompleted ps) of
				(NoFinishedCompiler,ps)
					-> check_unknow_processors_are_known state ps
				(UnknownFinishedCompiler,ps)
					-> case state of
418
						DComp force done (Async current cmax n_used_processors unknown_finished_processors) todo fileinfo dircache abccache libsinfo project newpaths setproject
Diederik van Arkel's avatar
Diederik van Arkel committed
419
							# unknown_finished_processors = add_unknown_finished_processor unknown_finished_processors
420
							# state = DComp force done (Async current cmax n_used_processors unknown_finished_processors) todo fileinfo dircache abccache libsinfo project newpaths setproject
Diederik van Arkel's avatar
Diederik van Arkel committed
421
422
423
424
425
426
427
428
							-> check_completed state ps
				(FinishedCompiler completedSlot exitcode,ps)
					# ps = traceInfo (Level3 ["process_completed...",toString completedSlot,toString exitcode]) ps
					#! (state,ps) = process_completed completedSlot exitcode state ps
					-> check_completed state ps
		check_completed state ps
			= check_unknow_processors_are_known state ps

429
		check_unknow_processors_are_known (DComp force done (Async current cmax n_used_processors (UnknownFinishedProcessors n_unknown_finished_processors known_finished_processors)) todo fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
430
			| n_unknown_finished_processors+length known_finished_processors>=cmax
431
				# state = DComp force done (Async current cmax n_used_processors NoUnknownFinishedProcessors) todo fileinfo dircache abccache libsinfo project newpaths setproject
Diederik van Arkel's avatar
Diederik van Arkel committed
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
				# (state,ps) = handle_completed_processes 0 state ps
					with
						handle_completed_processes process_n state ps
							| process_n>=cmax
								= (state,ps)
							| isMember process_n known_finished_processors
								= handle_completed_processes (process_n+1) state ps
								# (_,ps) = SendRepeatResult process_n ps
								/*
								# exitcode = 1
								# ps = traceInfo (Level3 ["process_completed...",toString process_n,toString exitcode]) ps
								#! (state,ps) = process_completed process_n exitcode state ps
								*/
								= handle_completed_processes (process_n+1) state ps								
				= (state, ps)
		check_unknow_processors_are_known state ps
			=	(state, ps)

450
451
452
453
454
455
456
457
458
		process_completed :: !Int !Int !*DriverState !*(PSt General) -> (!*DriverState,!*PSt General)
		process_completed completedSlot exitcode (DComp force done (Async current cmax n_used_processors unknown_finished_processors) todo fileinfo dircache abccache libsinfo project newpaths setproject) ps
			# (completed, current) = removeFromCurrent completedSlot current
			# unknown_finished_processors = remove_from_unknown_finished_processors completedSlot unknown_finished_processors
			# (startupdir,ps)	= getStup ps
			  typewin = updateTypeWindow True (GetModuleName completed.iclModule) [typeWinKeyboard, typeWinMouse]
			# ccstring = "dummy ccstring for now.."
			# (ps,abcpath,res) = CompileHandleExitCode exitcode ccstring startupdir completedSlot updateErrorWindow typewin 
									completed.iclModule completed.options.listTypes ps // types param
Diederik van Arkel's avatar
Diederik van Arkel committed
459
			# (ps,fileinfo,dircache,abccache,project,ok,newpaths`,_,deps)
460
461
				= ProcessCompilerMsg Compilation completed.options completed.iclModule abcpath res fileinfo dircache abccache project ps
			# newpaths = newpaths || newpaths`
Diederik van Arkel's avatar
Diederik van Arkel committed
462
			| ok
463
				= (DComp force (completed.iclModule :! done) (Async current cmax n_used_processors unknown_finished_processors) (Concat deps todo) fileinfo dircache abccache libsinfo project newpaths setproject, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
464
465
			// not ok
				# (os_error,ps) = ClearCompilerCaches n_used_processors ps;
466
				= (DGene ok newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
467
468
469
470
471
472
473
474
475
476
477
478
			where
				removeFromCurrent :: Int [CurrentlyCompiled] -> (CurrentlyCompiled, [CurrentlyCompiled])
				removeFromCurrent _ []
					=	abort "driver.icl: unknown threadId"
				removeFromCurrent completedSlot [current=:{slot} : rest]
					| completedSlot == slot
						=	(current, rest)
					// otherwise
						# (completed, rest) = removeFromCurrent completedSlot rest
						= (completed, [current : rest])

		start_compilations :: !*DriverState !*(PSt General) -> (!*DriverState,!*PSt General)
479
		start_compilations state=:(DComp force done (Async current cmax n_used_processors unknown_finished_processors) (next :! rest) fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
480
481
			| length current >= cmax
				= (state, ps)
482
483
484
		// compile phase: check module 'next'
			| StringOccurs next done || currently_compiled next current
				= start_compilations (DComp force done (Async current cmax n_used_processors unknown_finished_processors) rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
485
			# modname = GetModuleName next
486
487
488
489
490
			| isProjLibraryModule modname libsinfo
				// kan ipv dit hier te testen deze ook meteen in done zetten!
				= (DComp force done (Async current cmax n_used_processors unknown_finished_processors) rest fileinfo dircache abccache libsinfo project newpaths setproject, ps)
			# (ps,fileinfo,dircache,abccache,project,ok,_,rest,current,done,_)
				= UpdateDependencies force next done rest (Async current cmax n_used_processors unknown_finished_processors) fileinfo dircache abccache libsinfo project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
491
492
			| not ok
				# (os_error,ps) = ClearCompilerCaches n_used_processors ps;
493
494
				= (DGene ok newpaths fileinfo libsinfo done done SyncCodeGeneration abccache project setproject, ps)
			= start_compilations (DComp force done current rest fileinfo dircache abccache libsinfo project newpaths setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
495
496
497
498
499
500
501
502
		start_compilations state ps
//			# ps = traceInfo (Level3 ["start_compilations no next..."]) ps
			= (state, ps)

		currently_compiled :: String [CurrentlyCompiled] -> Bool
		currently_compiled next current
			=	or [c.iclModule == next \\ c <- current]

503
/*XXX
Diederik van Arkel's avatar
Diederik van Arkel committed
504
505
506
507
508
509
510
511
step intr state=:(DComp force dircache compinfo=:(AsyncWin _ _) rest ds) ps
	# ps					= traceInfo (Level3 ["check_completed..."]) ps
	# (state, ps) = check_completed state ps
	# ps					= traceInfo (Level3 ["start_compilations..."]) ps
	# (state, ps) = start_compilations state ps
	= cont (state, ps)
	where
		check_completed :: !*DriverState !*(PSt General) -> !(!*DriverState,!*PSt General)
512
		check_completed state=:(DComp force _ _ (AsyncWin cmax current=:[_:_]) _ _)  ps
Diederik van Arkel's avatar
Diederik van Arkel committed
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
			=	case (CompilePollCompleted ps) of
					(NoFinishedCompiler, ps)
						-> (state, ps)
					(FinishedCompiler completedSlot exitcode, ps)
						#! (state,ps) = process_completed completedSlot exitcode state ps
						-> check_completed state ps
					(UnknownFinishedCompiler,ps)
						-> (state, ps)	// -> doesn't occur on win
		check_completed state ps
			=	(state, ps)

		process_completed :: !Int !Int !*DriverState !*(PSt General) -> !(!*DriverState,!*PSt General)
		process_completed completedSlot exitcode (DComp force dircache (AsyncWin cmax current) todo ds) ps
			# (completed, current)	= removeFromCurrent completedSlot current
			# (startupdir,ps)		= getStup ps
			  typewin				= updateTypeWindow (GetModuleName completed.iclModule) [typeWinKeyboard, typeWinMouse]
			# ccstring				= "dummy ccstring for now.."
			# (ps,abcpath,res)		= CompileHandleExitCode exitcode ccstring startupdir completedSlot updateErrorWindow typewin 
										completed.iclModule completed.options.listTypes ps // types param
			# (ps,fileinfo,dircache,abccache,project,ok,newpaths`,_,deps)
									= ProcessCompilerMsg Compilation completed.options completed.iclModule abcpath res ds.fileinfo dircache ds.abccache ds.project ps
			# ds					= {ds & newpaths = ds.newpaths || newpaths`, fileinfo = fileinfo, abccache = abccache, project = project, ok = ok}
			| ok
				# ds						= {ds & modpaths = completed.iclModule :! ds.modpaths}
				= (DComp force dircache (AsyncWin cmax current) (Concat deps todo) ds, ps)
			// not ok
				# (paths,ds)	= ds!modpaths
				= (DGene paths SyncCodeGeneration ds, ps)
			where
				removeFromCurrent :: Int [CurrentlyCompiled] -> (CurrentlyCompiled, [CurrentlyCompiled])
				removeFromCurrent _ []
					=	abort "driver.icl: unknown threadId"
				removeFromCurrent completedSlot [current=:{slot} : rest]
					| completedSlot == slot
						=	(current, rest)
					// otherwise
						# (completed, rest) = removeFromCurrent completedSlot rest
						= (completed, [current : rest])

		start_compilations :: !*DriverState !*(PSt General) -> (!*DriverState,!*PSt General)
		start_compilations state=:(DComp force dircache (AsyncWin cmax current) (next :! rest) ds) ps
			| length current >= cmax
				= (state, ps)
		// compile phase: check module 'next'
			| StringOccurs next ds.modpaths || currently_compiled next current
				= start_compilations (DComp force dircache (AsyncWin cmax current) rest ds) ps
			# modname = GetModuleName next
			| isProjLibraryModule modname ds.libsinfo
				// instead of testing explicitly put libmodules in done <= conflicts with other administration
				= (DComp force dircache (AsyncWin cmax current) rest ds, ps)
			# (ps,dircache,ok,_,rest,compinfo,ds,_)
				= UpdateDependencies force next rest (AsyncWin cmax current) dircache ds ps
			# ds = {ds & ok = ok}
			| not ok
				#! (paths,ds)	= ds!modpaths
				= (DGene paths SyncCodeGeneration ds, ps)
			= start_compilations (DComp force dircache compinfo rest ds) ps
		start_compilations state ps
			= (state, ps)

		currently_compiled :: String [CurrentlyCompiled] -> Bool
		currently_compiled next current
			=	or [c.iclModule == next \\ c <- current]
*/
577
step intr (DGene ok newpaths fileinfo libsinfo Nil modpaths SyncCodeGeneration abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
578
	#! ps	= showInfo (Level1 "Linking...") ps
579
580
581
	= step intr (DLink ok newpaths fileinfo libsinfo modpaths abccache project setproject) ps

step intr (DGene ok newpaths fileinfo libsinfo Nil modpaths (ASyncCodeGeneration [] _ NoUnknownFinishedProcessors) abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
582
	#! ps	= showInfo (Level1 "Linking...") ps
583
584
585
586
587
588
589
	= step intr (DLink ok newpaths fileinfo libsinfo modpaths abccache project setproject) ps

step intr (DGene ok newpaths fileinfo libsinfo (path:!rest) modpaths SyncCodeGeneration abccache project setproject) ps
	| not ok || intr
		= step intr (DLink False newpaths fileinfo libsinfo modpaths abccache project setproject) ps
	# (ps,abccache,fileinfo,gen,abcpath)	= CheckABCOutOfDate False path abccache fileinfo project ps
	# (ps,abccache,fileinfo,project,ok,_)	= GenCodeTheProjectModule gen False CodeGeneration abcpath abccache fileinfo project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
590
	| not ok
591
592
593
594
595
		= step intr (DLink ok newpaths fileinfo libsinfo modpaths abccache project setproject) ps
	= cont (DGene True newpaths fileinfo libsinfo rest modpaths SyncCodeGeneration abccache project setproject, ps)

step intr (DGene no_errors newpaths fileinfo libsinfo paths modpaths (ASyncCodeGeneration busy_processes max_n_processes unknown_finished_processors) abccache project setproject) ps
	# (ok,busy_processes,unknown_finished_processors,project,fileinfo,ps) = handle_finished_code_generators busy_processes unknown_finished_processors project fileinfo ps
Diederik van Arkel's avatar
Diederik van Arkel committed
596
597
598
599
600
601
602
603
604
605
606
607
608
		with
			handle_finished_code_generators busy_processes=:[_:_] unknown_finished_processors project fileinfo ps
				= case (CompilePollCompleted ps) of
					(NoFinishedCompiler, ps)
						-> check_unknow_processors_are_known busy_processes unknown_finished_processors project fileinfo ps
					(UnknownFinishedCompiler,ps)
						# unknown_finished_processors = add_unknown_finished_processor unknown_finished_processors
						-> (True,busy_processes,unknown_finished_processors,project,fileinfo,ps)
					(FinishedCompiler finished_cg_slot_n exit_code, ps)
//						# ps  = trace ("code generator finished "+++toString finished_cg_slot_n+++" "+++toString exit_code+++"\n") ps
//						# ps  = trace ("f "+++toString finished_cg_slot_n+++" "+++toString exit_code+++" ") ps

						# unknown_finished_processors = remove_from_unknown_finished_processors finished_cg_slot_n unknown_finished_processors
609
						# (abc_path,obj_path,busy_processes) = get_paths_and_remove_process_from_list finished_cg_slot_n busy_processes
Diederik van Arkel's avatar
Diederik van Arkel committed
610
							with
611
								get_paths_and_remove_process_from_list finished_cg_slot_n [busy_process=:(slot,abc_path,obj_path) : rest]
Diederik van Arkel's avatar
Diederik van Arkel committed
612
613
									| finished_cg_slot_n==slot
										= (abc_path,obj_path,rest)
614
										# (abc_path,obj_path,rest) = get_paths_and_remove_process_from_list finished_cg_slot_n rest
Diederik van Arkel's avatar
Diederik van Arkel committed
615
										= (abc_path,obj_path,[busy_process:rest])
616
								get_paths_and_remove_process_from_list finished_cg_slot_n []
Diederik van Arkel's avatar
Diederik van Arkel committed
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
									= abort "driver.icl: unknown code generator id"
						| exit_code==0
							# (fileinfo,ps) = accFiles (FI_UpdateObjDate abc_path obj_path fileinfo) ps
							# project = PR_SetCodeGenerated (GetModuleName abc_path) project
							-> handle_finished_code_generators busy_processes unknown_finished_processors project fileinfo ps
							-> (False,busy_processes,unknown_finished_processors,project,fileinfo,ps)
			handle_finished_code_generators [] unknown_finished_processors project fileinfo ps
				= check_unknow_processors_are_known [] unknown_finished_processors project fileinfo ps

			check_unknow_processors_are_known busy_processes (UnknownFinishedProcessors n_unknown_finished_processors known_finished_processors) project fileinfo ps
				| n_unknown_finished_processors+length known_finished_processors>=max_n_processes
					# (busy_processes,project,fileinfo,ps) = handle_completed_processes 0 busy_processes project fileinfo ps
						with
							handle_completed_processes process_n busy_processes project fileinfo ps
								| process_n>=max_n_processes
									= (busy_processes,project,fileinfo,ps)
								| isMember process_n known_finished_processors
									= handle_completed_processes (process_n+1) busy_processes project fileinfo ps
									# (_,ps) = SendRepeatResult process_n ps
									/*
									# unknown_finished_processors = remove_from_unknown_finished_processors finished_cg_slot_n unknown_finished_processors
638
									# (abc_path,obj_path,busy_processes) = get_paths_and_remove_process_from_list finished_cg_slot_n busy_processes
Diederik van Arkel's avatar
Diederik van Arkel committed
639
										with
640
											get_paths_and_remove_process_from_list finished_cg_slot_n [busy_process=:(slot,abc_path,obj_path) : rest]
Diederik van Arkel's avatar
Diederik van Arkel committed
641
642
												| process_n==slot
													= (abc_path,obj_path,rest)
643
													# (abc_path,obj_path,rest) = get_paths_and_remove_process_from_list finished_cg_slot_n rest
Diederik van Arkel's avatar
Diederik van Arkel committed
644
													= (abc_path,obj_path,[busy_process:rest])
645
											get_paths_and_remove_process_from_list finished_cg_slot_n []
Diederik van Arkel's avatar
Diederik van Arkel committed
646
647
648
649
650
651
652
653
												= abort "driver.icl: unknown code generator id"
									# (fileinfo,ps) = accFiles (FI_UpdateObjDate abc_path obj_path fileinfo) ps
									# project = PR_SetCodeGenerated (GetModuleName abc_path) project
									*/
									= handle_completed_processes (process_n+1) busy_processes project fileinfo ps								
					= (True,busy_processes,NoUnknownFinishedProcessors,project,fileinfo,ps)
			check_unknow_processors_are_known busy_processes unknown_finished_processors project fileinfo ps
				= (True,busy_processes,unknown_finished_processors,project,fileinfo,ps)
654
655
	| not no_errors || intr || not ok
		= cont (DGene False newpaths fileinfo libsinfo paths modpaths (ASyncCodeGeneration busy_processes max_n_processes unknown_finished_processors) abccache project setproject,ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
656
	| length busy_processes>=max_n_processes || (case paths of Nil -> True ; _ -> False)
657
658
		= cont (DGene ok newpaths fileinfo libsinfo paths modpaths (ASyncCodeGeneration busy_processes max_n_processes unknown_finished_processors) abccache project setproject,ps)
	# (ok,paths,busy_processes,fileinfo,abccache,ps) = start_code_generators paths busy_processes fileinfo abccache ps
Diederik van Arkel's avatar
Diederik van Arkel committed
659
660
661
662
		with
			start_code_generators paths=:(path :! rest) busy_processes fileinfo abccache ps
				| length busy_processes>=max_n_processes
					= (True,paths,busy_processes,fileinfo,abccache,ps)
663
664
665
				# (ps,abccache,fileinfo,gen,abc_path) = CheckABCOutOfDate False path abccache fileinfo project ps
				# cgo = PR_GetCodeGenOptions project
				# ((abccache,fileinfo,info), ps) = FI_GetFileInfo cgo.tp abc_path abccache fileinfo ps
Diederik van Arkel's avatar
Diederik van Arkel committed
666
667
				| not gen
					= start_code_generators rest busy_processes fileinfo abccache ps
668
669
				# ps = showInfo (Level2 (
//													"Generating code for " +++ RemovePath abc_path
Diederik van Arkel's avatar
Diederik van Arkel committed
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
													(foldl (+++) ("Generating code for "
																	+++ RemovePath abc_path) [" "+++RemovePath abc_path \\ (_,abc_path,_)<-busy_processes])
													)) ps
				# (startupdir,ps)	= getStup ps
				# (cgen,ps)			= getCurrentCgen ps
				# ao				= PR_GetApplicationOptions project
				# (prefs,ps)		= getPrefs ps
				# defaultCO			= prefs.compopts
				# modname			= GetModuleName abc_path
				# co				= case (PR_GetModuleInfo modname project) of
										Just modinfo	-> modinfo.compilerOptions
										_				-> defaultCO
				# tp				= ao.profiling && (not co.neverTimeProfile)
				# free_slot			= hd (removeMembers [0..max_n_processes-1] [slot \\ (slot,_,_) <- busy_processes])				

//				# ps  = trace ("code generator started "+++toString free_slot+++"\n") ps
//				# ps  = trace ("s "+++toString free_slot+++" ") ps

688
				# (res,obj_path,ps) = StartCodeGenerator cgen updateErrorWindow CodeGeneration abc_path free_slot tp cgo ao startupdir ps
Diederik van Arkel's avatar
Diederik van Arkel committed
689
690
691
692
693
694
				| not res				
					= (False,rest,busy_processes,fileinfo,abccache,ps)
				# busy_processes	= [(free_slot,abc_path,obj_path):busy_processes]
				= start_code_generators rest busy_processes fileinfo abccache ps
			start_code_generators Nil busy_processes fileinfo abccache ps
				= (True,Nil,busy_processes,fileinfo,abccache,ps)
695
696
697
	= cont (DGene ok newpaths fileinfo libsinfo paths modpaths (ASyncCodeGeneration busy_processes max_n_processes unknown_finished_processors) abccache project setproject, ps)

step intr (DLink ok newpaths fileinfo libsinfo modpaths abccache project setproject) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
698
699
	//	Check whether executable is out of date and relink it	if required.
	| intr || not ok
700
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
	# lo						= PR_GetLinkOptions project
	# (prj_path,ps)				= getPath ps
	# (app_path,ps)				= getStup ps
	# (defpaths,ps)				= getCurrentPaths ps
	# prjpaths					= PR_GetPaths project
	# srcpaths					= AppendLists prjpaths defpaths

	// set up dircache for 'Clean System Files'
	# ((errs,warns,abcPathsCache),ps)	= accFiles (DC_Setup (Map MakeSystemPathname srcpaths)) ps
	// need to handle this differently? Now barfs on paths without Clean System File subdirs
	// maybe use variant DC_Setup which ignores nonexistent CSF-dirs...
	# ({be_verbose},ps)			= getPrefs ps
	# ps						= HandleDCErrors be_verbose errs warns ps
	# (ok,full_sys0,_,abcPathsCache) = DC_Search (MakeABCPathname System) abcPathsCache
	# full_sys					= full_sys0 +++ {dirseparator} +++ (MakeABCPathname System)
	# full_sys`					= MakeImpPathname full_sys
	
	# ao						= PR_GetApplicationOptions project
	// possibly patch _system to correct profiling settings...

	# tp						= PR_GetProcessor project
	# ((abccache,fileinfo,modinfo),ps)
								= FI_GetFileInfo tp  full_sys` abccache fileinfo ps
	
	# wantstp					= ao.profiling //&& (not co.neverTimeProfile)
	# compile					= /*mp <> info.abcOptions.abcMemoryProfile ||*/ wantstp <> modinfo.abcOptions.abcTimeProfile
	# lines						= if (be_verbose && compile)
									(Level3 ["["+++(MakeABCPathname System)+++",]: compiled with different options"])
									(Level3 [])
730
	# ps						= showInfo lines ps
Diederik van Arkel's avatar
Diederik van Arkel committed
731
732
733
734
735
	# (version,ps)				= getCurrentVers ps
	# (patched, ps)				= accFiles (PatchSystemABC version compile full_sys /*ao.memoryProfiling*/ wantstp) ps
	| not patched
		# line					= Level3 ["Error: ["+++(MakeABCPathname System)+++",]: could not be patched."]
		# ps					= showInfo line ps
736
737
738
739
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
	# ((abcdate,fileinfo), ps)= accFiles (FI_UpdateAbcDate full_sys` full_sys wantstp fileinfo) ps
				// MOET OOK INFO.abcOptions.abcTimeProfile AANPASSEN!!!!

Diederik van Arkel's avatar
Diederik van Arkel committed
740
741
742
743
744
745
746
	# (ps,abccache,fileinfo,genabc,abcpath)
								// check _system module out of date
								= CheckABCOutOfDate True full_sys` abccache fileinfo project ps
	# (ps,abccache,fileinfo,project,ok,system_obj_path)
								// if out of date regenerate
								= GenCodeTheProjectModule genabc True CodeGeneration abcpath abccache fileinfo project ps
	# (abcPathsCache,ps)		= case genabc of
Diederik van Arkel's avatar
Diederik van Arkel committed
747
									True
748
749
										-> let (sysdate,ps`) = fmodified` (full_sys0 +++ {dirseparator} +++ (MakeObjPathname tp System)) ps in
												(DC_Update ((MakeObjPathname tp System),full_sys0,sysdate) abcPathsCache,ps`)
Diederik van Arkel's avatar
Diederik van Arkel committed
750
												// need to check if line above actually works now...
Diederik van Arkel's avatar
Diederik van Arkel committed
751
752
									False
										-> (abcPathsCache,ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
753
	| not ok
754
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
755
756
757
758
759
760
761

	# prj_path`					= RemoveFilename prj_path
	# execpath					= PR_GetExecPath project
	# execpath					= fulPath app_path prj_path` execpath
	# ps						= showInfo (Level2 ("Linking '" +++ RemovePath execpath +++ "'")) ps
	
	// runtime objects and dynamic libs
762
763
	# stdl						= standardStaticLibraries lo.method
	# stdo						= standardObjectFiles ao.stack_traces ao.profiling tp
Diederik van Arkel's avatar
Diederik van Arkel committed
764
765
766
767
768
769
770
771
772
773
774
	# (stdoOk,ofiles,abcPathsCache)
								= case ao.standard_rte of
									True	-> GetPathNames stdo Nil abcPathsCache
									False	-> (True,Nil,abcPathsCache)
	# (stdlOk,lfiles,abcPathsCache)
								= case ao.standard_rte of
									True	-> GetPathNames stdl Nil abcPathsCache
									False	-> (True,Nil,abcPathsCache)
	| not stdoOk
		# line					= Level3 ["Link error: File: '" +++ (Head ofiles) +++ "' not found."]
		# ps					= showInfo line ps
775
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
776
777
778
	| not stdlOk
		# line					= Level3 ["Link error: File: '" +++ (Head lfiles) +++ "' not found."]
		# ps					= showInfo line ps
779
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
780
781
782
783

	// environment objects and dynamic libs
	# (deflibs,ps)				= getCurrentDlibs ps
	# (defobjs,ps)				= getCurrentObjts ps
784
785
	# ofiles = Concat defobjs ofiles
	# lfiles = Concat deflibs lfiles
Diederik van Arkel's avatar
Diederik van Arkel committed
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
/* NO: these are stored with full path so need different approach???
	# (defobjsOk,defobjs,abcPathsCache)
								= GetPathNames defobjs Nil abcPathsCache
	# (deflibsOk,deflibs,abcPathsCache)
								= GetPathNames deflibs Nil abcPathsCache
	| not defobjsOk
		# line					= Level3 ["Link error: File: '" +++ (Head defobjs) +++ "' not found."]
		# ps					= showInfo line ps
		= continue False newpaths False fileinfo libsinfo abccache modpaths project intr ps
	| not deflibsOk
		# line					= Level3 ["Link error: File: '" +++ (Head deflibs) +++ "' not found."]
		# ps					= showInfo line ps
		= continue False newpaths False fileinfo libsinfo abccache modpaths project intr ps
*/

	// clean modules
	# (clmodpaths,fileinfo)		= FI_GetCleanModules system_obj_path libsinfo fileinfo
803
//	# ofiles					= Concat clmodpaths ofiles
804
805
806
807
	// why couldn't we use ds.modpaths above??? No we need to do trickery to ensure main module is first!
	# (rootpath,project)		= PR_GetRootPathName project
	# rootpath					= MakeObjSystemPathname tp rootpath 
	# clmodpaths				= RemoveStringFromList rootpath clmodpaths
Diederik van Arkel's avatar
Diederik van Arkel committed
808
	# ofiles` = ofiles
809
810
	# ofiles					= rootpath :! ofiles
	
Diederik van Arkel's avatar
Diederik van Arkel committed
811
	# ofiles					= Reverse2 clmodpaths ofiles
Diederik van Arkel's avatar
Diederik van Arkel committed
812
813
814

	// module imported objects and dynamic libs
	# abcLinkInfo				= PR_GetABCLinkInfo project
815
816
817
818
819
820
	# linkObjFileNames			= Map fix abcLinkInfo.linkObjFileNames
									with
										fix s
											| s.[size s - 1] == '.'
												= trace_n` ("!",s) MakeObjPathname tp s
												= trace_n` ("?",s) s
Diederik van Arkel's avatar
Diederik van Arkel committed
821
	# (objPathsOk,ofiles,abcPathsCache)
822
								= GetPathNames linkObjFileNames ofiles abcPathsCache
Diederik van Arkel's avatar
Diederik van Arkel committed
823
	# (_,ofiles`,abcPathsCache) = GetPathNames abcLinkInfo.linkObjFileNames ofiles` abcPathsCache
Diederik van Arkel's avatar
Diederik van Arkel committed
824
825
826
827
828
	# (libPathsOk,lfiles,abcPathsCache)
								= GetPathNames abcLinkInfo.linkLibraryNames lfiles abcPathsCache
	| not objPathsOk
		# line					= Level3 ["Link error: File: '" +++ (Head ofiles) +++ "' not found."]
		# ps					= showInfo line ps
829
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
830
831
832
	| not libPathsOk
		# line					= Level3 ["Link error: File: '" +++ (Head lfiles) +++ "' not found."]
		# ps					= showInfo line ps
833
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
834
835
836
837
838
839
840
841
842
843

	// project objects and dynamic libs
/* full paths again...
	# (loobjsOk,ofiles,abcPathsCache)
								= GetPathNames lo.extraObjectModules ofiles abcPathsCache
	# (lolibsOk,lfiles,_)
								= GetPathNames lo.libraries lfiles abcPathsCache
*/
	# loobjsOk					= True
	# lolibsOk					= True
844
845
846
847
848
849
850
851
852
	# extraObjectModules		= lo.extraObjectModules
	# extraObjectModules		= Map fix extraObjectModules
									with
										fix s
											| s.[size s - 1] == '.'
												= trace_n` ("!",s) MakeObjPathname tp s
												= trace_n` ("?",s) s
	# ofiles					= Concat extraObjectModules ofiles
	# ofiles`					= Concat extraObjectModules ofiles`
Diederik van Arkel's avatar
Diederik van Arkel committed
853
854
855
856
857
	# lfiles					= Concat lo.libraries lfiles
	
	| not loobjsOk
		# line					= Level3 ["Link error: File: '" +++ (Head ofiles) +++ "' not found."]
		# ps					= showInfo line ps
858
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
859
860
861
	| not lolibsOk
		# line					= Level3 ["Link error: File: '" +++ (Head lfiles) +++ "' not found."]
		# ps					= showInfo line ps
862
		= setproject False newpaths False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
863
864

	# (env_static_libs,ps)		= getCurrentSlibs ps
865
	#! sfiles					= Concat (SL_Libs libsinfo) env_static_libs				// eigenlijk alleen als echt gebruikt?
Diederik van Arkel's avatar
Diederik van Arkel committed
866
867
868
869
870
871
872
873
874
875
876
877
	#! ofiles					= Reverse ofiles
	#! lfiles					= Reverse lfiles

//*	
	// .exe or .dat older than module.o
	// martijn also wants comparison with other libs and objs
	// !!! fails to check if console type options have changed...
	// ie. tries with old-fashioned PR_ExecUptoDate...
	// can't really fix this...
//	# (genabc,ps)				= CheckObjsOutOfDate genabc ofiles ps
//	# (genabc,ps) 				= CheckLibsOutOfDate genabc lfiles ps
	# (ood,ps)					= case lo.method of
878
									LM_Static
Diederik van Arkel's avatar
Diederik van Arkel committed
879
880
										# (ood,ps) = CheckObjsOutOfDate genabc execpath ofiles` ps
										| ood -> (ood,ps)
881
882
									  	-> CheckExecOutOfDate genabc execpath fileinfo project ps
									LM_Dynamic -> (True,ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
883
	| not ood
884
		= setproject True False False fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
885
886
887
888
889
890
891
892
893
894
895
896
//*/
	# static_info = 
		{ stat_mods				= symPaths app_path prj_path` modpaths
		, stat_objs				= symPaths app_path prj_path` ofiles
		, stat_slibs			= symPaths app_path prj_path` sfiles
		, stat_dlibs			= symPaths app_path prj_path` lfiles
		, stat_paths			= symPaths app_path prj_path` srcpaths
		, stat_app_path			= app_path
		, stat_prj_path			= prj_path`
		}
	# project					= setStaticInfo static_info project
	# (_,ps)					= accFiles (SaveProjectFile prj_path project app_path) ps
897
898
899
900
901
902
903
904
905
906
	| lo.method == LM_Dynamic

//			# (dynlstr,ps) = getCurrentDynl ps
//			# (ok,ps) = DynLink (app_path +++ {dirseparator} +++dynlstr) prj_path app_path ps
//			# ps = okNotice ["Dynamic linked: "+++toString ok] ps

		// wil geen exe gaan executen!!! De aanroep van DynLink hoort eigenlijk in de exe fase thuis...
		// probleem is nog dat ide de wijzigingen van DynLink in het project zo negeert...
		= setproject ok newpaths ok fileinfo libsinfo modpaths project intr (abccache, ps)

Diederik van Arkel's avatar
Diederik van Arkel committed
907
908
909
	# (linkstr,ps)				= getCurrentLink ps
	# (startupdir,ps)			= getStup ps
		
910
// wil eigenlijk hier pas controleren of exe ood...
Diederik van Arkel's avatar
Diederik van Arkel committed
911
912
913
914
// ao ok
// lfiles ok
// ofiles ok
// sfiles ok
915
916
// dus exe date cachen met gebruikte ao en lfiles,ofiles,sfiles dates...
// kan nu al verbeteren door in Younger naast clean objecten ook overige mee te nemen
Diederik van Arkel's avatar
Diederik van Arkel committed
917

918
	# optionspath				= MakeOptionsName prj_path tp
Diederik van Arkel's avatar
Diederik van Arkel committed
919
920
921
922
923
924
	# (ps, ok)					= Link linkstr updateErrorWindow execpath ao
									optionspath lfiles ofiles sfiles
									(lo.method == LM_Static)
									lo.generate_relocations
									lo.generate_link_map
									lo.link_resources
925
									lo.resource_source
Diederik van Arkel's avatar
Diederik van Arkel committed
926
									lo.generate_dll
927
928
									lo.dll_export_list_name
									startupdir lo.add_carb_resource ps
Diederik van Arkel's avatar
Diederik van Arkel committed
929
	# project					= if ok (PR_SetLinked project) project
930
	= setproject ok False ok fileinfo libsinfo modpaths project intr (abccache, ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
931
where
932
933
934
	fmodified` fname ps
		# ({DATE | yy,mm,dd,h,m,s},ps) = accFiles (FModified fname) ps
		= (({year`=yy,month`=mm,day`=dd,dayNr`=0},{hours`=h,minutes`=m,seconds`=s}),ps)
Diederik van Arkel's avatar
Diederik van Arkel committed
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
step intr DDone ps
	= stop (DDone,ps)

//-- Compile Phase...

:: UnknownFinishedProcessors = NoUnknownFinishedProcessors | UnknownFinishedProcessors !Int ![Int]

add_unknown_finished_processor NoUnknownFinishedProcessors
	= UnknownFinishedProcessors 1 []
add_unknown_finished_processor (UnknownFinishedProcessors n_unknown_finished_processors known_finished_processors)
	= UnknownFinishedProcessors (n_unknown_finished_processors+1) known_finished_processors							

remove_from_unknown_finished_processors completedSlot (UnknownFinishedProcessors n_unknown_finished_processors known_finished_processors)
	| not (isMember completedSlot known_finished_processors)
		= UnknownFinishedProcessors n_unknown_finished_processors [completedSlot:known_finished_processors]
remove_from_unknown_finished_processors completedSlot unknown_finished_processors
	= unknown_finished_processors

:: *DriverCodeGenerationInfo
	= SyncCodeGeneration
955
	| ASyncCodeGeneration ![(Int,String,String)] !Int !UnknownFinishedProcessors // [(busy_process_number,abc_path,obj_path)] max_n_processes unknown_finished_processors
Diederik van Arkel's avatar
Diederik van Arkel committed
956
957
958

:: *DriverState
	= DInit !Bool !Project !MTPContinuation
959
	| DComp !Bool !(List String) !DriverCompilingInfo !(List String) !FileInfoCache !*DirCache !*ABCCache !StaticLibInfo !Project !Bool !MTPContinuation
Diederik van Arkel's avatar
Diederik van Arkel committed
960
//XXX	| DGene !Bool !Bool !FileInfoCache !StaticLibInfo !(List String) !(List String) !*ABCCache !Project !MTPContinuation
961
962
	| DGene !Bool !Bool !FileInfoCache !StaticLibInfo !(List String) !(List String) !DriverCodeGenerationInfo !*ABCCache !Project !MTPContinuation
	| DLink !Bool !Bool !FileInfoCache !StaticLibInfo !(List String) !*ABCCache !Project !MTPContinuation
Diederik van Arkel's avatar
Diederik van Arkel committed
963
964
965
966
967
968
969
970
971
	| DDone

:: *DriverCompilingInfo
	= Sync
	| AsyncWin	!Int ![CurrentlyCompiled]
	| Async	![CurrentlyCompiled] !Int !Int !UnknownFinishedProcessors // busy_processors max_n_processes n_used_processors unknown_finished_processors
	| Pers	!*CompilingInfo

compiling_info :: !DriverCompilingInfo -> (String,DriverCompilingInfo)
972
973
974
975
976
977
978
979
/*XXX
compiling_info info=:(Async _ [])
	=	("",info)
compiling_info info=:(Async _ current)
	=	(foldl (\s c -> s +++ c.iclModule) "Compiling " current,info)
compiling_info info
	=	("",info)
*/
Diederik van Arkel's avatar
Diederik van Arkel committed
980
981
982
983
984
985
986
987
compiling_info info=:(Async current _ _ _)
	= (compiling_info_async current,info);
compiling_info info
	= ("",info)

compiling_info_async []
	= ""
compiling_info_async current
988
//	=	foldl (\s c -> s +++ c.iclModule) "Compiling " current
Diederik van Arkel's avatar
Diederik van Arkel committed
989
990
991
	=	foldl (\s c -> s +++ " "+++(GetModuleName c.iclModule)) "Compiling:" current

//	Scan modified modules and update the dependencies (recompile if necessary).
992
993
994
UpdateDependencies :: !Bool !String !(List String) !(List String) !DriverCompilingInfo !FileInfoCache !*DirCache !*ABCCache !StaticLibInfo !Project !*(PSt *General)
	-> (*(PSt *General),FileInfoCache,*DirCache,*ABCCache,Project,Bool,Bool,List String,DriverCompilingInfo,List String,Bool)
UpdateDependencies force next done rest compinfo fileinfo dircache abccache libsinfo project ps`
Diederik van Arkel's avatar
Diederik van Arkel committed
995
	# (version,ps)				= getCurrentVers ps					// lift to DriverState
996
//	# line						= if verbose (Level2 ("Analyzing \'" +++  modname +++ "\'.")) (Level2 "")
Diederik van Arkel's avatar
Diederik van Arkel committed
997
	# (cinf,compinfo)			= compiling_info compinfo
998
999
1000
	# line						= Level2 ((if verbose ("Analyzing \'" +++  modname +++ "\'. ") (""))
														+++ cinf)
	# ps						= showInfo line ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1001
	# ((abccache,fileinfo,info),ps)
1002
								= FI_GetFileInfo proc impname abccache fileinfo ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1003
1004
1005
	# abcexists					= info.abcdate.exists
	| not abcexists
		= case compinfo of
1006
1007
1008
1009
			Sync				-> UpdateSyncDependencies done rest impname co fileinfo dircache abccache project ps
//XXX		async=:(Async _ _ )		-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
			async=:(Async _ _ _ _)-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
			(Pers info)			-> UpdatePersDependencies info done rest impname co fileinfo dircache abccache project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1010
1011
1012
1013
1014
	| info.sys	// system module
		# wrongVersion			= info.version <> version
		| wrongVersion
			# line				= Level3 ["Error: System file: '" +++ modname +++ "' has incorrect abc version."]
			# ps				= showInfo line ps
1015
			= (ps, fileinfo, dircache,abccache,project, False, False, rest,compinfo,done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1016
1017
1018
		# wantstp				= tp && (not co.neverTimeProfile)
		# compile				= /*mp <> info.abcOptions.abcMemoryProfile ||*/ wantstp <> info.abcOptions.abcTimeProfile
		# lines					= (Level3 (if (verbose && compile) ["["+++modname+++".abc,]: System module compiled with different options"] []))
1019
		# ps					= showInfo lines ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1020
		| compile
1021
//			# (abcPath, ps)		= accFiles (MakeABCSystemPathname next) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1022
1023
1024
			# abcPath			= MakeABCSystemPathname next
			# (patched, ps)		= accFiles (PatchSystemABC version True abcPath /*ao.memoryProfiling*/ wantstp) ps
			| patched
1025
1026
1027
1028
				# ((abcdate,fileinfo), ps)= accFiles (FI_UpdateAbcDate impname abcPath wantstp fileinfo) ps
				// MOET OOK INFO.abcOptions.abcTimeProfile AANPASSEN!!!!
				# ((ok,mods,_,_,objs,libs,abccache/*,fileinfo*/),ps)
								= accFiles (ParseABCDependencies` info.abcpath abcdate abccache /*fileinfo*/) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1029
				| not ok
1030
					# line				= Level3 ["Error: Strange error parsing dependencies: '" +++ info.abcpath +++ "'."]
Diederik van Arkel's avatar
Diederik van Arkel committed
1031
					// can actually only occur when failed to open .abc file...
1032
1033
					# ps				= showInfo line ps
					= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1034
1035
1036
				# (ok,paths,dircache)
								= LookupModulePaths mods dircache
				| not ok
1037
1038
1039
1040
1041
1042
					# line				= Level3 ["Error: '" +++ (Head paths) +++ "' not found."]
					# ps				= showInfo line ps
					= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
				#! rest					= Concat rest paths
				#! project				= PR_AddABCInfo next objs libs defaultCO defeo impeo project
				=	(ps, fileinfo, dircache,abccache,project, True, False, rest,compinfo,next:!done,True)
Diederik van Arkel's avatar
Diederik van Arkel committed
1043
1044
			# line				= Level3 ["Error: System file: '" +++ modname +++ "' could not be patched."]
			# ps				= showInfo line ps
1045
1046
1047
			=	(ps, fileinfo,dircache, abccache,project, False, False, rest,compinfo,done,False)
		# ((ok,mods,_,_,objs,libs,abccache/*,fileinfo*/),ps)
						= accFiles (ParseABCDependencies` info.abcpath info.abcdate abccache /*fileinfo*/) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1048
1049
1050
		| not ok
			# line				= Level3 ["Error: Strange error parsing dependencies: '" +++ info.abcpath +++ "'."]
			# ps				= showInfo line ps
1051
1052
			= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
		# (ok,paths,dircache)	= LookupModulePaths mods dircache							// <--
Diederik van Arkel's avatar
Diederik van Arkel committed
1053
1054
1055
		| not ok
			# line				= Level3 ["Error: '" +++ (Head paths) +++ "' not found."]
			# ps				= showInfo line ps
1056
1057
1058
1059
1060
			= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
//		#! rest					= Concat rest paths											// <--
		#! rest					= Concat paths rest											// <--
		#! project				= PR_AddABCInfo next objs libs defaultCO defeo impeo project
		=	(ps, fileinfo, dircache,abccache,project, True, False, rest,compinfo,next:!done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1061
1062
1063

	// normal module
	| force
1064
1065
		# line				= Level3 ["["+++modname+++".icl,]: force compile"]
		# ps				= showInfo line ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1066
		= case compinfo of
1067
1068
1069
1070
1071
1072
1073
			Sync				-> UpdateSyncDependencies done rest impname co fileinfo dircache abccache project ps
	//XXX		async=:(Async _ _ )		-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
			async=:(Async _ _ _ _ )-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
			(Pers info)			-> UpdatePersDependencies info done rest impname co fileinfo dircache abccache project ps
			
	# ((ok,mods,xxx_md,xxx_dd,objs,libs,abccache/*,fileinfo*/),ps)
								= accFiles (ParseABCDependencies` info.abcpath info.abcdate abccache /*fileinfo*/) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1074
	| not ok
1075
1076
1077
		# line				= Level3 ["Error: Strange error parsing dependencies: '" +++ info.abcpath +++ "'."]
		# ps				= showInfo line ps
		= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1078
1079
1080
1081
	# (okA,whyA,dircache)		= check_dependant_dates modname info.abcpath mods xxx_md xxx_dd dircache
	# (okC,whyC)				= check_module_options modname info co mp tp eod version
	
	| okA && okC
1082
		# (ok,paths,dircache)	= LookupModulePaths mods dircache							// <--
Diederik van Arkel's avatar
Diederik van Arkel committed
1083
1084
1085
		| not ok
			# line				= Level3 ["Error: '" +++ (Head paths) +++ "' not found."]
			# ps				= showInfo line ps
1086
1087
1088
1089
1090
			= (ps,fileinfo,dircache,abccache,project,False,False,rest,compinfo,done,False)
//		#! rest					= Concat rest paths											// <--
		#! rest					= Concat paths rest											// <--
		#! project				= PR_AddABCInfo next objs libs co defeo impeo project
		= (ps,fileinfo,dircache,abccache,project,True,False,rest,compinfo,next:!done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1091
		
1092
	# lines						= Level3 [if okC whyA whyC]	//(if verbose [if okC whyA whyC] [])
Diederik van Arkel's avatar
Diederik van Arkel committed
1093
1094
	#! ps						= showInfo lines ps
	= case compinfo of
1095
1096
1097
1098
		Sync				-> UpdateSyncDependencies done rest impname co fileinfo dircache abccache project ps
//XXX		async=:(Async _ _ )		-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
		async=:(Async _ _ _ _ )-> UpdateAsyncDependencies async done rest impname co fileinfo dircache abccache project ps
		(Pers info)			-> UpdatePersDependencies info done rest impname co fileinfo dircache abccache project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
where
	(prefs,ps) 			= getPrefs ps`				// lift to DriverState

	proc				= PR_GetProcessor project
	ao					= PR_GetApplicationOptions project
	mp					= ao.memoryProfiling
	tp					= ao.profiling
	lo					= PR_GetLinkOptions project
	eod					= case lo.method of
							LM_Static	-> False
Diederik van Arkel's avatar
Diederik van Arkel committed
1109
//							LM_Eager	-> True
Diederik van Arkel's avatar
Diederik van Arkel committed
1110
							LM_Dynamic	-> True				
1111
//	st					= ao.stack_traces
Diederik van Arkel's avatar
Diederik van Arkel committed
1112
1113
	verbose				= prefs.be_verbose
	defaultCO			= prefs.compopts
1114
1115
//	(tabsize, autotab, showtabs, showlinenos, showsyncols)
//						= prefs.edwintabs
Diederik van Arkel's avatar
Diederik van Arkel committed
1116
1117
	eo =
		{	newlines	= HostNativeNewlineConvention}
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
/*		{	tabs		= tabsize
		,	fontname	= prefs.edwinfont.fName
		,	fontsize	= prefs.edwinfont.fSize
		,	autoi		= autotab
		,	newlines	= HostNativeNewlineConvention
		,	showtabs	= showtabs
		,	showlins	= showlinenos
		,	showsync	= showsyncols
		}
*/
Diederik van Arkel's avatar
Diederik van Arkel committed
1128
1129
1130
1131
1132
1133
1134
1135
1136
	defeo = {pos_size = DefWindowPos_and_Size, eo = eo}
	impeo = {pos_size = DefWindowPos_and_Size, eo = eo}

	modname					= GetModuleName next
	impname					= MakeImpPathname next
	modinfo					= PR_GetModuleInfo modname project
	co						= case modinfo of
								Just modinfo	-> modinfo.compilerOptions
								_				-> defaultCO
1137
1138
1139

/*XXX
UpdateAsyncDependencies (Async cmax current) rest impname co fileinfo dircache abccache project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1140
1141
	# free_slot = get_free_slot current
	# (compileStarted, fileinfo, dircache, abccache, ps)
1142
1143
1144
1145
		= CompileTheProjectModuleStart Compilation impname free_slot fileinfo dircache abccache project ps
	// RWS: this replaces the (single module) showInfo in CTPMcommon
	# (cinf,_)			= compiling_info (Async cmax current)
	# ps = showInfo (Level2 cinf) ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1146
1147
	| compileStarted
		# current = [{iclModule = impname, options = co, slot = free_slot} : current]
1148
		= (ps,fileinfo,dircache,abccache,project,True,False,rest,Async cmax current,done,True)
Diederik van Arkel's avatar
Diederik van Arkel committed
1149
	// not compileStarted
1150
		= (ps,fileinfo,dircache,abccache,project,False,False,rest,Async cmax current,done,False)
Diederik van Arkel's avatar
Diederik van Arkel committed
1151
1152
1153
1154
where
	get_free_slot :: [CurrentlyCompiled] -> Int
	get_free_slot current
		=	hd (removeMembers [0..] [slot \\ {slot} <- current])
1155
1156
*/
UpdateAsyncDependencies (Async current cmax n_used_processors unknown_finished_processors) done rest impname co fileinfo dircache abccache project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1157
1158
	# free_slot = get_free_slot current
	# (compileStarted, fileinfo, dircache, abccache, ps)
1159
		= CompileTheProjectModuleStart Compilation impname free_slot fileinfo dircache abccache project ps
Diederik van Arkel's avatar
Diederik van Arkel committed
1160
1161
1162
1163
1164
1165
	| compileStarted
		# n_used_processors = if (free_slot>=n_used_processors) (free_slot+1) n_used_processors
		# current = [{iclModule = impname, options = co, slot = free_slot} : current]
		# cinf = compiling_info_async current
		# ps = showInfo (Level2 cinf) ps
		# async = Async current cmax n_used_processors unknown_finished_processors
1166
		= (ps,fileinfo,dircache,abccache,project,True,False,rest,async,done,True)
Diederik van Arkel's avatar
Diederik van Arkel committed
1167
1168
1169
1170
	// not compileStarted
		# cinf = compiling_info_async current
		# ps = showInfo (Level2 cinf) ps
		# async = Async current cmax n_used_processors unknown_finished_processors
1171
		= (ps,fileinfo,dircache,abccache,project