0027458: Configuration, genproj.tcl - add -rpath-link option to linker in Code::Block...
[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" } {
1079 set aLibsMap(CSF_FreeImagePlus) "FreeImage FreeImagePlus"
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"
1109 set aLibsMap(CSF_winspool) "Winspool"
1110 set aLibsMap(CSF_psapi) "Psapi"
1111 set aLibsMap(CSF_d3d9) "d3d9"
1112
1113 # the naming is different on Windows
1114 set aLibsMap(CSF_TclLibs) "tcl86"
1115 set aLibsMap(CSF_TclTkLibs) "tk86"
1116
1117 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1118
1119 # tbb headers define different pragma lib depending on debug/release
1120 set aLibsMap(CSF_TBB) ""
910970ab 1121 } else {
c7d774c5 1122 if { "$theOS" == "mac" } {
1123 set aLibsMap(CSF_objc) "objc"
1124 set aFrmsMap(CSF_Appkit) "Appkit"
1125 set aFrmsMap(CSF_IOKit) "IOKit"
1126 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1127 set aFrmsMap(CSF_TclLibs) "Tcl"
7c65581d 1128 set aLibsMap(CSF_TclLibs) ""
c7d774c5 1129 set aFrmsMap(CSF_TclTkLibs) "Tk"
7c65581d 1130 set aLibsMap(CSF_TclTkLibs) ""
c7d774c5 1131 } else {
d8d01f6e 1132 if { "$theOS" == "qnx" } {
7c65581d 1133 # CSF_ThreadLibs - pthread API is part of libc on QNX
d8d01f6e 1134 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
d8d01f6e 1135 } else {
1136 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1137 set aLibsMap(CSF_OpenGlLibs) "GL"
d8d01f6e 1138 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1139 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1140 set aLibsMap(CSF_MotifLibs) "X11"
1141 }
910970ab 1142 }
910970ab 1143 }
1144}
1145
1c29294e 1146# Returns string of library dependencies for generation of Visual Studio project or make lists.
1147proc osutils:vtkCsf {{theOS ""}} {
1148 set aVtkVer "6.1"
1149
1c29294e 1150 set aPathSplitter ":"
1c29294e 1151 if {"$theOS" == "wnt"} {
1152 set aPathSplitter ";"
1c29294e 1153 }
1154
1155 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1156 foreach anIncItem $anOptIncs {
1157 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1158 set aVtkVer $aFoundVtkVer
1159 }
1160 }
1161
1162 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1163 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1164
1165 # Additional suffices for the libraries
1166 set anIdx 0
1167 foreach anItem $aLibArray {
7c65581d 1168 lset aLibArray $anIdx $anItem-$aVtkVer
1c29294e 1169 incr anIdx
1170 }
1171
1172 return [join $aLibArray " "]
1173}
1174
c7d774c5 1175# @param theLibsList - dependencies (libraries list)
1176# @param theFrameworks - dependencies (frameworks list, OS X specific)
1177proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
910970ab 1178 global path
c7d774c5 1179 upvar $theLibsList aLibsList
1180 upvar $theFrameworks aFrameworks
1181 set aLibsList [list]
1182 set aFrameworks [list]
910970ab 1183
c7d774c5 1184 osutils:csfList $theOS aLibsMap aFrmsMap
910970ab 1185
c7d774c5 1186 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1187 if [info exists aLibsMap($aCsfElem)] {
1188 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1189 if { [lsearch $aLibsList $aLib] == "-1" } {
1190 lappend aLibsList $aLib
1191 }
1192 }
910970ab 1193 }
c7d774c5 1194 if [info exists aFrmsMap($aCsfElem)] {
1195 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1196 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1197 lappend aFrameworks $aFrm
1198 }
910970ab 1199 }
1200 }
1201 }
910970ab 1202}
1203
1204# Returns liste of UD in a toolkit. tkloc is a full path wok.
1205proc osutils:tk:units { tkloc } {
1206 global path
1207 set l {}
1208 set PACKAGES "$path/src/$tkloc/PACKAGES"
1209 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1210 if {[file isdirectory "$path/src/$u"]} {
1211 lappend l $u
1212 }
1213 }
1214 if { $l == {} } {
1215 ;#puts stderr "Warning. No devunit included in $tkloc"
1216 }
1217 return $l
1218}
1219
1220proc osutils:justwnt { listloc } {
1221 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1222 set goaway [list Xdps Xw ImageUtility WOKUnix]
1223 return [osutils:juststation $goaway $listloc]
1224}
1225
1226# remove from listloc OpenCascade units indesirables on NT
1227proc osutils:juststation {goaway listloc} {
1228 global path
1229 set lret {}
1230 foreach u $listloc {
1231 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1232 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1233 lappend lret $u
1234 }
1235 }
1236 return $lret
1237}
1238
1239# intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1240# The first list is everything in the first list that wasn't in the second,
1241# the second list contains the intersection of the two lists, the third list contains everything
1242# in the second list that wasn't in the first.
1243proc osutils:intersect3 {list1 list2} {
1244 set la1(0) {} ; unset la1(0)
1245 set lai(0) {} ; unset lai(0)
1246 set la2(0) {} ; unset la2(0)
1247 foreach v $list1 {
1248 set la1($v) {}
1249 }
1250 foreach v $list2 {
1251 set la2($v) {}
1252 }
1253 foreach elem [concat $list1 $list2] {
1254 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1255 unset la1($elem)
1256 unset la2($elem)
1257 set lai($elem) {}
1258 }
1259 }
1260 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1261}
1262
1263# Prepare relative path
1264proc relativePath {thePathFrom thePathTo} {
1265 if { [file isdirectory "$thePathFrom"] == 0 } {
1266 return ""
1267 }
1268
1269 set aPathFrom [file normalize "$thePathFrom"]
1270 set aPathTo [file normalize "$thePathTo"]
1271
1272 set aCutedPathFrom "${aPathFrom}/dummy"
1273 set aRelatedDeepPath ""
1274
1275 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1276 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1277 # does aPathTo contain aCutedPathFrom?
1278 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1279 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1280 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1281 set aPathTo ".${aPathTo}"
1282 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1283 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1284 }
1285 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1286 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1287 return $aPathToAfterCut
1288 }
1289 set aRelatedDeepPath "$aRelatedDeepPath../"
1290
1291 }
1292
1293 return $thePathTo
1294}
1295
1296proc wokUtils:EASY:bs1 { s } {
1297 regsub -all {/} $s {\\} r
1298 return $r
1299}
1300
1301# Returs for a full path the liste of n last directory part
1302# n = 1 => tail
1303# n = 2 => dir/file.c
1304# n = 3 => sdir/dir/file.c
1305# etc..
1306proc wokUtils:FILES:wtail { f n } {
1307 set ll [expr [llength [set lif [file split $f]]] -$n]
1308 return [join [lrange $lif $ll end] /]
1309}
1310
1311# Generate entry for one source file in Visual Studio 10 project file
1312proc osutils:vcxproj:file { vcversion file params } {
1313 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1314 if { $params != "" } {
1315 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1316 }
1317
1318 if { $params != "" } {
1319 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1320 }
1321
1322 if { $params != "" } {
1323 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1324 }
1325
1326 if { $params != "" } {
1327 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1328 }
1329
1330 append text " </ClCompile>\n"
1331 return $text
1332}
1333
1334# Generate Visual Studio 2010 project filters file
1335proc osutils:vcxproj:filters { dir proj theFilesMap } {
1336 upvar $theFilesMap aFilesMap
1337
1338 # header
1339 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1340 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1341
1342 # list of "filters" (units)
1343 append text " <ItemGroup>\n"
1344 append text " <Filter Include=\"Source files\">\n"
1345 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1346 append text " </Filter>\n"
1347 foreach unit $aFilesMap(units) {
1348 append text " <Filter Include=\"Source files\\${unit}\">\n"
1349 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1350 append text " </Filter>\n"
1351 }
1352 append text " </ItemGroup>\n"
1353
1354 # list of files
1355 append text " <ItemGroup>\n"
1356 foreach unit $aFilesMap(units) {
1357 foreach file $aFilesMap($unit) {
1358 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1359 append text " <Filter>Source files\\${unit}</Filter>\n"
1360 append text " </ClCompile>\n"
1361 }
1362 }
1363 append text " </ItemGroup>\n"
1364
1365 # end
1366 append text "</Project>"
1367
1368 # write file
1369 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1370 fconfigure $fp -translation crlf
1371 puts $fp $text
1372 close $fp
1373
1374 return ${proj}.vcxproj.filters
1375}
1376
1377# Generate Visual Studio 2011 project filters file
1378proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1379 upvar $theFilesMap aFilesMap
1380
1381 # header
1382 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1383 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1384
1385 # list of "filters" (units)
1386 append text " <ItemGroup>\n"
1387 append text " <Filter Include=\"Source files\">\n"
1388 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1389 append text " </Filter>\n"
1390 foreach unit $aFilesMap(units) {
1391 append text " <Filter Include=\"Source files\\${unit}\">\n"
1392 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1393 append text " </Filter>\n"
1394 }
1395 append text " </ItemGroup>\n"
1396
1397 # list of files
1398 append text " <ItemGroup>\n"
1399 foreach unit $aFilesMap(units) {
1400 foreach file $aFilesMap($unit) {
1401 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1402 append text " <Filter>Source files\\${unit}</Filter>\n"
1403 append text " </ClCompile>\n"
1404 }
1405 }
1406 append text " </ItemGroup>\n"
1407
1408 append text " <ItemGroup>\n"
1409 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1410 append text " </ItemGroup>\n"
1411
1412 # end
1413 append text "</Project>"
1414
1415 # write file
1416 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1417 fconfigure $fp -translation crlf
1418 puts $fp $text
1419 close $fp
1420
1421 return ${proj}.vcxproj.filters
1422}
1423
1424# Generate RC file content for ToolKit from template
1425proc osutils:readtemplate:rc {theOutDir theToolKit} {
e31a8e52 1426 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
910970ab 1427 set aBody [wokUtils:FILES:FileToString $aLoc]
1428 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1429
1430 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1431 fconfigure $aFile -translation lf
1432 puts $aFile $aBody
1433 close $aFile
1434 return "${theOutDir}/${theToolKit}.rc"
1435}
1436
1437# Generate Visual Studio project file for ToolKit
1438proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1439 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1440
944d808c 1441 set l_compilable [osutils:compilable wnt]
910970ab 1442 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1443
1444 upvar $theGuidsMap aGuidsMap
1445 if { ! [info exists aGuidsMap($theToolKit)] } {
1446 set aGuidsMap($theToolKit) [OS:genGUID]
1447 }
1448 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1449
7c65581d 1450 set aUsedLibs [list]
910970ab 1451 foreach tkx [osutils:commonUsedTK $theToolKit] {
7c65581d 1452 lappend aUsedLibs "${tkx}.lib"
910970ab 1453 }
1454
c7d774c5 1455 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
7c65581d 1456 foreach aLibIter $aLibs {
1457 lappend aUsedLibs "${aLibIter}.lib"
1458 }
910970ab 1459
1460 # correct names of referred third-party libraries that are named with suffix
1461 # depending on VC version
7c65581d 1462 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
910970ab 1463
1464 # and put this list to project file
7c65581d 1465 #puts "$theToolKit requires $aUsedLibs"
39bff09c 1466 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
7c65581d 1467 set aUsedLibs [join $aUsedLibs {;}]
910970ab 1468 }
7c65581d 1469 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
910970ab 1470
1471 set anIncPaths "..\\..\\..\\inc"
1472 set aTKDefines ""
1473 set aFilesSection ""
1474 set aVcFilesX(units) ""
1475 set listloc [osutils:tk:units $theToolKit]
1476 set resultloc [osutils:justwnt $listloc]
1477 if [array exists written] { unset written }
1478 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1479 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1480 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1481 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1482 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1483 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1484 set fxloparam ""
1485 foreach fxlo $resultloc {
1486 set xlo $fxlo
944d808c 1487 set aSrcFiles [osutils:tk:files $xlo wnt]
910970ab 1488 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1489 if {$fxlo_cmplrs_options_cxx == ""} {
1490 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1491 }
1492 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1493 if {$fxlo_cmplrs_options_c == ""} {
1494 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1495 }
1496 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1497 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1498 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1499 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1500 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1501 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1502 set needparam ""
1503 foreach partopt $fxloparam {
1504 if {[string first "-I" $partopt] == "0"} {
1505 # this is an additional includes search path
1506 continue
1507 }
1508 set needparam "$needparam $partopt"
1509 }
1510
39bff09c 1511 # Format of projects in vc10+ is different from vc7-9
1512 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1513 foreach aSrcFile [lsort $aSrcFiles] {
1514 if { ![info exists written([file tail $aSrcFile])] } {
1515 set written([file tail $aSrcFile]) 1
1516 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1517 } else {
1518 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1519 }
1520 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1521 lappend aVcFilesX($xlo) $aSrcFile
1522 }
1523 } else {
1524 append aFilesSection "\t\t\t<Filter\n"
1525 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1526 append aFilesSection "\t\t\t\t>\n"
1527 foreach aSrcFile [lsort $aSrcFiles] {
1528 if { ![info exists written([file tail $aSrcFile])] } {
1529 set written([file tail $aSrcFile]) 1
1530 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1531 } else {
1532 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1533 }
1534 }
1535 append aFilesSection "\t\t\t</Filter>\n"
1536 }
1537
1538 # macros
1539 append aTKDefines ";__${xlo}_DLL"
1540 # common includes
1541# append anIncPaths ";..\\..\\..\\src\\${xlo}"
1542 }
1543
1544 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1545 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1546 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1547
1548 # write file
1549 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1550 fconfigure $aFile -translation crlf
1551 puts $aFile $theProjTmpl
1552 close $aFile
1553
39bff09c 1554 # write filters file for vc10+
1555 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1556 # nothing
1557 } elseif { "$theVcVer" == "vc10" } {
910970ab 1558 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
39bff09c 1559 } else {
910970ab 1560 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1561 }
1562
1563 # write resource file
1564 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1565
1566 return $aVcFiles
1567}
1568
1569# for a unit returns a map containing all its file in the current
1570# workbench
1571# local = 1 only local files
1572proc osutils:tk:loadunit { loc map } {
1573 #puts $loc
1574 upvar $map TLOC
1575 catch { unset TLOC }
1576 set lfiles [_get_used_files $loc]
1577 foreach f $lfiles {
1578 #puts "\t$f"
1579 set t [lindex $f 0]
1580 set p [lindex $f 2]
1581 if [info exists TLOC($t)] {
1582 set l $TLOC($t)
1583 lappend l $p
1584 set TLOC($t) $l
1585 } else {
1586 set TLOC($t) $p
1587 }
1588 }
1589 return
1590}
1591
1592# Returns the list of all compilable files name in a toolkit, or devunit of any type
910970ab 1593# Tfiles lists for each unit the type of file that can be compiled.
944d808c 1594proc osutils:tk:files { tkloc thePlatform } {
910970ab 1595 set Tfiles(source,nocdlpack) {source pubinclude}
1596 set Tfiles(source,toolkit) {}
1597 set Tfiles(source,executable) {source pubinclude}
1598 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1599 #puts " listloc = $listloc"
944d808c 1600
1601 set l_comp [osutils:compilable $thePlatform]
1602 set resultloc $listloc
910970ab 1603 set lret {}
1604 foreach loc $resultloc {
1605 set utyp [_get_type $loc]
1606 #puts "\"$utyp\" \"$loc\""
1607 switch $utyp {
1608 "t" { set utyp "toolkit" }
1609 "n" { set utyp "nocdlpack" }
1610 "x" { set utyp "executable" }
1611 }
1612 if [array exists map] { unset map }
1613 osutils:tk:loadunit $loc map
1614 #puts " loc = $loc === > [array names map]"
1615 set LType $Tfiles(source,${utyp})
1616 foreach typ [array names map] {
1617 if { [lsearch $LType $typ] == -1 } {
1618 unset map($typ)
1619 }
1620 }
1621 foreach type [array names map] {
1622 #puts $type
1623 foreach f $map($type) {
1624 #puts $f
1625 if { [lsearch $l_comp [file extension $f]] != -1 } {
944d808c 1626 lappend lret $f
910970ab 1627 }
1628 }
1629 }
1630 }
1631 return $lret
1632}
1633
1634# Generate Visual Studio project file for executable
1635proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
910970ab 1636 set aVcFiles {}
944d808c 1637 foreach f [osutils:tk:files $theToolKit wnt] {
910970ab 1638 if { $theProjTmpl == {} } {
1639 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1640 } else {
1641 set aProjTmpl $theProjTmpl
1642 }
1643 set aProjName [file rootname [file tail $f]]
944d808c 1644 set l_compilable [osutils:compilable wnt]
910970ab 1645 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1646
1647 upvar $theGuidsMap aGuidsMap
1648 if { ! [info exists aGuidsMap($aProjName)] } {
1649 set aGuidsMap($aProjName) [OS:genGUID]
1650 }
1651 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1652
7c65581d 1653 set aUsedLibs [list]
910970ab 1654 foreach tkx [osutils:commonUsedTK $theToolKit] {
7c65581d 1655 lappend aUsedLibs "${tkx}.lib"
910970ab 1656 }
1657
c7d774c5 1658 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
7c65581d 1659 foreach aLibIter $aLibs {
1660 lappend aUsedLibs "${aLibIter}.lib"
1661 }
910970ab 1662
1663 # correct names of referred third-party libraries that are named with suffix
1664 # depending on VC version
7c65581d 1665 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
910970ab 1666
7c65581d 1667# puts "$aProjName requires $aUsedLibs"
39bff09c 1668 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
7c65581d 1669 set aUsedLibs [join $aUsedLibs {;}]
910970ab 1670 }
7c65581d 1671 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
910970ab 1672
1673 set aFilesSection ""
1674 set aVcFilesX(units) ""
1675
1676 if { ![info exists written([file tail $f])] } {
1677 set written([file tail $f]) 1
1678
39bff09c 1679 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1680 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1681 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1682 lappend aVcFilesX($theToolKit) $f
1683 } else {
1684 append aFilesSection "\t\t\t<Filter\n"
1685 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1686 append aFilesSection "\t\t\t\t>\n"
1687 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1688 append aFilesSection "\t\t\t</Filter>"
1689 }
1690 } else {
1691 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1692 }
1693 #puts "$aProjTmpl $aFilesSection"
1694 set aTKDefines ";__${theToolKit}_DLL"
1695 set anIncPaths "..\\..\\..\\inc"
1696 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1697 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1698 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1c29294e 1699 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1700
1701 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
910970ab 1702
1703 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1704 fconfigure $aFile -translation crlf
1705 puts $aFile $aProjTmpl
1706 close $aFile
1707
1708 set aCommonSettingsFile "$aVcFilePath.user"
1709 lappend aVcFiles $aVcFilePath
1710
1711 # write filters file for vc10
39bff09c 1712 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
910970ab 1713 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1714 }
1715
1716 set aCommonSettingsFileTmpl ""
39bff09c 1717 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1718 # nothing
1719 } elseif { "$theVcVer" == "vc9" } {
e31a8e52 1720 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
39bff09c 1721 } else {
e31a8e52 1722 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
910970ab 1723 }
1724 if { "$aCommonSettingsFileTmpl" != "" } {
39bff09c 1725 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1726
1727 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1728 fconfigure $aFile -translation crlf
1729 puts $aFile $aCommonSettingsFileTmpl
1730 close $aFile
1731
910970ab 1732 lappend aVcFiles "$aCommonSettingsFile"
1733 }
1734 }
1735 return $aVcFiles
1736}
1737
1738# Generate entry for one source file in Visual Studio 7 - 9 project file
1739proc osutils:vcproj:file { theVcVer theFile theOptions } {
1740 append aText "\t\t\t\t<File\n"
1741 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1742 if { $theOptions == "" } {
1743 append aText "\t\t\t\t</File>\n"
1744 return $aText
1745 }
1746
1747 append aText "\t\t\t\t\t<FileConfiguration\n"
1748 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1749 append aText "\t\t\t\t\t\t<Tool\n"
1750 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1751 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1752 foreach aParam $theOptions {
1753 append aText "$aParam "
1754 }
1755 append aText "\"\n"
1756 append aText "\t\t\t\t\t\t/>\n"
1757 append aText "\t\t\t\t\t</FileConfiguration>\n"
1758
1759 append aText "\t\t\t\t\t<FileConfiguration\n"
1760 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1761 append aText "\t\t\t\t\t\t<Tool\n"
1762 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1763 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1764 foreach aParam $theOptions {
1765 append aText "$aParam "
1766 }
1767 append aText "\"\n"
1768 append aText "\t\t\t\t\t\t/>\n"
1769 append aText "\t\t\t\t\t</FileConfiguration>\n"
1770 if { "$theVcVer" == "vc7" } {
1771 append aText "\t\t\t\t</File>\n"
1772 return $aText
1773 }
1774
1775 append aText "\t\t\t\t\t<FileConfiguration\n"
1776 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1777 append aText "\t\t\t\t\t\t<Tool\n"
1778 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1779 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1780 foreach aParam $theOptions {
1781 append aText "$aParam "
1782 }
1783 append aText "\"\n"
1784 append aText "\t\t\t\t\t\t/>\n"
1785 append aText "\t\t\t\t\t</FileConfiguration>\n"
1786
1787 append aText "\t\t\t\t\t<FileConfiguration\n"
1788 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1789 append aText "\t\t\t\t\t\t<Tool\n"
1790 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1791 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1792 foreach aParam $theOptions {
1793 append aText "$aParam "
1794 }
1795 append aText "\"\n"
1796 append aText "\t\t\t\t\t\t/>\n"
1797 append aText "\t\t\t\t\t</FileConfiguration>\n"
1798
1799 append aText "\t\t\t\t</File>\n"
1800 return $aText
1801}
1802
910970ab 1803proc wokUtils:FILES:mkdir { d } {
1804 global tcl_version
1805 regsub -all {\.[^.]*} $tcl_version "" major
1806 if { $major == 8 } {
1807 file mkdir $d
1808 } else {
1809 if ![file exists $d] {
1810 if { "[info command mkdir]" == "mkdir" } {
1811 mkdir -path $d
1812 } else {
1813 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1814 }
1815 }
1816 }
1817 if [file exists $d] {
1818 return $d
1819 } else {
1820 return {}
1821 }
1822}
1823
910970ab 1824# remove from listloc OpenCascade units indesirables on Unix
1825proc osutils:justunix { listloc } {
c7d774c5 1826 if { "$::tcl_platform(os)" == "Darwin" } {
910970ab 1827 set goaway [list Xw WNT]
1828 } else {
1829 set goaway [list WNT]
1830 }
1831 return [osutils:juststation $goaway $listloc]
1832}
1833
910970ab 1834
1835####### CODEBLOCK ###################################################################
1836# Function to generate Code Blocks workspace and project files
944d808c 1837proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
910970ab 1838 puts stderr "Generating project files for Code Blocks"
1839
1840 # Generate projects for toolkits and separate workspace for each module
1841 foreach aModule $theModules {
7c65581d 1842 OS:cworkspace $aModule $aModule $theOutDir
944d808c 1843 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
910970ab 1844 }
1845
1846 # Generate single workspace "OCCT" containing projects from all modules
1847 if { "$theAllSolution" != "" } {
1848 OS:cworkspace $theAllSolution $theModules $theOutDir
1849 }
1850
1851 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
1852}
1853
1854# Generate Code Blocks projects
944d808c 1855proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
910970ab 1856 set aProjectFiles {}
1857 foreach aModule $theModules {
1858 foreach aToolKit [${aModule}:toolkits] {
944d808c 1859 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
910970ab 1860 }
1861 foreach anExecutable [OS:executable ${aModule}] {
944d808c 1862 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
910970ab 1863 }
1864 }
1865 return $aProjectFiles
1866}
1867
1868# Generate Code::Blocks project file for ToolKit
944d808c 1869proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
7c65581d 1870 set aUsedLibs [list]
910970ab 1871 set aFrameworks [list]
1872 set anIncPaths [list]
1873 set aTKDefines [list]
1874 set aTKSrcFiles [list]
1875
7c65581d 1876 # collect list of referred libraries to link with
944d808c 1877 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
7c65581d 1878 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
1879 foreach tkx $aDepToolkits {
1880 lappend aUsedLibs "${tkx}"
1881 }
1882
1883 lappend anIncPaths "../../../inc"
1884 set listloc [osutils:tk:units $theToolKit]
1885
1886 if { [llength $listloc] == 0 } {
1887 set listloc $theToolKit
1888 }
1889
944d808c 1890 if { $thePlatform == "wnt" } {
7c65581d 1891 set resultloc [osutils:justwnt $listloc]
1892 } else {
1893 set resultloc [osutils:justunix $listloc]
1894 }
1895 if [array exists written] { unset written }
1896 foreach fxlo $resultloc {
1897 set xlo $fxlo
944d808c 1898 set aSrcFiles [osutils:tk:files $xlo $thePlatform]
7c65581d 1899 foreach aSrcFile [lsort $aSrcFiles] {
1900 if { ![info exists written([file tail $aSrcFile])] } {
1901 set written([file tail $aSrcFile]) 1
1902 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
1903 } else {
1904 puts "Warning : more than one occurences for [file tail $aSrcFile]"
1905 }
1906 }
1907
1908 # macros for correct DLL exports
944d808c 1909 if { $thePlatform == "wnt" } {
7c65581d 1910 lappend aTKDefines "__${xlo}_DLL"
1911 }
1912 }
910970ab 1913
944d808c 1914 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
910970ab 1915}
1916
1917# Generates Code Blocks workspace.
1918proc OS:cworkspace { theSolName theModules theOutDir } {
1919 global path
1920 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
1921 set aFile [open $aWsFilePath "w"]
1922 set isActiveSet 0
1923 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
1924 puts $aFile "<CodeBlocks_workspace_file>"
1925 puts $aFile "\t<Workspace title=\"${theSolName}\">"
1926
1927 # collect list of projects to be created
1928 foreach aModule $theModules {
1929 # toolkits
1930 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1931 set aDependencies [LibToLink $aToolKit]
1932 if { [llength $aDependencies] == 0 } {
1933 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
1934 } else {
1935 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
1936 foreach aDepTk $aDependencies {
1937 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1938 }
1939 puts $aFile "\t\t</Project>"
1940 }
1941 }
1942
1943 # executables, assume one project per cxx file...
1944 foreach aUnit [OS:executable ${aModule}] {
1945 set aUnitLoc $aUnit
1946 set src_files [_get_used_files $aUnit false]
1947 set aSrcFiles {}
1948 foreach s $src_files {
1949 regexp {source ([^\s]+)} $s dummy name
1950 lappend aSrcFiles $name
1951 }
1952 foreach aSrcFile $aSrcFiles {
1953 set aFileExtension [file extension $aSrcFile]
1954 if { $aFileExtension == ".cxx" } {
1955 set aPrjName [file rootname $aSrcFile]
1956 set aDependencies [list]
1957 if {[file isdirectory $path/src/$aUnitLoc]} {
1958 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1959 }
1960 set anActiveState ""
1961 if { $isActiveSet == 0 } {
1962 set anActiveState " active=\"1\""
1963 set isActiveSet 1
1964 }
1965 if { [llength $aDependencies] == 0 } {
1966 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
1967 } else {
1968 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
1969 foreach aDepTk $aDependencies {
1970 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1971 }
1972 puts $aFile "\t\t</Project>"
1973 }
1974 }
1975 }
1976 }
1977 }
1978
1979 puts $aFile "\t</Workspace>"
1980 puts $aFile "</CodeBlocks_workspace_file>"
1981 close $aFile
1982
1983 return $aWsFilePath
1984}
1985
1986# Generate Code::Blocks project file for Executable
944d808c 1987proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
1988 global path
910970ab 1989 set aWokArch "$::env(ARCH)"
1990
1991 set aCbpFiles {}
944d808c 1992 foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
910970ab 1993 # collect list of referred libraries to link with
7c65581d 1994 set aUsedLibs [list]
910970ab 1995 set aFrameworks [list]
1996 set anIncPaths [list]
1997 set aTKDefines [list]
1998 set aTKSrcFiles [list]
1999 set aProjName [file rootname [file tail $aSrcFile]]
2000
944d808c 2001 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
7c65581d 2002
910970ab 2003 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2004 foreach tkx $aDepToolkits {
2005 if {[_get_type $tkx] == "t"} {
7c65581d 2006 lappend aUsedLibs "${tkx}"
910970ab 2007 }
2008 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
7c65581d 2009 lappend aUsedLibs "${tkx}"
910970ab 2010 }
2011 }
2012
910970ab 2013 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2014 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2015 set isExecutable "false"
2016 } else {
2017 set isExecutable "true"
2018 }
2019
2020 if { ![info exists written([file tail $aSrcFile])] } {
2021 set written([file tail $aSrcFile]) 1
7c65581d 2022 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
910970ab 2023 } else {
2024 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2025 }
2026
2027 # macros for correct DLL exports
944d808c 2028 if { $thePlatform == "wnt" } {
910970ab 2029 lappend aTKDefines "__${theToolKit}_DLL"
2030 }
2031
2032 # common include paths
2033 lappend anIncPaths "../../../inc"
2034
944d808c 2035 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
910970ab 2036 }
2037
2038 return $aCbpFiles
2039}
2040
910970ab 2041# This function intended to generate Code::Blocks project file
7c65581d 2042# @param theCmpl - the compiler (gcc or msvc)
910970ab 2043# @param theOutDir - output directory to place project file
2044# @param theProjName - project name
2045# @param theSrcFiles - list of source files
2046# @param theLibsList - dependencies (libraries list)
2047# @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2048# @param theIncPaths - header search paths
2049# @param theDefines - compiler macro definitions
2050# @param theIsExe - flag to indicate executable / library target
944d808c 2051proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2052 set aWokStation $thePlatform
910970ab 2053 set aWokArch "$::env(ARCH)"
2054
7c65581d 2055 set aCmplCbp "gcc"
2056 set aCmplFlags [list]
2057 set aCmplFlagsRelease [list]
2058 set aCmplFlagsDebug [list]
2059 set toPassArgsByFile 0
2060 set aLibPrefix "lib"
2061 if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
2062 set toPassArgsByFile 1
2063 }
2064 if { "$theCmpl" == "msvc" } {
2065 set aCmplCbp "msvc8"
2066 set aLibPrefix ""
2067 }
2068
2069 if { "$theCmpl" == "msvc" } {
2070 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2071 set aCmplFlagsRelease "-MD -O2"
2072 set aCmplFlagsDebug "-MDd -Od -Zi"
2073 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2074 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2075 } elseif { "$theCmpl" == "gcc" } {
2076 if { "$aWokStation" != "qnx" } {
2077 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2078 }
2079 set aCmplFlagsRelease "-O2"
2080 set aCmplFlagsDebug "-O0 -g"
2081 if { "$aWokStation" == "wnt" } {
2082 lappend aCmplFlags "-std=gnu++0x"
2083 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2084 } else {
2085 lappend aCmplFlags "-std=c++0x"
2086 lappend aCmplFlags "-fPIC"
2087 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2088 }
2089 lappend aCmplFlags "-Wall"
2090 lappend aCmplFlags "-fexceptions"
2091 }
2092 lappend aCmplFlagsRelease "-DNDEBUG"
2093 lappend aCmplFlagsRelease "-DNo_Exception"
2094 lappend aCmplFlagsDebug "-D_DEBUG"
2095 if { "$aWokStation" == "qnx" } {
2096 lappend aCmplFlags "-D_QNX_SOURCE"
2097 }
2098
2099 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2100 set aLnkFileName "${theProjName}_obj.link"
2101 set aLnkDebFileName "${theProjName}_objd.link"
2102 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2103 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
910970ab 2104 set aFile [open $aCbpFilePath "w"]
2105 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2106 puts $aFile "<CodeBlocks_project_file>"
2107 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2108 puts $aFile "\t<Project>"
2109 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2110 puts $aFile "\t\t<Option pch_mode=\"2\" />"
7c65581d 2111 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
910970ab 2112 puts $aFile "\t\t<Build>"
2113
2114 # Release target configuration
2115 puts $aFile "\t\t\t<Target title=\"Release\">"
2116 if { "$theIsExe" == "true" } {
d8d01f6e 2117 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
910970ab 2118 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2119 } else {
2120 if { "$aWokStation" == "wnt" } {
7c65581d 2121 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 2122 } else {
d8d01f6e 2123 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
910970ab 2124 }
2125 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2126 }
2127 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
7c65581d 2128 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2129 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
910970ab 2130 if { "$aWokStation" == "wnt" } {
7c65581d 2131 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
910970ab 2132 } else {
7c65581d 2133 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
910970ab 2134 }
910970ab 2135
2136 # compiler options per TARGET (including defines)
2137 puts $aFile "\t\t\t\t<Compiler>"
7c65581d 2138 foreach aFlagIter $aCmplFlagsRelease {
2139 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
910970ab 2140 }
2141 foreach aMacro $theDefines {
2142 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2143 }
910970ab 2144 puts $aFile "\t\t\t\t</Compiler>"
2145
2146 puts $aFile "\t\t\t\t<Linker>"
7c65581d 2147 if { $toPassArgsByFile == 1 } {
2148 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2149 }
910970ab 2150 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
7c65581d 2151 if { "$aWokStation" == "mac" } {
2152 if { [ lsearch $theLibsList X11 ] >= 0} {
2153 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2154 }
910970ab 2155 }
2156 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
55fb31da 2157 if { "$aWokStation" == "lin" } {
2158 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/lib\" />"
2159 }
910970ab 2160 puts $aFile "\t\t\t\t</Linker>"
2161
2162 puts $aFile "\t\t\t</Target>"
2163
2164 # Debug target configuration
2165 puts $aFile "\t\t\t<Target title=\"Debug\">"
2166 if { "$theIsExe" == "true" } {
d8d01f6e 2167 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
910970ab 2168 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2169 } else {
2170 if { "$aWokStation" == "wnt" } {
7c65581d 2171 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 2172 } else {
d8d01f6e 2173 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
910970ab 2174 }
2175 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2176 }
2177 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
7c65581d 2178 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2179 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
910970ab 2180 if { "$aWokStation" == "wnt" } {
7c65581d 2181 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
910970ab 2182 } else {
7c65581d 2183 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
910970ab 2184 }
910970ab 2185
2186 # compiler options per TARGET (including defines)
2187 puts $aFile "\t\t\t\t<Compiler>"
7c65581d 2188 foreach aFlagIter $aCmplFlagsDebug {
2189 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
910970ab 2190 }
2191 foreach aMacro $theDefines {
2192 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2193 }
910970ab 2194 puts $aFile "\t\t\t\t</Compiler>"
2195
2196 puts $aFile "\t\t\t\t<Linker>"
7c65581d 2197 if { $toPassArgsByFile == 1 } {
2198 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2199 }
910970ab 2200 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
7c65581d 2201 if { "$aWokStation" == "mac" } {
2202 if { [ lsearch $theLibsList X11 ] >= 0} {
2203 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2204 }
910970ab 2205 }
2206 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
55fb31da 2207 if { "$aWokStation" == "lin" } {
2208 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/libd\" />"
2209 }
910970ab 2210 puts $aFile "\t\t\t\t</Linker>"
2211
2212 puts $aFile "\t\t\t</Target>"
2213
2214 puts $aFile "\t\t</Build>"
2215
2216 # COMMON compiler options
2217 puts $aFile "\t\t<Compiler>"
7c65581d 2218 foreach aFlagIter $aCmplFlags {
2219 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2220 }
910970ab 2221 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2222 foreach anIncPath $theIncPaths {
2223 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2224 }
2225 puts $aFile "\t\t</Compiler>"
2226
2227 # COMMON linker options
2228 puts $aFile "\t\t<Linker>"
7c65581d 2229 if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
2230 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2231 }
910970ab 2232 foreach aFrameworkName $theFrameworks {
2233 if { "$aFrameworkName" != "" } {
2234 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2235 }
2236 }
2237 foreach aLibName $theLibsList {
2238 if { "$aLibName" != "" } {
7c65581d 2239 if { "$theCmpl" == "msvc" } {
2240 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2241 } else {
2242 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2243 }
910970ab 2244 }
2245 }
2246 puts $aFile "\t\t</Linker>"
2247
2248 # list of sources
7c65581d 2249
2250 set aFileLnkObj ""
2251 set aFileLnkObjd ""
2252 set isFirstSrcFile 1
2253 if { $toPassArgsByFile == 1 } {
2254 set aFileLnkObj [open $aLnkFilePath "w"]
2255 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2256 }
2257
910970ab 2258 foreach aSrcFile $theSrcFiles {
2259 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2260 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2261 puts $aFile "\t\t\t<Option compile=\"1\" />"
2262 puts $aFile "\t\t\t<Option link=\"1\" />"
2263 puts $aFile "\t\t</Unit>"
2264 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2265 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2266 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2267 puts $aFile "\t\t</Unit>"
7c65581d 2268 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2269 # pass at list single source file to Code::Blocks as is
2270 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2271 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2272 puts $aFile "\t\t\t<Option link=\"0\" />"
2273 puts $aFile "\t\t</Unit>"
2274
2275 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"] $aSrcFile]]
2276 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
2277 puts -nonewline $aFileLnkObj "$aFileObj "
2278 puts -nonewline $aFileLnkObjd "$aFileObjd "
910970ab 2279 } else {
2280 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
7c65581d 2281 set isFirstSrcFile 0
910970ab 2282 }
2283 }
2284
7c65581d 2285 if { "$aWokStation" == "wnt" } {
2286 close $aFileLnkObj
2287 close $aFileLnkObjd
2288 }
2289
910970ab 2290 puts $aFile "\t</Project>"
2291 puts $aFile "</CodeBlocks_project_file>"
2292 close $aFile
2293
2294 return $aCbpFilePath
2295}
2296
910970ab 2297# Define libraries to link using only EXTERNLIB file
2298proc LibToLinkX {thePackage theDummyName} {
2299 set aToolKits [LibToLink $thePackage]
2300 return $aToolKits
2301}
2302
c7d774c5 2303# Function to generate Xcode workspace and project files
2304proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2305
2306 puts stderr "Generating project files for Xcode"
2307
2308 # Generate projects for toolkits and separate workspace for each module
2309 foreach aModule $theModules {
2310 OS:xcworkspace $aModule $aModule $theOutDir
2311 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2312 }
2313
2314 # Generate single workspace "OCCT" containing projects from all modules
2315 if { "$theAllSolution" != "" } {
2316 OS:xcworkspace $theAllSolution $theModules $theOutDir
2317 }
2318}
2319
2320# Generates toolkits sections for Xcode workspace file.
2321proc OS:xcworkspace:toolkits { theModule } {
2322 set aBuff ""
2323
2324 # Adding toolkits for module in workspace.
2325 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2326 append aBuff " <FileRef\n"
2327 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2328 append aBuff " </FileRef>\n"
2329 }
2330
2331 # Adding executables for module, assume one project per cxx file...
2332 foreach aUnit [OS:executable ${theModule}] {
2333 set aUnitLoc $aUnit
2334 set src_files [_get_used_files $aUnit false]
2335 set aSrcFiles {}
2336 foreach s $src_files {
2337 regexp {source ([^\s]+)} $s dummy name
2338 lappend aSrcFiles $name
2339 }
2340 foreach aSrcFile $aSrcFiles {
2341 set aFileExtension [file extension $aSrcFile]
2342 if { $aFileExtension == ".cxx" } {
2343 set aPrjName [file rootname $aSrcFile]
2344 append aBuff " <FileRef\n"
2345 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2346 append aBuff " </FileRef>\n"
2347 }
2348 }
2349 }
2350
2351 # Removing unnecessary newline character from the end.
2352 set aBuff [string replace $aBuff end end]
2353 return $aBuff
2354}
2355
2356# Generates workspace files for Xcode.
2357proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2358 # Creating workspace directory for Xcode.
2359 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2360 wokUtils:FILES:mkdir $aWorkspaceDir
2361 if { ! [file exists $aWorkspaceDir] } {
2362 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2363 return
2364 }
2365
2366 # Creating workspace file.
2367 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2368 set aFile [open $aWsFilePath "w"]
2369
2370 # Adding header and section for main Group.
2371 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2372 puts $aFile "<Workspace"
2373 puts $aFile " version = \"1.0\">"
2374 puts $aFile " <Group"
2375 puts $aFile " location = \"container:\""
2376 puts $aFile " name = \"${theWorkspaceName}\">"
2377
2378 # Adding modules.
2379 if { [llength "$theModules"] > 1 } {
2380 foreach aModule $theModules {
2381 puts $aFile " <Group"
2382 puts $aFile " location = \"container:\""
2383 puts $aFile " name = \"${aModule}\">"
2384 puts $aFile [OS:xcworkspace:toolkits $aModule]
2385 puts $aFile " </Group>"
2386 }
2387 } else {
2388 puts $aFile [OS:xcworkspace:toolkits $theModules]
2389 }
2390
2391 # Adding footer.
2392 puts $aFile " </Group>"
2393 puts $aFile "</Workspace>"
2394 close $aFile
2395}
2396
2397# Generates Xcode project files.
2398proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2399 upvar $theGuidsMap aGuidsMap
2400
2401 set isStatic 0
2402 if { "$theLibType" == "static" } {
2403 set isStatic 1
2404 } elseif { "$thePlatform" == "ios" } {
2405 set isStatic 1
2406 }
2407
2408 set aProjectFiles {}
2409 foreach aModule $theModules {
2410 foreach aToolKit [${aModule}:toolkits] {
2411 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2412 }
2413 foreach anExecutable [OS:executable ${aModule}] {
2414 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2415 }
2416 }
2417 return $aProjectFiles
2418}
2419
2420# Generates dependencies section for Xcode project files.
2421proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
c7d774c5 2422 upvar $theGuidsMap aGuidsMap
2423 upvar $theFileRefSection aFileRefSection
2424 upvar $theDepsGuids aDepsGuids
2425 upvar $theDepsRefGuids aDepsRefGuids
2426
2427 set aBuildFileSection ""
7c65581d 2428 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
c7d774c5 2429 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2430
2431 if { "$theTargetType" == "executable" } {
944d808c 2432 set aFile [osutils:tk:files $theToolKit mac]
c7d774c5 2433 set aProjName [file rootname [file tail $aFile]]
2434 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2435 }
2436
2437 set aLibExt "dylib"
2438 if { $theIsStatic == 1 } {
2439 set aLibExt "a"
2440 if { "$theTargetType" != "executable" } {
2441 return $aBuildFileSection
2442 }
2443 }
2444
2445 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
7c65581d 2446 set aUsedLibs [concat $aUsedLibs $aLibs]
2447 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2448 foreach tkx $aUsedLibs {
c7d774c5 2449 set aDepLib "${tkx}_Dep"
2450 set aDepLibRef "${tkx}_DepRef"
2451
2452 if { ! [info exists aGuidsMap($aDepLib)] } {
2453 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2454 }
2455 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2456 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2457 }
2458
2459 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2460 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2461 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2462 } else {
2463 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2464 }
2465 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2466 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2467 }
2468
2469 return $aBuildFileSection
2470}
2471
2472# Generates PBXBuildFile and PBXGroup sections for project file.
2473proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2474 upvar $theSrcFileRefSection aSrcFileRefSection
2475 upvar $theGroupSection aGroupSection
2476 upvar $thePackageGuids aPackagesGuids
2477 upvar $theSrcFileGuids aSrcFileGuids
2478 upvar $theGuidsMap aGuidsMap
2479 upvar $theIncPaths anIncPaths
2480
2481 set listloc [osutils:tk:units $theToolKit]
2482 set resultloc [osutils:justunix $listloc]
2483 set aBuildFileSection ""
2484 set aPackages [lsort -nocase $resultloc]
2485 if { "$theTargetType" == "executable" } {
2486 set aPackages [list "$theToolKit"]
2487 }
2488
2489 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2490 foreach fxlo $aPackages {
2491 set xlo $fxlo
2492 set aPackage "${xlo}_Package"
2493 set aSrcFileRefGuids ""
2494 if { ! [info exists aGuidsMap($aPackage)] } {
2495 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2496 }
2497
944d808c 2498 set aSrcFiles [osutils:tk:files $xlo mac]
c7d774c5 2499 foreach aSrcFile [lsort $aSrcFiles] {
2500 set aFileExt "sourcecode.cpp.cpp"
2501
2502 if { [file extension $aSrcFile] == ".c" } {
2503 set aFileExt "sourcecode.c.c"
2504 } elseif { [file extension $aSrcFile] == ".mm" } {
2505 set aFileExt "sourcecode.cpp.objcpp"
2506 }
2507
2508 if { ! [info exists aGuidsMap($aSrcFile)] } {
2509 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2510 }
2511 set aSrcFileRef "${aSrcFile}_Ref"
2512 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2513 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2514 }
2515 if { ! [info exists written([file tail $aSrcFile])] } {
2516 set written([file tail $aSrcFile]) 1
2517 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2518 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"
2519 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2520 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2521 } else {
2522 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2523 }
2524 }
2525
2526 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2527 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2528 append aGroupSection "\t\t\tchildren = (\n"
2529 append aGroupSection $aSrcFileRefGuids
2530 append aGroupSection "\t\t\t);\n"
2531 append aGroupSection "\t\t\tname = $xlo;\n"
2532 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2533 append aGroupSection "\t\t\};\n"
2534
2535 # Storing packages IDs for adding them later as a child of toolkit
2536 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2537 }
2538
2539 # Removing unnecessary newline character from the end.
2540 set aPackagesGuids [string replace $aPackagesGuids end end]
2541
2542 return $aBuildFileSection
2543}
2544
2545# Creates folders structure and all necessary files for Xcode project.
2546proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2547 set aPBXBuildPhase "Headers"
2548 set aRunOnlyForDeployment "0"
2549 set aProductType "library.dynamic"
2550 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2551 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2552 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
050c18ac 2553 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
c7d774c5 2554
2555 if { "$theTargetType" == "executable" } {
2556 set aPBXBuildPhase "CopyFiles"
2557 set aRunOnlyForDeployment "1"
2558 set aProductType "tool"
2559 set anExecExtension ""
2560 set anExecPrefix ""
2561 set aWrapperExtension ""
2562 } elseif { $theIsStatic == 1 } {
2563 set aProductType "library.static"
2564 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2565 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2566 }
2567
2568 set aUsername [exec whoami]
2569
2570 # Creation of folders for Xcode projectP.
2571 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2572 wokUtils:FILES:mkdir $aToolkitDir
2573 if { ! [file exists $aToolkitDir] } {
2574 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2575 return
2576 }
2577
2578 set aUserDataDir "${aToolkitDir}/xcuserdata"
2579 wokUtils:FILES:mkdir $aUserDataDir
2580 if { ! [file exists $aUserDataDir] } {
2581 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2582 return
2583 }
2584
2585 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2586 wokUtils:FILES:mkdir $aUserDataDir
2587 if { ! [file exists $aUserDataDir] } {
2588 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2589 return
2590 }
2591
2592 set aSchemesDir "${aUserDataDir}/xcschemes"
2593 wokUtils:FILES:mkdir $aSchemesDir
2594 if { ! [file exists $aSchemesDir] } {
2595 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2596 return
2597 }
2598 # End of folders creation.
2599
2600 # Generating GUID for tookit.
2601 upvar $theGuidsMap aGuidsMap
2602 if { ! [info exists aGuidsMap($theToolKit)] } {
2603 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2604 }
2605
2606 # Creating xcscheme file for toolkit from template.
2607 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2608 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2609 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2610 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2611 puts $aXcschemeFile $aXcschemeTmpl
2612 close $aXcschemeFile
2613
2614 # Creating xcschememanagement.plist file for toolkit from template.
2615 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2616 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2617 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2618 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2619 puts $aPlistFile $aPlistTmpl
2620 close $aPlistFile
2621
2622 # Creating project.pbxproj file for toolkit.
2623 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2624 puts $aPbxprojFile "// !\$*UTF8*\$!"
2625 puts $aPbxprojFile "\{"
2626 puts $aPbxprojFile "\tarchiveVersion = 1;"
2627 puts $aPbxprojFile "\tclasses = \{"
2628 puts $aPbxprojFile "\t\};"
2629 puts $aPbxprojFile "\tobjectVersion = 46;"
2630 puts $aPbxprojFile "\tobjects = \{\n"
2631
2632 # Begin PBXBuildFile section
2633 set aPackagesGuids ""
2634 set aGroupSection ""
2635 set aSrcFileRefSection ""
2636 set aSrcFileGuids ""
2637 set aDepsFileRefSection ""
2638 set aDepsGuids ""
2639 set aDepsRefGuids ""
2640 set anIncPaths [list "../../../inc"]
2641 set anLibPaths ""
2642
2643 if { [info exists ::env(CSF_OPT_INC)] } {
2644 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2645 foreach anIncCfgPath $anIncCfg {
2646 lappend anIncPaths $anIncCfgPath
2647 }
2648 }
2649 if { [info exists ::env(CSF_OPT_LIB64)] } {
2650 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2651 foreach anLibCfgPath $anLibCfg {
2652 lappend anLibPaths $anLibCfgPath
2653 }
2654 }
2655
2656 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2657 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2658 # End PBXBuildFile section
2659
2660 # Begin PBXFileReference section
2661 set aToolkitLib "lib${theToolKit}.dylib"
2662 set aPath "$aToolkitLib"
2663 if { "$theTargetType" == "executable" } {
2664 set aPath "$theToolKit"
2665 } elseif { $theIsStatic == 1 } {
2666 set aToolkitLib "lib${theToolKit}.a"
2667 }
2668
2669 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2670 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2671 }
2672
2673 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2674 puts $aPbxprojFile $aSrcFileRefSection
2675 puts $aPbxprojFile $aDepsFileRefSection
2676 # End PBXFileReference section
2677
2678
2679 # Begin PBXFrameworksBuildPhase section
2680 set aTkFrameworks "${theToolKit}_Frameworks"
2681 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2682 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2683 }
2684
2685 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2686 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2687 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2688 puts $aPbxprojFile "\t\t\tfiles = ("
2689 puts $aPbxprojFile $aDepsGuids
2690 puts $aPbxprojFile "\t\t\t);"
2691 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2692 puts $aPbxprojFile "\t\t\};\n"
2693 # End PBXFrameworksBuildPhase section
2694
2695 # Begin PBXGroup section
2696 set aTkPBXGroup "${theToolKit}_PBXGroup"
2697 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2698 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2699 }
2700
2701 set aTkSrcGroup "${theToolKit}_SrcGroup"
2702 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2703 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2704 }
2705
2706 puts $aPbxprojFile $aGroupSection
2707 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2708 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2709 puts $aPbxprojFile "\t\t\tchildren = ("
2710 puts $aPbxprojFile $aDepsRefGuids
2711 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2712 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2713 puts $aPbxprojFile "\t\t\t);"
2714 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2715 puts $aPbxprojFile "\t\t\};"
2716 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2717 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2718 puts $aPbxprojFile "\t\t\tchildren = ("
2719 puts $aPbxprojFile $aPackagesGuids
2720 puts $aPbxprojFile "\t\t\t);"
2721 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2722 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2723 puts $aPbxprojFile "\t\t\};\n"
2724 # End PBXGroup section
2725
2726 # Begin PBXHeadersBuildPhase section
2727 set aTkHeaders "${theToolKit}_Headers"
2728 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2729 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2730 }
2731
2732 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2733 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2734 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2735 puts $aPbxprojFile "\t\t\tfiles = ("
2736 puts $aPbxprojFile "\t\t\t);"
2737 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2738 puts $aPbxprojFile "\t\t\};\n"
2739 # End PBXHeadersBuildPhase section
2740
2741 # Begin PBXNativeTarget section
2742 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2743 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2744 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2745 }
2746
2747 set aTkSources "${theToolKit}_Sources"
2748 if { ! [info exists aGuidsMap($aTkSources)] } {
2749 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2750 }
2751
2752 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2753 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2754 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2755 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2756 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2757 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2758 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2759 puts $aPbxprojFile "\t\t\t);"
2760 puts $aPbxprojFile "\t\t\tbuildRules = ("
2761 puts $aPbxprojFile "\t\t\t);"
2762 puts $aPbxprojFile "\t\t\tdependencies = ("
2763 puts $aPbxprojFile "\t\t\t);"
2764 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
2765 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
2766 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
2767 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
2768 puts $aPbxprojFile "\t\t\};\n"
2769 # End PBXNativeTarget section
2770
2771 # Begin PBXProject section
2772 set aTkProjectObj "${theToolKit}_ProjectObj"
2773 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
2774 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
2775 }
2776
2777 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
2778 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
2779 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
2780 }
2781
2782 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
2783 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
2784 puts $aPbxprojFile "\t\t\tattributes = \{"
2785 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
2786 puts $aPbxprojFile "\t\t\t\};"
2787 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
2788 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
2789 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
2790 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
2791 puts $aPbxprojFile "\t\t\tknownRegions = ("
2792 puts $aPbxprojFile "\t\t\t\ten,"
2793 puts $aPbxprojFile "\t\t\t);"
2794 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
2795 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
2796 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
2797 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
2798 puts $aPbxprojFile "\t\t\ttargets = ("
2799 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
2800 puts $aPbxprojFile "\t\t\t);"
2801 puts $aPbxprojFile "\t\t\};\n"
2802 # End PBXProject section
2803
2804 # Begin PBXSourcesBuildPhase section
2805 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
2806 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
2807 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2808 puts $aPbxprojFile "\t\t\tfiles = ("
2809 puts $aPbxprojFile $aSrcFileGuids
2810 puts $aPbxprojFile "\t\t\t);"
2811 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2812 puts $aPbxprojFile "\t\t\};\n"
2813 # End PBXSourcesBuildPhase section
2814
2815 # Begin XCBuildConfiguration section
2816 set aTkDebugProject "${theToolKit}_DebugProject"
2817 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
2818 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
2819 }
2820
2821 set aTkReleaseProject "${theToolKit}_ReleaseProject"
2822 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
2823 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
2824 }
2825
2826 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
2827 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
2828 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
2829 }
2830
2831 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
2832 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
2833 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
2834 }
2835
2836 # Debug target
2837 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
2838 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2839 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2840
2841 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
2842 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2843 if { "$thePlatform" == "ios" } {
2844 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2845 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2846 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2847 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2848 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2849 }
2850 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2851 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2852 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
2853 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2854 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
2855 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2856 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
2857 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2858 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
2859 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
2860 puts $aPbxprojFile "\t\t\t\t);"
2861 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
2862 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2863 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2864 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2865 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2866 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2867 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
2868 if { "$thePlatform" == "ios" } {
2869 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
2870 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2871 } else {
2872 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
2873 }
2874 puts $aPbxprojFile "\t\t\t\};"
2875
2876 puts $aPbxprojFile "\t\t\tname = Debug;"
2877 puts $aPbxprojFile "\t\t\};"
2878
2879 # Release target
2880 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
2881 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2882 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2883
2884 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
2885 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2886 if { "$thePlatform" == "ios" } {
2887 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2888 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2889 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2890 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2891 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2892 }
2893 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2894 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2895 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
2896 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2897 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2898 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
2899 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
2900 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2901 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2902 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2903 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2904 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2905 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
2906 if { "$thePlatform" == "ios" } {
2907 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
2908 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2909 }
2910 puts $aPbxprojFile "\t\t\t\};"
2911 puts $aPbxprojFile "\t\t\tname = Release;"
2912 puts $aPbxprojFile "\t\t\};"
2913 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
2914 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2915 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2916 puts $aPbxprojFile "${anExecExtension}"
2917 puts $aPbxprojFile "${anExecPrefix}"
2918 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2919 foreach aMacro $aTKDefines {
2920 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2921 }
2922 puts $aPbxprojFile "\t\t\t\t);"
2923
2924 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2925 foreach anIncPath $anIncPaths {
2926 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2927 }
2928 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2929 puts $aPbxprojFile "\t\t\t\t);"
2930
2931 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2932 foreach anLibPath $anLibPaths {
2933 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2934 }
2935 puts $aPbxprojFile "\t\t\t\t);"
2936
2937 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2938 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2939 puts $aPbxprojFile "\t\t\t\t);"
2940 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2941 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2942 puts $aPbxprojFile "\t\t\t\t);"
2943 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2944 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
2945 foreach anIncPath $anIncPaths {
2946 append anUserHeaderSearchPath " ${anIncPath}"
2947 }
2948 append anUserHeaderSearchPath "\";"
2949 puts $aPbxprojFile $anUserHeaderSearchPath
2950 puts $aPbxprojFile "${aWrapperExtension}"
2951 puts $aPbxprojFile "\t\t\t\};"
2952 puts $aPbxprojFile "\t\t\tname = Debug;"
2953 puts $aPbxprojFile "\t\t\};"
2954 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
2955 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2956 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2957 puts $aPbxprojFile "${anExecExtension}"
2958 puts $aPbxprojFile "${anExecPrefix}"
2959 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2960 foreach aMacro $aTKDefines {
2961 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2962 }
2963 puts $aPbxprojFile "\t\t\t\t);"
2964 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2965 foreach anIncPath $anIncPaths {
2966 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2967 }
2968 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2969 puts $aPbxprojFile "\t\t\t\t);"
2970
2971 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2972 foreach anLibPath $anLibPaths {
2973 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2974 }
2975 puts $aPbxprojFile "\t\t\t\t);"
2976
2977 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2978 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2979 puts $aPbxprojFile "\t\t\t\t);"
2980 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2981 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2982 puts $aPbxprojFile "\t\t\t\t);"
2983 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2984 puts $aPbxprojFile $anUserHeaderSearchPath
2985 puts $aPbxprojFile "${aWrapperExtension}"
2986 puts $aPbxprojFile "\t\t\t\};"
2987 puts $aPbxprojFile "\t\t\tname = Release;"
2988 puts $aPbxprojFile "\t\t\};\n"
2989 # End XCBuildConfiguration section
2990
2991 # Begin XCConfigurationList section
2992 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
2993 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
2994 puts $aPbxprojFile "\t\tbuildConfigurations = ("
2995 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
2996 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
2997 puts $aPbxprojFile "\t\t\t);"
2998 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
2999 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3000 puts $aPbxprojFile "\t\t\};"
3001 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3002 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3003 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3004 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3005 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
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\};\n"
3010 # End XCConfigurationList section
3011
3012 puts $aPbxprojFile "\t\};"
3013 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3014 puts $aPbxprojFile "\}"
3015
3016 close $aPbxprojFile
3017}
3018
3019proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3020 set aUsername [exec whoami]
3021
3022 # Creating folders for Xcode project file.
3023 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3024 wokUtils:FILES:mkdir $anExecutableDir
3025 if { ! [file exists $anExecutableDir] } {
3026 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3027 return
3028 }
3029
3030 set aUserDataDir "${anExecutableDir}/xcuserdata"
3031 wokUtils:FILES:mkdir $aUserDataDir
3032 if { ! [file exists $aUserDataDir] } {
3033 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3034 return
3035 }
3036
3037 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3038 wokUtils:FILES:mkdir $aUserDataDir
3039 if { ! [file exists $aUserDataDir] } {
3040 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3041 return
3042 }
3043
3044 set aSchemesDir "${aUserDataDir}/xcschemes"
3045 wokUtils:FILES:mkdir $aSchemesDir
3046 if { ! [file exists $aSchemesDir] } {
3047 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3048 return
3049 }
3050 # End folders creation.
3051
3052 # Generating GUID for tookit.
3053 upvar $theGuidsMap aGuidsMap
3054 if { ! [info exists aGuidsMap($theExecutable)] } {
3055 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3056 }
3057
3058 # Creating xcscheme file for toolkit from template.
3059 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3060 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3061 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3062 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3063 puts $aXcschemeFile $aXcschemeTmpl
3064 close $aXcschemeFile
3065
3066 # Creating xcschememanagement.plist file for toolkit from template.
3067 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3068 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3069 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3070 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3071 puts $aPlistFile $aPlistTmpl
3072 close $aPlistFile
3073}