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