0026546: Configuration, genproj.tcl - add support for VS2015 in project file generator
[occt.git] / adm / genproj.tcl
CommitLineData
910970ab 1# =======================================================================
2# This script generates project files for different IDEs:
39bff09c 3# "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "amk" "xcd"
910970ab 4#
5# Example:
6# genproj -path=D:/occt -target=vc10
c7d774c5 7# genproj -target=xcd -ios -static
910970ab 8# =======================================================================
9
10set path ""
11set fBranch ""
12switch -exact -- "$tcl_platform(platform)" {
c7d774c5 13 "windows" {set targetStation "wnt"}
14 "unix" {set targetStation "lin"}
910970ab 15}
16
c7d774c5 17switch -exact -- "$tcl_platform(os)" {
18 "Darwin" {set targetStation "mac"}
19}
20
21source "./adm/genconfdeps.tcl"
22
910970ab 23proc _get_options { platform type branch } {
24 global path
25 set res ""
26 if {[file exists "$path/adm/CMPLRS"]} {
27 set fd [open "$path/adm/CMPLRS" rb]
28 set opts [split [read $fd] "\n"]
29 close $fd
30 foreach line $opts {
31 if {[regexp "^${platform} ${type} ${branch} (.+)$" $line dummy res]} {
32 while {[regexp {\(([^\(\)]+) ([^\(\)]+) ([^\(\)]+)\)(.+)} $res dummy p t b oldres]} {
33 set res "[_get_options $p $t $b] $oldres"
34 }
35 }
36 }
37 }
38 return $res
39}
40
41proc _get_type { name } {
42 global path
43 if {[file exists "$path/adm/UDLIST"]} {
44 set fd [open "$path/adm/UDLIST" rb]
45 set UDLIST [split [read $fd] "\n"]
46 close $fd
47 foreach uitem $UDLIST {
48 set line [split $uitem]
49 if {[lindex $line 1] == "$name"} {
50 return [lindex $line 0]
51 }
52 }
53 }
54 return ""
55}
56
57proc _get_used_files { pk {inc true} {src true} } {
58 global path
59 set type [_get_type $pk]
60 set lret {}
61 set pk_path "$path/src/$pk"
62 set FILES_path "$path/src/$pk/FILES"
63 set FILES {}
64 if {[file exists $FILES_path]} {
65 set fd [open $FILES_path rb]
66 set FILES [split [read $fd] "\n"]
67 close $fd
68 }
69 set FILES [lsearch -inline -all -not -exact $FILES ""]
70
71 set index -1
72 foreach line $FILES {
73 incr index
74 if {$inc && ([regexp {([^:\s]*\.[hgl]xx)$} $line dummy name] || [regexp {([^:\s]*\.h)$} $line dummy name]) && [file exists $pk_path/$name]} {
75 lappend lret "pubinclude $name $pk_path/$name"
76 continue
77 }
78 if {[regexp {:} $line]} {
79 regexp {[^:]*:+([^\s]*)} $line dummy line
80 }
81 regexp {([^\s]*)} $line dummy line
82 if {$src && [file exists $pk_path/$line]} {
83 lappend lret "source $line $pk_path/$line"
84 }
85 }
86 return $lret
87}
88
89# Wrapper-function to generate VS project files
90proc genproj { args } {
91 global path targetStation
39bff09c 92 set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "amk" "xcd" }
910970ab 93 set anArgs $args
94
95 # Setting default IDE.
96 set anTarget ""
97 switch -exact -- "$targetStation" {
98 "wnt" {set anTarget "$::env(VCVER)"}
99 "lin" {set anTarget "amk"}
c7d774c5 100 "mac" {set anTarget "xcd"}
910970ab 101 }
102
103 set isTargetDefault true
910970ab 104 if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
105 regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
106 set anArgs [removeAllOccurrencesOf -target=* $anArgs]
107 set isTargetDefault false
108 }
109
110 if { [set anIndex [lsearch -nocase $anArgs -path=*]] != -1} {
111 regsub -nocase "\\-path=" [lindex $anArgs $anIndex] "" path
112 set anArgs [removeAllOccurrencesOf -path=* $anArgs]
113 puts "Starting work with \"$path\""
114 }
115
116 if { [llength $anArgs] == 0 && $isTargetDefault == true } {
117 puts "the default \'$anTarget\' target has been applied"
118 }
119
120 set isHelpRequire false
121 if { [lsearch -nocase $anArgs -h] != -1} {
122 set anArgs [removeAllOccurrencesOf -h $anArgs]
123 set isHelpRequire true
124 }
125
126 if {$path == ""} {
127 set isHelpRequire true
128 }
129
c7d774c5 130 set aLibType "dynamic"
131 if { [lsearch -nocase $anArgs "-static"] != -1} {
132 set anArgs [removeAllOccurrencesOf "-static" $anArgs]
133 set aLibType "static"
134 puts "static build has been selected"
135 } elseif { [lsearch -nocase $anArgs "-dynamic"] != -1} {
136 set anArgs [removeAllOccurrencesOf "-dynamic" $anArgs]
137 set aLibType "dynamic"
138 puts "dynamic build has been selected"
139 }
140
141 set aPlatform ""
142 if { [lsearch -nocase $anArgs "-ios"] != -1} {
143 set anArgs [removeAllOccurrencesOf "-ios" $anArgs]
144 set aPlatform "ios"
145 }
146
910970ab 147 if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
148 puts "the \'$anTarget\' is wrong TARGET"
149 set isHelpRequire true
150 }
151
152 if {[llength $anArgs] > 0} {
153 set isHelpRequire true
154
155 foreach anArg $anArgs {
156 puts "genproj: unrecognized option \'$anArg\'"
157 }
158 }
159
160 if { $isHelpRequire == true } {
161 puts "usage: genproj \[ -target=<TARGET> \] \[ -path=<PATH> \]
162
163 PATH:
164 path to the project
165
166 TARGET:
167 vc8 - Visual Studio 2005
168 vc9 - Visual Studio 2008
169 vc10 - Visual Studio 2010
170 vc11 - Visual Studio 2012
171 vc12 - Visual Studio 2013
39bff09c 172 vc14 - Visual Studio 2015
910970ab 173 cbp - CodeBlocks
c7d774c5 174 xcd - XCode
910970ab 175 amk - AutoMake"
176 return
177 }
178
179 if {!$isTargetDefault} {
180 puts "the \'$anTarget\' target has been applied"
181 }
182
183 if {"$anTarget" == "amk"} {
184 set targetStation "lin"
185 }
186 set anAdmPath "$path/adm"
187
c7d774c5 188 OS:MKPRC "$anAdmPath" "$anTarget" "$aLibType" "$aPlatform"
910970ab 189
190 genprojbat "$anAdmPath" "$anTarget"
191}
192
193proc genprojbat {thePath theIDE} {
194 global path
195
196 set anOsIncPath "$path/src/OS"
197 set anOsRootPath "$path"
198
199 set aTargetPlatform "lin"
200 if { "$::tcl_platform(platform)" == "windows" } {
201 set aTargetPlatform "wnt"
202 }
203
204 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
205 set aTargetPlatform wnt
206 } elseif {"$theIDE" == "amk"} {
207 set aTargetPlatform lin
c7d774c5 208 } elseif {"$theIDE" == "xcd"} {
209 set aTargetPlatform mac
910970ab 210 }
211
212 set aTargetPlatformExt sh
213 if { "$aTargetPlatform" == "wnt" } {
214 set aTargetPlatformExt bat
215 }
216
217 set aBox [file normalize "$thePath/.."]
218
910970ab 219 if {"$theIDE" != "cmake"} {
220 set anEnvTmplFile [open "$path/adm/templates/env.${aTargetPlatformExt}" "r"]
221 set anEnvTmpl [read $anEnvTmplFile]
222 close $anEnvTmplFile
223
224 set aCasRoot ""
225 if { [file normalize "$anOsRootPath"] != "$aBox" } {
226 set aCasRoot [relativePath "$aBox" "$anOsRootPath"]
227 }
228 set anOsIncPath [relativePath "$aBox" "$anOsRootPath"]
229
230 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
231
232 set anEnvFile [open "$aBox/env.${aTargetPlatformExt}" "w"]
233 puts $anEnvFile $anEnvTmpl
234 close $anEnvFile
235
236 file copy -force -- "$path/adm/templates/draw.${aTargetPlatformExt}" "$aBox/draw.${aTargetPlatformExt}"
237 }
238
239 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
240 file copy -force -- "$path/adm/templates/msvc.bat" "$aBox/msvc.bat"
241 } else {
242 switch -exact -- "$theIDE" {
243 "cbp" { file copy -force -- "$path/adm/templates/codeblocks.sh" "$aBox/codeblocks.sh" }
c7d774c5 244 "xcd" { file copy -force -- "$path/adm/templates/xcode.sh" "$aBox/xcode.sh" }
910970ab 245 }
246 }
247}
248
249###### MSVC #############################################################33
250proc removeAllOccurrencesOf { theObject theList } {
251 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
252 foreach anIndex $aSortIndices {
253 set theList [lreplace $theList $anIndex $anIndex]
254 }
255 return $theList
256}
257
c7d774c5 258set aTKNullKey "TKNull"
259set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
910970ab 260
261# Entry function to generate project files and solutions for IDE
c7d774c5 262proc OS:MKPRC { {theOutDir {}} {theIDE ""} {theLibType "dynamic"} {thePlatform ""} } {
910970ab 263 global path targetStation
39bff09c 264 set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "amk" "xcd" }
910970ab 265
266 if { [lsearch $aSupportedIDE $theIDE] < 0 } {
267 puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
268 return
269 }
270
271 set anOutRoot $theOutDir
272 if { $anOutRoot == "" } {
273 error "Error : \"theOutDir\" is not initialized"
274 }
275
276 # Create output directory
277 set aWokStation "$targetStation"
278
39bff09c 279 if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12 vc14} $theIDE] != -1 } {
910970ab 280 set aWokStation "msvc"
281 }
282
283 set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
284
285 # read map of already generated GUIDs
286 set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
287 if [file exists "$aGuidsFilePath"] {
288 set aFileIn [open "$aGuidsFilePath" r]
289 set aFileDataRaw [read $aFileIn]
290 close $aFileIn
291 set aFileData [split $aFileDataRaw "\n"]
292 foreach aLine $aFileData {
293 set aLineSplt [split $aLine "="]
294 if { [llength $aLineSplt] == 2 } {
295 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
296 }
297 }
298 }
299
300 # make list of modules and platforms
301 set aModules [OS:init]
c7d774c5 302 if { "$thePlatform" == "ios" } {
303 set goaway [list Draw]
304 set aModules [osutils:juststation $goaway $aModules]
305 }
910970ab 306
307 # generate one solution for all projects if complete OS or VAS is processed
308 set anAllSolution "OCCT"
309
c7d774c5 310 wokUtils:FILES:mkdir $anOutDir
910970ab 311 if { ![file exists $anOutDir] } {
312 puts stderr "Error: Could not create output directory \"$anOutDir\""
313 return
314 }
315
316 # create the out dir if it does not exist
317 if (![file isdirectory $path/inc]) {
318 puts "$path/inc folder does not exists and will be created"
319 wokUtils:FILES:mkdir $path/inc
320 }
321
322 # collect all required header files
323 puts "Collecting required header files into $path/inc ..."
324 osutils:collectinc $aModules $path/inc $targetStation
325
326 # Generating project files for the selected IDE
327 switch -exact -- "$theIDE" {
328 "vc7" -
329 "vc8" -
330 "vc9" -
331 "vc10" -
332 "vc11" -
39bff09c 333 "vc12" -
334 "vc14" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE }
910970ab 335 "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution }
336 "amk" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
c7d774c5 337 "xcd" {
338 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
339 OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
340 }
910970ab 341 }
910970ab 342
343 # Store generated GUIDs map
344 set anOutFile [open "$aGuidsFilePath" "w"]
345 fconfigure $anOutFile -translation lf
346 foreach aKey [array names ::THE_GUIDS_LIST] {
347 set aValue $::THE_GUIDS_LIST($aKey)
348 puts $anOutFile "${aKey}=${aValue}"
349 }
350 close $anOutFile
351}
352
353# Function to generate Visual Studio solution and project files
354proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
355
356 puts stderr "Generating VS project files for $theVcVer"
357
358 # generate projects for toolkits and separate solution for each module
359 foreach aModule $theModules {
360 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
361 OS:vcproj $theVcVer $aModule $theOutDir ::THE_GUIDS_LIST
362 }
363
364 # generate single solution "OCCT" containing projects from all modules
365 if { "$theAllSolution" != "" } {
366 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
367 }
368
369 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
370}
371
372proc OS:init {{os {}}} {
373 global path
374 global env
375 global tcl_platform
376
377 set askplat $os
378 if { "$os" == "" } {
379 set os $tcl_platform(os)
380 }
381
382 ;# Load list of OCCT modules and their definitions
383 source "$path/src/OS/Modules.tcl"
384 set Modules {}
385 foreach module [OS:Modules] {
386 set f "$path/src/OS/${module}.tcl"
387 if [file exists $f] {
388 source $f
389 lappend Modules $module
390 } else {
391 puts stderr "Definition file for module $module is not found in unit OS"
392 }
393 }
394
395 # Load list of products and their definitions
396# set Products [woklocate -p VAS:source:Products.tcl]
397 #if { "$Products" != "" } {
398 #source "$Products"
399 #foreach product [VAS:Products] {
400 #set f [woklocate -p VAS:source:${product}.tcl]
401 #if [file exists $f] {
402 #source $f
403 #} else {
404 #puts stderr "Definition file for product $product is not found in unit VAS"
405 #}
406 #}
407 #}
408
409 return $Modules
410}
411
412# topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
413proc wokUtils:EASY:tsort { listofpairs } {
414 foreach x $listofpairs {
415 set e1 [lindex $x 0]
416 set e2 [lindex $x 1]
417 if ![info exists pcnt($e1)] {
418 set pcnt($e1) 0
419 }
420 if ![ info exists pcnt($e2)] {
421 set pcnt($e2) 1
422 } else {
423 incr pcnt($e2)
424 }
425 if ![info exists scnt($e1)] {
426 set scnt($e1) 1
427 } else {
428 incr scnt($e1)
429 }
430 set l {}
431 if [info exists slist($e1)] {
432 set l $slist($e1)
433 }
434 lappend l $e2
435 set slist($e1) $l
436 }
437 set nodecnt 0
438 set back 0
439 foreach node [array names pcnt] {
440 incr nodecnt
441 if { $pcnt($node) == 0 } {
442 incr back
443 set q($back) $node
444 }
445 if ![info exists scnt($node)] {
446 set scnt($node) 0
447 }
448 }
449 set res {}
450 for {set front 1} { $front <= $back } { incr front } {
451 lappend res [set node $q($front)]
452 for {set i 1} {$i <= $scnt($node) } { incr i } {
453 set ll $slist($node)
454 set j [expr {$i - 1}]
455 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
456 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
457 incr back
458 set q($back) [lindex $ll $j]
459 }
460 }
461 }
462 if { $back != $nodecnt } {
463 puts stderr "input contains a cycle"
464 return {}
465 } else {
466 return $res
467 }
468}
469
470proc wokUtils:LIST:Purge { l } {
471 set r {}
472 foreach e $l {
473 if ![info exist tab($e)] {
474 lappend r $e
475 set tab($e) {}
476 }
477 }
478 return $r
479}
480
481# Read file pointed to by path
482# 1. sort = 1 tri
483# 2. trim = 1 plusieurs blancs => 1 seul blanc
484# 3. purge= not yet implemented.
485# 4. emptl= dont process blank lines
486proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
487 if ![ catch { set id [ open $path r ] } ] {
488 set l {}
489 while {[gets $id line] >= 0 } {
490 if { $trim } {
491 regsub -all {[ ]+} $line " " line
492 }
493 if { $emptl } {
494 if { [string length ${line}] != 0 } {
495 lappend l $line
496 }
497 } else {
498 lappend l $line
499 }
500 }
501 close $id
502 if { $sort } {
503 return [lsort $l]
504 } else {
505 return $l
506 }
507 } else {
508 return {}
509 }
510}
511
512# retorn the list of executables in module.
513proc OS:executable { module } {
514 set lret {}
515 foreach XXX [${module}:ressources] {
516 if { "[lindex $XXX 1]" == "x" } {
517 lappend lret [lindex $XXX 2]
518 }
519 }
520 return $lret
521}
522
523# Topological sort of toolkits in tklm
524proc osutils:tk:sort { tklm } {
525 set tkby2 {}
526 foreach tkloc $tklm {
527 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
528 foreach tkx $lprg {
529 if { [lsearch $tklm $tkx] != -1 } {
530 lappend tkby2 [list $tkx $tkloc]
531 } else {
532 lappend tkby2 [list $tkloc {}]
533 }
534 }
535 }
536 set lret {}
537 foreach e [wokUtils:EASY:tsort $tkby2] {
538 if { $e != {} } {
539 lappend lret $e
540 }
541 }
542 return $lret
543}
544
545# close dependencies of ltk. (full wok pathes of toolkits)
546# The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
547# (locate not performed.)
548proc osutils:tk:close { ltk } {
549 set result {}
550 set recurse {}
551 foreach dir $ltk {
552 set ids [LibToLink $dir]
553 set eated [osutils:tk:eatpk $ids]
554 set result [concat $result $eated]
555 set ids [LibToLink $dir]
556 set result [concat $result $ids]
557
558 foreach file $eated {
559 set kds "$path/src/$file/EXTERNLIB"
560 if { [osutils:tk:eatpk $kds] != {} } {
561 lappend recurse $file
562 }
563 }
564 }
565 if { $recurse != {} } {
566 set result [concat $result [osutils:tk:close $recurse]]
567 }
568 return $result
569}
570
571proc osutils:tk:eatpk { EXTERNLIB } {
572 set l [wokUtils:FILES:FileToList $EXTERNLIB]
573 set lret {}
574 foreach str $l {
575 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
576 lappend lret $str
577 }
578 }
579 return $lret
580}
581# Define libraries to link using only EXTERNLIB file
582
583proc LibToLink {theTKit} {
584 global path
585 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
586 set type [_get_type $theTKit]
587 if {$type != "t" && $type != "x"} {
588 return
589 }
590 set aToolkits {}
591 set anExtLibList [osutils:tk:eatpk "$path/src/$theTKit/EXTERNLIB"]
592 foreach anExtLib $anExtLibList {
593 set aFullPath [LocateRecur $anExtLib]
594 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
595 lappend aToolkits $anExtLib
596 }
597 }
598 return $aToolkits
599}
600# Search unit recursively
601
602proc LocateRecur {theName} {
603 global path
604 set theNamePath "$path/src/$theName"
605 if {[file isdirectory $theNamePath]} {
606 return $theNamePath
607 }
608 return ""
609}
610
611proc OS:genGUID { {theIDE "vc"} } {
612 if { "$theIDE" == "vc" } {
613 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
614 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
615 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
616 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
617 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
618 return "{$p1-$p2-$p3-$p4-$p5}"
619 } else {
620 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
621 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
622 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
623 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
624 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
625 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
626 return "$p1$p2$p3$p4$p5$p6"
627 }
628}
629
630# collect all include file that required for theModules in theOutDir
631proc osutils:collectinc {theModules theIncPath theTargetStation} {
632 global path
633
634 set aCasRoot [file normalize $path]
635 set anIncPath [file normalize $theIncPath]
636
637 if {![file isdirectory $aCasRoot]} {
638 puts "OCCT directory is not defined correctly: $aCasRoot"
639 return
640 }
641
642 set anUsedToolKits {}
643 foreach aModule $theModules {
644 foreach aToolKit [${aModule}:toolkits] {
645 lappend anUsedToolKits $aToolKit
646
647 foreach aDependency [LibToLink $aToolKit] {
648 lappend anUsedToolKits $aDependency
649 }
650 }
651 foreach anExecutable [OS:executable ${aModule}] {
652 lappend anUsedToolKits $anExecutable
653
654 foreach aDependency [LibToLink $anExecutable] {
655 lappend anUsedToolKits $aDependency
656 }
657 }
658 }
659 lsort -unique $anUsedToolKits
660
661 set anUnits {}
662 foreach anUsedToolKit $anUsedToolKits {
663 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
664 }
665 lsort -unique $anUnits
666
667 if { [info exists ::env(SHORTCUT_HEADERS)] &&
668 $::env(SHORTCUT_HEADERS) == "true" } {
669 # template preparation
670 if { ![file exists $aCasRoot/adm/templates/header.in] } {
671 puts "template file does not exist: $aCasRoot/adm/templates/header.in"
672 return
673 }
674 set aHeaderTmpl [wokUtils:FILES:FileToString $aCasRoot/adm/templates/header.in]
675
676 # relative anIncPath in connection with aCasRoot/src
677 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
678
679 # create and copy short-cut header files
680 foreach anUnit $anUnits {
681 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
682 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
683 set aHeaderFileName [file tail $aHeaderFile]
684
685 regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
686
687 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
688 set fp [open "$theIncPath/$aHeaderFileName" r]
689 set aHeaderContent [read $fp]
690 close $fp
691
692 # minus eof
693 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
694
695 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
696 # remove eof from string
697 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
698
699 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
700 continue
701 }
702 }
703 }
704
705 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
706 fconfigure $aShortCutHeaderFile -translation lf
707 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
708 close $aShortCutHeaderFile
709 }
710 }
711 } else {
712 set nbcopied 0
713 foreach anUnit $anUnits {
714 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
715 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
716 set aHeaderFileName [file tail $aHeaderFile]
717
718 # copy file only if target does not exist or is older than original
719 set torig [file mtime $aHeaderFile]
720 if { ! [file isfile $anIncPath/$aHeaderFileName] } {
721 set tcopy 0
722 } else {
723 set tcopy [file mtime $anIncPath/$aHeaderFileName]
724 }
725 if { $tcopy < $torig } {
726 incr nbcopied
727 file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
728 } elseif { $tcopy != $torig } {
729 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
730 }
731 }
732 }
733 puts "Info: $nbcopied files updated"
734 }
735}
736
737# Generate header for VS solution file
738proc osutils:vcsolution:header { vcversion } {
739 if { "$vcversion" == "vc7" } {
740 append var \
741 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
742 } elseif { "$vcversion" == "vc8" } {
743 append var \
744 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
745 "# Visual Studio 2005\n"
746 } elseif { "$vcversion" == "vc9" } {
747 append var \
748 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
749 "# Visual Studio 2008\n"
750 } elseif { "$vcversion" == "vc10" } {
751 append var \
752 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
753 "# Visual Studio 2010\n"
754 } elseif { "$vcversion" == "vc11" } {
755 append var \
756 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
757 "# Visual Studio 2012\n"
758 } elseif { "$vcversion" == "vc12" } {
759 append var \
760 "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
761 "# Visual Studio 2013\n"
39bff09c 762 } elseif { "$vcversion" == "vc14" } {
763 append var \
764 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
765 "# Visual Studio 14\n"
910970ab 766 } else {
767 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
768 }
769 return $var
770}
771# Returns extension (without dot) for project files of given version of VC
772
773proc osutils:vcproj:ext { vcversion } {
774 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
775 return "vcproj"
910970ab 776 } else {
39bff09c 777 return "vcxproj"
910970ab 778 }
779}
780# Generate start of configuration section of VS solution file
781
782proc osutils:vcsolution:config:begin { vcversion } {
783 if { "$vcversion" == "vc7" } {
784 append var \
785 "Global\n" \
786 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
787 "\t\tDebug = Debug\n" \
788 "\t\tRelease = Release\n" \
789 "\tEndGlobalSection\n" \
790 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
39bff09c 791 } else {
910970ab 792 append var \
793 "Global\n" \
794 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
795 "\t\tDebug|Win32 = Debug|Win32\n" \
796 "\t\tRelease|Win32 = Release|Win32\n" \
797 "\t\tDebug|x64 = Debug|x64\n" \
798 "\t\tRelease|x64 = Release|x64\n" \
799 "\tEndGlobalSection\n" \
800 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
910970ab 801 }
802 return $var
803}
804# Generate part of configuration section of VS solution file describing one project
805
806proc osutils:vcsolution:config:project { vcversion guid } {
807 if { "$vcversion" == "vc7" } {
808 append var \
809 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
810 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
811 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
812 "\t\t$guid.Release.Build.0 = Release|Win32\n"
39bff09c 813 } else {
910970ab 814 append var \
815 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
816 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
817 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
818 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
819 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
820 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
821 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
822 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
910970ab 823 }
824 return $var
825}
826# Generate start of configuration section of VS solution file
827
828proc osutils:vcsolution:config:end { vcversion } {
829 if { "$vcversion" == "vc7" } {
830 append var \
831 "\tEndGlobalSection\n" \
832 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
833 "\tEndGlobalSection\n" \
834 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
835 "\tEndGlobalSection\n"
39bff09c 836 } else {
910970ab 837 append var \
838 "\tEndGlobalSection\n" \
839 "\tGlobalSection(SolutionProperties) = preSolution\n" \
840 "\t\tHideSolutionNode = FALSE\n" \
841 "\tEndGlobalSection\n"
910970ab 842 }
843 return $var
844}
845# generate Visual Studio solution file
846# if module is empty, generates one solution for all known modules
847
848proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
849 global path
850 upvar $theGuidsMap aGuidsMap
851
852 # collect list of projects to be created
853 set aProjects {}
854 set aDependencies {}
855 foreach aModule $theModules {
856 # toolkits
857 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
858 lappend aProjects $aToolKit
859 lappend aProjectsInModule($aModule) $aToolKit
860 lappend aDependencies [LibToLink $aToolKit]
861 }
862 # executables, assume one project per cxx file...
863 foreach aUnit [OS:executable ${aModule}] {
864 set aUnitLoc $aUnit
865 set src_files [_get_used_files $aUnit false]
866 set aSrcFiles {}
867 foreach s $src_files {
868 regexp {source ([^\s]+)} $s dummy name
869 lappend aSrcFiles $name
870 }
871 foreach aSrcFile $aSrcFiles {
872 set aFileExtension [file extension $aSrcFile]
873 if { $aFileExtension == ".cxx" } {
874 set aPrjName [file rootname $aSrcFile]
875 lappend aProjects $aPrjName
876 lappend aProjectsInModule($aModule) $aPrjName
877 if {[file isdirectory $path/src/$aUnitLoc]} {
878 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
879 } else {
880 lappend aDependencies {}
881 }
882 }
883 }
884 }
885 }
886
887# generate GUIDs for projects (unless already known)
888 foreach aProject $aProjects {
889 if { ! [info exists aGuidsMap($aProject)] } {
890 set aGuidsMap($aProject) [OS:genGUID]
891 }
892 }
893
894 # generate solution file
895# puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
896 append aFileBuff [osutils:vcsolution:header $theVcVer]
897
898 # GUID identifying group projects in Visual Studio
899 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
900
901 # generate group projects -- one per module
902 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
903 foreach aModule $theModules {
904 if { ! [info exists aGuidsMap(_$aModule)] } {
905 set aGuidsMap(_$aModule) [OS:genGUID]
906 }
907 set aGuid $aGuidsMap(_$aModule)
908 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
909 }
910 }
911
912 # extension of project files
913 set aProjExt [osutils:vcproj:ext $theVcVer]
914
915 # GUID identifying C++ projects in Visual Studio
916 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
917
918 # generate normal projects
919 set aProjsNb [llength $aProjects]
920 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
921 set aProj [lindex $aProjects $aProjId]
922 set aGuid $aGuidsMap($aProj)
923 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
924 # write projects dependencies information (vc7 to vc9)
925 set aDepGuids ""
926 foreach aDepLib [lindex $aDependencies $aProjId] {
927 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
928 set depGUID $aGuidsMap($aDepLib)
929 append aDepGuids "\t\t$depGUID = $depGUID\n"
930 }
931 }
932 if { "$aDepGuids" != "" } {
933 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
934 append aFileBuff "$aDepGuids"
935 append aFileBuff "\tEndProjectSection\n"
936 }
937 append aFileBuff "EndProject\n"
938 }
939
940 # generate configuration section
941 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
942 foreach aProj $aProjects {
943 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
944 }
945 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
946
947 # write information of grouping of projects by module
948 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
949 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
950 foreach aModule $theModules {
951 if { ! [info exists aProjectsInModule($aModule)] } { continue }
952 foreach aProject $aProjectsInModule($aModule) {
953 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
954 }
955 }
956 append aFileBuff " EndGlobalSection\n"
957 }
958
959 # final word (footer)
960 append aFileBuff "EndGlobal"
961
962 # write solution
963 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
964 fconfigure $aFile -translation crlf
965 puts $aFile $aFileBuff
966 close $aFile
967 return [file join $theOutDir ${theSolName}.sln]
968}
969# Generate Visual Studio projects for specified version
970
971proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
972 upvar $theGuidsMap aGuidsMap
973
974 set aProjectFiles {}
975
976 foreach aModule $theModules {
977 foreach aToolKit [${aModule}:toolkits] {
978 lappend aProjectFiles [osutils:vcproj $theVcVer $theOutDir $aToolKit aGuidsMap]
979 }
980 foreach anExecutable [OS:executable ${aModule}] {
981 lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
982 }
983 }
984 return $aProjectFiles
985}
986# generate template name and load it for given version of Visual Studio and platform
987
39bff09c 988proc osutils:vcproj:readtemplate {theVcVer isexec} {
989 set anExt $theVcVer
990 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
991 set anExt vc10
992 }
993
994 set what "$theVcVer"
995 set aVerExt [string range $theVcVer 2 end]
996 set aVerExt "v${aVerExt}0"
997 set aCmpl32 ""
998 set aCmpl64 ""
910970ab 999 if { $isexec } {
39bff09c 1000 set anExt "${anExt}x"
910970ab 1001 set what "$what executable"
1002 }
39bff09c 1003 if { "$theVcVer" == "vc10" } {
1004 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
1005 set aCmpl32 "\n <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
1006 }
1007 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
1008 regsub -all -- {__VCVER__} $aTmpl $theVcVer aTmpl
1009 regsub -all -- {__VCVEREXT__} $aTmpl $aVerExt aTmpl
1010 regsub -all -- {__VCMPL32__} $aTmpl $aCmpl32 aTmpl
1011 regsub -all -- {__VCMPL64__} $aTmpl $aCmpl64 aTmpl
1012 return $aTmpl
910970ab 1013}
1014
1015proc osutils:readtemplate {ext what} {
1016 global env
1017 global path
1018 set loc "$path/adm/templates/template.$ext"
1019 return [wokUtils:FILES:FileToString $loc]
1020}
1021# Read a file in a string as is.
1022
1023proc wokUtils:FILES:FileToString { fin } {
1024 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1025 set strin [read $in [file size $fin]]
1026 close $in
1027 return $strin
1028 } else {
1029 return {}
1030 }
1031}
1032# List extensions of compilable files in OCCT
1033
1034proc osutils:compilable { } {
1035 global targetStation
1036 set aWokStation "$targetStation"
1037 if { "$aWokStation" == "mac" } {
1038 return [list .c .cxx .cpp .mm]
1039 }
1040 return [list .c .cxx .cpp]
1041}
1042
1043proc osutils:commonUsedTK { theToolKit } {
1044 global path
1045 set anUsedToolKits [list]
1046 set aDepToolkits [LibToLink $theToolKit]
1047 foreach tkx $aDepToolkits {
1048 if {[_get_type $tkx] == "t"} {
1049 lappend anUsedToolKits "${tkx}"
1050 }
1051 }
1052 return $anUsedToolKits
1053}
910970ab 1054
c7d774c5 1055# Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1056proc osutils:tk:csfInExternlib { EXTERNLIB } {
910970ab 1057 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1058 set lret {STLPort}
1059 foreach str $l {
1060 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1061 lappend lret $csf
1062 }
1063 }
1064 return $lret
1065}
1066
c7d774c5 1067# @param theCsfLibsMap - libraries map
1068# @param theCsfFrmsMap - frameworks map, OS X specific
1069proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1070 upvar $theCsfLibsMap aLibsMap
1071 upvar $theCsfFrmsMap aFrmsMap
910970ab 1072
c7d774c5 1073 unset theCsfLibsMap
1074 unset theCsfFrmsMap
910970ab 1075
1076 if { "$theOS" == "wnt" } {
c7d774c5 1077 # WinAPI libraries
1078 set aLibsMap(CSF_kernel32) "kernel32.lib"
1079 set aLibsMap(CSF_advapi32) "advapi32.lib"
1080 set aLibsMap(CSF_gdi32) "gdi32.lib"
1081 set aLibsMap(CSF_user32) "user32.lib"
1082 set aLibsMap(CSF_glu32) "glu32.lib"
1083 set aLibsMap(CSF_opengl32) "opengl32.lib"
1084 set aLibsMap(CSF_wsock32) "wsock32.lib"
1085 set aLibsMap(CSF_netapi32) "netapi32.lib"
1086 set aLibsMap(CSF_AviLibs) "ws2_32.lib vfw32.lib"
1087 set aLibsMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib"
1088
1089 set aLibsMap(CSF_QT) "QtCore4.lib QtGui4.lib"
1090
1091 # VTK
1e75b579 1092 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
910970ab 1093 } else {
c7d774c5 1094 set aLibsMap(CSF_FREETYPE) "freetype"
1095 if { "$theOS" == "mac" } {
1096 set aLibsMap(CSF_objc) "objc"
1097 set aFrmsMap(CSF_Appkit) "Appkit"
1098 set aFrmsMap(CSF_IOKit) "IOKit"
1099 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1100 set aFrmsMap(CSF_TclLibs) "Tcl"
1101 set aFrmsMap(CSF_TclTkLibs) "Tk"
1102 } else {
1103 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1104 set aLibsMap(CSF_OpenGlLibs) "GLU GL"
1105 set aLibsMap(CSF_TclLibs) "tcl8.6"
1106 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1107 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1108 set aLibsMap(CSF_MotifLibs) "X11"
910970ab 1109 }
1110
c7d774c5 1111 # optional 3rd-parties
1112 if { "$::HAVE_TBB" == "true" } {
1113 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1114 }
1115 if { "$::HAVE_FREEIMAGE" == "true" } {
1116 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1117 }
1118 if { "$::HAVE_GL2PS" == "true" } {
1119 set aLibsMap(CSF_GL2PS) "gl2ps"
1120 }
1121 if { "$::HAVE_VTK" == "true" } {
1e75b579 1122 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
c7d774c5 1123 }
910970ab 1124 }
1125}
1126
1c29294e 1127# Returns string of library dependencies for generation of Visual Studio project or make lists.
1128proc osutils:vtkCsf {{theOS ""}} {
1129 set aVtkVer "6.1"
1130
1131 set aLibSuffix ""
1132 set aPathSplitter ":"
1133
1134 if {"$theOS" == "wnt"} {
1135 set aPathSplitter ";"
1136 set aLibSuffix ".lib"
1137 }
1138
1139 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1140 foreach anIncItem $anOptIncs {
1141 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1142 set aVtkVer $aFoundVtkVer
1143 }
1144 }
1145
1146 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1147 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1148
1149 # Additional suffices for the libraries
1150 set anIdx 0
1151 foreach anItem $aLibArray {
1152 lset aLibArray $anIdx $anItem-$aVtkVer$aLibSuffix
1153 incr anIdx
1154 }
1155
1156 return [join $aLibArray " "]
1157}
1158
c7d774c5 1159# @param theLibsList - dependencies (libraries list)
1160# @param theFrameworks - dependencies (frameworks list, OS X specific)
1161proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
910970ab 1162 global path
c7d774c5 1163 upvar $theLibsList aLibsList
1164 upvar $theFrameworks aFrameworks
1165 set aLibsList [list]
1166 set aFrameworks [list]
910970ab 1167
c7d774c5 1168 osutils:csfList $theOS aLibsMap aFrmsMap
910970ab 1169
c7d774c5 1170 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1171 if [info exists aLibsMap($aCsfElem)] {
1172 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1173 if { [lsearch $aLibsList $aLib] == "-1" } {
1174 lappend aLibsList $aLib
1175 }
1176 }
910970ab 1177 }
c7d774c5 1178 if [info exists aFrmsMap($aCsfElem)] {
1179 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1180 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1181 lappend aFrameworks $aFrm
1182 }
910970ab 1183 }
1184 }
1185 }
910970ab 1186}
1187
1188# Returns liste of UD in a toolkit. tkloc is a full path wok.
1189proc osutils:tk:units { tkloc } {
1190 global path
1191 set l {}
1192 set PACKAGES "$path/src/$tkloc/PACKAGES"
1193 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1194 if {[file isdirectory "$path/src/$u"]} {
1195 lappend l $u
1196 }
1197 }
1198 if { $l == {} } {
1199 ;#puts stderr "Warning. No devunit included in $tkloc"
1200 }
1201 return $l
1202}
1203
1204proc osutils:justwnt { listloc } {
1205 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1206 set goaway [list Xdps Xw ImageUtility WOKUnix]
1207 return [osutils:juststation $goaway $listloc]
1208}
1209
1210# remove from listloc OpenCascade units indesirables on NT
1211proc osutils:juststation {goaway listloc} {
1212 global path
1213 set lret {}
1214 foreach u $listloc {
1215 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1216 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1217 lappend lret $u
1218 }
1219 }
1220 return $lret
1221}
1222
1223# intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1224# The first list is everything in the first list that wasn't in the second,
1225# the second list contains the intersection of the two lists, the third list contains everything
1226# in the second list that wasn't in the first.
1227proc osutils:intersect3 {list1 list2} {
1228 set la1(0) {} ; unset la1(0)
1229 set lai(0) {} ; unset lai(0)
1230 set la2(0) {} ; unset la2(0)
1231 foreach v $list1 {
1232 set la1($v) {}
1233 }
1234 foreach v $list2 {
1235 set la2($v) {}
1236 }
1237 foreach elem [concat $list1 $list2] {
1238 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1239 unset la1($elem)
1240 unset la2($elem)
1241 set lai($elem) {}
1242 }
1243 }
1244 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1245}
1246
1247# Prepare relative path
1248proc relativePath {thePathFrom thePathTo} {
1249 if { [file isdirectory "$thePathFrom"] == 0 } {
1250 return ""
1251 }
1252
1253 set aPathFrom [file normalize "$thePathFrom"]
1254 set aPathTo [file normalize "$thePathTo"]
1255
1256 set aCutedPathFrom "${aPathFrom}/dummy"
1257 set aRelatedDeepPath ""
1258
1259 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1260 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1261 # does aPathTo contain aCutedPathFrom?
1262 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1263 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1264 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1265 set aPathTo ".${aPathTo}"
1266 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1267 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1268 }
1269 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1270 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1271 return $aPathToAfterCut
1272 }
1273 set aRelatedDeepPath "$aRelatedDeepPath../"
1274
1275 }
1276
1277 return $thePathTo
1278}
1279
1280proc wokUtils:EASY:bs1 { s } {
1281 regsub -all {/} $s {\\} r
1282 return $r
1283}
1284
1285# Returs for a full path the liste of n last directory part
1286# n = 1 => tail
1287# n = 2 => dir/file.c
1288# n = 3 => sdir/dir/file.c
1289# etc..
1290proc wokUtils:FILES:wtail { f n } {
1291 set ll [expr [llength [set lif [file split $f]]] -$n]
1292 return [join [lrange $lif $ll end] /]
1293}
1294
1295# Generate entry for one source file in Visual Studio 10 project file
1296proc osutils:vcxproj:file { vcversion file params } {
1297 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1298 if { $params != "" } {
1299 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1300 }
1301
1302 if { $params != "" } {
1303 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1304 }
1305
1306 if { $params != "" } {
1307 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1308 }
1309
1310 if { $params != "" } {
1311 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1312 }
1313
1314 append text " </ClCompile>\n"
1315 return $text
1316}
1317
1318# Generate Visual Studio 2010 project filters file
1319proc osutils:vcxproj:filters { dir proj theFilesMap } {
1320 upvar $theFilesMap aFilesMap
1321
1322 # header
1323 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1324 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1325
1326 # list of "filters" (units)
1327 append text " <ItemGroup>\n"
1328 append text " <Filter Include=\"Source files\">\n"
1329 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1330 append text " </Filter>\n"
1331 foreach unit $aFilesMap(units) {
1332 append text " <Filter Include=\"Source files\\${unit}\">\n"
1333 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1334 append text " </Filter>\n"
1335 }
1336 append text " </ItemGroup>\n"
1337
1338 # list of files
1339 append text " <ItemGroup>\n"
1340 foreach unit $aFilesMap(units) {
1341 foreach file $aFilesMap($unit) {
1342 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1343 append text " <Filter>Source files\\${unit}</Filter>\n"
1344 append text " </ClCompile>\n"
1345 }
1346 }
1347 append text " </ItemGroup>\n"
1348
1349 # end
1350 append text "</Project>"
1351
1352 # write file
1353 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1354 fconfigure $fp -translation crlf
1355 puts $fp $text
1356 close $fp
1357
1358 return ${proj}.vcxproj.filters
1359}
1360
1361# Generate Visual Studio 2011 project filters file
1362proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1363 upvar $theFilesMap aFilesMap
1364
1365 # header
1366 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1367 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1368
1369 # list of "filters" (units)
1370 append text " <ItemGroup>\n"
1371 append text " <Filter Include=\"Source files\">\n"
1372 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1373 append text " </Filter>\n"
1374 foreach unit $aFilesMap(units) {
1375 append text " <Filter Include=\"Source files\\${unit}\">\n"
1376 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1377 append text " </Filter>\n"
1378 }
1379 append text " </ItemGroup>\n"
1380
1381 # list of files
1382 append text " <ItemGroup>\n"
1383 foreach unit $aFilesMap(units) {
1384 foreach file $aFilesMap($unit) {
1385 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1386 append text " <Filter>Source files\\${unit}</Filter>\n"
1387 append text " </ClCompile>\n"
1388 }
1389 }
1390 append text " </ItemGroup>\n"
1391
1392 append text " <ItemGroup>\n"
1393 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1394 append text " </ItemGroup>\n"
1395
1396 # end
1397 append text "</Project>"
1398
1399 # write file
1400 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1401 fconfigure $fp -translation crlf
1402 puts $fp $text
1403 close $fp
1404
1405 return ${proj}.vcxproj.filters
1406}
1407
1408# Generate RC file content for ToolKit from template
1409proc osutils:readtemplate:rc {theOutDir theToolKit} {
1410 global path
1411 set aLoc "$path/adm/templates/template_dll.rc"
1412 set aBody [wokUtils:FILES:FileToString $aLoc]
1413 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1414
1415 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1416 fconfigure $aFile -translation lf
1417 puts $aFile $aBody
1418 close $aFile
1419 return "${theOutDir}/${theToolKit}.rc"
1420}
1421
1422# Generate Visual Studio project file for ToolKit
1423proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1424 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1425
1426 set l_compilable [osutils:compilable]
1427 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1428
1429 upvar $theGuidsMap aGuidsMap
1430 if { ! [info exists aGuidsMap($theToolKit)] } {
1431 set aGuidsMap($theToolKit) [OS:genGUID]
1432 }
1433 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1434
1435 set aCommonUsedTK [list]
1436 foreach tkx [osutils:commonUsedTK $theToolKit] {
1437 lappend aCommonUsedTK "${tkx}.lib"
1438 }
1439
c7d774c5 1440 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1441 set aUsedToolKits [concat $aCommonUsedTK $aLibs]
910970ab 1442
1443 # correct names of referred third-party libraries that are named with suffix
1444 # depending on VC version
1445 regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
1446
1447 # and put this list to project file
1448 #puts "$theToolKit requires $aUsedToolKits"
39bff09c 1449 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1450 set aUsedToolKits [join $aUsedToolKits {;}]
1451 }
1452 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedToolKits theProjTmpl
1453
1454 set anIncPaths "..\\..\\..\\inc"
1455 set aTKDefines ""
1456 set aFilesSection ""
1457 set aVcFilesX(units) ""
1458 set listloc [osutils:tk:units $theToolKit]
1459 set resultloc [osutils:justwnt $listloc]
1460 if [array exists written] { unset written }
1461 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1462 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1463 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1464 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1465 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1466 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1467 set fxloparam ""
1468 foreach fxlo $resultloc {
1469 set xlo $fxlo
1470 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
1471 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1472 if {$fxlo_cmplrs_options_cxx == ""} {
1473 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1474 }
1475 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1476 if {$fxlo_cmplrs_options_c == ""} {
1477 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1478 }
1479 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1480 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1481 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1482 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1483 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1484 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1485 set needparam ""
1486 foreach partopt $fxloparam {
1487 if {[string first "-I" $partopt] == "0"} {
1488 # this is an additional includes search path
1489 continue
1490 }
1491 set needparam "$needparam $partopt"
1492 }
1493
39bff09c 1494 # Format of projects in vc10+ is different from vc7-9
1495 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1496 foreach aSrcFile [lsort $aSrcFiles] {
1497 if { ![info exists written([file tail $aSrcFile])] } {
1498 set written([file tail $aSrcFile]) 1
1499 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1500 } else {
1501 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1502 }
1503 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1504 lappend aVcFilesX($xlo) $aSrcFile
1505 }
1506 } else {
1507 append aFilesSection "\t\t\t<Filter\n"
1508 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1509 append aFilesSection "\t\t\t\t>\n"
1510 foreach aSrcFile [lsort $aSrcFiles] {
1511 if { ![info exists written([file tail $aSrcFile])] } {
1512 set written([file tail $aSrcFile]) 1
1513 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1514 } else {
1515 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1516 }
1517 }
1518 append aFilesSection "\t\t\t</Filter>\n"
1519 }
1520
1521 # macros
1522 append aTKDefines ";__${xlo}_DLL"
1523 # common includes
1524# append anIncPaths ";..\\..\\..\\src\\${xlo}"
1525 }
1526
1527 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1528 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1529 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1530
1531 # write file
1532 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1533 fconfigure $aFile -translation crlf
1534 puts $aFile $theProjTmpl
1535 close $aFile
1536
39bff09c 1537 # write filters file for vc10+
1538 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1539 # nothing
1540 } elseif { "$theVcVer" == "vc10" } {
910970ab 1541 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
39bff09c 1542 } else {
910970ab 1543 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1544 }
1545
1546 # write resource file
1547 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1548
1549 return $aVcFiles
1550}
1551
1552# for a unit returns a map containing all its file in the current
1553# workbench
1554# local = 1 only local files
1555proc osutils:tk:loadunit { loc map } {
1556 #puts $loc
1557 upvar $map TLOC
1558 catch { unset TLOC }
1559 set lfiles [_get_used_files $loc]
1560 foreach f $lfiles {
1561 #puts "\t$f"
1562 set t [lindex $f 0]
1563 set p [lindex $f 2]
1564 if [info exists TLOC($t)] {
1565 set l $TLOC($t)
1566 lappend l $p
1567 set TLOC($t) $l
1568 } else {
1569 set TLOC($t) $p
1570 }
1571 }
1572 return
1573}
1574
1575# Returns the list of all compilable files name in a toolkit, or devunit of any type
1576# Call unit filter on units name to accept or reject a unit
1577# Tfiles lists for each unit the type of file that can be compiled.
1578proc osutils:tk:files { tkloc {l_compilable {} } {justail 1} {unitfilter {}} } {
1579 global path
1580 set Tfiles(source,nocdlpack) {source pubinclude}
1581 set Tfiles(source,toolkit) {}
1582 set Tfiles(source,executable) {source pubinclude}
1583 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1584 #puts " listloc = $listloc"
1585 if { $l_compilable == {} } {
1586 set l_comp [list .c .cxx .cpp]
1587 } else {
1588 set l_comp [$l_compilable]
1589 }
1590 if { $unitfilter == {} } {
1591 set resultloc $listloc
1592 } else {
1593 set resultloc [$unitfilter $listloc]
1594 }
1595 set lret {}
1596 foreach loc $resultloc {
1597 set utyp [_get_type $loc]
1598 #puts "\"$utyp\" \"$loc\""
1599 switch $utyp {
1600 "t" { set utyp "toolkit" }
1601 "n" { set utyp "nocdlpack" }
1602 "x" { set utyp "executable" }
1603 }
1604 if [array exists map] { unset map }
1605 osutils:tk:loadunit $loc map
1606 #puts " loc = $loc === > [array names map]"
1607 set LType $Tfiles(source,${utyp})
1608 foreach typ [array names map] {
1609 if { [lsearch $LType $typ] == -1 } {
1610 unset map($typ)
1611 }
1612 }
1613 foreach type [array names map] {
1614 #puts $type
1615 foreach f $map($type) {
1616 #puts $f
1617 if { [lsearch $l_comp [file extension $f]] != -1 } {
1618 if { $justail == 1 } {
1619 if {$type == "source"} {
1620 if {[lsearch $lret "@top_srcdir@/src/$loc/[file tail $f]"] == -1} {
1621 lappend lret @top_srcdir@/src/$loc/[file tail $f]
1622 }
1623 }
1624 } else {
1625 lappend lret $f
1626 }
1627 }
1628 }
1629 }
1630 }
1631 return $lret
1632}
1633
1634# Generate Visual Studio project file for executable
1635proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1636 global path
1637 set aVcFiles {}
1638 foreach f [osutils:tk:files $theToolKit osutils:compilable 0] {
1639 if { $theProjTmpl == {} } {
1640 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1641 } else {
1642 set aProjTmpl $theProjTmpl
1643 }
1644 set aProjName [file rootname [file tail $f]]
1645 set l_compilable [osutils:compilable]
1646 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1647
1648 upvar $theGuidsMap aGuidsMap
1649 if { ! [info exists aGuidsMap($aProjName)] } {
1650 set aGuidsMap($aProjName) [OS:genGUID]
1651 }
1652 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1653
1654 set aCommonUsedTK [list]
1655 foreach tkx [osutils:commonUsedTK $theToolKit] {
1656 lappend aCommonUsedTK "${tkx}.lib"
1657 }
1658
c7d774c5 1659 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1660 set aUsedToolKits [concat $aCommonUsedTK $aLibs]
910970ab 1661
1662 # correct names of referred third-party libraries that are named with suffix
1663 # depending on VC version
1664 regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
1665
1666# puts "$aProjName requires $aUsedToolKits"
39bff09c 1667 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1668 set aUsedToolKits [join $aUsedToolKits {;}]
1669 }
1670 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedToolKits aProjTmpl
1671
1672 set aFilesSection ""
1673 set aVcFilesX(units) ""
1674
1675 if { ![info exists written([file tail $f])] } {
1676 set written([file tail $f]) 1
1677
39bff09c 1678 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1679 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1680 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1681 lappend aVcFilesX($theToolKit) $f
1682 } else {
1683 append aFilesSection "\t\t\t<Filter\n"
1684 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1685 append aFilesSection "\t\t\t\t>\n"
1686 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1687 append aFilesSection "\t\t\t</Filter>"
1688 }
1689 } else {
1690 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1691 }
1692 #puts "$aProjTmpl $aFilesSection"
1693 set aTKDefines ";__${theToolKit}_DLL"
1694 set anIncPaths "..\\..\\..\\inc"
1695 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1696 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1697 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1c29294e 1698 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1699
1700 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
910970ab 1701
1702 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1703 fconfigure $aFile -translation crlf
1704 puts $aFile $aProjTmpl
1705 close $aFile
1706
1707 set aCommonSettingsFile "$aVcFilePath.user"
1708 lappend aVcFiles $aVcFilePath
1709
1710 # write filters file for vc10
39bff09c 1711 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1712 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1713 }
1714
1715 set aCommonSettingsFileTmpl ""
39bff09c 1716 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1717 # nothing
1718 } elseif { "$theVcVer" == "vc9" } {
1719 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$path/adm/templates/vcproj.user.vc9x"]
1720 } else {
1721 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$path/adm/templates/vcxproj.user.vc10x"]
910970ab 1722 }
1723 if { "$aCommonSettingsFileTmpl" != "" } {
39bff09c 1724 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1725
1726 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1727 fconfigure $aFile -translation crlf
1728 puts $aFile $aCommonSettingsFileTmpl
1729 close $aFile
1730
910970ab 1731 lappend aVcFiles "$aCommonSettingsFile"
1732 }
1733 }
1734 return $aVcFiles
1735}
1736
1737# Generate entry for one source file in Visual Studio 7 - 9 project file
1738proc osutils:vcproj:file { theVcVer theFile theOptions } {
1739 append aText "\t\t\t\t<File\n"
1740 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1741 if { $theOptions == "" } {
1742 append aText "\t\t\t\t</File>\n"
1743 return $aText
1744 }
1745
1746 append aText "\t\t\t\t\t<FileConfiguration\n"
1747 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1748 append aText "\t\t\t\t\t\t<Tool\n"
1749 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1750 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1751 foreach aParam $theOptions {
1752 append aText "$aParam "
1753 }
1754 append aText "\"\n"
1755 append aText "\t\t\t\t\t\t/>\n"
1756 append aText "\t\t\t\t\t</FileConfiguration>\n"
1757
1758 append aText "\t\t\t\t\t<FileConfiguration\n"
1759 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1760 append aText "\t\t\t\t\t\t<Tool\n"
1761 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1762 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1763 foreach aParam $theOptions {
1764 append aText "$aParam "
1765 }
1766 append aText "\"\n"
1767 append aText "\t\t\t\t\t\t/>\n"
1768 append aText "\t\t\t\t\t</FileConfiguration>\n"
1769 if { "$theVcVer" == "vc7" } {
1770 append aText "\t\t\t\t</File>\n"
1771 return $aText
1772 }
1773
1774 append aText "\t\t\t\t\t<FileConfiguration\n"
1775 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1776 append aText "\t\t\t\t\t\t<Tool\n"
1777 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1778 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1779 foreach aParam $theOptions {
1780 append aText "$aParam "
1781 }
1782 append aText "\"\n"
1783 append aText "\t\t\t\t\t\t/>\n"
1784 append aText "\t\t\t\t\t</FileConfiguration>\n"
1785
1786 append aText "\t\t\t\t\t<FileConfiguration\n"
1787 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1788 append aText "\t\t\t\t\t\t<Tool\n"
1789 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1790 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1791 foreach aParam $theOptions {
1792 append aText "$aParam "
1793 }
1794 append aText "\"\n"
1795 append aText "\t\t\t\t\t\t/>\n"
1796 append aText "\t\t\t\t\t</FileConfiguration>\n"
1797
1798 append aText "\t\t\t\t</File>\n"
1799 return $aText
1800}
1801
1802### AUTOMAKE ###############################################################################
1803proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
1804 global path
1805 wokUtils:FILES:mkdir $theOutDir
1806
1807 foreach aModule $theModules {
1808 foreach aToolKit [$aModule:toolkits] {
1809 puts " toolkit: $aToolKit ==> $path/src/$aToolKit/EXTERNLIB"
1810 wokUtils:FILES:rmdir $theOutDir/$aToolKit
1811 wokUtils:FILES:mkdir $theOutDir/$aToolKit
1812 osutils:tk:mkam $theOutDir/$aToolKit $aToolKit
1813 }
1814 foreach anExecutable [OS:executable $aModule] {
1815 wokUtils:FILES:rmdir $theOutDir/$anExecutable
1816 wokUtils:FILES:mkdir $theOutDir/$anExecutable
1817 osutils:tk:mkamx $theOutDir/$anExecutable $anExecutable
1818 }
1819 }
1820 osutils:am:adm $theOutDir $theModules
1821 osutils:am:root $path $theSubPath $theModules
1822
1823 puts "The automake files are stored in the $theOutDir directory"
1824}
1825
1826proc wokUtils:FILES:rmdir { d } {
1827 global env
1828 global tcl_platform tcl_version
1829 regsub -all {\.[^.]*} $tcl_version "" major
1830 if { $major == 8 } {
1831 file delete -force $d
1832 } else {
1833 if { "$tcl_platform(platform)" == "unix" } {
1834 catch { exec rm -rf $d}
1835 } else {
1836
1837 }
1838 }
1839 return
1840}
1841
1842proc wokUtils:FILES:mkdir { d } {
1843 global tcl_version
1844 regsub -all {\.[^.]*} $tcl_version "" major
1845 if { $major == 8 } {
1846 file mkdir $d
1847 } else {
1848 if ![file exists $d] {
1849 if { "[info command mkdir]" == "mkdir" } {
1850 mkdir -path $d
1851 } else {
1852 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1853 }
1854 }
1855 }
1856 if [file exists $d] {
1857 return $d
1858 } else {
1859 return {}
1860 }
1861}
1862
1863# "Nice letter: %s" { a b c } => {Nice letter: %a} {Nice letter: %b} ..
1864# as a string without backslash
1865proc wokUtils:EASY:FmtSimple1 { fmt l {backslh 1} } {
1866 foreach e $l {
1867 if { $backslh } {
1868 append str [format $fmt $e] "\n"
1869 } else {
1870 append str [format $fmt $e]
1871 }
1872 }
1873 return $str
1874}
1875
1876# edit_last is performed ONCE fmt has been applied.
1877proc wokUtils:EASY:FmtString2 { fmt l {yes_for_last 0} {edit_last {}} } {
1878 set ldeb [lrange $l 0 [expr [llength $l] -2]]
1879 set last [lrange $l end end]
1880 foreach e $ldeb {
1881 append str [format $fmt $e $e] " \\" "\n"
1882 }
1883
1884 if {$edit_last != {} } {
1885 set slast [$edit_last [format $fmt $last $last]]
1886 } else {
1887 set slast [format $fmt $last $last]
1888 }
1889
1890 if { $yes_for_last } {
1891 append str $slast " \\" "\n"
1892 } else {
1893 append str $slast "\n"
1894 }
1895
1896 return $str
1897}
1898
1899# { a.x b.c c.v } => { a b c}
1900proc wokUtils:LIST:sanspoint { l } {
1901 set rr {}
1902 foreach x $l {
1903 lappend rr [file root $x]
1904 }
1905 return $rr
1906}
1907
1908# remove from listloc OpenCascade units indesirables on Unix
1909proc osutils:justunix { listloc } {
c7d774c5 1910 if { "$::tcl_platform(os)" == "Darwin" } {
910970ab 1911 set goaway [list Xw WNT]
1912 } else {
1913 set goaway [list WNT]
1914 }
1915 return [osutils:juststation $goaway $listloc]
1916}
1917
1918# remove ":" from last item of dependencies list in target VPATH of Makefile.am
1919proc osutils:am:__VPATH__lastoccur { str } {
1920 if { [regsub {:$} $str "" u] != 0 } {
1921 return $u
1922 }
1923}
1924
1925# ((((((((((((( Formats in Makefile.am )))))))))))))
1926# Used to replace the string __VPATH__ in Makefile.am
1927# l is the list of the units in a toolkit.
1928proc osutils:am:__VPATH__ { l } {
1929 set fmt "@top_srcdir@/src/%s:"
1930 return [wokUtils:EASY:FmtString2 $fmt $l 0 osutils:am:__VPATH__lastoccur]
1931}
1932
1933# Used to replace the string __INCLUDES__ in Makefile.am
1934# l is the list of packages in a toolkit.
1935proc osutils:am:__INCLUDES__ { l } {
1936 set fmt "-I@top_srcdir@/src/%s"
1937 return [wokUtils:EASY:FmtString2 $fmt $l]
1938}
1939
1940# Used to replace the string __LIBADD__ in Makefile.am
1941# l is the toolkit closure list of a toolkit.
1942proc osutils:am:__LIBADD__ { theIncToolkits {final 0} } {
1943 global path
1944 global fBranch
1945 set aFatherModules ""
1946 set aCurrentWorkBench [file tail $path]
1947 if { $fBranch != "" } {
1948 set fd [open $fBranch/adm/UDLIST rb]
1949 set fileContent [split [read $fd] "\n"]
1950 close $fd
1951 set ftoolkits [lsearch -all -inline $fileContent "t *"]
1952 foreach ft $ftoolkits {
1953 set aFatherModules "$aFatherModules [string range $ft 2 end]"
1954 }
1955 }
1956 set aLibString ""
1957 foreach aIncToolkit $theIncToolkits {
1958 if { [lsearch [split $aFatherModules " "] $aIncToolkit] != -1} {
1959 append aLibString " \\\n-l$aIncToolkit"
1960 } else {
1961 append aLibString " \\\n../$aIncToolkit/lib$aIncToolkit.la"
1962 }
1963 }
1964 return $aLibString
1965}
1966
1967# Used to replace the string __SOURCES__ in Makefile.am
1968# l is the list of all compilable files in a toolkit.
1969proc osutils:am:__SOURCES__ { l } {
1970 set fmt "%s"
1971 return [wokUtils:EASY:FmtString1 $fmt $l]
1972}
1973
1974proc osutils:am:__CXXFLAG__ { l } {
1975 set fmt "%s"
1976 return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCXXOption $l]]
1977}
1978
1979proc osutils:am:PkCXXOption { ppk } {
1980 global path
1981 #puts "\t 1 [lindex [wokparam -e %CMPLRS_CXX_Options [wokcd]] 0]"
1982 set CXXCOMMON [_get_options lin cmplrs_cxx b]
1983 #puts "\t 2 [wokparam -v %CMPLRS_CXX_Options [w_info -f]]"
1984 #puts "\t 3 [wokparam -v %CMPLRS_CXX_Options]"
1985 set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_cxx f]] [split [_get_options lin cmplrs_cxx b]] ] 2]"
1986 foreach pk $ppk {
1987 #puts $pk
1988 if {![file isdirectory $path/src/$pk]} {
1989 continue
1990 }
1991 set src_files [_get_used_files $pk false]
1992 set only_src_files {}
1993 foreach s $src_files {
1994 regexp {source ([^\s]+)} $s dummy name
1995 lappend only_src_files $name
1996 }
1997 if {[lsearch $only_src_files ${pk}_CMPLRS.edl] != "-1"} {
1998 set pk_cmplrs_cxx [_get_options lin cmplrs_cxx $pk]
1999 if {$pk_cmplrs_cxx == ""} {
2000 set pk_cmplrs_cxx [_get_options lin cmplrs_cxx b]
2001 }
2002 set CXXStr $pk_cmplrs_cxx
2003 #puts "\t 4 [wokparam -e %CMPLRS_CXX_Options [woklocate -u $pk]] $pk"
2004 set LastIndex [expr {[string length $CXXCOMMON ] - 1}]
2005 if {[string equal $CXXCOMMON [string range $CXXStr 0 $LastIndex]]} {
2006 set CXXOption " "
2007 } else {
2008 set CXXOption [string range $CXXStr 0 [expr {[string last $CXXCOMMON $CXXStr] - 1}]]
2009 }
2010 if {$CXXOption != " " && $CXXOption != "" && $CXXOption != " " && $CXXOption != " "} {
2011 set FoundList [split $CXXOption " "]
2012 foreach elem $FoundList {
2013 if {$elem != ""} {
2014 if {[string first "-I" $elem] == "-1" } {
2015 if {[string first $elem $FoundFlag] == "-1"} {
2016 set FoundFlag "$FoundFlag $elem"
2017 }
2018 }
2019 }
2020 }
2021 }
2022 }
2023 }
2024 return $FoundFlag
2025}
2026
2027# Create in dir the Makefile.am associated with toolkit tkloc.
2028# Returns the full path of the created file.
2029proc osutils:tk:mkam { dir tkloc } {
2030 global path
2031 set pkgs $path/src/${tkloc}/PACKAGES
2032 if { ![file exists $pkgs] } {
2033 puts stderr "osutils:tk:mkam : Error. File PACKAGES not found for toolkit $tkloc."
2034 return {}
2035 }
2036
2037 set tmplat [osutils:readtemplate mam "Makefile.am"]
2038 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
2039 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2040 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2041 set lobj [wokUtils:LIST:sanspoint $lsrc]
2042
c7d774c5 2043 set lcsf [osutils:tk:csfInExternlib $path/src/${tkloc}/EXTERNLIB]
910970ab 2044
2045 set final 0
2046 set externinc ""
2047 set externlib ""
2048 if { $lcsf != {} } {
2049 set final 1
2050 set fmtinc "\$(%s_INCLUDES) "
2051 set fmtlib "\$(%s_LIB) "
2052 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2053 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2054 }
2055
2056 regsub -all -- {__TKNAM__} $tmplat $tkloc tmplat
2057 set vpath [osutils:am:__VPATH__ $lpkgs]
2058 regsub -all -- {__VPATH__} $tmplat $vpath tmplat
2059 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2060 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2061 if { $close != {} } {
2062 set libadd [osutils:am:__LIBADD__ $close $final]
2063 } else {
2064 set libadd ""
2065 }
2066 regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
2067 set source [osutils:am:__SOURCES__ $lsrc]
2068 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2069 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2070 set CXXFl [osutils:am:__CXXFLAG__ $lpkgs]
2071 regsub -all -- {__CXXFLAG__} $tmplat $CXXFl tmplat
2072 set CFl [osutils:am:__CFLAG__ $lpkgs]
2073 regsub -all -- {__CFLAG__} $tmplat $CFl tmplat
2074
2075 regsub -all -- {__EXTERNLIB__} $tmplat $externlib tmplat
2076
2077 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2078 return [list $fmam]
2079}
2080
2081# Write a string in a file
2082proc wokUtils:FILES:StringToFile { str path } {
2083 if { [catch { set out [ open $path w ] } errout] == 0 } {
2084 puts -nonewline $out $str
2085 close $out
2086 return 1
2087 } else {
2088 return {}
2089 }
2090}
2091
2092# Create in dir the Makefile.am associated with toolkit tkloc.
2093# Returns the full path of the created file.
2094proc osutils:tk:mkamx { dir tkloc } {
2095 global path
2096 set src_files [_get_used_files $tkloc false]
2097 set only_src_files {}
2098 foreach s $src_files {
2099 regexp {source ([^\s]+)} $s dummy name
2100 lappend only_src_files $name
2101 }
2102 if { [lsearch $only_src_files ${tkloc}_WOKSteps.edl] != "-1"} {
2103 set pkgs "$path/src/${tkloc}/EXTERNLIB"
2104 if { $pkgs == {} } {
2105 puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
2106 #return {}
2107 }
2108 set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
2109 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2110 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2111 set lobj [wokUtils:LIST:sanspoint $lsrc]
2112 set CXXList {}
2113 foreach SourceFile $only_src_files {
2114 if {[file extension $SourceFile] == ".cxx"} {
2115 lappend CXXList [file rootname $SourceFile]
2116 }
2117 }
2118 set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
2119 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
2120 puts "pkgs $pkgs"
c7d774c5 2121 #set lcsf [osutils:tk:csfInExternlib [woklocate -p ${tkloc}:source:EXTERNLIB [wokcd]]]
910970ab 2122
2123 set lcsf {}
2124 foreach tk $pkgs {
c7d774c5 2125 foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
910970ab 2126 if {[lsearch $lcsf $element] == "-1"} {
2127 set lcsf [concat $lcsf $element]
2128 }
2129 }
2130 }
2131 set final 0
2132 set externinc ""
2133 set externlib ""
2134 if { $lcsf != {} } {
2135 set final 1
2136 set fmtinc "\$(%s_INCLUDES) "
2137 set fmtlib "\$(%s_LIB) "
2138 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2139 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2140 }
2141 regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
2142 set tmplat "$tmplat \nlib_LTLIBRARIES="
2143 foreach entity $CXXList {
2144 set tmplat "$tmplat lib${entity}.la"
2145 }
2146 set tmplat "$tmplat\n"
2147 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2148 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2149 if { $pkgs != {} } {
2150 set libadd [osutils:am:__LIBADD__ $pkgs $final]
2151 } else {
2152 set libadd ""
2153 }
2154 regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
2155 set source [osutils:am:__SOURCES__ $CXXList]
2156 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2157 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2158 foreach entity $CXXList {
2159 set tmplat "$tmplat lib${entity}_la_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
2160 }
2161 foreach entity $CXXList {
2162 set tmplat "$tmplat lib${entity}_la_LIBADD = $libadd $externlib \n"
2163 }
2164 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2165
2166 unset tmplat
2167
2168 return [list $fmam]
2169
2170 } else {
2171 set pkgs "$path/src/${tkloc}/EXTERNLIB"
2172 if { $pkgs == {} } {
2173 puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
2174 #return {}
2175 }
2176 set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
2177 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2178 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2179 set lobj [wokUtils:LIST:sanspoint $lsrc]
2180 set CXXList {}
2181 foreach SourceFile $only_src_files {
2182 if {[file extension $SourceFile] == ".cxx"} {
2183 lappend CXXList [file rootname $SourceFile]
2184 }
2185 }
2186 set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
2187 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
c7d774c5 2188 set lcsf [osutils:tk:csfInExternlib "$path/src/${tkloc}/EXTERNLIB"]
910970ab 2189
2190 set lcsf {}
2191 foreach tk $pkgs {
c7d774c5 2192 foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
910970ab 2193 if {[lsearch $lcsf $element] == "-1"} {
2194 set lcsf [concat $lcsf $element]
2195 }
2196 }
2197 }
2198 set final 0
2199 set externinc ""
2200 set externlib ""
2201 if { $lcsf != {} } {
2202 set final 1
2203 set fmtinc "\$(%s_INCLUDES) "
2204 set fmtlib "\$(%s_LIB) "
2205 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2206 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2207 }
2208 regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
2209 set tmplat "$tmplat \nbin_PROGRAMS="
2210 foreach entity $CXXList {
2211 set tmplat "${tmplat} ${entity}"
2212 }
2213
2214 set tmplat "${tmplat}\n"
2215 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2216 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2217 if { $pkgs != {} } {
2218 set libadd [osutils:am:__LIBADD__ $pkgs $final]
2219 } else {
2220 set libadd ""
2221 }
2222 set source [osutils:am:__SOURCES__ $CXXList]
2223 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2224 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2225 foreach entity $CXXList {
2226 set tmplat "$tmplat ${entity}_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
2227 }
2228 foreach entity $CXXList {
2229 set tmplat "$tmplat ${entity}_LDADD = $libadd $externlib \n"
2230 }
2231 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2232
2233 return [list $fmam]
2234 }
2235}
2236
2237# Create in dir the Makefile.am in $dir directory.
2238# Returns the full path of the created file.
2239proc osutils:am:adm { dir {lesmodules {}} } {
2240 set amstring "srcdir = @srcdir@\n\n"
2241 set subdirs "SUBDIRS ="
2242 set vpath "VPATH = @srcdir@ ${dir}: "
2243 set make ""
2244 set phony ".PHONY:"
2245 foreach theModule $lesmodules {
2246 set units [osutils:tk:sort [$theModule:toolkits]]
2247 set units [concat $units [OS:executable $theModule]]
2248 append amstring "${theModule}_PKGS ="
2249 append vpath "\\\n"
2250 foreach unit $units {
2251 append amstring " ${unit}"
2252 append vpath "${dir}/${unit}: "
2253 }
2254 set up ${theModule}
2255 if { [info procs ${theModule}:alias] != "" } {
2256 set up [${theModule}:alias]
2257 }
2258 set up [string toupper ${up}]
2259 append amstring "\n\nif ENABLE_${up}\n"
2260 append amstring " ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
2261 append amstring "else\n"
2262 append amstring " ${theModule}_DIRS = \n"
2263 append amstring "endif\n\n"
2264 append subdirs " \$(${theModule}_DIRS)"
2265 append make "${theModule}:\n"
2266 append make "\tfor d in \$(${theModule}_PKGS); do \\\n"
2267 append make "\t\tcd \$\$d; \$(MAKE) \$(AM_MAKEFLAGS) lib\$\$d.la; cd ..; \\\n"
2268 append make "\tdone\n\n"
2269 append phony " ${theModule}"
2270 }
2271 append amstring "$subdirs\n\n"
2272 append amstring "$vpath\n\n"
2273 append amstring $make
2274 append amstring $phony
2275 wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
2276 return [list $fmam]
2277}
2278
2279# retourne la liste de dependances de module.
2280proc OS:lsdep { m } {
2281 set res {}
2282 set l [${m}:depends]
2283 if { $l != {} } {
2284 set res [concat $res $l]
2285 foreach h $l {
2286 set res [concat $res [OS:lsdep ${h}]]
2287 }
2288 }
2289 return $res
2290}
2291
2292# Create in dir the Makefile.am and configure.ac in CASROOT directory.
2293# Returns the full path of the created file.
2294proc osutils:am:root { dir theSubPath {lesmodules {}} } {
2295 global path
2296 set amstring "srcdir = @srcdir@\n\n"
2297 append amstring "SUBDIRS = ${theSubPath}\n\n"
2298 append amstring "VPATH = @srcdir@ @top_srcdir@/${theSubPath}: @top_srcdir@/${theSubPath}:\n\n"
2299
2300 set phony ".PHONY:"
2301
2302 set acstring [osutils:readtemplate ac "Makefile.am"]
2303 set enablestr ""
2304 set confstr ""
2305 set condstr ""
2306 set repstr ""
2307 set acconfstr ""
2308
2309 set exelocal "install-exec-local:\n"
2310 append exelocal "\t"
2311 append exelocal {$(INSTALL) -d $(prefix)/$(platform)}
2312 append exelocal "\n"
2313 foreach d {bin lib} {
2314 append exelocal "\t"
2315 append exelocal "if \[ -e \$(prefix)/${d} -a ! -e \$(prefix)/\$(platform)/${d} \]; then \\\n"
2316 append exelocal "\t\tcd \$(prefix)/\$(platform) && ln -s ../${d} ${d}; \\\n"
2317 append exelocal "\tfi\n"
2318 }
2319 append exelocal "\t"
2320 append exelocal {buildd=`pwd`; cd $(top_srcdir); sourced=`pwd`; cd $(prefix); installd=`pwd`; cd $$buildd;}
2321 append exelocal " \\\n"
2322 append exelocal "\t"
2323 append exelocal {if [ "$$installd" != "$$sourced" ]; then}
2324 append exelocal " \\\n"
2325 append exelocal "\t\t"
2326 append exelocal {$(INSTALL) -d $(prefix)/src;}
2327 append exelocal " \\\n"
2328 append exelocal "\t\t"
2329 append exelocal {cp -frL $(top_srcdir)/src $(prefix);}
2330 append exelocal " \\\n"
2331 append exelocal "\t\t"
2332 append exelocal {cp -frL $$buildd/config.h $(prefix);}
2333 append exelocal " \\\n"
2334 append exelocal "\t\tfor d in "
2335
2336 foreach theModule $lesmodules {
2337 append amstring "${theModule}_PKGS ="
2338 foreach r [${theModule}:ressources] {
2339 if { "[lindex $r 1]" == "r" } {
2340 append amstring " [lindex $r 2]"
2341 }
2342 }
2343 set up ${theModule}
2344 if { [info procs ${theModule}:alias] != "" } {
2345 set up [${theModule}:alias]
2346 }
2347 set up [string toupper ${up}]
2348 set lower ${theModule}
2349 if { [info procs ${theModule}:alias] != "" } {
2350 set lower [${theModule}:alias]
2351 }
2352 set lower [string tolower ${lower}]
2353
2354 append amstring "\n\nif ENABLE_${up}\n"
2355 append amstring " ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
2356 append amstring "else\n"
2357 append amstring " ${theModule}_DIRS = \n"
2358 append amstring "endif\n\n"
2359 append amstring "${theModule}:\n"
2360 append amstring "\tcd \$(top_builddir)/${theSubPath} && \$(MAKE) \$(AM_MAKEFLAGS) ${theModule}\n\n"
2361 append phony " ${theModule}"
2362
2363 append exelocal " \$(${theModule}_DIRS)"
2364
2365 append enablestr "AC_ARG_ENABLE(\[${lower}\],\n"
2366 append enablestr " \[AS_HELP_STRING(\[--disable-${lower}\],\[Disable ${theModule} components\])\],\n"
2367 append enablestr " \[ENABLE_${up}=\${enableval}\],\[ENABLE_${up}=yes\])\n"
2368
2369 set deplist [OS:lsdep ${theModule}]
2370 set acdeplist {}
2371 if { [info procs ${theModule}:acdepends] != "" } {
2372 set acdeplist [${theModule}:acdepends]
2373 }
2374
2375 if { [llength $deplist] > 0 || [llength $acdeplist] > 0} {
2376 append confstr "if test \"xyes\" = \"x\$ENABLE_${up}\"; then\n"
2377 } else {
2378 append confstr "if test \"xyes\" != \"x\$ENABLE_${up}\"; then\n"
2379 }
2380 foreach dep $deplist {
2381 set dup ${dep}
2382 if { [info procs ${dep}:alias] != "" } {
2383 set dup [${dep}:alias]
2384 }
2385 set dup [string toupper ${dup}]
2386 append confstr " if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$ENABLE_${dup}\"; then\n"
2387 append confstr " AC_MSG_NOTICE(\[Disabling ${theModule}: not building ${dep} component\])\n"
2388 append confstr " DISABLE_${up}_REASON=\"(${dep} component disabled)\"\n"
2389 append confstr " ENABLE_${up}=no\n"
2390 append confstr " fi\n"
2391 }
2392 foreach dep $acdeplist {
2393 append confstr " if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$HAVE_${dep}\"; then\n"
2394 append confstr " AC_MSG_NOTICE(\[Disabling ${theModule}: ${dep} not found\])\n"
2395 append confstr " DISABLE_${up}_REASON=\"(${dep} not found)\"\n"
2396 append confstr " ENABLE_${up}=no\n"
2397 append confstr " fi\n"
2398 }
2399 if { [llength $deplist] > 0 || [llength $acdeplist] > 0 } {
2400 append confstr "else\n"
2401 }
2402 append confstr " DISABLE_${up}_REASON=\"(Disabled)\"\n"
2403 append confstr "fi\n"
2404
2405 append condstr "AM_CONDITIONAL(\[ENABLE_${up}\], \[test \"xyes\" = \"x\$ENABLE_${up}\"\])\n"
2406 append repstr [format "echo \"%-*s \$ENABLE_${up} \$DISABLE_${up}_REASON\"" 26 ${theModule}]
2407 append repstr "\n"
2408
2409 set units [$theModule:toolkits]
2410 set units [concat $units [OS:executable $theModule]]
2411 foreach unit $units {
2412 append acconfstr "${theSubPath}/${unit}/Makefile \\\n"
2413 }
2414 }
2415
2416 append exelocal "; do \\\n"
2417 append exelocal "\t\t\t"
2418 append exelocal {$(INSTALL) -d $(prefix)/src/$$d;}
2419 append exelocal " \\\n"
2420 append exelocal "\t\t\t"
2421 append exelocal {cp -frL $(top_srcdir)/src/$$d $(prefix)/src;}
2422 append exelocal " \\\n"
2423 append exelocal "\t\tdone; \\\n"
2424 append exelocal "\tfi\n"
2425 append exelocal "\t"
2426 append exelocal {if [ -e $(prefix)/src/config.h ]; then}
2427 append exelocal " \\\n"
2428 append exelocal "\t\t"
2429 append exelocal {unlink $(prefix)/src/config.h;}
2430 append exelocal " \\\n"
2431 append exelocal "\tfi\n"
2432 append exelocal "\t"
2433 append exelocal {cd $(prefix)/src && ln -s ../config.h config.h}
2434 append exelocal "\n"
2435 append exelocal "\t"
2436 append exelocal {cd $(top_srcdir) && cp *.sh $(prefix)}
2437 append exelocal "\n"
2438 append exelocal "\n"
2439
2440 append amstring $exelocal
2441 append amstring $phony
2442
2443 regsub -all -- {__ENABLEMODULES__} $acstring $enablestr acstring
2444 regsub -all -- {__CONFMODULES__} $acstring $confstr acstring
2445 regsub -all -- {__CONDMODULES__} $acstring $condstr acstring
2446 regsub -all -- {__REPMODULES__} $acstring $repstr acstring
2447 regsub -all -- {__ACCONFMODULES__} $acstring $acconfstr acstring
2448
2449 wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
2450 wokUtils:FILES:StringToFile $acstring [set fmam [file join $dir configure.ac]]
2451 file copy -force -- [file join $path/adm/templates build_configure] [file join $dir build_configure]
2452 file copy -force -- [file join $path/adm/templates acinclude.m4] [file join $dir acinclude.m4]
2453 file copy -force -- [file join $path/adm/templates custom.sh.in] [file join $dir custom.sh.in]
2454 return [list $fmam]
2455}
2456
2457proc wokUtils:EASY:FmtString1 { fmt l {yes_for_last 0} {edit_last {}} } {
2458 set ldeb [lrange $l 0 [expr [llength $l] -2]]
2459 set last [lrange $l end end]
2460 foreach e $ldeb {
2461 append str [format $fmt $e] " \\" "\n"
2462 }
2463
2464 if {$edit_last != {} } {
2465 set slast [$edit_last [format $fmt $last]]
2466 } else {
2467 set slast [format $fmt $last]
2468 }
2469
2470 if { $yes_for_last } {
2471 append str $slast " \\" "\n"
2472 } else {
2473 append str $slast "\n"
2474 }
2475 return $str
2476}
2477
2478# Used to replace the string __CFLAG__ in Makefile.am
2479# l is the list of all compilable files in a toolkit.
2480proc osutils:am:__CFLAG__ { l } {
2481 set fmt "%s"
2482 return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCOption $l]]
2483}
2484
2485proc osutils:am:PkCOption { ppk } {
2486 global path
2487 #puts "\t\t $ppk"
2488 #puts "\t 5 [lindex [wokparam -e %CMPLRS_C_Options [wokcd]] 0]"
2489 set CCOMMON [_get_options lin cmplrs_c b]
2490 #puts "\t 6 [lindex [wokparam -v %CMPLRS_C_Options [w_info -f]] 0]"
2491 set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_c f]] [split [_get_options lin cmplrs_c b]]] 2]"
2492 foreach pk $ppk {
2493 if {![file isdirectory $path/src/$pk]} {
2494 continue
2495 }
2496 set src_files [_get_used_files $pk false]
2497 set only_src_files {}
2498 foreach s $src_files {
2499 regexp {source ([^\s]+)} $s dummy name
2500 lappend only_src_files $name
2501 }
2502 if {[lsearch $src_files ${pk}_CMPLRS.edl] != "-1"} {
2503 #puts "\t 7 [lindex [wokparam -e %CMPLRS_C_Options [woklocate -u $pk]] 0] $pk"
2504 set aPkList [split "[_get_options lin cmplrs_c $pk]" " "]
2505 set aCcomList [split "$CCOMMON" " "]
2506
2507 foreach aPkItem $aPkList {
2508 if { [lsearch aCcomList $aPkItem] != -1 } {
2509 if {[string first "-I" $aPkItem] == "-1" } {
2510 set FoundFlag "$FoundFlag $aPkItem"
2511 }
2512 }
2513 }
2514 }
2515 }
2516 return $FoundFlag
2517}
2518
2519proc osutils:tksrcfiles { theUnits theRelatedPath {theCompatible {}} } {
2520 set aTKSrcFiles [list]
2521
2522 if [array exists written] { unset written }
2523 foreach anUnit $theUnits {
2524 set xlo $anUnit
2525 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
2526
2527 if { $theCompatible != {} } {
2528 set aSrcFiles [osutils:tk:files $xlo $theCompatible 0]
2529 }
2530
2531 foreach aSrcFile [lsort $aSrcFiles] {
2532 if { ![info exists written([file tail $aSrcFile])] } {
2533 set written([file tail $aSrcFile]) 1
2534 lappend aTKSrcFiles "${theRelatedPath}/[wokUtils:FILES:wtail $aSrcFile 3]"
2535 } else {
2536 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2537 }
2538 }
2539 }
2540
2541 return $aTKSrcFiles
2542}
2543
2544proc osutils:mm_compilable { } {
2545 return [list .mm]
2546}
2547
2548proc osutils:tkdefs { theUnits } {
2549 set aTKDefines [list]
2550
2551 foreach anUnit $theUnits {
2552 lappend aTKDefines "__${anUnit}_DLL"
2553 }
2554
2555 return $aTKDefines
2556}
2557
2558proc osutils:fileGroupName { theSrcFile } {
2559 set path [file dirname [file normalize ${theSrcFile}]]
2560 regsub -all [file normalize "${path}/.."] ${path} "" aGroupName
2561
2562 return $aGroupName
2563}
2564
2565
2566####### CODEBLOCK ###################################################################
2567# Function to generate Code Blocks workspace and project files
2568proc OS:MKCBP { theOutDir {theModules {}} {theAllSolution ""} } {
2569 puts stderr "Generating project files for Code Blocks"
2570
2571 # Generate projects for toolkits and separate workspace for each module
2572 foreach aModule $theModules {
2573 OS:cworkspace $aModule $aModule $theOutDir
2574 OS:cbp $aModule $theOutDir
2575 }
2576
2577 # Generate single workspace "OCCT" containing projects from all modules
2578 if { "$theAllSolution" != "" } {
2579 OS:cworkspace $theAllSolution $theModules $theOutDir
2580 }
2581
2582 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
2583}
2584
2585# Generate Code Blocks projects
2586proc OS:cbp { theModules theOutDir } {
2587 set aProjectFiles {}
2588 foreach aModule $theModules {
2589 foreach aToolKit [${aModule}:toolkits] {
2590 lappend aProjectFiles [osutils:cbptk $theOutDir $aToolKit ]
2591 }
2592 foreach anExecutable [OS:executable ${aModule}] {
2593 lappend aProjectFiles [osutils:cbpx $theOutDir $anExecutable]
2594 }
2595 }
2596 return $aProjectFiles
2597}
2598
2599# Generate Code::Blocks project file for ToolKit
2600proc osutils:cbptk { theOutDir theToolKit } {
2601 set aUsedToolKits [list]
2602 set aFrameworks [list]
2603 set anIncPaths [list]
2604 set aTKDefines [list]
2605 set aTKSrcFiles [list]
2606
2607 osutils:tkinfo "../../.." $theToolKit aUsedToolKits aFrameworks anIncPaths aTKDefines aTKSrcFiles
2608
2609 return [osutils:cbp $theOutDir $theToolKit $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines]
2610}
2611
2612# Generates Code Blocks workspace.
2613proc OS:cworkspace { theSolName theModules theOutDir } {
2614 global path
2615 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
2616 set aFile [open $aWsFilePath "w"]
2617 set isActiveSet 0
2618 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2619 puts $aFile "<CodeBlocks_workspace_file>"
2620 puts $aFile "\t<Workspace title=\"${theSolName}\">"
2621
2622 # collect list of projects to be created
2623 foreach aModule $theModules {
2624 # toolkits
2625 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
2626 set aDependencies [LibToLink $aToolKit]
2627 if { [llength $aDependencies] == 0 } {
2628 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
2629 } else {
2630 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
2631 foreach aDepTk $aDependencies {
2632 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2633 }
2634 puts $aFile "\t\t</Project>"
2635 }
2636 }
2637
2638 # executables, assume one project per cxx file...
2639 foreach aUnit [OS:executable ${aModule}] {
2640 set aUnitLoc $aUnit
2641 set src_files [_get_used_files $aUnit false]
2642 set aSrcFiles {}
2643 foreach s $src_files {
2644 regexp {source ([^\s]+)} $s dummy name
2645 lappend aSrcFiles $name
2646 }
2647 foreach aSrcFile $aSrcFiles {
2648 set aFileExtension [file extension $aSrcFile]
2649 if { $aFileExtension == ".cxx" } {
2650 set aPrjName [file rootname $aSrcFile]
2651 set aDependencies [list]
2652 if {[file isdirectory $path/src/$aUnitLoc]} {
2653 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
2654 }
2655 set anActiveState ""
2656 if { $isActiveSet == 0 } {
2657 set anActiveState " active=\"1\""
2658 set isActiveSet 1
2659 }
2660 if { [llength $aDependencies] == 0 } {
2661 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
2662 } else {
2663 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
2664 foreach aDepTk $aDependencies {
2665 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2666 }
2667 puts $aFile "\t\t</Project>"
2668 }
2669 }
2670 }
2671 }
2672 }
2673
2674 puts $aFile "\t</Workspace>"
2675 puts $aFile "</CodeBlocks_workspace_file>"
2676 close $aFile
2677
2678 return $aWsFilePath
2679}
2680
2681# Generate Code::Blocks project file for Executable
2682proc osutils:cbpx { theOutDir theToolKit } {
2683 global path targetStation
2684 set aWokStation "$targetStation"
2685 set aWokArch "$::env(ARCH)"
2686
2687 set aCbpFiles {}
2688 foreach aSrcFile [osutils:tk:files $theToolKit osutils:compilable 0] {
2689 # collect list of referred libraries to link with
2690 set aUsedToolKits [list]
2691 set aFrameworks [list]
2692 set anIncPaths [list]
2693 set aTKDefines [list]
2694 set aTKSrcFiles [list]
2695 set aProjName [file rootname [file tail $aSrcFile]]
2696
c7d774c5 2697 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedToolKits aFrameworks
910970ab 2698 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2699 foreach tkx $aDepToolkits {
2700 if {[_get_type $tkx] == "t"} {
2701 lappend aUsedToolKits "${tkx}"
2702 }
2703 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2704 lappend aUsedToolKits "${tkx}"
2705 }
2706 }
2707
910970ab 2708 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2709 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2710 set isExecutable "false"
2711 } else {
2712 set isExecutable "true"
2713 }
2714
2715 if { ![info exists written([file tail $aSrcFile])] } {
2716 set written([file tail $aSrcFile]) 1
2717 lappend aTKSrcFiles $aSrcFile
2718 } else {
2719 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2720 }
2721
2722 # macros for correct DLL exports
2723 if { "$aWokStation" == "wnt" } {
2724 lappend aTKDefines "__${theToolKit}_DLL"
2725 }
2726
2727 # common include paths
2728 lappend anIncPaths "../../../inc"
2729
c7d774c5 2730 # extra macros
910970ab 2731 lappend aTKDefines "CSFDB"
2732 if { "$aWokStation" == "wnt" } {
2733 lappend aTKDefines "WNT"
2734 lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
2735 } else {
910970ab 2736 if { "$aWokStation" == "lin" } {
2737 lappend aTKDefines "LIN"
2738 }
2739 lappend aTKDefines "OCC_CONVERT_SIGNALS"
2740 #lappend aTKDefines "_GNU_SOURCE=1"
2741 }
2742
2743 lappend aCbpFiles [osutils:cbp $theOutDir $aProjName $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2744 }
2745
2746 return $aCbpFiles
2747}
2748
2749proc osutils:optinal_libs { } {
2750 return [list tbb.lib tbbmalloc.lib FreeImage.lib FreeImagePlus.lib gl2ps.lib]
2751}
2752
2753# This function intended to generate Code::Blocks project file
2754# @param theOutDir - output directory to place project file
2755# @param theProjName - project name
2756# @param theSrcFiles - list of source files
2757# @param theLibsList - dependencies (libraries list)
2758# @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2759# @param theIncPaths - header search paths
2760# @param theDefines - compiler macro definitions
2761# @param theIsExe - flag to indicate executable / library target
2762proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2763 global targetStation
2764 set aWokStation "$targetStation"
2765 set aWokArch "$::env(ARCH)"
2766
2767 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2768 set aFile [open $aCbpFilePath "w"]
2769 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2770 puts $aFile "<CodeBlocks_project_file>"
2771 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2772 puts $aFile "\t<Project>"
2773 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2774 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2775 if { "$aWokStation" == "wnt" } {
2776 puts $aFile "\t\t<Option compiler=\"msvc8\" />"
2777 } else {
2778 puts $aFile "\t\t<Option compiler=\"gcc\" />"
2779 }
2780 puts $aFile "\t\t<Build>"
2781
2782 # Release target configuration
2783 puts $aFile "\t\t\t<Target title=\"Release\">"
2784 if { "$theIsExe" == "true" } {
2785 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2786 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2787 } else {
2788 if { "$aWokStation" == "wnt" } {
2789 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2790 } else {
2791 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2792 }
2793 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2794 }
2795 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2796 if { "$aWokStation" == "wnt" } {
2797 puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
2798 } else {
2799 puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
2800 }
2801 puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
2802 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2803
2804 # compiler options per TARGET (including defines)
2805 puts $aFile "\t\t\t\t<Compiler>"
2806 if { "$aWokStation" == "wnt" } {
2807 puts $aFile "\t\t\t\t\t<Add option=\"-MD\" />"
2808 puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
2809 puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
2810 puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
2811 puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
2812 puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
2813 } else {
2814 puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
2815 puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
2816 puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
2817 puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
2818 puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
2819 }
2820 foreach aMacro $theDefines {
2821 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2822 }
2823 puts $aFile "\t\t\t\t\t<Add option=\"-DNDEBUG\" />"
2824 puts $aFile "\t\t\t\t\t<Add option=\"-DNo_Exception\" />"
2825
2826 puts $aFile "\t\t\t\t</Compiler>"
2827
2828 puts $aFile "\t\t\t\t<Linker>"
2829 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2830 if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
2831 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2832 }
2833 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2834 puts $aFile "\t\t\t\t</Linker>"
2835
2836 puts $aFile "\t\t\t</Target>"
2837
2838 # Debug target configuration
2839 puts $aFile "\t\t\t<Target title=\"Debug\">"
2840 if { "$theIsExe" == "true" } {
2841 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2842 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2843 } else {
2844 if { "$aWokStation" == "wnt" } {
2845 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2846 } else {
2847 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2848 }
2849 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2850 }
2851 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2852 if { "$aWokStation" == "wnt" } {
2853 puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
2854 } else {
2855 puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
2856 }
2857 puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
2858 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2859
2860 # compiler options per TARGET (including defines)
2861 puts $aFile "\t\t\t\t<Compiler>"
2862 if { "$aWokStation" == "wnt" } {
2863 puts $aFile "\t\t\t\t\t<Add option=\"-MDd\" />"
2864 puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
2865 puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
2866 puts $aFile "\t\t\t\t\t<Add option=\"-Od\" />"
2867 puts $aFile "\t\t\t\t\t<Add option=\"-Zi\" />"
2868 puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
2869 puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
2870 } else {
2871 puts $aFile "\t\t\t\t\t<Add option=\"-O0\" />"
2872 puts $aFile "\t\t\t\t\t<Add option=\"-g\" />"
2873 puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
2874 puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
2875 puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
2876 puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
2877 }
2878 foreach aMacro $theDefines {
2879 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2880 }
2881 puts $aFile "\t\t\t\t\t<Add option=\"-D_DEBUG\" />"
2882 puts $aFile "\t\t\t\t\t<Add option=\"-DDEB\" />"
2883 puts $aFile "\t\t\t\t</Compiler>"
2884
2885 puts $aFile "\t\t\t\t<Linker>"
2886 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2887 if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
2888 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2889 }
2890 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2891 puts $aFile "\t\t\t\t</Linker>"
2892
2893 puts $aFile "\t\t\t</Target>"
2894
2895 puts $aFile "\t\t</Build>"
2896
2897 # COMMON compiler options
2898 puts $aFile "\t\t<Compiler>"
2899 puts $aFile "\t\t\t<Add option=\"-Wall\" />"
2900 puts $aFile "\t\t\t<Add option=\"-fexceptions\" />"
2901 puts $aFile "\t\t\t<Add option=\"-fPIC\" />"
2902 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2903 foreach anIncPath $theIncPaths {
2904 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2905 }
2906 puts $aFile "\t\t</Compiler>"
2907
2908 # COMMON linker options
2909 puts $aFile "\t\t<Linker>"
2910 foreach aFrameworkName $theFrameworks {
2911 if { "$aFrameworkName" != "" } {
2912 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2913 }
2914 }
2915 foreach aLibName $theLibsList {
2916 if { "$aLibName" != "" } {
2917 puts $aFile "\t\t\t<Add library=\"$aLibName\" />"
2918 }
2919 }
2920 puts $aFile "\t\t</Linker>"
2921
2922 # list of sources
2923 foreach aSrcFile $theSrcFiles {
2924 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2925 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2926 puts $aFile "\t\t\t<Option compile=\"1\" />"
2927 puts $aFile "\t\t\t<Option link=\"1\" />"
2928 puts $aFile "\t\t</Unit>"
2929 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2930 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2931 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2932 puts $aFile "\t\t</Unit>"
2933 } else {
2934 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2935 }
2936 }
2937
2938 puts $aFile "\t</Project>"
2939 puts $aFile "</CodeBlocks_project_file>"
2940 close $aFile
2941
2942 return $aCbpFilePath
2943}
2944
2945# Auxiliary function to achieve complete information to build Toolkit
2946# @param theRelativePath - relative path to CASROOT
2947# @param theToolKit - Toolkit name
2948# @param theUsedLib - dependencies (libraries list)
2949# @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2950# @param theIncPaths - header search paths
2951# @param theTKDefines - compiler macro definitions
2952# @param theTKSrcFiles - list of source files
2953proc osutils:tkinfo { theRelativePath theToolKit theUsedLib theFrameworks theIncPaths theTKDefines theTKSrcFiles } {
2954 global path targetStation
2955 set aWokStation "$targetStation"
2956
2957 # collect list of referred libraries to link with
2958 upvar $theUsedLib aUsedLibs
2959 upvar $theFrameworks aFrameworks
2960 upvar $theIncPaths anIncPaths
2961 upvar $theTKDefines aTKDefines
2962 upvar $theTKSrcFiles aTKSrcFiles
2963
c7d774c5 2964 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedLibs aFrameworks
910970ab 2965 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2966 foreach tkx $aDepToolkits {
2967 lappend aUsedLibs "${tkx}"
2968 }
2969
910970ab 2970 lappend anIncPaths "$theRelativePath/inc"
2971 set listloc [osutils:tk:units $theToolKit]
2972
2973 if { [llength $listloc] == 0 } {
2974 set listloc $theToolKit
2975 }
2976
2977 if { "$aWokStation" == "wnt" } {
2978 set resultloc [osutils:justwnt $listloc]
2979 } else {
2980 set resultloc [osutils:justunix $listloc]
2981 }
2982 if [array exists written] { unset written }
2983 foreach fxlo $resultloc {
2984 set xlo $fxlo
2985 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
2986 foreach aSrcFile [lsort $aSrcFiles] {
2987 if { ![info exists written([file tail $aSrcFile])] } {
2988 set written([file tail $aSrcFile]) 1
2989 lappend aTKSrcFiles "${theRelativePath}/[wokUtils:FILES:wtail $aSrcFile 3]"
2990 } else {
2991 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2992 }
2993 }
2994
2995 # macros for correct DLL exports
2996 if { "$aWokStation" == "wnt" } {
2997 lappend aTKDefines "__${xlo}_DLL"
2998 }
2999
3000 # common include paths
3001# lappend anIncPaths "${theRelativePath}/src/${xlo}"
3002 }
3003
c7d774c5 3004 # extra macros
910970ab 3005 lappend aTKDefines "CSFDB"
3006 if { "$aWokStation" == "wnt" } {
3007 lappend aTKDefines "WNT"
3008 lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
3009 } else {
910970ab 3010 if { "$aWokStation" == "lin" } {
3011 lappend aTKDefines "LIN"
3012 }
3013 lappend aTKDefines "OCC_CONVERT_SIGNALS"
3014 #lappend aTKDefines "_GNU_SOURCE=1"
3015 }
3016}
3017
3018# Define libraries to link using only EXTERNLIB file
3019proc LibToLinkX {thePackage theDummyName} {
3020 set aToolKits [LibToLink $thePackage]
3021 return $aToolKits
3022}
3023
c7d774c5 3024# Function to generate Xcode workspace and project files
3025proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
3026
3027 puts stderr "Generating project files for Xcode"
3028
3029 # Generate projects for toolkits and separate workspace for each module
3030 foreach aModule $theModules {
3031 OS:xcworkspace $aModule $aModule $theOutDir
3032 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
3033 }
3034
3035 # Generate single workspace "OCCT" containing projects from all modules
3036 if { "$theAllSolution" != "" } {
3037 OS:xcworkspace $theAllSolution $theModules $theOutDir
3038 }
3039}
3040
3041# Generates toolkits sections for Xcode workspace file.
3042proc OS:xcworkspace:toolkits { theModule } {
3043 set aBuff ""
3044
3045 # Adding toolkits for module in workspace.
3046 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
3047 append aBuff " <FileRef\n"
3048 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
3049 append aBuff " </FileRef>\n"
3050 }
3051
3052 # Adding executables for module, assume one project per cxx file...
3053 foreach aUnit [OS:executable ${theModule}] {
3054 set aUnitLoc $aUnit
3055 set src_files [_get_used_files $aUnit false]
3056 set aSrcFiles {}
3057 foreach s $src_files {
3058 regexp {source ([^\s]+)} $s dummy name
3059 lappend aSrcFiles $name
3060 }
3061 foreach aSrcFile $aSrcFiles {
3062 set aFileExtension [file extension $aSrcFile]
3063 if { $aFileExtension == ".cxx" } {
3064 set aPrjName [file rootname $aSrcFile]
3065 append aBuff " <FileRef\n"
3066 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
3067 append aBuff " </FileRef>\n"
3068 }
3069 }
3070 }
3071
3072 # Removing unnecessary newline character from the end.
3073 set aBuff [string replace $aBuff end end]
3074 return $aBuff
3075}
3076
3077# Generates workspace files for Xcode.
3078proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
3079 # Creating workspace directory for Xcode.
3080 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
3081 wokUtils:FILES:mkdir $aWorkspaceDir
3082 if { ! [file exists $aWorkspaceDir] } {
3083 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
3084 return
3085 }
3086
3087 # Creating workspace file.
3088 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
3089 set aFile [open $aWsFilePath "w"]
3090
3091 # Adding header and section for main Group.
3092 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
3093 puts $aFile "<Workspace"
3094 puts $aFile " version = \"1.0\">"
3095 puts $aFile " <Group"
3096 puts $aFile " location = \"container:\""
3097 puts $aFile " name = \"${theWorkspaceName}\">"
3098
3099 # Adding modules.
3100 if { [llength "$theModules"] > 1 } {
3101 foreach aModule $theModules {
3102 puts $aFile " <Group"
3103 puts $aFile " location = \"container:\""
3104 puts $aFile " name = \"${aModule}\">"
3105 puts $aFile [OS:xcworkspace:toolkits $aModule]
3106 puts $aFile " </Group>"
3107 }
3108 } else {
3109 puts $aFile [OS:xcworkspace:toolkits $theModules]
3110 }
3111
3112 # Adding footer.
3113 puts $aFile " </Group>"
3114 puts $aFile "</Workspace>"
3115 close $aFile
3116}
3117
3118# Generates Xcode project files.
3119proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
3120 upvar $theGuidsMap aGuidsMap
3121
3122 set isStatic 0
3123 if { "$theLibType" == "static" } {
3124 set isStatic 1
3125 } elseif { "$thePlatform" == "ios" } {
3126 set isStatic 1
3127 }
3128
3129 set aProjectFiles {}
3130 foreach aModule $theModules {
3131 foreach aToolKit [${aModule}:toolkits] {
3132 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
3133 }
3134 foreach anExecutable [OS:executable ${aModule}] {
3135 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
3136 }
3137 }
3138 return $aProjectFiles
3139}
3140
3141# Generates dependencies section for Xcode project files.
3142proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
3143 global path
3144 upvar $theGuidsMap aGuidsMap
3145 upvar $theFileRefSection aFileRefSection
3146 upvar $theDepsGuids aDepsGuids
3147 upvar $theDepsRefGuids aDepsRefGuids
3148
3149 set aBuildFileSection ""
3150 set aUsedToolKits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
3151 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
3152
3153 if { "$theTargetType" == "executable" } {
3154 set aFile [osutils:tk:files $theToolKit osutils:compilable 0]
3155 set aProjName [file rootname [file tail $aFile]]
3156 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
3157 }
3158
3159 set aLibExt "dylib"
3160 if { $theIsStatic == 1 } {
3161 set aLibExt "a"
3162 if { "$theTargetType" != "executable" } {
3163 return $aBuildFileSection
3164 }
3165 }
3166
3167 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
3168 set aUsedToolKits [concat $aUsedToolKits $aLibs]
3169 set aUsedToolKits [concat $aUsedToolKits $aFrameworks]
3170 foreach tkx $aUsedToolKits {
3171 set aDepLib "${tkx}_Dep"
3172 set aDepLibRef "${tkx}_DepRef"
3173
3174 if { ! [info exists aGuidsMap($aDepLib)] } {
3175 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
3176 }
3177 if { ! [info exists aGuidsMap($aDepLibRef)] } {
3178 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
3179 }
3180
3181 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
3182 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
3183 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
3184 } else {
3185 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
3186 }
3187 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
3188 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
3189 }
3190
3191 return $aBuildFileSection
3192}
3193
3194# Generates PBXBuildFile and PBXGroup sections for project file.
3195proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
3196 upvar $theSrcFileRefSection aSrcFileRefSection
3197 upvar $theGroupSection aGroupSection
3198 upvar $thePackageGuids aPackagesGuids
3199 upvar $theSrcFileGuids aSrcFileGuids
3200 upvar $theGuidsMap aGuidsMap
3201 upvar $theIncPaths anIncPaths
3202
3203 set listloc [osutils:tk:units $theToolKit]
3204 set resultloc [osutils:justunix $listloc]
3205 set aBuildFileSection ""
3206 set aPackages [lsort -nocase $resultloc]
3207 if { "$theTargetType" == "executable" } {
3208 set aPackages [list "$theToolKit"]
3209 }
3210
3211 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
3212 foreach fxlo $aPackages {
3213 set xlo $fxlo
3214 set aPackage "${xlo}_Package"
3215 set aSrcFileRefGuids ""
3216 if { ! [info exists aGuidsMap($aPackage)] } {
3217 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
3218 }
3219
3220 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
3221 foreach aSrcFile [lsort $aSrcFiles] {
3222 set aFileExt "sourcecode.cpp.cpp"
3223
3224 if { [file extension $aSrcFile] == ".c" } {
3225 set aFileExt "sourcecode.c.c"
3226 } elseif { [file extension $aSrcFile] == ".mm" } {
3227 set aFileExt "sourcecode.cpp.objcpp"
3228 }
3229
3230 if { ! [info exists aGuidsMap($aSrcFile)] } {
3231 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
3232 }
3233 set aSrcFileRef "${aSrcFile}_Ref"
3234 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
3235 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
3236 }
3237 if { ! [info exists written([file tail $aSrcFile])] } {
3238 set written([file tail $aSrcFile]) 1
3239 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
3240 append aSrcFileRefSection "\t\t$aGuidsMap($aSrcFileRef) = \{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = ${aFileExt}; name = [wokUtils:FILES:wtail $aSrcFile 1]; path = ../../../[wokUtils:FILES:wtail $aSrcFile 3]; sourceTree = \"<group>\"; \};\n"
3241 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
3242 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
3243 } else {
3244 puts "Warning : more than one occurences for [file tail $aSrcFile]"
3245 }
3246 }
3247
3248 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
3249 append aGroupSection "\t\t\tisa = PBXGroup;\n"
3250 append aGroupSection "\t\t\tchildren = (\n"
3251 append aGroupSection $aSrcFileRefGuids
3252 append aGroupSection "\t\t\t);\n"
3253 append aGroupSection "\t\t\tname = $xlo;\n"
3254 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
3255 append aGroupSection "\t\t\};\n"
3256
3257 # Storing packages IDs for adding them later as a child of toolkit
3258 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
3259 }
3260
3261 # Removing unnecessary newline character from the end.
3262 set aPackagesGuids [string replace $aPackagesGuids end end]
3263
3264 return $aBuildFileSection
3265}
3266
3267# Creates folders structure and all necessary files for Xcode project.
3268proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
3269 set aPBXBuildPhase "Headers"
3270 set aRunOnlyForDeployment "0"
3271 set aProductType "library.dynamic"
3272 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
3273 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
3274 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
3275 set aTKDefines [list "CSFDB" "OCC_CONVERT_SIGNALS"]
3276
3277 if { "$theTargetType" == "executable" } {
3278 set aPBXBuildPhase "CopyFiles"
3279 set aRunOnlyForDeployment "1"
3280 set aProductType "tool"
3281 set anExecExtension ""
3282 set anExecPrefix ""
3283 set aWrapperExtension ""
3284 } elseif { $theIsStatic == 1 } {
3285 set aProductType "library.static"
3286 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
3287 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
3288 }
3289
3290 set aUsername [exec whoami]
3291
3292 # Creation of folders for Xcode projectP.
3293 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
3294 wokUtils:FILES:mkdir $aToolkitDir
3295 if { ! [file exists $aToolkitDir] } {
3296 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
3297 return
3298 }
3299
3300 set aUserDataDir "${aToolkitDir}/xcuserdata"
3301 wokUtils:FILES:mkdir $aUserDataDir
3302 if { ! [file exists $aUserDataDir] } {
3303 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
3304 return
3305 }
3306
3307 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3308 wokUtils:FILES:mkdir $aUserDataDir
3309 if { ! [file exists $aUserDataDir] } {
3310 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
3311 return
3312 }
3313
3314 set aSchemesDir "${aUserDataDir}/xcschemes"
3315 wokUtils:FILES:mkdir $aSchemesDir
3316 if { ! [file exists $aSchemesDir] } {
3317 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3318 return
3319 }
3320 # End of folders creation.
3321
3322 # Generating GUID for tookit.
3323 upvar $theGuidsMap aGuidsMap
3324 if { ! [info exists aGuidsMap($theToolKit)] } {
3325 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
3326 }
3327
3328 # Creating xcscheme file for toolkit from template.
3329 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
3330 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
3331 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
3332 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
3333 puts $aXcschemeFile $aXcschemeTmpl
3334 close $aXcschemeFile
3335
3336 # Creating xcschememanagement.plist file for toolkit from template.
3337 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
3338 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
3339 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
3340 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3341 puts $aPlistFile $aPlistTmpl
3342 close $aPlistFile
3343
3344 # Creating project.pbxproj file for toolkit.
3345 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
3346 puts $aPbxprojFile "// !\$*UTF8*\$!"
3347 puts $aPbxprojFile "\{"
3348 puts $aPbxprojFile "\tarchiveVersion = 1;"
3349 puts $aPbxprojFile "\tclasses = \{"
3350 puts $aPbxprojFile "\t\};"
3351 puts $aPbxprojFile "\tobjectVersion = 46;"
3352 puts $aPbxprojFile "\tobjects = \{\n"
3353
3354 # Begin PBXBuildFile section
3355 set aPackagesGuids ""
3356 set aGroupSection ""
3357 set aSrcFileRefSection ""
3358 set aSrcFileGuids ""
3359 set aDepsFileRefSection ""
3360 set aDepsGuids ""
3361 set aDepsRefGuids ""
3362 set anIncPaths [list "../../../inc"]
3363 set anLibPaths ""
3364
3365 if { [info exists ::env(CSF_OPT_INC)] } {
3366 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
3367 foreach anIncCfgPath $anIncCfg {
3368 lappend anIncPaths $anIncCfgPath
3369 }
3370 }
3371 if { [info exists ::env(CSF_OPT_LIB64)] } {
3372 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
3373 foreach anLibCfgPath $anLibCfg {
3374 lappend anLibPaths $anLibCfgPath
3375 }
3376 }
3377
3378 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
3379 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
3380 # End PBXBuildFile section
3381
3382 # Begin PBXFileReference section
3383 set aToolkitLib "lib${theToolKit}.dylib"
3384 set aPath "$aToolkitLib"
3385 if { "$theTargetType" == "executable" } {
3386 set aPath "$theToolKit"
3387 } elseif { $theIsStatic == 1 } {
3388 set aToolkitLib "lib${theToolKit}.a"
3389 }
3390
3391 if { ! [info exists aGuidsMap($aToolkitLib)] } {
3392 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
3393 }
3394
3395 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
3396 puts $aPbxprojFile $aSrcFileRefSection
3397 puts $aPbxprojFile $aDepsFileRefSection
3398 # End PBXFileReference section
3399
3400
3401 # Begin PBXFrameworksBuildPhase section
3402 set aTkFrameworks "${theToolKit}_Frameworks"
3403 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
3404 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
3405 }
3406
3407 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
3408 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
3409 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3410 puts $aPbxprojFile "\t\t\tfiles = ("
3411 puts $aPbxprojFile $aDepsGuids
3412 puts $aPbxprojFile "\t\t\t);"
3413 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3414 puts $aPbxprojFile "\t\t\};\n"
3415 # End PBXFrameworksBuildPhase section
3416
3417 # Begin PBXGroup section
3418 set aTkPBXGroup "${theToolKit}_PBXGroup"
3419 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
3420 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
3421 }
3422
3423 set aTkSrcGroup "${theToolKit}_SrcGroup"
3424 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
3425 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
3426 }
3427
3428 puts $aPbxprojFile $aGroupSection
3429 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
3430 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3431 puts $aPbxprojFile "\t\t\tchildren = ("
3432 puts $aPbxprojFile $aDepsRefGuids
3433 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
3434 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
3435 puts $aPbxprojFile "\t\t\t);"
3436 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3437 puts $aPbxprojFile "\t\t\};"
3438 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
3439 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3440 puts $aPbxprojFile "\t\t\tchildren = ("
3441 puts $aPbxprojFile $aPackagesGuids
3442 puts $aPbxprojFile "\t\t\t);"
3443 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
3444 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3445 puts $aPbxprojFile "\t\t\};\n"
3446 # End PBXGroup section
3447
3448 # Begin PBXHeadersBuildPhase section
3449 set aTkHeaders "${theToolKit}_Headers"
3450 if { ! [info exists aGuidsMap($aTkHeaders)] } {
3451 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
3452 }
3453
3454 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
3455 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
3456 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3457 puts $aPbxprojFile "\t\t\tfiles = ("
3458 puts $aPbxprojFile "\t\t\t);"
3459 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
3460 puts $aPbxprojFile "\t\t\};\n"
3461 # End PBXHeadersBuildPhase section
3462
3463 # Begin PBXNativeTarget section
3464 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
3465 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
3466 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
3467 }
3468
3469 set aTkSources "${theToolKit}_Sources"
3470 if { ! [info exists aGuidsMap($aTkSources)] } {
3471 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
3472 }
3473
3474 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
3475 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
3476 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
3477 puts $aPbxprojFile "\t\t\tbuildPhases = ("
3478 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
3479 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
3480 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
3481 puts $aPbxprojFile "\t\t\t);"
3482 puts $aPbxprojFile "\t\t\tbuildRules = ("
3483 puts $aPbxprojFile "\t\t\t);"
3484 puts $aPbxprojFile "\t\t\tdependencies = ("
3485 puts $aPbxprojFile "\t\t\t);"
3486 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
3487 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
3488 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
3489 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
3490 puts $aPbxprojFile "\t\t\};\n"
3491 # End PBXNativeTarget section
3492
3493 # Begin PBXProject section
3494 set aTkProjectObj "${theToolKit}_ProjectObj"
3495 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
3496 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
3497 }
3498
3499 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
3500 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
3501 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
3502 }
3503
3504 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
3505 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
3506 puts $aPbxprojFile "\t\t\tattributes = \{"
3507 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
3508 puts $aPbxprojFile "\t\t\t\};"
3509 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
3510 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
3511 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
3512 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
3513 puts $aPbxprojFile "\t\t\tknownRegions = ("
3514 puts $aPbxprojFile "\t\t\t\ten,"
3515 puts $aPbxprojFile "\t\t\t);"
3516 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
3517 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
3518 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
3519 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
3520 puts $aPbxprojFile "\t\t\ttargets = ("
3521 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
3522 puts $aPbxprojFile "\t\t\t);"
3523 puts $aPbxprojFile "\t\t\};\n"
3524 # End PBXProject section
3525
3526 # Begin PBXSourcesBuildPhase section
3527 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
3528 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
3529 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3530 puts $aPbxprojFile "\t\t\tfiles = ("
3531 puts $aPbxprojFile $aSrcFileGuids
3532 puts $aPbxprojFile "\t\t\t);"
3533 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3534 puts $aPbxprojFile "\t\t\};\n"
3535 # End PBXSourcesBuildPhase section
3536
3537 # Begin XCBuildConfiguration section
3538 set aTkDebugProject "${theToolKit}_DebugProject"
3539 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
3540 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
3541 }
3542
3543 set aTkReleaseProject "${theToolKit}_ReleaseProject"
3544 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
3545 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
3546 }
3547
3548 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
3549 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
3550 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
3551 }
3552
3553 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
3554 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
3555 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
3556 }
3557
3558 # Debug target
3559 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
3560 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3561 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3562
3563 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
3564 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3565 if { "$thePlatform" == "ios" } {
3566 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3567 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3568 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3569 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3570 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3571 }
3572 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3573 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
3574 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
3575 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3576 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
3577 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3578 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
3579 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3580 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
3581 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
3582 puts $aPbxprojFile "\t\t\t\t);"
3583 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
3584 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3585 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3586 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3587 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3588 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3589 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
3590 if { "$thePlatform" == "ios" } {
3591 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
3592 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3593 } else {
3594 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
3595 }
3596 puts $aPbxprojFile "\t\t\t\};"
3597
3598 puts $aPbxprojFile "\t\t\tname = Debug;"
3599 puts $aPbxprojFile "\t\t\};"
3600
3601 # Release target
3602 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
3603 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3604 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3605
3606 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
3607 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3608 if { "$thePlatform" == "ios" } {
3609 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3610 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3611 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3612 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3613 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3614 }
3615 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3616 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
3617 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
3618 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3619 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3620 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
3621 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
3622 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3623 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3624 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3625 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3626 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3627 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
3628 if { "$thePlatform" == "ios" } {
3629 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
3630 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3631 }
3632 puts $aPbxprojFile "\t\t\t\};"
3633 puts $aPbxprojFile "\t\t\tname = Release;"
3634 puts $aPbxprojFile "\t\t\};"
3635 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
3636 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3637 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3638 puts $aPbxprojFile "${anExecExtension}"
3639 puts $aPbxprojFile "${anExecPrefix}"
3640 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3641 foreach aMacro $aTKDefines {
3642 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3643 }
3644 puts $aPbxprojFile "\t\t\t\t);"
3645
3646 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3647 foreach anIncPath $anIncPaths {
3648 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3649 }
3650 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3651 puts $aPbxprojFile "\t\t\t\t);"
3652
3653 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3654 foreach anLibPath $anLibPaths {
3655 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3656 }
3657 puts $aPbxprojFile "\t\t\t\t);"
3658
3659 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3660 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3661 puts $aPbxprojFile "\t\t\t\t);"
3662 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3663 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3664 puts $aPbxprojFile "\t\t\t\t);"
3665 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3666 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
3667 foreach anIncPath $anIncPaths {
3668 append anUserHeaderSearchPath " ${anIncPath}"
3669 }
3670 append anUserHeaderSearchPath "\";"
3671 puts $aPbxprojFile $anUserHeaderSearchPath
3672 puts $aPbxprojFile "${aWrapperExtension}"
3673 puts $aPbxprojFile "\t\t\t\};"
3674 puts $aPbxprojFile "\t\t\tname = Debug;"
3675 puts $aPbxprojFile "\t\t\};"
3676 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
3677 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3678 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3679 puts $aPbxprojFile "${anExecExtension}"
3680 puts $aPbxprojFile "${anExecPrefix}"
3681 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3682 foreach aMacro $aTKDefines {
3683 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3684 }
3685 puts $aPbxprojFile "\t\t\t\t);"
3686 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3687 foreach anIncPath $anIncPaths {
3688 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3689 }
3690 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3691 puts $aPbxprojFile "\t\t\t\t);"
3692
3693 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3694 foreach anLibPath $anLibPaths {
3695 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3696 }
3697 puts $aPbxprojFile "\t\t\t\t);"
3698
3699 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3700 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3701 puts $aPbxprojFile "\t\t\t\t);"
3702 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3703 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3704 puts $aPbxprojFile "\t\t\t\t);"
3705 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3706 puts $aPbxprojFile $anUserHeaderSearchPath
3707 puts $aPbxprojFile "${aWrapperExtension}"
3708 puts $aPbxprojFile "\t\t\t\};"
3709 puts $aPbxprojFile "\t\t\tname = Release;"
3710 puts $aPbxprojFile "\t\t\};\n"
3711 # End XCBuildConfiguration section
3712
3713 # Begin XCConfigurationList section
3714 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3715 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3716 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3717 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3718 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3719 puts $aPbxprojFile "\t\t\t);"
3720 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3721 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3722 puts $aPbxprojFile "\t\t\};"
3723 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3724 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3725 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3726 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3727 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3728 puts $aPbxprojFile "\t\t\t);"
3729 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3730 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3731 puts $aPbxprojFile "\t\t\};\n"
3732 # End XCConfigurationList section
3733
3734 puts $aPbxprojFile "\t\};"
3735 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3736 puts $aPbxprojFile "\}"
3737
3738 close $aPbxprojFile
3739}
3740
3741proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3742 set aUsername [exec whoami]
3743
3744 # Creating folders for Xcode project file.
3745 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3746 wokUtils:FILES:mkdir $anExecutableDir
3747 if { ! [file exists $anExecutableDir] } {
3748 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3749 return
3750 }
3751
3752 set aUserDataDir "${anExecutableDir}/xcuserdata"
3753 wokUtils:FILES:mkdir $aUserDataDir
3754 if { ! [file exists $aUserDataDir] } {
3755 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3756 return
3757 }
3758
3759 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3760 wokUtils:FILES:mkdir $aUserDataDir
3761 if { ! [file exists $aUserDataDir] } {
3762 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3763 return
3764 }
3765
3766 set aSchemesDir "${aUserDataDir}/xcschemes"
3767 wokUtils:FILES:mkdir $aSchemesDir
3768 if { ! [file exists $aSchemesDir] } {
3769 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3770 return
3771 }
3772 # End folders creation.
3773
3774 # Generating GUID for tookit.
3775 upvar $theGuidsMap aGuidsMap
3776 if { ! [info exists aGuidsMap($theExecutable)] } {
3777 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3778 }
3779
3780 # Creating xcscheme file for toolkit from template.
3781 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3782 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3783 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3784 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3785 puts $aXcschemeFile $aXcschemeTmpl
3786 close $aXcschemeFile
3787
3788 # Creating xcschememanagement.plist file for toolkit from template.
3789 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3790 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3791 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3792 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3793 puts $aPlistFile $aPlistTmpl
3794 close $aPlistFile
3795}
3796
910970ab 3797# launch generation
3798genproj {*}$::argv