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