1 # =======================================================================
2 # Created on: 2014-07-24
4 # Copyright (c) 2014 OPEN CASCADE SAS
6 # This file is part of Open CASCADE Technology software library.
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.
14 # Alternatively, this file may be used under the terms of Open CASCADE
15 # commercial license or contractual agreement.
17 # =======================================================================
18 # This script defines Tcl command genproj generating project files for
19 # different IDEs and platforms. Run it with -help to get synopsis.
20 # =======================================================================
22 source [file join [file dirname [info script]] genconfdeps.tcl]
24 # the script is assumed to be run from CASROOT (or dependent Products root)
25 set path [file normalize .]
28 if { [info exists ::env(CASROOT)] } {
29 set THE_CASROOT [file normalize "$::env(CASROOT)"]
32 proc _get_options { platform type branch } {
34 if {[file exists "$::THE_CASROOT/adm/CMPLRS"]} {
35 set fd [open "$::THE_CASROOT/adm/CMPLRS" rb]
36 set opts [split [read $fd] "\n"]
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"
49 proc _get_type { name } {
51 if {[file exists "$::path/adm/UDLIST"]} {
52 set fd [open "$::path/adm/UDLIST" rb]
53 set UDLIST [concat $UDLIST [split [read $fd] "\n"]]
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"]]
62 foreach uitem $UDLIST {
63 set line [split $uitem]
64 if {[lindex $line 1] == "$name"} {
65 return [lindex $line 0]
71 proc _get_used_files { pk {inc true} {src true} } {
73 set type [_get_type $pk]
75 set pk_path "$path/src/$pk"
76 set FILES_path "$path/src/$pk/FILES"
78 if {[file exists $FILES_path]} {
79 set fd [open $FILES_path rb]
80 set FILES [split [read $fd] "\n"]
83 set FILES [lsearch -inline -all -not -exact $FILES ""]
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"
92 if {[regexp {:} $line]} {
93 regexp {[^:]*:+([^\s]*)} $line dummy line
95 regexp {([^\s]*)} $line dummy line
96 if {$src && [file exists $pk_path/$line]} {
97 lappend lret "source $line $pk_path/$line"
103 # return location of the path within src directory
104 proc osutils:findSrcSubPath {theSubPath} {
105 if {[file exists "$::path/src/$theSubPath"]} {
106 return "$::path/src/$theSubPath"
108 return "$::THE_CASROOT/src/$theSubPath"
111 # Auxiliary tool comparing content of two files line-by-line.
112 proc osutils:isEqualContent { theContent1 theContent2 } {
113 set aLen1 [llength $theContent1]
114 set aLen2 [llength $theContent2]
115 if { $aLen1 != $aLen2 } {
119 for {set aLineIter 0} {$aLineIter < $aLen1} {incr aLineIter} {
120 set aLine1 [lindex $theContent1 $aLineIter]
121 set aLine2 [lindex $theContent2 $aLineIter]
122 if { $aLine1 != $aLine2 } {
129 # Auxiliary function for writing new file content only if it has been actually changed
130 # (e.g. to preserve file timestamp on no change).
131 # Useful for automatically (re)generated files.
132 proc osutils:writeTextFile { theFile theContent {theEol lf} } {
133 if {[file exists "${theFile}"]} {
134 set aFileOld [open "${theFile}" rb]
135 fconfigure $aFileOld -translation crlf
136 set aLineListOld [split [read $aFileOld] "\n"]
139 # append empty line for proper comparison (which will be implicitly added by last puts below)
140 set aContent $theContent
142 if { [osutils:isEqualContent $aLineListOld $aContent] == true } {
146 file delete -force "${theFile}"
149 set anOutFile [open "$theFile" "w"]
150 fconfigure $anOutFile -translation $theEol
151 foreach aLine ${theContent} {
152 puts $anOutFile "${aLine}"
158 # Function re-generating header files for specified text resource
159 proc genResources { theResource } {
163 set aResourceAbsPath [file normalize "${path}/src/${theResource}"]
164 set aResourceDirectory ""
165 set isResDirectory false
167 if {[file isdirectory "${aResourceAbsPath}"]} {
168 if {[file exists "${aResourceAbsPath}/FILES"]} {
169 set aFilesFile [open "${aResourceAbsPath}/FILES" rb]
170 set aResFileList [split [read $aFilesFile] "\n"]
173 set aResFileList [lsearch -inline -all -not -exact $aResFileList ""]
174 set aResourceDirectory "${theResource}"
175 set isResDirectory true
177 set aResourceName [file tail "${theResource}"]
178 lappend aResFileList "res:::${aResourceName}"
179 set aResourceDirectory [file dirname "${theResource}"]
182 foreach aResFileIter ${aResFileList} {
183 if {![regexp {^[^:]+:::(.+)} "${aResFileIter}" dump aResFileIter]} {
187 set aResFileName [file tail "${aResFileIter}"]
188 regsub -all {\.} "${aResFileName}" {_} aResFileName
189 set aHeaderFileName "${aResourceDirectory}_${aResFileName}.pxx"
190 if { $isResDirectory == true && [lsearch $aResFileList $aHeaderFileName] == -1 } {
196 lappend aContent "// This file has been automatically generated from resource file src/${aResourceDirectory}/${aResFileIter}"
199 # generate necessary structures
201 if {[file exists "${path}/src/${aResourceDirectory}/${aResFileIter}"]} {
202 set anInputFile [open "${path}/src/${aResourceDirectory}/${aResFileIter}" rb]
203 fconfigure $anInputFile -translation crlf
204 set aLineList [split [read $anInputFile] "\n"]
208 # drop empty trailing line
210 if { [lindex $aLineList end] == "" } {
211 set aLineList [lreplace $aLineList end end]
212 set anEndOfFile "\\n"
215 lappend aContent "static const char ${aResourceDirectory}_${aResFileName}\[\] ="
216 set aNbLines [llength $aLineList]
217 set aLastLine [expr $aNbLines - 1]
218 for {set aLineIter 0} {$aLineIter < $aNbLines} {incr aLineIter} {
219 set aLine [lindex $aLineList $aLineIter]
220 regsub -all {\"} "${aLine}" {\\"} aLine
221 if { $aLineIter == $aLastLine } {
222 lappend aContent " \"${aLine}${anEndOfFile}\";"
224 lappend aContent " \"${aLine}\\n\""
228 # Save generated content to header file
229 set aHeaderFilePath "${path}/src/${aResourceDirectory}/${aHeaderFileName}"
230 if { [osutils:writeTextFile $aHeaderFilePath $aContent] == true } {
231 puts "Generating header file from resource file: ${path}/src/${aResourceDirectory}/${aResFileIter}"
233 #puts "Header file from resource ${path}/src/${aResourceDirectory}/${aResFileIter} is up-to-date"
238 # Function re-generating header files for all text resources
239 proc genAllResources {} {
241 set aCasRoot [file normalize $path]
242 if {![file exists "$aCasRoot/adm/RESOURCES"]} {
243 puts "OCCT directory is not defined correctly: $aCasRoot"
247 set aFileResources [open "$aCasRoot/adm/RESOURCES" rb]
248 set anAdmResources [split [read $aFileResources] "\r\n"]
249 close $aFileResources
250 set anAdmResources [lsearch -inline -all -not -exact $anAdmResources ""]
252 foreach line $anAdmResources {
253 genResources "${line}"
257 # Wrapper-function to generate VS project files
258 proc genproj {theFormat args} {
259 set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "cbp" "xcd"}
260 set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" }
261 set isHelpRequire false
263 # check format argument
264 if { $theFormat == "-h" || $theFormat == "-help" || $theFormat == "--help" } {
265 set isHelpRequire true
266 } elseif { [lsearch -exact $aSupportedFormats $theFormat] < 0 } {
267 puts "Error: genproj: unrecognized project format \"$theFormat\""
268 set isHelpRequire true
271 # choice of compiler for Code::Blocks, currently hard-coded
274 # Determine default platform: wnt for vc*, mac for xcd, current for cbp
275 if { [regexp "^vc" $theFormat] } {
277 } elseif { $theFormat == "xcd" || $::tcl_platform(os) == "Darwin" } {
279 } elseif { $::tcl_platform(platform) == "windows" } {
281 } elseif { $::tcl_platform(platform) == "unix" } {
285 # Check optional arguments
286 set aLibType "dynamic"
288 if { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
289 set isHelpRequire true
290 } elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
292 } elseif { $arg == "-static" } {
293 set aLibType "static"
294 puts "Static build has been selected"
295 } elseif { $arg == "-dynamic" } {
296 set aLibType "dynamic"
297 puts "Dynamic build has been selected"
299 puts "Error: genproj: unrecognized option \"$arg\""
300 set isHelpRequire true
304 if { $isHelpRequire == true } {
305 puts "usage: genproj Format \[Platform\] \[-static\] \[-h|-help|--help\]
307 Format must be one of:
308 vc8 - Visual Studio 2005
309 vc9 - Visual Studio 2008
310 vc10 - Visual Studio 2010
311 vc11 - Visual Studio 2012
312 vc12 - Visual Studio 2013
313 vc14 - Visual Studio 2015
314 vc141 - Visual Studio 2017
319 wnt - Windows Desktop
320 uwp - Universal Windows Platform
326 Option -static can be used with XCode to build static libraries
331 if { ! [info exists aPlatform] } {
332 puts "Error: genproj: Cannon identify default platform, please specify!"
336 puts "Preparing to generate $theFormat projects for $aPlatform platform..."
338 # base path to where to generate projects, hardcoded from current dir
339 set anAdmPath [file normalize "${::path}/adm"]
341 OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl"
343 genprojbat "$theFormat" "$aPlatform"
347 # copy file providing warning if the target file exists and has
348 # different date or size; if it is newer than source, save it as .bak
349 proc copy_with_warning {from to} {
350 if { [file exists "$to"] &&
351 ([file size "$to"] != [file size "$from"] ||
352 [file mtime "$to"] != [file mtime "$from"]) } {
353 puts "Warning: file $to is updated (copied from $from)!"
354 if { [file mtime $to] > [file mtime $from] } {
355 puts "Info: old content of file $to is saved in ${to}.bak"
356 file copy -force -- "$to" "${to}.bak"
360 file copy -force -- "$from" "$to"
363 proc genprojbat {theFormat thePlatform} {
364 set aTargetPlatformExt sh
365 if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
366 set aTargetPlatformExt bat
369 if {"$theFormat" != "cmake"} {
370 # copy env.bat/sh only if not yet present
371 if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
372 set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
373 set anEnvTmpl [read $anEnvTmplFile]
377 if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
378 set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
381 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
383 set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
384 puts $anEnvFile $anEnvTmpl
388 copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
391 if { [regexp {^vc} $theFormat] } {
392 copy_with_warning "$::THE_CASROOT/adm/templates/msvc.bat" "$::path/msvc.bat"
394 switch -exact -- "$theFormat" {
396 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.sh" "$::path/codeblocks.sh"
397 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.bat" "$::path/codeblocks.bat"
398 # Code::Blocks 16.01 does not create directory for import libs, help him
399 file mkdir "$::path/$thePlatform/cbp/lib"
400 file mkdir "$::path/$thePlatform/cbp/libd"
402 "xcd" { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh" "$::path/xcode.sh" }
407 ###### MSVC #############################################################33
408 proc removeAllOccurrencesOf { theObject theList } {
409 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
410 foreach anIndex $aSortIndices {
411 set theList [lreplace $theList $anIndex $anIndex]
416 set aTKNullKey "TKNull"
417 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
419 # Entry function to generate project files
420 # @param theOutDir Root directory for project files
421 # @param theFormat Project format name (vc.. for Visual Studio projects, cbp for Code::Blocks, xcd for XCode)
422 # @param theLibType Library type - dynamic or static
423 # @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
424 # @param theCmpl Compiler option (msvc or gcc)
425 proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
427 set anOutRoot $theOutDir
428 if { $anOutRoot == "" } {
429 error "Error : \"theOutDir\" is not initialized"
432 # Create output directory
433 set aWokStation "$thePlatform"
434 if { [regexp {^vc} $theFormat] } {
435 set aWokStation "msvc"
439 if { $thePlatform == "uwp" } {
443 set anOutDir "${anOutRoot}/${aWokStation}/${theFormat}${aSuffix}"
445 # read map of already generated GUIDs
446 set aGuidsFilePath [file join $anOutDir "wok_${theFormat}_guids.txt"]
447 if [file exists "$aGuidsFilePath"] {
448 set aFileIn [open "$aGuidsFilePath" r]
449 set aFileDataRaw [read $aFileIn]
451 set aFileData [split $aFileDataRaw "\n"]
452 foreach aLine $aFileData {
453 set aLineSplt [split $aLine "="]
454 if { [llength $aLineSplt] == 2 } {
455 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
460 # make list of modules and platforms
461 set aModules [OS:init]
462 if { "$thePlatform" == "ios" } {
463 set goaway [list Draw]
464 set aModules [osutils:juststation $goaway $aModules]
467 # Draw module is turned off due to it is not supported on UWP
469 set aDrawIndex [lsearch -exact ${aModules} "Draw"]
470 if { ${aDrawIndex} != -1 } {
471 set aModules [lreplace ${aModules} ${aDrawIndex} ${aDrawIndex}]
475 # generate one solution for all projects if complete OS or VAS is processed
476 set anAllSolution "OCCT"
478 wokUtils:FILES:mkdir $anOutDir
479 if { ![file exists $anOutDir] } {
480 puts stderr "Error: Could not create output directory \"$anOutDir\""
484 # create the out dir if it does not exist
485 if (![file isdirectory $path/inc]) {
486 puts "$path/inc folder does not exists and will be created"
487 wokUtils:FILES:mkdir $path/inc
490 # collect all required header files
491 puts "Collecting required header files into $path/inc ..."
492 osutils:collectinc $aModules $path/inc
494 # Generating project files for the selected format
495 switch -exact -- "$theFormat" {
503 "vc141" { OS:MKVC $anOutDir $aModules $anAllSolution $theFormat $isUWP}
504 "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution $thePlatform $theCmpl }
506 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
507 OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
511 # Store generated GUIDs map
512 set anOutFile [open "$aGuidsFilePath" "w"]
513 fconfigure $anOutFile -translation lf
514 foreach aKey [array names ::THE_GUIDS_LIST] {
515 set aValue $::THE_GUIDS_LIST($aKey)
516 puts $anOutFile "${aKey}=${aValue}"
521 # Function to generate Visual Studio solution and project files
522 proc OS:MKVC { theOutDir theModules theAllSolution theVcVer isUWP } {
524 puts stderr "Generating VS project files for $theVcVer"
526 # generate projects for toolkits and separate solution for each module
527 foreach aModule $theModules {
528 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
529 OS:vcproj $theVcVer $isUWP $aModule $theOutDir ::THE_GUIDS_LIST
532 # generate single solution "OCCT" containing projects from all modules
533 if { "$theAllSolution" != "" } {
534 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
537 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
540 proc OS:init {{os {}}} {
544 set os $::tcl_platform(os)
547 if [file exists "$::path/src/VAS/Products.tcl"] {
548 source "$::path/src/VAS/Products.tcl"
549 foreach aModuleIter [VAS:Products] {
550 set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
551 if [file exists $aFileTcl] {
553 lappend aModules $aModuleIter
555 puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
561 # Load list of OCCT modules and their definitions
562 source "$::path/src/OS/Modules.tcl"
563 foreach aModuleIter [OS:Modules] {
564 set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
565 if [file exists $aFileTcl] {
567 lappend aModules $aModuleIter
569 puts stderr "Definition file for module $aModuleIter is not found in unit OS"
576 # topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
577 proc wokUtils:EASY:tsort { listofpairs } {
578 foreach x $listofpairs {
581 if ![info exists pcnt($e1)] {
584 if ![ info exists pcnt($e2)] {
589 if ![info exists scnt($e1)] {
595 if [info exists slist($e1)] {
603 foreach node [array names pcnt] {
605 if { $pcnt($node) == 0 } {
609 if ![info exists scnt($node)] {
614 for {set front 1} { $front <= $back } { incr front } {
615 lappend res [set node $q($front)]
616 for {set i 1} {$i <= $scnt($node) } { incr i } {
618 set j [expr {$i - 1}]
619 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
620 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
622 set q($back) [lindex $ll $j]
626 if { $back != $nodecnt } {
627 puts stderr "input contains a cycle"
634 proc wokUtils:LIST:Purge { l } {
637 if ![info exist tab($e)] {
645 # Read file pointed to by path
647 # 2. trim = 1 plusieurs blancs => 1 seul blanc
648 # 3. purge= not yet implemented.
649 # 4. emptl= dont process blank lines
650 proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
651 if ![ catch { set id [ open $path r ] } ] {
653 while {[gets $id line] >= 0 } {
655 regsub -all {[ ]+} $line " " line
658 if { [string length ${line}] != 0 } {
676 # retorn the list of executables in module.
677 proc OS:executable { module } {
679 foreach XXX [${module}:ressources] {
680 if { "[lindex $XXX 1]" == "x" } {
681 lappend lret [lindex $XXX 2]
687 # Topological sort of toolkits in tklm
688 proc osutils:tk:sort { tklm } {
690 foreach tkloc $tklm {
691 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
693 if { [lsearch $tklm $tkx] != -1 } {
694 lappend tkby2 [list $tkx $tkloc]
696 lappend tkby2 [list $tkloc {}]
701 foreach e [wokUtils:EASY:tsort $tkby2] {
709 # close dependencies of ltk. (full wok pathes of toolkits)
710 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
711 # (locate not performed.)
712 proc osutils:tk:close { ltk } {
716 set ids [LibToLink $dir]
717 # puts "osutils:tk:close($ltk) ids='$ids'"
718 set eated [osutils:tk:eatpk $ids]
719 set result [concat $result $eated]
720 set ids [LibToLink $dir]
721 set result [concat $result $ids]
723 foreach file $eated {
724 set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
725 if { [osutils:tk:eatpk $kds] != {} } {
726 lappend recurse $file
730 if { $recurse != {} } {
731 set result [concat $result [osutils:tk:close $recurse]]
736 proc osutils:tk:eatpk { EXTERNLIB } {
737 set l [wokUtils:FILES:FileToList $EXTERNLIB]
740 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
746 # Define libraries to link using only EXTERNLIB file
748 proc LibToLink {theTKit} {
749 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
750 set type [_get_type $theTKit]
751 if {$type != "t" && $type != "x"} {
755 set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
756 foreach anExtLib $anExtLibList {
757 set aFullPath [LocateRecur $anExtLib]
758 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
759 lappend aToolkits $anExtLib
764 # Search unit recursively
766 proc LocateRecur {theName} {
767 set theNamePath [osutils:findSrcSubPath "$theName"]
768 if {[file isdirectory $theNamePath]} {
774 proc OS:genGUID { {theFormat "vc"} } {
775 if { "$theFormat" == "vc" } {
776 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
777 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
778 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
779 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
780 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
781 return "{$p1-$p2-$p3-$p4-$p5}"
783 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
784 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
785 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
786 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
787 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
788 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
789 return "$p1$p2$p3$p4$p5$p6"
793 # collect all include file that required for theModules in theOutDir
794 proc osutils:collectinc {theModules theIncPath} {
796 set aCasRoot [file normalize $path]
797 set anIncPath [file normalize $theIncPath]
799 if {![file isdirectory $aCasRoot]} {
800 puts "OCCT directory is not defined correctly: $aCasRoot"
804 set anUsedToolKits {}
805 foreach aModule $theModules {
806 foreach aToolKit [${aModule}:toolkits] {
807 lappend anUsedToolKits $aToolKit
809 foreach aDependency [LibToLink $aToolKit] {
810 lappend anUsedToolKits $aDependency
813 foreach anExecutable [OS:executable ${aModule}] {
814 lappend anUsedToolKits $anExecutable
816 foreach aDependency [LibToLink $anExecutable] {
817 lappend anUsedToolKits $aDependency
821 set anUsedToolKits [lsort -unique $anUsedToolKits]
824 foreach anUsedToolKit $anUsedToolKits {
825 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
827 set anUnits [lsort -unique $anUnits]
829 # define copying style
831 if { [info exists ::env(SHORTCUT_HEADERS)] } {
832 if { [string equal -nocase $::env(SHORTCUT_HEADERS) "hard"]
833 || [string equal -nocase $::env(SHORTCUT_HEADERS) "hardlink"] } {
834 set aCopyType "hardlink"
835 } elseif { [string equal -nocase $::env(SHORTCUT_HEADERS) "true"]
836 || [string equal -nocase $::env(SHORTCUT_HEADERS) "shortcut"] } {
837 set aCopyType "shortcut"
841 set allHeaderFiles {}
842 if { $aCopyType == "shortcut" } {
843 # template preparation
844 if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
845 puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
848 set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
850 # relative anIncPath in connection with aCasRoot/src
851 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
853 # create and copy short-cut header files
854 foreach anUnit $anUnits {
855 osutils:checksrcfiles ${anUnit}
857 set aHFiles [_get_used_files ${anUnit} true false]
858 foreach aHeaderFile ${aHFiles} {
859 set aHeaderFileName [lindex ${aHeaderFile} 1]
860 lappend allHeaderFiles "${aHeaderFileName}"
862 regsub -all -- {@OCCT_HEADER_FILE_CONTENT@} $aHeaderTmpl "#include \"$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName\"" aShortCutHeaderFileContent
864 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
865 set fp [open "$theIncPath/$aHeaderFileName" r]
866 set aHeaderContent [read $fp]
870 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
872 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
873 # remove eof from string
874 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
876 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
880 file delete -force "$theIncPath/$aHeaderFileName"
883 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
884 fconfigure $aShortCutHeaderFile -translation lf
885 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
886 close $aShortCutHeaderFile
891 foreach anUnit $anUnits {
892 osutils:checksrcfiles ${anUnit}
894 set aHFiles [_get_used_files ${anUnit} true false]
895 foreach aHeaderFile ${aHFiles} {
896 set aHeaderFileName [lindex ${aHeaderFile} 1]
897 lappend allHeaderFiles "${aHeaderFileName}"
899 # copy file only if target does not exist or is older than original
900 set torig [file mtime $aCasRoot/src/$anUnit/$aHeaderFileName]
902 if { [file isfile $anIncPath/$aHeaderFileName] } {
903 set tcopy [file mtime $anIncPath/$aHeaderFileName]
905 if { $tcopy < $torig } {
907 if { $aCopyType == "hardlink" } {
909 file delete -force "$theIncPath/$aHeaderFileName"
911 file link -hard $anIncPath/$aHeaderFileName $aCasRoot/src/$anUnit/$aHeaderFileName
913 file copy -force $aCasRoot/src/$anUnit/$aHeaderFileName $anIncPath/$aHeaderFileName
915 } elseif { $tcopy != $torig } {
916 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aCasRoot/src/$anUnit/$aHeaderFileName, not changed!"
920 puts "Info: $nbcopied files updated"
923 # remove header files not listed in FILES
924 set anIncFiles [glob -tails -nocomplain -dir ${anIncPath} "*"]
925 foreach anIncFile ${anIncFiles} {
926 if { [lsearch -exact ${allHeaderFiles} ${anIncFile}] == -1 } {
927 puts "Warning: file ${anIncPath}/${anIncFile} is not presented in the sources and will be removed from ${theIncPath}!"
928 file delete -force "${theIncPath}/${anIncFile}"
933 # Generate header for VS solution file
934 proc osutils:vcsolution:header { vcversion } {
935 if { "$vcversion" == "vc7" } {
937 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
938 } elseif { "$vcversion" == "vc8" } {
940 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
941 "# Visual Studio 2005\n"
942 } elseif { "$vcversion" == "vc9" } {
944 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
945 "# Visual Studio 2008\n"
946 } elseif { "$vcversion" == "vc10" } {
948 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
949 "# Visual Studio 2010\n"
950 } elseif { "$vcversion" == "vc11" } {
952 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
953 "# Visual Studio 2012\n"
954 } elseif { "$vcversion" == "vc12" } {
956 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
957 "# Visual Studio 2013\n"
958 } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141"} {
960 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
961 "# Visual Studio 14\n"
963 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
967 # Returns extension (without dot) for project files of given version of VC
969 proc osutils:vcproj:ext { vcversion } {
970 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
976 # Generate start of configuration section of VS solution file
978 proc osutils:vcsolution:config:begin { vcversion } {
979 if { "$vcversion" == "vc7" } {
982 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
983 "\t\tDebug = Debug\n" \
984 "\t\tRelease = Release\n" \
985 "\tEndGlobalSection\n" \
986 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
990 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
991 "\t\tDebug|Win32 = Debug|Win32\n" \
992 "\t\tRelease|Win32 = Release|Win32\n" \
993 "\t\tDebug|x64 = Debug|x64\n" \
994 "\t\tRelease|x64 = Release|x64\n" \
995 "\tEndGlobalSection\n" \
996 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
1000 # Generate part of configuration section of VS solution file describing one project
1002 proc osutils:vcsolution:config:project { vcversion guid } {
1003 if { "$vcversion" == "vc7" } {
1005 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
1006 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
1007 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
1008 "\t\t$guid.Release.Build.0 = Release|Win32\n"
1011 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
1012 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
1013 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
1014 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
1015 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
1016 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
1017 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
1018 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
1022 # Generate start of configuration section of VS solution file
1024 proc osutils:vcsolution:config:end { vcversion } {
1025 if { "$vcversion" == "vc7" } {
1027 "\tEndGlobalSection\n" \
1028 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
1029 "\tEndGlobalSection\n" \
1030 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
1031 "\tEndGlobalSection\n"
1034 "\tEndGlobalSection\n" \
1035 "\tGlobalSection(SolutionProperties) = preSolution\n" \
1036 "\t\tHideSolutionNode = FALSE\n" \
1037 "\tEndGlobalSection\n"
1041 # generate Visual Studio solution file
1042 # if module is empty, generates one solution for all known modules
1044 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
1046 upvar $theGuidsMap aGuidsMap
1048 # collect list of projects to be created
1050 set aDependencies {}
1051 foreach aModule $theModules {
1053 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1054 lappend aProjects $aToolKit
1055 lappend aProjectsInModule($aModule) $aToolKit
1056 lappend aDependencies [LibToLink $aToolKit]
1058 # executables, assume one project per cxx file...
1059 foreach aUnit [OS:executable ${aModule}] {
1061 set src_files [_get_used_files $aUnit false]
1063 foreach s $src_files {
1064 regexp {source ([^\s]+)} $s dummy name
1065 lappend aSrcFiles $name
1067 foreach aSrcFile $aSrcFiles {
1068 set aFileExtension [file extension $aSrcFile]
1069 if { $aFileExtension == ".cxx" } {
1070 set aPrjName [file rootname $aSrcFile]
1071 lappend aProjects $aPrjName
1072 lappend aProjectsInModule($aModule) $aPrjName
1073 if {[file isdirectory $path/src/$aUnitLoc]} {
1074 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1076 lappend aDependencies {}
1083 # generate GUIDs for projects (unless already known)
1084 foreach aProject $aProjects {
1085 if { ! [info exists aGuidsMap($aProject)] } {
1086 set aGuidsMap($aProject) [OS:genGUID]
1090 # generate solution file
1091 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
1092 append aFileBuff [osutils:vcsolution:header $theVcVer]
1094 # GUID identifying group projects in Visual Studio
1095 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
1097 # generate group projects -- one per module
1098 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
1099 foreach aModule $theModules {
1100 if { ! [info exists aGuidsMap(_$aModule)] } {
1101 set aGuidsMap(_$aModule) [OS:genGUID]
1103 set aGuid $aGuidsMap(_$aModule)
1104 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
1108 # extension of project files
1109 set aProjExt [osutils:vcproj:ext $theVcVer]
1111 # GUID identifying C++ projects in Visual Studio
1112 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
1114 # generate normal projects
1115 set aProjsNb [llength $aProjects]
1116 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
1117 set aProj [lindex $aProjects $aProjId]
1118 set aGuid $aGuidsMap($aProj)
1119 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
1120 # write projects dependencies information (vc7 to vc9)
1122 foreach aDepLib [lindex $aDependencies $aProjId] {
1123 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
1124 set depGUID $aGuidsMap($aDepLib)
1125 append aDepGuids "\t\t$depGUID = $depGUID\n"
1128 if { "$aDepGuids" != "" } {
1129 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
1130 append aFileBuff "$aDepGuids"
1131 append aFileBuff "\tEndProjectSection\n"
1133 append aFileBuff "EndProject\n"
1136 # generate configuration section
1137 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
1138 foreach aProj $aProjects {
1139 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
1141 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
1143 # write information of grouping of projects by module
1144 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
1145 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
1146 foreach aModule $theModules {
1147 if { ! [info exists aProjectsInModule($aModule)] } { continue }
1148 foreach aProject $aProjectsInModule($aModule) {
1149 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
1152 append aFileBuff " EndGlobalSection\n"
1155 # final word (footer)
1156 append aFileBuff "EndGlobal"
1159 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
1160 fconfigure $aFile -translation crlf
1161 puts $aFile $aFileBuff
1163 return [file join $theOutDir ${theSolName}.sln]
1165 # Generate Visual Studio projects for specified version
1167 proc OS:vcproj { theVcVer isUWP theModules theOutDir theGuidsMap } {
1168 upvar $theGuidsMap aGuidsMap
1170 set aProjectFiles {}
1172 foreach aModule $theModules {
1173 foreach aToolKit [${aModule}:toolkits] {
1174 lappend aProjectFiles [osutils:vcproj $theVcVer $isUWP $theOutDir $aToolKit aGuidsMap]
1176 foreach anExecutable [OS:executable ${aModule}] {
1177 lappend aProjectFiles [osutils:vcprojx $theVcVer $isUWP $theOutDir $anExecutable aGuidsMap]
1180 return $aProjectFiles
1182 # generate template name and load it for given version of Visual Studio and platform
1184 proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} {
1186 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1190 # determine versions of runtime and toolset
1191 set aVCRTVer $theVcVer
1192 set aToolset "v[string range $theVcVer 2 3]0"
1193 if { $theVcVer == "vc141" } {
1198 set what "$theVcVer"
1201 set aCharSet "Unicode"
1203 set anExt "${anExt}x"
1204 set what "$what executable"
1206 if { "$theVcVer" == "vc10" } {
1207 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
1208 set aCmpl32 "<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
1210 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
1213 set UwpWinRt "<CompileAsWinRT>false</CompileAsWinRT>"
1214 foreach bitness {32 64} {
1216 if {"[set aCmpl${bitness}]" != ""} {
1219 set aCmpl${bitness} "[set aCmpl${bitness}]${indent}${UwpWinRt}"
1223 set format_template "\[\\r\\n\\s\]*"
1224 foreach bitness {32 64} {
1225 set format_templateloc ""
1226 if {"[set aCmpl${bitness}]" == ""} {
1227 set format_templateloc "$format_template"
1229 regsub -all -- "${format_templateloc}__VCMPL${bitness}__" $aTmpl "[set aCmpl${bitness}]" aTmpl
1234 if { "$::HAVE_RelWithDebInfo" == "true" } {
1235 set aDebugInfo "true"
1236 set aReleaseLnk "\n <OptimizeReferences>true</OptimizeReferences>\n <EnableCOMDATFolding>true</EnableCOMDATFolding>"
1239 regsub -all -- {__VCVER__} $aTmpl $aVCRTVer aTmpl
1240 regsub -all -- {__VCVEREXT__} $aTmpl $aToolset aTmpl
1241 regsub -all -- {__VCCHARSET__} $aTmpl $aCharSet aTmpl
1242 regsub -all -- {__VCReleasePDB__} $aTmpl $aDebugInfo aTmpl
1243 regsub -all -- "${format_template}__VCLNKREL__" $aTmpl "${aReleaseLnk}" aTmpl
1248 proc osutils:readtemplate {ext what} {
1249 set loc "$::THE_CASROOT/adm/templates/template.$ext"
1250 return [wokUtils:FILES:FileToString $loc]
1252 # Read a file in a string as is.
1254 proc wokUtils:FILES:FileToString { fin } {
1255 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1256 set strin [read $in [file size $fin]]
1264 # List extensions of compilable files in OCCT
1265 proc osutils:compilable {thePlatform} {
1266 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .c .cxx .cpp .mm] }
1267 return [list .c .cxx .cpp]
1270 # List extensions of header file in OCCT
1271 proc osutils:fileExtensionsHeaders {thePlatform} {
1272 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .h .hxx .hpp .lxx .pxx .gxx ] }
1273 return [list .h .hxx .hpp .lxx .pxx .gxx .mm ]
1276 proc osutils:commonUsedTK { theToolKit } {
1277 set anUsedToolKits [list]
1278 set aDepToolkits [LibToLink $theToolKit]
1279 foreach tkx $aDepToolkits {
1280 if {[_get_type $tkx] == "t"} {
1281 lappend anUsedToolKits "${tkx}"
1284 return $anUsedToolKits
1287 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1288 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1289 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1292 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1299 # Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
1300 # @param theOS - target OS
1301 # @param theCsfLibsMap - libraries map
1302 # @param theCsfFrmsMap - frameworks map, OS X specific
1303 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1304 upvar $theCsfLibsMap aLibsMap
1305 upvar $theCsfFrmsMap aFrmsMap
1310 set aLibsMap(CSF_FREETYPE) "freetype"
1311 set aLibsMap(CSF_TclLibs) "tcl8.6"
1312 set aLibsMap(CSF_TclTkLibs) "tk8.6"
1313 if { "$::HAVE_FREEIMAGE" == "true" } {
1314 if { "$theOS" == "wnt" } {
1315 set aLibsMap(CSF_FreeImagePlus) "FreeImage"
1317 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1319 } elseif { "$theOS" == "wnt" } {
1320 set aLibsMap(CSF_FreeImagePlus) "windowscodecs"
1322 if { "$::HAVE_FFMPEG" == "true" } {
1323 set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil"
1325 if { "$::HAVE_TBB" == "true" } {
1326 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1328 if { "$::HAVE_VTK" == "true" } {
1329 if { "$theOS" == "wnt" } {
1330 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1332 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1335 if { "$::HAVE_ZLIB" == "true" } {
1336 set aLibsMap(CSF_ZLIB) "zlib"
1338 if { "$::HAVE_LIBLZMA" == "true" } {
1339 set aLibsMap(CSF_LIBLZMA) "liblzma"
1342 if { "$theOS" == "wnt" } {
1344 set aLibsMap(CSF_kernel32) "kernel32"
1345 set aLibsMap(CSF_advapi32) "advapi32"
1346 set aLibsMap(CSF_gdi32) "gdi32"
1347 set aLibsMap(CSF_user32) "user32 comdlg32"
1348 set aLibsMap(CSF_shell32) "shell32"
1349 set aLibsMap(CSF_opengl32) "opengl32"
1350 set aLibsMap(CSF_wsock32) "wsock32"
1351 set aLibsMap(CSF_netapi32) "netapi32"
1352 set aLibsMap(CSF_OpenGlLibs) "opengl32"
1353 if { "$::HAVE_GLES2" == "true" } {
1354 set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2"
1356 set aLibsMap(CSF_psapi) "Psapi"
1357 set aLibsMap(CSF_d3d9) "d3d9"
1359 # the naming is different on Windows
1360 set aLibsMap(CSF_TclLibs) "tcl86"
1361 set aLibsMap(CSF_TclTkLibs) "tk86"
1363 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1365 # tbb headers define different pragma lib depending on debug/release
1366 set aLibsMap(CSF_TBB) ""
1368 set aLibsMap(CSF_dl) "dl"
1369 if { "$theOS" == "mac" } {
1370 set aLibsMap(CSF_objc) "objc"
1371 set aFrmsMap(CSF_Appkit) "AppKit"
1372 set aFrmsMap(CSF_IOKit) "IOKit"
1373 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1374 set aFrmsMap(CSF_TclLibs) "Tcl"
1375 set aLibsMap(CSF_TclLibs) ""
1376 set aFrmsMap(CSF_TclTkLibs) "Tk"
1377 set aLibsMap(CSF_TclTkLibs) ""
1378 set aLibsMap(CSF_QT) "QtCore QtGui"
1380 if { "$theOS" == "qnx" } {
1381 # CSF_ThreadLibs - pthread API is part of libc on QNX
1382 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1384 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1385 set aLibsMap(CSF_OpenGlLibs) "GL"
1386 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1387 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1388 set aLibsMap(CSF_MotifLibs) "X11"
1391 if { "$::HAVE_GLES2" == "true" } {
1392 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1398 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1399 proc osutils:vtkCsf {{theOS ""}} {
1402 set aPathSplitter ":"
1403 if {"$theOS" == "wnt"} {
1404 set aPathSplitter ";"
1407 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1408 foreach anIncItem $anOptIncs {
1409 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1410 set aVtkVer $aFoundVtkVer
1414 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1415 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1417 # Additional suffices for the libraries
1419 foreach anItem $aLibArray {
1420 lset aLibArray $anIdx $anItem-$aVtkVer
1424 return [join $aLibArray " "]
1427 # @param theLibsList - dependencies (libraries list)
1428 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1429 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1431 upvar $theLibsList aLibsList
1432 upvar $theFrameworks aFrameworks
1433 set aLibsList [list]
1434 set aFrameworks [list]
1436 osutils:csfList $theOS aLibsMap aFrmsMap
1438 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1439 if [info exists aLibsMap($aCsfElem)] {
1440 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1441 if { [lsearch $aLibsList $aLib] == "-1" } {
1442 lappend aLibsList $aLib
1446 if [info exists aFrmsMap($aCsfElem)] {
1447 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1448 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1449 lappend aFrameworks $aFrm
1456 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1457 proc osutils:tk:units { tkloc } {
1460 set PACKAGES "$path/src/$tkloc/PACKAGES"
1461 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1462 if {[file isdirectory "$path/src/$u"]} {
1467 ;#puts stderr "Warning. No devunit included in $tkloc"
1472 proc osutils:justwnt { listloc } {
1473 set goaway [list Xw]
1474 return [osutils:juststation $goaway $listloc]
1477 # remove from listloc OpenCascade units indesirables on NT
1478 proc osutils:juststation {goaway listloc} {
1481 foreach u $listloc {
1482 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1483 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1490 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1491 # The first list is everything in the first list that wasn't in the second,
1492 # the second list contains the intersection of the two lists, the third list contains everything
1493 # in the second list that wasn't in the first.
1494 proc osutils:intersect3 {list1 list2} {
1495 set la1(0) {} ; unset la1(0)
1496 set lai(0) {} ; unset lai(0)
1497 set la2(0) {} ; unset la2(0)
1504 foreach elem [concat $list1 $list2] {
1505 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1511 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1514 # Prepare relative path
1515 proc relativePath {thePathFrom thePathTo} {
1516 if { [file isdirectory "$thePathFrom"] == 0 } {
1520 set aPathFrom [file normalize "$thePathFrom"]
1521 set aPathTo [file normalize "$thePathTo"]
1523 set aCutedPathFrom "${aPathFrom}/dummy"
1524 set aRelatedDeepPath ""
1526 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1527 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1528 # does aPathTo contain aCutedPathFrom?
1529 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1530 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1531 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1532 set aPathTo ".${aPathTo}"
1533 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1534 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1536 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1537 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1538 return $aPathToAfterCut
1540 set aRelatedDeepPath "$aRelatedDeepPath../"
1547 proc wokUtils:EASY:bs1 { s } {
1548 regsub -all {/} $s {\\} r
1552 # Returs for a full path the liste of n last directory part
1554 # n = 2 => dir/file.c
1555 # n = 3 => sdir/dir/file.c
1557 proc wokUtils:FILES:wtail { f n } {
1558 set ll [expr [llength [set lif [file split $f]]] -$n]
1559 return [join [lrange $lif $ll end] /]
1562 # Generate entry for one source file in Visual Studio 10 project file
1563 proc osutils:vcxproj:cxxfile { theFile theParams } {
1564 if { $theParams == "" } {
1565 return " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n"
1568 set aParams [string trim ${theParams}]
1569 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1570 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1571 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1572 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1573 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1574 append text " </ClCompile>\n"
1578 # Generate entry for one header file in Visual Studio 10 project file
1579 proc osutils:vcxproj:hxxfile { theFile } { return " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n" }
1581 # Generate Visual Studio 2010 project filters file
1582 proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
1583 upvar $theCxxFilesMap aCxxFilesMap
1584 upvar $theHxxFilesMap aHxxFilesMap
1587 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1588 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1590 # list of "filters" (units)
1591 append text " <ItemGroup>\n"
1592 append text " <Filter Include=\"Source files\">\n"
1593 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1594 append text " </Filter>\n"
1595 append text " <Filter Include=\"Header files\">\n"
1596 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1597 append text " </Filter>\n"
1598 foreach unit $aCxxFilesMap(units) {
1599 append text " <Filter Include=\"Source files\\${unit}\">\n"
1600 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1601 append text " </Filter>\n"
1603 foreach unit $aHxxFilesMap(units) {
1604 append text " <Filter Include=\"Header files\\${unit}\">\n"
1605 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1606 append text " </Filter>\n"
1608 append text " </ItemGroup>\n"
1611 append text " <ItemGroup>\n"
1612 foreach unit $aCxxFilesMap(units) {
1613 foreach file $aCxxFilesMap($unit) {
1614 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1615 append text " <Filter>Source files\\${unit}</Filter>\n"
1616 append text " </ClCompile>\n"
1619 append text " </ItemGroup>\n"
1622 append text " <ItemGroup>\n"
1623 foreach unit $aHxxFilesMap(units) {
1624 foreach file $aHxxFilesMap($unit) {
1625 append text " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1626 append text " <Filter>Header files\\${unit}</Filter>\n"
1627 append text " </ClInclude>\n"
1630 append text " </ItemGroup>\n"
1632 append text " <ItemGroup>\n"
1633 append text " <ResourceCompile Include=\"${proj}.rc\" />\n"
1634 append text " </ItemGroup>\n"
1637 append text "</Project>"
1640 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1641 fconfigure $fp -translation crlf
1645 return ${proj}.vcxproj.filters
1648 # Generate RC file content for ToolKit from template
1649 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1650 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1651 set aBody [wokUtils:FILES:FileToString $aLoc]
1652 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1654 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1655 fconfigure $aFile -translation lf
1658 return "${theOutDir}/${theToolKit}.rc"
1661 # Generate Visual Studio project file for ToolKit
1662 proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
1663 set theProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 0]
1665 set l_compilable [osutils:compilable wnt]
1666 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1668 upvar $theGuidsMap aGuidsMap
1669 if { ! [info exists aGuidsMap($theToolKit)] } {
1670 set aGuidsMap($theToolKit) [OS:genGUID]
1672 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1674 set theProjTmpl [osutils:uwp:proj $isUWP ${theProjTmpl}]
1676 set aUsedLibs [list]
1679 lappend aUsedLibs "WindowsApp.lib"
1682 foreach tkx [osutils:commonUsedTK $theToolKit] {
1683 lappend aUsedLibs "${tkx}.lib"
1686 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1687 foreach aLibIter $aLibs {
1688 lappend aUsedLibs "${aLibIter}.lib"
1691 # correct names of referred third-party libraries that are named with suffix
1692 # depending on VC version
1693 set aVCRTVer [string range $theVcVer 0 3]
1694 regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
1696 # and put this list to project file
1697 #puts "$theToolKit requires $aUsedLibs"
1698 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1699 set aUsedLibs [join $aUsedLibs {;}]
1701 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1703 set anIncPaths "..\\..\\..\\inc"
1705 set aFilesSection ""
1706 set aVcFilesCxx(units) ""
1707 set aVcFilesHxx(units) ""
1708 set listloc [osutils:tk:units $theToolKit]
1709 if [array exists written] { unset written }
1710 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1711 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1712 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1713 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1714 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1715 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1717 foreach fxlo $listloc {
1719 set aSrcFiles [osutils:tk:cxxfiles $xlo wnt]
1720 set aHxxFiles [osutils:tk:hxxfiles $xlo wnt]
1721 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1722 if {$fxlo_cmplrs_options_cxx == ""} {
1723 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1725 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1726 if {$fxlo_cmplrs_options_c == ""} {
1727 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1729 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1730 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1731 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1732 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1733 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1734 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1736 foreach partopt $fxloparam {
1737 if {[string first "-I" $partopt] == "0"} {
1738 # this is an additional includes search path
1741 set needparam "$needparam $partopt"
1744 # Format of projects in vc10+ is different from vc7-9
1745 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1746 foreach aSrcFile [lsort $aSrcFiles] {
1747 if { ![info exists written([file tail $aSrcFile])] } {
1748 set written([file tail $aSrcFile]) 1
1749 append aFilesSection [osutils:vcxproj:cxxfile $aSrcFile $needparam]
1751 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1753 if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
1754 lappend aVcFilesCxx($xlo) $aSrcFile
1756 foreach aHxxFile [lsort $aHxxFiles] {
1757 if { ![info exists written([file tail $aHxxFile])] } {
1758 set written([file tail $aHxxFile]) 1
1759 append aFilesSection [osutils:vcxproj:hxxfile $aHxxFile]
1761 puts "Warning : in vcproj more than one occurences for [file tail $aHxxFile]"
1763 if { ! [info exists aVcFilesHxx($xlo)] } { lappend aVcFilesHxx(units) $xlo }
1764 lappend aVcFilesHxx($xlo) $aHxxFile
1767 append aFilesSection "\t\t\t<Filter\n"
1768 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1769 append aFilesSection "\t\t\t\t>\n"
1770 foreach aSrcFile [lsort $aSrcFiles] {
1771 if { ![info exists written([file tail $aSrcFile])] } {
1772 set written([file tail $aSrcFile]) 1
1773 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1775 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1778 append aFilesSection "\t\t\t</Filter>\n"
1782 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1783 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1786 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1787 fconfigure $aFile -translation crlf
1788 puts $aFile $theProjTmpl
1791 # write filters file for vc10+
1792 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1793 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesCxx aVcFilesHxx]
1796 # write resource file
1797 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1802 # for a unit returns a map containing all its file in the current
1804 # local = 1 only local files
1805 proc osutils:tk:loadunit { loc map } {
1808 catch { unset TLOC }
1809 set lfiles [_get_used_files $loc]
1814 if [info exists TLOC($t)] {
1825 # Returns the list of all files name in a toolkit within specified list of file extensions.
1826 proc osutils:tk:files { tkloc theExtensions } {
1827 set Tfiles(source,nocdlpack) {source pubinclude}
1828 set Tfiles(source,toolkit) {}
1829 set Tfiles(source,executable) {source pubinclude}
1830 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1831 #puts " listloc = $listloc"
1833 set resultloc $listloc
1835 foreach loc $resultloc {
1836 set utyp [_get_type $loc]
1837 #puts "\"$utyp\" \"$loc\""
1839 "t" { set utyp "toolkit" }
1840 "n" { set utyp "nocdlpack" }
1841 "x" { set utyp "executable" }
1842 default { error "Error: Cannot determine type of unit $loc, check adm/UDLIST!" }
1844 if [array exists map] { unset map }
1845 osutils:tk:loadunit $loc map
1846 #puts " loc = $loc === > [array names map]"
1847 set LType $Tfiles(source,${utyp})
1848 foreach typ [array names map] {
1849 if { [lsearch $LType $typ] == -1 } {
1853 foreach type [array names map] {
1855 foreach f $map($type) {
1857 if { [lsearch $theExtensions [file extension $f]] != -1 } {
1866 # Returns the list of all compilable files name in a toolkit.
1867 proc osutils:tk:cxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:compilable $thePlatform]] }
1869 # Returns the list of all header files name in a toolkit.
1870 proc osutils:tk:hxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:fileExtensionsHeaders $thePlatform]] }
1872 # Generate Visual Studio project file for executable
1873 proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
1875 foreach f [osutils:tk:cxxfiles $theToolKit wnt] {
1876 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
1878 set aProjName [file rootname [file tail $f]]
1879 set l_compilable [osutils:compilable wnt]
1880 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1882 upvar $theGuidsMap aGuidsMap
1883 if { ! [info exists aGuidsMap($aProjName)] } {
1884 set aGuidsMap($aProjName) [OS:genGUID]
1886 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1888 set aUsedLibs [list]
1889 foreach tkx [osutils:commonUsedTK $theToolKit] {
1890 lappend aUsedLibs "${tkx}.lib"
1893 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1894 foreach aLibIter $aLibs {
1895 lappend aUsedLibs "${aLibIter}.lib"
1898 # correct names of referred third-party libraries that are named with suffix
1899 # depending on VC version
1900 set aVCRTVer [string range $theVcVer 0 3]
1901 regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
1903 # puts "$aProjName requires $aUsedLibs"
1904 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1905 set aUsedLibs [join $aUsedLibs {;}]
1907 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1909 set aFilesSection ""
1910 set aVcFilesCxx(units) ""
1911 set aVcFilesHxx(units) ""
1913 if { ![info exists written([file tail $f])] } {
1914 set written([file tail $f]) 1
1916 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1917 append aFilesSection [osutils:vcxproj:cxxfile $f ""]
1918 if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
1919 lappend aVcFilesCxx($theToolKit) $f
1921 append aFilesSection "\t\t\t<Filter\n"
1922 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1923 append aFilesSection "\t\t\t\t>\n"
1924 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1925 append aFilesSection "\t\t\t</Filter>"
1928 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1930 #puts "$aProjTmpl $aFilesSection"
1931 set anIncPaths "..\\..\\..\\inc"
1932 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1933 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1934 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1936 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1938 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1939 fconfigure $aFile -translation crlf
1940 puts $aFile $aProjTmpl
1943 set aCommonSettingsFile "$aVcFilePath.user"
1944 lappend aVcFiles $aVcFilePath
1946 # write filters file for vc10
1947 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1948 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
1951 # write resource file
1952 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
1954 set aCommonSettingsFileTmpl ""
1955 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1957 } elseif { "$theVcVer" == "vc9" } {
1958 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
1960 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
1962 if { "$aCommonSettingsFileTmpl" != "" } {
1963 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
1965 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1966 fconfigure $aFile -translation crlf
1967 puts $aFile $aCommonSettingsFileTmpl
1970 lappend aVcFiles "$aCommonSettingsFile"
1976 # Generate entry for one source file in Visual Studio 7 - 9 project file
1977 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1978 append aText "\t\t\t\t<File\n"
1979 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1980 if { $theOptions == "" } {
1981 append aText "\t\t\t\t</File>\n"
1985 append aText "\t\t\t\t\t<FileConfiguration\n"
1986 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1987 append aText "\t\t\t\t\t\t<Tool\n"
1988 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1989 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1990 foreach aParam $theOptions {
1991 append aText "$aParam "
1994 append aText "\t\t\t\t\t\t/>\n"
1995 append aText "\t\t\t\t\t</FileConfiguration>\n"
1997 append aText "\t\t\t\t\t<FileConfiguration\n"
1998 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1999 append aText "\t\t\t\t\t\t<Tool\n"
2000 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2001 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2002 foreach aParam $theOptions {
2003 append aText "$aParam "
2006 append aText "\t\t\t\t\t\t/>\n"
2007 append aText "\t\t\t\t\t</FileConfiguration>\n"
2008 if { "$theVcVer" == "vc7" } {
2009 append aText "\t\t\t\t</File>\n"
2013 append aText "\t\t\t\t\t<FileConfiguration\n"
2014 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
2015 append aText "\t\t\t\t\t\t<Tool\n"
2016 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2017 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2018 foreach aParam $theOptions {
2019 append aText "$aParam "
2022 append aText "\t\t\t\t\t\t/>\n"
2023 append aText "\t\t\t\t\t</FileConfiguration>\n"
2025 append aText "\t\t\t\t\t<FileConfiguration\n"
2026 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
2027 append aText "\t\t\t\t\t\t<Tool\n"
2028 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2029 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2030 foreach aParam $theOptions {
2031 append aText "$aParam "
2034 append aText "\t\t\t\t\t\t/>\n"
2035 append aText "\t\t\t\t\t</FileConfiguration>\n"
2037 append aText "\t\t\t\t</File>\n"
2041 proc wokUtils:FILES:mkdir { d } {
2043 regsub -all {\.[^.]*} $tcl_version "" major
2044 if { $major == 8 } {
2047 if ![file exists $d] {
2048 if { "[info command mkdir]" == "mkdir" } {
2051 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
2055 if [file exists $d] {
2062 # remove from listloc OpenCascade units indesirables on Unix
2063 proc osutils:justunix { listloc } {
2064 if { "$::tcl_platform(os)" == "Darwin" } {
2065 set goaway [list Xw WNT]
2067 set goaway [list WNT]
2069 return [osutils:juststation $goaway $listloc]
2073 ####### CODEBLOCK ###################################################################
2074 # Function to generate Code Blocks workspace and project files
2075 proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
2076 puts stderr "Generating project files for Code Blocks"
2078 # Generate projects for toolkits and separate workspace for each module
2079 foreach aModule $theModules {
2080 OS:cworkspace $aModule $aModule $theOutDir
2081 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
2084 # Generate single workspace "OCCT" containing projects from all modules
2085 if { "$theAllSolution" != "" } {
2086 OS:cworkspace $theAllSolution $theModules $theOutDir
2089 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
2092 # Generate Code Blocks projects
2093 proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
2094 set aProjectFiles {}
2095 foreach aModule $theModules {
2096 foreach aToolKit [${aModule}:toolkits] {
2097 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
2099 foreach anExecutable [OS:executable ${aModule}] {
2100 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
2103 return $aProjectFiles
2106 # Generate Code::Blocks project file for ToolKit
2107 proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
2108 set aUsedLibs [list]
2109 set aFrameworks [list]
2110 set anIncPaths [list]
2111 set aTKDefines [list]
2112 set aTKSrcFiles [list]
2114 # collect list of referred libraries to link with
2115 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2116 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2117 foreach tkx $aDepToolkits {
2118 lappend aUsedLibs "${tkx}"
2121 lappend anIncPaths "../../../inc"
2122 set listloc [osutils:tk:units $theToolKit]
2124 if { [llength $listloc] == 0 } {
2125 set listloc $theToolKit
2128 if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2129 set resultloc [osutils:justwnt $listloc]
2131 set resultloc [osutils:justunix $listloc]
2133 if [array exists written] { unset written }
2134 foreach fxlo $resultloc {
2136 set aSrcFiles [osutils:tk:cxxfiles $xlo $thePlatform]
2137 foreach aSrcFile [lsort $aSrcFiles] {
2138 if { ![info exists written([file tail $aSrcFile])] } {
2139 set written([file tail $aSrcFile]) 1
2140 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2142 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2146 # macros for correct DLL exports
2147 # if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2148 # lappend aTKDefines "__${xlo}_DLL"
2152 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
2155 # Generates Code Blocks workspace.
2156 proc OS:cworkspace { theSolName theModules theOutDir } {
2158 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
2159 set aFile [open $aWsFilePath "w"]
2161 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2162 puts $aFile "<CodeBlocks_workspace_file>"
2163 puts $aFile "\t<Workspace title=\"${theSolName}\">"
2165 # collect list of projects to be created
2166 foreach aModule $theModules {
2168 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
2169 set aDependencies [LibToLink $aToolKit]
2170 if { [llength $aDependencies] == 0 } {
2171 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
2173 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
2174 foreach aDepTk $aDependencies {
2175 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2177 puts $aFile "\t\t</Project>"
2181 # executables, assume one project per cxx file...
2182 foreach aUnit [OS:executable ${aModule}] {
2184 set src_files [_get_used_files $aUnit false]
2186 foreach s $src_files {
2187 regexp {source ([^\s]+)} $s dummy name
2188 lappend aSrcFiles $name
2190 foreach aSrcFile $aSrcFiles {
2191 set aFileExtension [file extension $aSrcFile]
2192 if { $aFileExtension == ".cxx" } {
2193 set aPrjName [file rootname $aSrcFile]
2194 set aDependencies [list]
2195 if {[file isdirectory $path/src/$aUnitLoc]} {
2196 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
2198 set anActiveState ""
2199 if { $isActiveSet == 0 } {
2200 set anActiveState " active=\"1\""
2203 if { [llength $aDependencies] == 0 } {
2204 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
2206 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
2207 foreach aDepTk $aDependencies {
2208 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2210 puts $aFile "\t\t</Project>"
2217 puts $aFile "\t</Workspace>"
2218 puts $aFile "</CodeBlocks_workspace_file>"
2224 # Generate Code::Blocks project file for Executable
2225 proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
2227 set aWokArch "$::env(ARCH)"
2230 foreach aSrcFile [osutils:tk:cxxfiles $theToolKit $thePlatform] {
2231 # collect list of referred libraries to link with
2232 set aUsedLibs [list]
2233 set aFrameworks [list]
2234 set anIncPaths [list]
2235 set aTKDefines [list]
2236 set aTKSrcFiles [list]
2237 set aProjName [file rootname [file tail $aSrcFile]]
2239 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2241 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2242 foreach tkx $aDepToolkits {
2243 if {[_get_type $tkx] == "t"} {
2244 lappend aUsedLibs "${tkx}"
2246 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2247 lappend aUsedLibs "${tkx}"
2251 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2252 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2253 set isExecutable "false"
2255 set isExecutable "true"
2258 if { ![info exists written([file tail $aSrcFile])] } {
2259 set written([file tail $aSrcFile]) 1
2260 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2262 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2265 # macros for correct DLL exports
2266 # if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2267 # lappend aTKDefines "__${theToolKit}_DLL"
2270 # common include paths
2271 lappend anIncPaths "../../../inc"
2273 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2279 # This function intended to generate Code::Blocks project file
2280 # @param theCmpl - the compiler (gcc or msvc)
2281 # @param theOutDir - output directory to place project file
2282 # @param theProjName - project name
2283 # @param theSrcFiles - list of source files
2284 # @param theLibsList - dependencies (libraries list)
2285 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2286 # @param theIncPaths - header search paths
2287 # @param theDefines - compiler macro definitions
2288 # @param theIsExe - flag to indicate executable / library target
2289 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2290 set aWokArch "$::env(ARCH)"
2293 set aCmplFlags [list]
2294 set aCmplFlagsRelease [list]
2295 set aCmplFlagsDebug [list]
2296 set toPassArgsByFile 0
2297 set aLibPrefix "lib"
2298 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" || "$thePlatform" == "qnx" } {
2299 set toPassArgsByFile 1
2301 if { "$theCmpl" == "msvc" } {
2302 set aCmplCbp "msvc8"
2306 if { "$theCmpl" == "msvc" } {
2307 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2308 set aCmplFlagsRelease "-MD -O2"
2309 set aCmplFlagsDebug "-MDd -Od -Zi"
2310 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2311 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2312 } elseif { "$theCmpl" == "gcc" } {
2313 if { "$thePlatform" != "qnx" } {
2314 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2316 set aCmplFlagsRelease "-O2"
2317 set aCmplFlagsDebug "-O0 -g"
2318 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2319 lappend aCmplFlags "-std=gnu++0x"
2320 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2322 lappend aCmplFlags "-std=c++0x"
2323 lappend aCmplFlags "-fPIC"
2324 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2326 lappend aCmplFlags "-Wall"
2327 lappend aCmplFlags "-fexceptions"
2329 lappend aCmplFlagsRelease "-DNDEBUG"
2330 lappend aCmplFlagsRelease "-DNo_Exception"
2331 lappend aCmplFlagsDebug "-D_DEBUG"
2332 if { "$thePlatform" == "qnx" } {
2333 lappend aCmplFlags "-D_QNX_SOURCE"
2336 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2337 set aLnkFileName "${theProjName}_obj.link"
2338 set aLnkDebFileName "${theProjName}_objd.link"
2339 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2340 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2341 set aFile [open $aCbpFilePath "w"]
2342 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2343 puts $aFile "<CodeBlocks_project_file>"
2344 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2345 puts $aFile "\t<Project>"
2346 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2347 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2348 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2349 puts $aFile "\t\t<Build>"
2351 # Release target configuration
2352 puts $aFile "\t\t\t<Target title=\"Release\">"
2353 if { "$theIsExe" == "true" } {
2354 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2355 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2357 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2358 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${thePlatform}/cbp/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2360 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2362 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2364 puts $aFile "\t\t\t\t<Option object_output=\"../../../${thePlatform}/cbp/obj\" />"
2365 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2366 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2367 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2368 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2370 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2373 # compiler options per TARGET (including defines)
2374 puts $aFile "\t\t\t\t<Compiler>"
2375 foreach aFlagIter $aCmplFlagsRelease {
2376 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2378 foreach aMacro $theDefines {
2379 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2381 puts $aFile "\t\t\t\t</Compiler>"
2383 puts $aFile "\t\t\t\t<Linker>"
2384 if { $toPassArgsByFile == 1 } {
2385 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2387 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${thePlatform}/cbp/lib\" />"
2388 if { "$thePlatform" == "mac" } {
2389 if { [ lsearch $theLibsList X11 ] >= 0} {
2390 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2393 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2394 if { "$thePlatform" == "lin" } {
2395 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${thePlatform}/cbp/lib\" />"
2397 puts $aFile "\t\t\t\t</Linker>"
2399 puts $aFile "\t\t\t</Target>"
2401 # Debug target configuration
2402 puts $aFile "\t\t\t<Target title=\"Debug\">"
2403 if { "$theIsExe" == "true" } {
2404 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2405 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2407 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2408 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${thePlatform}/cbp/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2410 puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2412 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2414 puts $aFile "\t\t\t\t<Option object_output=\"../../../${thePlatform}/cbp/objd\" />"
2415 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2416 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2417 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2418 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2420 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2423 # compiler options per TARGET (including defines)
2424 puts $aFile "\t\t\t\t<Compiler>"
2425 foreach aFlagIter $aCmplFlagsDebug {
2426 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2428 foreach aMacro $theDefines {
2429 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2431 puts $aFile "\t\t\t\t</Compiler>"
2433 puts $aFile "\t\t\t\t<Linker>"
2434 if { $toPassArgsByFile == 1 } {
2435 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2437 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${thePlatform}/cbp/libd\" />"
2438 if { "$thePlatform" == "mac" } {
2439 if { [ lsearch $theLibsList X11 ] >= 0} {
2440 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2443 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2444 if { "$thePlatform" == "lin" } {
2445 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${thePlatform}/cbp/libd\" />"
2447 puts $aFile "\t\t\t\t</Linker>"
2449 puts $aFile "\t\t\t</Target>"
2451 puts $aFile "\t\t</Build>"
2453 # COMMON compiler options
2454 puts $aFile "\t\t<Compiler>"
2455 foreach aFlagIter $aCmplFlags {
2456 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2458 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2459 foreach anIncPath $theIncPaths {
2460 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2462 puts $aFile "\t\t</Compiler>"
2464 # COMMON linker options
2465 puts $aFile "\t\t<Linker>"
2466 if { "$thePlatform" == "wnt" && "$theCmpl" == "gcc" } {
2467 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2469 foreach aFrameworkName $theFrameworks {
2470 if { "$aFrameworkName" != "" } {
2471 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2474 foreach aLibName $theLibsList {
2475 if { "$aLibName" != "" } {
2476 if { "$theCmpl" == "msvc" } {
2477 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2479 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2483 puts $aFile "\t\t</Linker>"
2489 set isFirstSrcFile 1
2490 if { $toPassArgsByFile == 1 } {
2491 set aFileLnkObj [open $aLnkFilePath "w"]
2492 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2495 foreach aSrcFile $theSrcFiles {
2496 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2497 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2498 puts $aFile "\t\t\t<Option compile=\"1\" />"
2499 puts $aFile "\t\t\t<Option link=\"1\" />"
2500 puts $aFile "\t\t</Unit>"
2501 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2502 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2503 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2504 puts $aFile "\t\t</Unit>"
2505 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2506 # pass at list single source file to Code::Blocks as is
2507 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2508 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2509 puts $aFile "\t\t\t<Option link=\"0\" />"
2510 puts $aFile "\t\t</Unit>"
2512 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$thePlatform/cbp/obj/src/"] $aSrcFile]]
2513 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$thePlatform/cbp/objd/src/"] $aSrcFile]]
2514 puts -nonewline $aFileLnkObj "$aFileObj "
2515 puts -nonewline $aFileLnkObjd "$aFileObjd "
2517 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2518 set isFirstSrcFile 0
2522 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2527 puts $aFile "\t</Project>"
2528 puts $aFile "</CodeBlocks_project_file>"
2531 return $aCbpFilePath
2534 # Define libraries to link using only EXTERNLIB file
2535 proc LibToLinkX {thePackage theDummyName} {
2536 set aToolKits [LibToLink $thePackage]
2540 # Function to generate Xcode workspace and project files
2541 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2543 puts stderr "Generating project files for Xcode"
2545 # Generate projects for toolkits and separate workspace for each module
2546 foreach aModule $theModules {
2547 OS:xcworkspace $aModule $aModule $theOutDir
2548 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2551 # Generate single workspace "OCCT" containing projects from all modules
2552 if { "$theAllSolution" != "" } {
2553 OS:xcworkspace $theAllSolution $theModules $theOutDir
2557 # Generates toolkits sections for Xcode workspace file.
2558 proc OS:xcworkspace:toolkits { theModule } {
2561 # Adding toolkits for module in workspace.
2562 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2563 append aBuff " <FileRef\n"
2564 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2565 append aBuff " </FileRef>\n"
2568 # Adding executables for module, assume one project per cxx file...
2569 foreach aUnit [OS:executable ${theModule}] {
2571 set src_files [_get_used_files $aUnit false]
2573 foreach s $src_files {
2574 regexp {source ([^\s]+)} $s dummy name
2575 lappend aSrcFiles $name
2577 foreach aSrcFile $aSrcFiles {
2578 set aFileExtension [file extension $aSrcFile]
2579 if { $aFileExtension == ".cxx" } {
2580 set aPrjName [file rootname $aSrcFile]
2581 append aBuff " <FileRef\n"
2582 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2583 append aBuff " </FileRef>\n"
2588 # Removing unnecessary newline character from the end.
2589 set aBuff [string replace $aBuff end end]
2593 # Generates workspace files for Xcode.
2594 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2595 # Creating workspace directory for Xcode.
2596 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2597 wokUtils:FILES:mkdir $aWorkspaceDir
2598 if { ! [file exists $aWorkspaceDir] } {
2599 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2603 # Creating workspace file.
2604 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2605 set aFile [open $aWsFilePath "w"]
2607 # Adding header and section for main Group.
2608 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2609 puts $aFile "<Workspace"
2610 puts $aFile " version = \"1.0\">"
2611 puts $aFile " <Group"
2612 puts $aFile " location = \"container:\""
2613 puts $aFile " name = \"${theWorkspaceName}\">"
2616 if { [llength "$theModules"] > 1 } {
2617 foreach aModule $theModules {
2618 puts $aFile " <Group"
2619 puts $aFile " location = \"container:\""
2620 puts $aFile " name = \"${aModule}\">"
2621 puts $aFile [OS:xcworkspace:toolkits $aModule]
2622 puts $aFile " </Group>"
2625 puts $aFile [OS:xcworkspace:toolkits $theModules]
2629 puts $aFile " </Group>"
2630 puts $aFile "</Workspace>"
2634 # Generates Xcode project files.
2635 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2636 upvar $theGuidsMap aGuidsMap
2639 if { "$theLibType" == "static" } {
2641 } elseif { "$thePlatform" == "ios" } {
2645 set aProjectFiles {}
2646 foreach aModule $theModules {
2647 foreach aToolKit [${aModule}:toolkits] {
2648 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2650 foreach anExecutable [OS:executable ${aModule}] {
2651 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2654 return $aProjectFiles
2657 # Generates dependencies section for Xcode project files.
2658 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
2659 upvar $theGuidsMap aGuidsMap
2660 upvar $theFileRefSection aFileRefSection
2661 upvar $theDepsGuids aDepsGuids
2662 upvar $theDepsRefGuids aDepsRefGuids
2664 set aBuildFileSection ""
2665 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2666 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2668 if { "$theTargetType" == "executable" } {
2669 set aFile [osutils:tk:cxxfiles $theToolKit mac]
2670 set aProjName [file rootname [file tail $aFile]]
2671 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2675 if { $theIsStatic == 1 } {
2677 if { "$theTargetType" != "executable" } {
2678 return $aBuildFileSection
2682 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
2683 set aUsedLibs [concat $aUsedLibs $aLibs]
2684 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2685 foreach tkx $aUsedLibs {
2686 set aDepLib "${tkx}_Dep"
2687 set aDepLibRef "${tkx}_DepRef"
2689 if { ! [info exists aGuidsMap($aDepLib)] } {
2690 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2692 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2693 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2696 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2697 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2698 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2700 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2702 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2703 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2706 return $aBuildFileSection
2709 # Generates PBXBuildFile and PBXGroup sections for project file.
2710 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2711 upvar $theSrcFileRefSection aSrcFileRefSection
2712 upvar $theGroupSection aGroupSection
2713 upvar $thePackageGuids aPackagesGuids
2714 upvar $theSrcFileGuids aSrcFileGuids
2715 upvar $theGuidsMap aGuidsMap
2716 upvar $theIncPaths anIncPaths
2718 set listloc [osutils:tk:units $theToolKit]
2719 set resultloc [osutils:justunix $listloc]
2720 set aBuildFileSection ""
2721 set aPackages [lsort -nocase $resultloc]
2722 if { "$theTargetType" == "executable" } {
2723 set aPackages [list "$theToolKit"]
2726 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2727 foreach fxlo $aPackages {
2729 set aPackage "${xlo}_Package"
2730 set aSrcFileRefGuids ""
2731 if { ! [info exists aGuidsMap($aPackage)] } {
2732 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2735 set aSrcFiles [osutils:tk:cxxfiles $xlo mac]
2736 foreach aSrcFile [lsort $aSrcFiles] {
2737 set aFileExt "sourcecode.cpp.cpp"
2739 if { [file extension $aSrcFile] == ".c" } {
2740 set aFileExt "sourcecode.c.c"
2741 } elseif { [file extension $aSrcFile] == ".mm" } {
2742 set aFileExt "sourcecode.cpp.objcpp"
2745 if { ! [info exists aGuidsMap($aSrcFile)] } {
2746 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2748 set aSrcFileRef "${aSrcFile}_Ref"
2749 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2750 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2752 if { ! [info exists written([file tail $aSrcFile])] } {
2753 set written([file tail $aSrcFile]) 1
2754 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2755 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"
2756 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2757 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2759 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2763 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2764 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2765 append aGroupSection "\t\t\tchildren = (\n"
2766 append aGroupSection $aSrcFileRefGuids
2767 append aGroupSection "\t\t\t);\n"
2768 append aGroupSection "\t\t\tname = $xlo;\n"
2769 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2770 append aGroupSection "\t\t\};\n"
2772 # Storing packages IDs for adding them later as a child of toolkit
2773 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2776 # Removing unnecessary newline character from the end.
2777 set aPackagesGuids [string replace $aPackagesGuids end end]
2779 return $aBuildFileSection
2782 # Creates folders structure and all necessary files for Xcode project.
2783 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2784 set aPBXBuildPhase "Headers"
2785 set aRunOnlyForDeployment "0"
2786 set aProductType "library.dynamic"
2787 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2788 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2789 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2790 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2791 if { $theIsStatic == 1 } {
2792 lappend aTKDefines "OCCT_NO_PLUGINS"
2795 if { "$theTargetType" == "executable" } {
2796 set aPBXBuildPhase "CopyFiles"
2797 set aRunOnlyForDeployment "1"
2798 set aProductType "tool"
2799 set anExecExtension ""
2801 set aWrapperExtension ""
2802 } elseif { $theIsStatic == 1 } {
2803 set aProductType "library.static"
2804 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2805 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2808 set aUsername [exec whoami]
2810 # Creation of folders for Xcode projectP.
2811 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2812 wokUtils:FILES:mkdir $aToolkitDir
2813 if { ! [file exists $aToolkitDir] } {
2814 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2818 set aUserDataDir "${aToolkitDir}/xcuserdata"
2819 wokUtils:FILES:mkdir $aUserDataDir
2820 if { ! [file exists $aUserDataDir] } {
2821 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2825 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2826 wokUtils:FILES:mkdir $aUserDataDir
2827 if { ! [file exists $aUserDataDir] } {
2828 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2832 set aSchemesDir "${aUserDataDir}/xcschemes"
2833 wokUtils:FILES:mkdir $aSchemesDir
2834 if { ! [file exists $aSchemesDir] } {
2835 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2838 # End of folders creation.
2840 # Generating GUID for tookit.
2841 upvar $theGuidsMap aGuidsMap
2842 if { ! [info exists aGuidsMap($theToolKit)] } {
2843 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2846 # Creating xcscheme file for toolkit from template.
2847 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2848 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2849 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2850 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2851 puts $aXcschemeFile $aXcschemeTmpl
2852 close $aXcschemeFile
2854 # Creating xcschememanagement.plist file for toolkit from template.
2855 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2856 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2857 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2858 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2859 puts $aPlistFile $aPlistTmpl
2862 # Creating project.pbxproj file for toolkit.
2863 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2864 puts $aPbxprojFile "// !\$*UTF8*\$!"
2865 puts $aPbxprojFile "\{"
2866 puts $aPbxprojFile "\tarchiveVersion = 1;"
2867 puts $aPbxprojFile "\tclasses = \{"
2868 puts $aPbxprojFile "\t\};"
2869 puts $aPbxprojFile "\tobjectVersion = 46;"
2870 puts $aPbxprojFile "\tobjects = \{\n"
2872 # Begin PBXBuildFile section
2873 set aPackagesGuids ""
2874 set aGroupSection ""
2875 set aSrcFileRefSection ""
2876 set aSrcFileGuids ""
2877 set aDepsFileRefSection ""
2879 set aDepsRefGuids ""
2880 set anIncPaths [list "../../../inc"]
2883 if { [info exists ::env(CSF_OPT_INC)] } {
2884 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2885 foreach anIncCfgPath $anIncCfg {
2886 lappend anIncPaths $anIncCfgPath
2889 if { [info exists ::env(CSF_OPT_LIB64)] } {
2890 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2891 foreach anLibCfgPath $anLibCfg {
2892 lappend anLibPaths $anLibCfgPath
2896 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2897 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2898 # End PBXBuildFile section
2900 # Begin PBXFileReference section
2901 set aToolkitLib "lib${theToolKit}.dylib"
2902 set aPath "$aToolkitLib"
2903 if { "$theTargetType" == "executable" } {
2904 set aPath "$theToolKit"
2905 } elseif { $theIsStatic == 1 } {
2906 set aToolkitLib "lib${theToolKit}.a"
2909 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2910 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2913 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2914 puts $aPbxprojFile $aSrcFileRefSection
2915 puts $aPbxprojFile $aDepsFileRefSection
2916 # End PBXFileReference section
2919 # Begin PBXFrameworksBuildPhase section
2920 set aTkFrameworks "${theToolKit}_Frameworks"
2921 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2922 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2925 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2926 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2927 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2928 puts $aPbxprojFile "\t\t\tfiles = ("
2929 puts $aPbxprojFile $aDepsGuids
2930 puts $aPbxprojFile "\t\t\t);"
2931 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2932 puts $aPbxprojFile "\t\t\};\n"
2933 # End PBXFrameworksBuildPhase section
2935 # Begin PBXGroup section
2936 set aTkPBXGroup "${theToolKit}_PBXGroup"
2937 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2938 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2941 set aTkSrcGroup "${theToolKit}_SrcGroup"
2942 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2943 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2946 puts $aPbxprojFile $aGroupSection
2947 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2948 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2949 puts $aPbxprojFile "\t\t\tchildren = ("
2950 puts $aPbxprojFile $aDepsRefGuids
2951 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2952 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2953 puts $aPbxprojFile "\t\t\t);"
2954 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2955 puts $aPbxprojFile "\t\t\};"
2956 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2957 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2958 puts $aPbxprojFile "\t\t\tchildren = ("
2959 puts $aPbxprojFile $aPackagesGuids
2960 puts $aPbxprojFile "\t\t\t);"
2961 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2962 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2963 puts $aPbxprojFile "\t\t\};\n"
2964 # End PBXGroup section
2966 # Begin PBXHeadersBuildPhase section
2967 set aTkHeaders "${theToolKit}_Headers"
2968 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2969 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2972 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2973 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2974 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2975 puts $aPbxprojFile "\t\t\tfiles = ("
2976 puts $aPbxprojFile "\t\t\t);"
2977 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2978 puts $aPbxprojFile "\t\t\};\n"
2979 # End PBXHeadersBuildPhase section
2981 # Begin PBXNativeTarget section
2982 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2983 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2984 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2987 set aTkSources "${theToolKit}_Sources"
2988 if { ! [info exists aGuidsMap($aTkSources)] } {
2989 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2992 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2993 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2994 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2995 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2996 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2997 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2998 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2999 puts $aPbxprojFile "\t\t\t);"
3000 puts $aPbxprojFile "\t\t\tbuildRules = ("
3001 puts $aPbxprojFile "\t\t\t);"
3002 puts $aPbxprojFile "\t\t\tdependencies = ("
3003 puts $aPbxprojFile "\t\t\t);"
3004 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
3005 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
3006 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
3007 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
3008 puts $aPbxprojFile "\t\t\};\n"
3009 # End PBXNativeTarget section
3011 # Begin PBXProject section
3012 set aTkProjectObj "${theToolKit}_ProjectObj"
3013 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
3014 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
3017 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
3018 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
3019 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
3022 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
3023 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
3024 puts $aPbxprojFile "\t\t\tattributes = \{"
3025 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
3026 puts $aPbxprojFile "\t\t\t\};"
3027 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
3028 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
3029 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
3030 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
3031 puts $aPbxprojFile "\t\t\tknownRegions = ("
3032 puts $aPbxprojFile "\t\t\t\ten,"
3033 puts $aPbxprojFile "\t\t\t);"
3034 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
3035 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
3036 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
3037 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
3038 puts $aPbxprojFile "\t\t\ttargets = ("
3039 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
3040 puts $aPbxprojFile "\t\t\t);"
3041 puts $aPbxprojFile "\t\t\};\n"
3042 # End PBXProject section
3044 # Begin PBXSourcesBuildPhase section
3045 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
3046 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
3047 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3048 puts $aPbxprojFile "\t\t\tfiles = ("
3049 puts $aPbxprojFile $aSrcFileGuids
3050 puts $aPbxprojFile "\t\t\t);"
3051 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3052 puts $aPbxprojFile "\t\t\};\n"
3053 # End PBXSourcesBuildPhase section
3055 # Begin XCBuildConfiguration section
3056 set aTkDebugProject "${theToolKit}_DebugProject"
3057 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
3058 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
3061 set aTkReleaseProject "${theToolKit}_ReleaseProject"
3062 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
3063 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
3066 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
3067 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
3068 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
3071 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
3072 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
3073 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
3077 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
3078 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3079 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3081 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
3082 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3083 if { "$thePlatform" == "ios" } {
3084 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3085 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3086 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3087 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3089 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3090 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3091 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
3092 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
3093 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3094 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
3095 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3096 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
3097 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3098 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
3099 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
3100 puts $aPbxprojFile "\t\t\t\t);"
3101 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
3102 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3103 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3104 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3105 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3106 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3107 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
3108 if { "$thePlatform" == "ios" } {
3109 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
3110 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3112 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
3114 puts $aPbxprojFile "\t\t\t\};"
3116 puts $aPbxprojFile "\t\t\tname = Debug;"
3117 puts $aPbxprojFile "\t\t\};"
3120 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
3121 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3122 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3124 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
3125 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3126 if { "$thePlatform" == "ios" } {
3127 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3128 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3129 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3130 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3132 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3133 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3134 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
3135 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
3136 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3137 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3138 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
3139 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
3140 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3141 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3142 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3143 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3144 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3145 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
3146 if { "$thePlatform" == "ios" } {
3147 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
3148 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3150 puts $aPbxprojFile "\t\t\t\};"
3151 puts $aPbxprojFile "\t\t\tname = Release;"
3152 puts $aPbxprojFile "\t\t\};"
3153 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
3154 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3155 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3156 puts $aPbxprojFile "${anExecExtension}"
3157 puts $aPbxprojFile "${anExecPrefix}"
3158 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3159 foreach aMacro $aTKDefines {
3160 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3162 puts $aPbxprojFile "\t\t\t\t);"
3164 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3165 foreach anIncPath $anIncPaths {
3166 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3168 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3169 puts $aPbxprojFile "\t\t\t\t);"
3171 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3172 foreach anLibPath $anLibPaths {
3173 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3175 puts $aPbxprojFile "\t\t\t\t);"
3177 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3178 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3179 puts $aPbxprojFile "\t\t\t\t);"
3180 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3181 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3182 puts $aPbxprojFile "\t\t\t\t);"
3183 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3184 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
3185 foreach anIncPath $anIncPaths {
3186 append anUserHeaderSearchPath " ${anIncPath}"
3188 append anUserHeaderSearchPath "\";"
3189 puts $aPbxprojFile $anUserHeaderSearchPath
3190 puts $aPbxprojFile "${aWrapperExtension}"
3191 puts $aPbxprojFile "\t\t\t\};"
3192 puts $aPbxprojFile "\t\t\tname = Debug;"
3193 puts $aPbxprojFile "\t\t\};"
3194 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
3195 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3196 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3197 puts $aPbxprojFile "${anExecExtension}"
3198 puts $aPbxprojFile "${anExecPrefix}"
3199 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3200 foreach aMacro $aTKDefines {
3201 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3203 puts $aPbxprojFile "\t\t\t\t);"
3204 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3205 foreach anIncPath $anIncPaths {
3206 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3208 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3209 puts $aPbxprojFile "\t\t\t\t);"
3211 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3212 foreach anLibPath $anLibPaths {
3213 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3215 puts $aPbxprojFile "\t\t\t\t);"
3217 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3218 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3219 puts $aPbxprojFile "\t\t\t\t);"
3220 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3221 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3222 puts $aPbxprojFile "\t\t\t\t);"
3223 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3224 puts $aPbxprojFile $anUserHeaderSearchPath
3225 puts $aPbxprojFile "${aWrapperExtension}"
3226 puts $aPbxprojFile "\t\t\t\};"
3227 puts $aPbxprojFile "\t\t\tname = Release;"
3228 puts $aPbxprojFile "\t\t\};\n"
3229 # End XCBuildConfiguration section
3231 # Begin XCConfigurationList section
3232 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3233 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3234 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3235 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3236 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3237 puts $aPbxprojFile "\t\t\t);"
3238 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3239 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3240 puts $aPbxprojFile "\t\t\};"
3241 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3242 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3243 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3244 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3245 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3246 puts $aPbxprojFile "\t\t\t);"
3247 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3248 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3249 puts $aPbxprojFile "\t\t\};\n"
3250 # End XCConfigurationList section
3252 puts $aPbxprojFile "\t\};"
3253 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3254 puts $aPbxprojFile "\}"
3259 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3260 set aUsername [exec whoami]
3262 # Creating folders for Xcode project file.
3263 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3264 wokUtils:FILES:mkdir $anExecutableDir
3265 if { ! [file exists $anExecutableDir] } {
3266 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3270 set aUserDataDir "${anExecutableDir}/xcuserdata"
3271 wokUtils:FILES:mkdir $aUserDataDir
3272 if { ! [file exists $aUserDataDir] } {
3273 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3277 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3278 wokUtils:FILES:mkdir $aUserDataDir
3279 if { ! [file exists $aUserDataDir] } {
3280 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3284 set aSchemesDir "${aUserDataDir}/xcschemes"
3285 wokUtils:FILES:mkdir $aSchemesDir
3286 if { ! [file exists $aSchemesDir] } {
3287 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3290 # End folders creation.
3292 # Generating GUID for tookit.
3293 upvar $theGuidsMap aGuidsMap
3294 if { ! [info exists aGuidsMap($theExecutable)] } {
3295 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3298 # Creating xcscheme file for toolkit from template.
3299 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3300 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3301 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3302 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3303 puts $aXcschemeFile $aXcschemeTmpl
3304 close $aXcschemeFile
3306 # Creating xcschememanagement.plist file for toolkit from template.
3307 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3308 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3309 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3310 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3311 puts $aPlistFile $aPlistTmpl
3315 # Returns available Windows SDKs versions
3316 proc osutils:sdk { theSdkMajorVer {isQuietMode false} {theSdkDirectories {}} } {
3317 if { ![llength ${theSdkDirectories}] } {
3318 foreach anEnvVar { "ProgramFiles" "ProgramFiles\(x86\)" "ProgramW6432" } {
3319 if {[ info exists ::env(${anEnvVar}) ]} {
3320 lappend theSdkDirectories "$::env(${anEnvVar})/Windows Kits/${theSdkMajorVer}/Include"
3326 foreach sdk_dir ${theSdkDirectories} {
3327 if { [file isdirectory ${sdk_dir}] } {
3328 lappend sdk_versions [glob -tails -directory "${sdk_dir}" -type d *]
3332 if {![llength ${sdk_versions}] && !${isQuietMode}} {
3333 error "Error : Could not find Windows SDK ${theSdkMajorVer}"
3336 return [join [lsort -unique ${sdk_versions}] " "]
3339 # Generate global properties to Visual Studio project file for UWP solution
3340 proc osutils:uwp:proj { isUWP theProjTmpl } {
3342 set uwp_properties ""
3343 set uwp_generate_metadata ""
3344 set uwp_app_container ""
3346 set format_template ""
3349 set sdk_versions [osutils:sdk 10]
3350 set sdk_max_ver [lindex ${sdk_versions} end]
3352 set uwp_properties "<DefaultLanguage>en-US</DefaultLanguage>\n \
3353 <ApplicationType>Windows Store</ApplicationType>\n \
3354 <ApplicationTypeRevision>10.0</ApplicationTypeRevision>\n \
3355 <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n \
3356 <AppContainerApplication>true</AppContainerApplication>\n \
3357 <WindowsTargetPlatformVersion>${sdk_max_ver}</WindowsTargetPlatformVersion>\n \
3358 <WindowsTargetPlatformMinVersion>${sdk_max_ver}</WindowsTargetPlatformMinVersion>"
3360 set uwp_generate_metadata "<GenerateWindowsMetadata>false</GenerateWindowsMetadata>"
3362 regsub -all -- {[\r\n\s]*<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>} ${theProjTmpl} "" theProjTmpl
3364 set format_template "\[\\r\\n\\s\]*"
3367 regsub -all -- "${format_template}__UWP_PROPERTIES__" ${theProjTmpl} "${uwp_properties}" theProjTmpl
3368 regsub -all -- "${format_template}__UWP_GENERATE_METADATA__" ${theProjTmpl} "${uwp_generate_metadata}" theProjTmpl
3370 return ${theProjTmpl}
3373 # Report all files found in package directory but not listed in FILES
3374 proc osutils:checksrcfiles { theUnit } {
3376 set aCasRoot [file normalize ${path}]
3378 if {![file isdirectory ${aCasRoot}]} {
3379 puts "OCCT directory is not defined correctly: ${aCasRoot}"
3383 set anUnitAbsPath [file normalize "${aCasRoot}/src/${theUnit}"]
3385 if {[file exists "${anUnitAbsPath}/FILES"]} {
3386 set aFilesFile [open "${anUnitAbsPath}/FILES" rb]
3387 set aFilesFileList [split [read ${aFilesFile}] "\n"]
3390 set aFilesFileList [lsearch -inline -all -not -exact ${aFilesFileList} ""]
3392 # report all files not listed in FILES
3393 set anAllFiles [glob -tails -nocomplain -dir ${anUnitAbsPath} "*"]
3394 foreach aFile ${anAllFiles} {
3395 if { "${aFile}" == "FILES" } {
3398 if { [lsearch -exact ${aFilesFileList} ${aFile}] == -1 } {
3399 puts "Warning: file ${anUnitAbsPath}/${aFile} is not listed in ${anUnitAbsPath}/FILES!"