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" "vc142" "vclang" "cbp" "xcd" "pro"}
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 for {set anArgIter 0} {$anArgIter < [llength args]} {incr anArgIter} {
289 set arg [lindex $args $anArgIter]
292 } elseif { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
293 set isHelpRequire true
294 } elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
296 } elseif { $arg == "-static" } {
297 set aLibType "static"
298 puts "Static build has been selected"
299 } elseif { $arg == "-dynamic" } {
300 set aLibType "dynamic"
301 puts "Dynamic build has been selected"
302 } elseif { $arg == "-solution" } {
304 set aSolution [lindex $args $anArgIter]
306 puts "Error: genproj: unrecognized option \"$arg\""
307 set isHelpRequire true
311 if { $isHelpRequire == true } {
312 puts "usage: genproj Format \[Platform\] \[-static\] \[-h|-help|--help\]
314 Format must be one of:
315 vc8 - Visual Studio 2005
316 vc9 - Visual Studio 2008
317 vc10 - Visual Studio 2010
318 vc11 - Visual Studio 2012
319 vc12 - Visual Studio 2013
320 vc14 - Visual Studio 2015
321 vc141 - Visual Studio 2017
322 vc142 - Visual Studio 2019
323 vclang - Visual Studio with ClangCL toolset
329 wnt - Windows Desktop
330 uwp - Universal Windows Platform
336 Option -static can be used with XCode to build static libraries
341 if { ! [info exists aPlatform] } {
342 puts "Error: genproj: Cannon identify default platform, please specify!"
346 puts "Preparing to generate $theFormat projects for $aPlatform platform..."
348 # base path to where to generate projects, hardcoded from current dir
349 set anAdmPath [file normalize "${::path}/adm"]
351 OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl" "$aSolution"
353 genprojbat "$theFormat" "$aPlatform" "$aSolution"
357 # copy file providing warning if the target file exists and has
358 # different date or size; if it is newer than source, save it as .bak
359 proc copy_with_warning {from to} {
360 if { [file exists "$to"] &&
361 ([file size "$to"] != [file size "$from"] ||
362 [file mtime "$to"] != [file mtime "$from"]) } {
363 puts "Warning: file $to is updated (copied from $from)!"
364 if { [file mtime $to] > [file mtime $from] } {
365 puts "Info: old content of file $to is saved in ${to}.bak"
366 file copy -force -- "$to" "${to}.bak"
370 file copy -force -- "$from" "$to"
373 # Generate auxiliary scripts for launching IDE.
374 proc genprojbat {theFormat thePlatform theSolution} {
375 set aTargetPlatformExt sh
376 if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
377 set aTargetPlatformExt bat
380 if {"$theFormat" != "cmake"} {
381 # copy env.bat/sh only if not yet present
382 if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
383 set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
384 set anEnvTmpl [read $anEnvTmplFile]
388 if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
389 set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
392 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
394 set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
395 puts $anEnvFile $anEnvTmpl
399 copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
403 if { [regexp {^vc} $theFormat] } {
404 set aSolShList "msvc.bat"
406 switch -exact -- "$theFormat" {
408 set aSolShList { "codeblocks.sh" "codeblocks.bat" }
409 # Code::Blocks 16.01 does not create directory for import libs, help him
410 set aPlatformAndCompiler "${thePlatform}/gcc"
411 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
412 set aPlatformAndCompiler "${thePlatform}/clang"
414 file mkdir "$::path/${aPlatformAndCompiler}/lib"
415 file mkdir "$::path/${aPlatformAndCompiler}/libd"
417 "xcd" { set aSolShList "xcode.sh" }
421 foreach aSolSh $aSolShList {
422 set anShFile [open "$::THE_CASROOT/adm/templates/${aSolSh}" "r"]
423 set anShTmpl [read $anShFile]
426 regsub -all -- {__SOLUTION__} $anShTmpl "$theSolution" anShTmpl
428 set anShFile [open "$::path/${aSolSh}" "w"]
429 puts $anShFile $anShTmpl
434 ###### MSVC #############################################################33
435 proc removeAllOccurrencesOf { theObject theList } {
436 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
437 foreach anIndex $aSortIndices {
438 set theList [lreplace $theList $anIndex $anIndex]
443 set aTKNullKey "TKNull"
444 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
446 # Entry function to generate project files
447 # @param theOutDir Root directory for project files
448 # @param theFormat Project format name (vc.. for Visual Studio projects, cbp for Code::Blocks, xcd for XCode)
449 # @param theLibType Library type - dynamic or static
450 # @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
451 # @param theCmpl Compiler option (msvc or gcc)
452 # @param theSolution Solution name
453 proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution } {
455 set anOutRoot $theOutDir
456 if { $anOutRoot == "" } {
457 error "Error : \"theOutDir\" is not initialized"
460 # Create output directory
461 set aWokStation "$thePlatform"
462 if { [regexp {^vc} $theFormat] } {
463 set aWokStation "msvc"
467 if { $thePlatform == "uwp" } {
471 set anOutDir "${anOutRoot}/${aWokStation}/${theFormat}${aSuffix}"
473 # read map of already generated GUIDs
474 set aGuidsFilePath [file join $anOutDir "wok_${theFormat}_guids.txt"]
475 if [file exists "$aGuidsFilePath"] {
476 set aFileIn [open "$aGuidsFilePath" r]
477 set aFileDataRaw [read $aFileIn]
479 set aFileData [split $aFileDataRaw "\n"]
480 foreach aLine $aFileData {
481 set aLineSplt [split $aLine "="]
482 if { [llength $aLineSplt] == 2 } {
483 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
488 # make list of modules and platforms
489 set aModules [OS:init]
490 if { "$thePlatform" == "ios" } {
491 set goaway [list Draw]
492 set aModules [osutils:juststation $goaway $aModules]
495 # Draw module is turned off due to it is not supported on UWP
497 set aDrawIndex [lsearch -exact ${aModules} "Draw"]
498 if { ${aDrawIndex} != -1 } {
499 set aModules [lreplace ${aModules} ${aDrawIndex} ${aDrawIndex}]
503 # create the out dir if it does not exist
504 if (![file isdirectory $path/inc]) {
505 puts "$path/inc folder does not exists and will be created"
506 wokUtils:FILES:mkdir $path/inc
509 # collect all required header files
510 puts "Collecting required header files into $path/inc ..."
511 osutils:collectinc $aModules $path/inc
513 if { "$theFormat" == "pro" } {
517 wokUtils:FILES:mkdir $anOutDir
518 if { ![file exists $anOutDir] } {
519 puts stderr "Error: Could not create output directory \"$anOutDir\""
523 # Generating project files for the selected format
524 switch -exact -- "$theFormat" {
534 "vclang" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP}
535 "cbp" { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl }
537 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
538 OS:MKXCD $anOutDir $aModules $theSolution $theLibType $thePlatform
542 # Store generated GUIDs map
543 set anOutFile [open "$aGuidsFilePath" "w"]
544 fconfigure $anOutFile -translation lf
545 foreach aKey [array names ::THE_GUIDS_LIST] {
546 set aValue $::THE_GUIDS_LIST($aKey)
547 puts $anOutFile "${aKey}=${aValue}"
552 # Function to generate Visual Studio solution and project files
553 proc OS:MKVC { theOutDir theModules theAllSolution theVcVer isUWP } {
555 puts stderr "Generating VS project files for $theVcVer"
557 # generate projects for toolkits and separate solution for each module
558 foreach aModule $theModules {
559 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
560 OS:vcproj $theVcVer $isUWP $aModule $theOutDir ::THE_GUIDS_LIST
563 # generate single solution "OCCT" containing projects from all modules
564 if { "$theAllSolution" != "" } {
565 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
568 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
571 proc OS:init {{os {}}} {
575 set os $::tcl_platform(os)
578 if [file exists "$::path/src/VAS/Products.tcl"] {
579 source "$::path/src/VAS/Products.tcl"
580 foreach aModuleIter [VAS:Products] {
581 set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
582 if [file exists $aFileTcl] {
584 lappend aModules $aModuleIter
586 puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
592 # Load list of OCCT modules and their definitions
593 source "$::path/src/OS/Modules.tcl"
594 foreach aModuleIter [OS:Modules] {
595 set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
596 if [file exists $aFileTcl] {
598 lappend aModules $aModuleIter
600 puts stderr "Definition file for module $aModuleIter is not found in unit OS"
607 # topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
608 proc wokUtils:EASY:tsort { listofpairs } {
609 foreach x $listofpairs {
612 if ![info exists pcnt($e1)] {
615 if ![ info exists pcnt($e2)] {
620 if ![info exists scnt($e1)] {
626 if [info exists slist($e1)] {
634 foreach node [array names pcnt] {
636 if { $pcnt($node) == 0 } {
640 if ![info exists scnt($node)] {
645 for {set front 1} { $front <= $back } { incr front } {
646 lappend res [set node $q($front)]
647 for {set i 1} {$i <= $scnt($node) } { incr i } {
649 set j [expr {$i - 1}]
650 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
651 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
653 set q($back) [lindex $ll $j]
657 if { $back != $nodecnt } {
658 puts stderr "input contains a cycle"
665 proc wokUtils:LIST:Purge { l } {
668 if ![info exist tab($e)] {
676 # Read file pointed to by path
678 # 2. trim = 1 plusieurs blancs => 1 seul blanc
679 # 3. purge= not yet implemented.
680 # 4. emptl= dont process blank lines
681 proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
682 if ![ catch { set id [ open $path r ] } ] {
684 while {[gets $id line] >= 0 } {
686 regsub -all {[ ]+} $line " " line
689 if { [string length ${line}] != 0 } {
707 # retorn the list of executables in module.
708 proc OS:executable { module } {
710 foreach XXX [${module}:ressources] {
711 if { "[lindex $XXX 1]" == "x" } {
712 lappend lret [lindex $XXX 2]
718 # Topological sort of toolkits in tklm
719 proc osutils:tk:sort { tklm } {
721 foreach tkloc $tklm {
722 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
724 if { [lsearch $tklm $tkx] != -1 } {
725 lappend tkby2 [list $tkx $tkloc]
727 lappend tkby2 [list $tkloc {}]
732 foreach e [wokUtils:EASY:tsort $tkby2] {
740 # close dependencies of ltk. (full wok pathes of toolkits)
741 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
742 # (locate not performed.)
743 proc osutils:tk:close { ltk } {
747 set ids [LibToLink $dir]
748 # puts "osutils:tk:close($ltk) ids='$ids'"
749 set eated [osutils:tk:eatpk $ids]
750 set result [concat $result $eated]
751 set ids [LibToLink $dir]
752 set result [concat $result $ids]
754 foreach file $eated {
755 set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
756 if { [osutils:tk:eatpk $kds] != {} } {
757 lappend recurse $file
761 if { $recurse != {} } {
762 set result [concat $result [osutils:tk:close $recurse]]
767 proc osutils:tk:eatpk { EXTERNLIB } {
768 set l [wokUtils:FILES:FileToList $EXTERNLIB]
771 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
777 # Define libraries to link using only EXTERNLIB file
779 proc LibToLink {theTKit} {
780 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
781 set type [_get_type $theTKit]
782 if {$type != "t" && $type != "x"} {
786 set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
787 foreach anExtLib $anExtLibList {
788 set aFullPath [LocateRecur $anExtLib]
789 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
790 lappend aToolkits $anExtLib
795 # Search unit recursively
797 proc LocateRecur {theName} {
798 set theNamePath [osutils:findSrcSubPath "$theName"]
799 if {[file isdirectory $theNamePath]} {
805 proc OS:genGUID { {theFormat "vc"} } {
806 if { "$theFormat" == "vc" } {
807 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
808 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
809 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
810 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
811 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
812 return "{$p1-$p2-$p3-$p4-$p5}"
814 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
815 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
816 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
817 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
818 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
819 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
820 return "$p1$p2$p3$p4$p5$p6"
824 # collect all include file that required for theModules in theOutDir
825 proc osutils:collectinc {theModules theIncPath} {
827 set aCasRoot [file normalize $path]
828 set anIncPath [file normalize $theIncPath]
830 if {![file isdirectory $aCasRoot]} {
831 puts "OCCT directory is not defined correctly: $aCasRoot"
835 set anUsedToolKits {}
836 foreach aModule $theModules {
837 foreach aToolKit [${aModule}:toolkits] {
838 lappend anUsedToolKits $aToolKit
840 foreach aDependency [LibToLink $aToolKit] {
841 lappend anUsedToolKits $aDependency
844 foreach anExecutable [OS:executable ${aModule}] {
845 lappend anUsedToolKits $anExecutable
847 foreach aDependency [LibToLink $anExecutable] {
848 lappend anUsedToolKits $aDependency
852 set anUsedToolKits [lsort -unique $anUsedToolKits]
855 foreach anUsedToolKit $anUsedToolKits {
856 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
858 set anUnits [lsort -unique $anUnits]
860 # define copying style
862 if { [info exists ::env(SHORTCUT_HEADERS)] } {
863 if { [string equal -nocase $::env(SHORTCUT_HEADERS) "hard"]
864 || [string equal -nocase $::env(SHORTCUT_HEADERS) "hardlink"] } {
865 set aCopyType "hardlink"
866 } elseif { [string equal -nocase $::env(SHORTCUT_HEADERS) "true"]
867 || [string equal -nocase $::env(SHORTCUT_HEADERS) "shortcut"] } {
868 set aCopyType "shortcut"
872 set allHeaderFiles {}
873 if { $aCopyType == "shortcut" } {
874 # template preparation
875 if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
876 puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
879 set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
881 # relative anIncPath in connection with aCasRoot/src
882 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
884 # create and copy short-cut header files
885 foreach anUnit $anUnits {
886 osutils:checksrcfiles ${anUnit}
888 set aHFiles [_get_used_files ${anUnit} true false]
889 foreach aHeaderFile ${aHFiles} {
890 set aHeaderFileName [lindex ${aHeaderFile} 1]
891 lappend allHeaderFiles "${aHeaderFileName}"
893 regsub -all -- {@OCCT_HEADER_FILE_CONTENT@} $aHeaderTmpl "#include \"$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName\"" aShortCutHeaderFileContent
895 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
896 set fp [open "$theIncPath/$aHeaderFileName" r]
897 set aHeaderContent [read $fp]
901 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
903 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
904 # remove eof from string
905 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
907 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
911 file delete -force "$theIncPath/$aHeaderFileName"
914 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
915 fconfigure $aShortCutHeaderFile -translation lf
916 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
917 close $aShortCutHeaderFile
922 foreach anUnit $anUnits {
923 osutils:checksrcfiles ${anUnit}
925 set aHFiles [_get_used_files ${anUnit} true false]
926 foreach aHeaderFile ${aHFiles} {
927 set aHeaderFileName [lindex ${aHeaderFile} 1]
928 lappend allHeaderFiles "${aHeaderFileName}"
930 # copy file only if target does not exist or is older than original
931 set torig [file mtime $aCasRoot/src/$anUnit/$aHeaderFileName]
933 if { [file isfile $anIncPath/$aHeaderFileName] } {
934 set tcopy [file mtime $anIncPath/$aHeaderFileName]
936 if { $tcopy < $torig } {
938 if { $aCopyType == "hardlink" } {
940 file delete -force "$theIncPath/$aHeaderFileName"
942 file link -hard $anIncPath/$aHeaderFileName $aCasRoot/src/$anUnit/$aHeaderFileName
944 file copy -force $aCasRoot/src/$anUnit/$aHeaderFileName $anIncPath/$aHeaderFileName
946 } elseif { $tcopy != $torig } {
947 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aCasRoot/src/$anUnit/$aHeaderFileName, not changed!"
951 puts "Info: $nbcopied files updated"
954 # remove header files not listed in FILES
955 set anIncFiles [glob -tails -nocomplain -dir ${anIncPath} "*"]
956 foreach anIncFile ${anIncFiles} {
957 if { [lsearch -exact ${allHeaderFiles} ${anIncFile}] == -1 } {
958 puts "Warning: file ${anIncPath}/${anIncFile} is not present in the sources and will be removed from ${theIncPath}"
959 file delete -force "${theIncPath}/${anIncFile}"
964 # Generate header for VS solution file
965 proc osutils:vcsolution:header { vcversion } {
966 if { "$vcversion" == "vc7" } {
968 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
969 } elseif { "$vcversion" == "vc8" } {
971 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
972 "# Visual Studio 2005\n"
973 } elseif { "$vcversion" == "vc9" } {
975 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
976 "# Visual Studio 2008\n"
977 } elseif { "$vcversion" == "vc10" } {
979 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
980 "# Visual Studio 2010\n"
981 } elseif { "$vcversion" == "vc11" } {
983 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
984 "# Visual Studio 2012\n"
985 } elseif { "$vcversion" == "vc12" } {
987 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
988 "# Visual Studio 2013\n"
989 } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" ||
990 "$vcversion" == "vc142" || "$vcversion" == "vclang" } {
992 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
993 "# Visual Studio 14\n"
995 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
999 # Returns extension (without dot) for project files of given version of VC
1001 proc osutils:vcproj:ext { vcversion } {
1002 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
1008 # Generate start of configuration section of VS solution file
1010 proc osutils:vcsolution:config:begin { vcversion } {
1011 if { "$vcversion" == "vc7" } {
1014 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
1015 "\t\tDebug = Debug\n" \
1016 "\t\tRelease = Release\n" \
1017 "\tEndGlobalSection\n" \
1018 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
1022 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
1023 "\t\tDebug|Win32 = Debug|Win32\n" \
1024 "\t\tRelease|Win32 = Release|Win32\n" \
1025 "\t\tDebug|x64 = Debug|x64\n" \
1026 "\t\tRelease|x64 = Release|x64\n" \
1027 "\tEndGlobalSection\n" \
1028 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
1032 # Generate part of configuration section of VS solution file describing one project
1034 proc osutils:vcsolution:config:project { vcversion guid } {
1035 if { "$vcversion" == "vc7" } {
1037 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
1038 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
1039 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
1040 "\t\t$guid.Release.Build.0 = Release|Win32\n"
1043 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
1044 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
1045 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
1046 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
1047 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
1048 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
1049 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
1050 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
1054 # Generate start of configuration section of VS solution file
1056 proc osutils:vcsolution:config:end { vcversion } {
1057 if { "$vcversion" == "vc7" } {
1059 "\tEndGlobalSection\n" \
1060 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
1061 "\tEndGlobalSection\n" \
1062 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
1063 "\tEndGlobalSection\n"
1066 "\tEndGlobalSection\n" \
1067 "\tGlobalSection(SolutionProperties) = preSolution\n" \
1068 "\t\tHideSolutionNode = FALSE\n" \
1069 "\tEndGlobalSection\n"
1073 # generate Visual Studio solution file
1074 # if module is empty, generates one solution for all known modules
1076 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
1078 upvar $theGuidsMap aGuidsMap
1080 # collect list of projects to be created
1082 set aDependencies {}
1083 foreach aModule $theModules {
1085 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1086 lappend aProjects $aToolKit
1087 lappend aProjectsInModule($aModule) $aToolKit
1088 lappend aDependencies [LibToLink $aToolKit]
1090 # executables, assume one project per cxx file...
1091 foreach aUnit [OS:executable ${aModule}] {
1093 set src_files [_get_used_files $aUnit false]
1095 foreach s $src_files {
1096 regexp {source ([^\s]+)} $s dummy name
1097 lappend aSrcFiles $name
1099 foreach aSrcFile $aSrcFiles {
1100 set aFileExtension [file extension $aSrcFile]
1101 if { $aFileExtension == ".cxx" } {
1102 set aPrjName [file rootname $aSrcFile]
1103 lappend aProjects $aPrjName
1104 lappend aProjectsInModule($aModule) $aPrjName
1105 if {[file isdirectory $path/src/$aUnitLoc]} {
1106 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1108 lappend aDependencies {}
1115 # generate GUIDs for projects (unless already known)
1116 foreach aProject $aProjects {
1117 if { ! [info exists aGuidsMap($aProject)] } {
1118 set aGuidsMap($aProject) [OS:genGUID]
1122 # generate solution file
1123 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
1124 append aFileBuff [osutils:vcsolution:header $theVcVer]
1126 # GUID identifying group projects in Visual Studio
1127 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
1129 # generate group projects -- one per module
1130 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
1131 foreach aModule $theModules {
1132 if { ! [info exists aGuidsMap(_$aModule)] } {
1133 set aGuidsMap(_$aModule) [OS:genGUID]
1135 set aGuid $aGuidsMap(_$aModule)
1136 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
1140 # extension of project files
1141 set aProjExt [osutils:vcproj:ext $theVcVer]
1143 # GUID identifying C++ projects in Visual Studio
1144 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
1146 # generate normal projects
1147 set aProjsNb [llength $aProjects]
1148 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
1149 set aProj [lindex $aProjects $aProjId]
1150 set aGuid $aGuidsMap($aProj)
1151 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
1152 # write projects dependencies information (vc7 to vc9)
1154 foreach aDepLib [lindex $aDependencies $aProjId] {
1155 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
1156 set depGUID $aGuidsMap($aDepLib)
1157 append aDepGuids "\t\t$depGUID = $depGUID\n"
1160 if { "$aDepGuids" != "" } {
1161 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
1162 append aFileBuff "$aDepGuids"
1163 append aFileBuff "\tEndProjectSection\n"
1165 append aFileBuff "EndProject\n"
1168 # generate configuration section
1169 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
1170 foreach aProj $aProjects {
1171 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
1173 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
1175 # write information of grouping of projects by module
1176 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
1177 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
1178 foreach aModule $theModules {
1179 if { ! [info exists aProjectsInModule($aModule)] } { continue }
1180 foreach aProject $aProjectsInModule($aModule) {
1181 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
1184 append aFileBuff " EndGlobalSection\n"
1187 # final word (footer)
1188 append aFileBuff "EndGlobal"
1191 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
1192 fconfigure $aFile -translation crlf
1193 puts $aFile $aFileBuff
1195 return [file join $theOutDir ${theSolName}.sln]
1197 # Generate Visual Studio projects for specified version
1199 proc OS:vcproj { theVcVer isUWP theModules theOutDir theGuidsMap } {
1200 upvar $theGuidsMap aGuidsMap
1202 set aProjectFiles {}
1204 foreach aModule $theModules {
1205 foreach aToolKit [${aModule}:toolkits] {
1206 lappend aProjectFiles [osutils:vcproj $theVcVer $isUWP $theOutDir $aToolKit aGuidsMap]
1208 foreach anExecutable [OS:executable ${aModule}] {
1209 lappend aProjectFiles [osutils:vcprojx $theVcVer $isUWP $theOutDir $anExecutable aGuidsMap]
1212 return $aProjectFiles
1214 # generate template name and load it for given version of Visual Studio and platform
1216 proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} {
1218 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1222 # determine versions of runtime and toolset
1223 set aVCRTVer $theVcVer
1224 set aToolset "v[string range $theVcVer 2 3]0"
1225 if { $theVcVer == "vc141" } {
1228 } elseif { $theVcVer == "vc142" } {
1231 } elseif { $theVcVer == "vclang" } {
1233 set aToolset "ClangCL"
1236 set what "$theVcVer"
1239 set aCharSet "Unicode"
1241 set anExt "${anExt}x"
1242 set what "$what executable"
1244 if { "$theVcVer" == "vc10" } {
1245 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
1246 set aCmpl32 "<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
1248 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
1251 set UwpWinRt "<CompileAsWinRT>false</CompileAsWinRT>"
1252 foreach bitness {32 64} {
1254 if {"[set aCmpl${bitness}]" != ""} {
1257 set aCmpl${bitness} "[set aCmpl${bitness}]${indent}${UwpWinRt}"
1261 set format_template "\[\\r\\n\\s\]*"
1262 foreach bitness {32 64} {
1263 set format_templateloc ""
1264 if {"[set aCmpl${bitness}]" == ""} {
1265 set format_templateloc "$format_template"
1267 regsub -all -- "${format_templateloc}__VCMPL${bitness}__" $aTmpl "[set aCmpl${bitness}]" aTmpl
1272 if { "$::HAVE_RelWithDebInfo" == "true" } {
1273 set aDebugInfo "true"
1274 set aReleaseLnk "\n <OptimizeReferences>true</OptimizeReferences>\n <EnableCOMDATFolding>true</EnableCOMDATFolding>"
1277 regsub -all -- {__VCVER__} $aTmpl $aVCRTVer aTmpl
1278 regsub -all -- {__VCVEREXT__} $aTmpl $aToolset aTmpl
1279 regsub -all -- {__VCCHARSET__} $aTmpl $aCharSet aTmpl
1280 regsub -all -- {__VCReleasePDB__} $aTmpl $aDebugInfo aTmpl
1281 regsub -all -- "${format_template}__VCLNKREL__" $aTmpl "${aReleaseLnk}" aTmpl
1286 proc osutils:readtemplate {ext what} {
1287 set loc "$::THE_CASROOT/adm/templates/template.$ext"
1288 return [wokUtils:FILES:FileToString $loc]
1290 # Read a file in a string as is.
1292 proc wokUtils:FILES:FileToString { fin } {
1293 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1294 set strin [read $in [file size $fin]]
1302 # List extensions of compilable files in OCCT
1303 proc osutils:compilable {thePlatform} {
1304 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .c .cxx .cpp .mm] }
1305 return [list .c .cxx .cpp]
1308 # List extensions of header file in OCCT
1309 proc osutils:fileExtensionsHeaders {thePlatform} {
1310 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .h .hxx .hpp .lxx .pxx .gxx ] }
1311 return [list .h .hxx .hpp .lxx .pxx .gxx .mm ]
1314 proc osutils:commonUsedTK { theToolKit } {
1315 set anUsedToolKits [list]
1316 set aDepToolkits [LibToLink $theToolKit]
1317 foreach tkx $aDepToolkits {
1318 if {[_get_type $tkx] == "t"} {
1319 lappend anUsedToolKits "${tkx}"
1322 return $anUsedToolKits
1325 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1326 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1327 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1330 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1337 # Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
1338 # @param theOS - target OS
1339 # @param theCsfLibsMap - libraries map
1340 # @param theCsfFrmsMap - frameworks map, OS X specific
1341 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1342 upvar $theCsfLibsMap aLibsMap
1343 upvar $theCsfFrmsMap aFrmsMap
1348 set aLibsMap(CSF_FREETYPE) "freetype"
1349 set aLibsMap(CSF_TclLibs) "tcl8.6"
1350 set aLibsMap(CSF_TclTkLibs) "tk8.6"
1351 if { "$::HAVE_FREEIMAGE" == "true" } {
1352 if { "$theOS" == "wnt" } {
1353 set aLibsMap(CSF_FreeImagePlus) "FreeImage"
1355 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1357 } elseif { "$theOS" == "wnt" } {
1358 set aLibsMap(CSF_FreeImagePlus) "windowscodecs"
1360 if { "$::HAVE_FFMPEG" == "true" } {
1361 set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil"
1363 if { "$::HAVE_TBB" == "true" } {
1364 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1366 if { "$::HAVE_VTK" == "true" } {
1367 if { "$theOS" == "wnt" } {
1368 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1370 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1373 if { "$::HAVE_ZLIB" == "true" } {
1374 set aLibsMap(CSF_ZLIB) "zlib"
1376 if { "$::HAVE_LIBLZMA" == "true" } {
1377 set aLibsMap(CSF_LIBLZMA) "liblzma"
1379 if { "$::HAVE_E57" == "true" && "$theOS" != "wnt" } {
1380 # exclude wnt, as there are different pragma lib depending on debug/release
1381 set aLibsMap(CSF_E57) "E57RefImpl"
1382 set aLibsMap(CSF_xerces) "xerces-c"
1385 if { "$theOS" == "wnt" } {
1387 set aLibsMap(CSF_kernel32) "kernel32"
1388 set aLibsMap(CSF_advapi32) "advapi32"
1389 set aLibsMap(CSF_gdi32) "gdi32"
1390 set aLibsMap(CSF_user32) "user32 comdlg32"
1391 set aLibsMap(CSF_shell32) "shell32"
1392 set aLibsMap(CSF_opengl32) "opengl32"
1393 set aLibsMap(CSF_wsock32) "wsock32"
1394 set aLibsMap(CSF_netapi32) "netapi32"
1395 set aLibsMap(CSF_winmm) "winmm"
1396 set aLibsMap(CSF_OpenGlLibs) "opengl32"
1397 if { "$::HAVE_GLES2" == "true" } {
1398 set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2"
1400 set aLibsMap(CSF_psapi) "Psapi"
1401 set aLibsMap(CSF_d3d9) "d3d9"
1403 # the naming is different on Windows
1404 set aLibsMap(CSF_TclLibs) "tcl86"
1405 set aLibsMap(CSF_TclTkLibs) "tk86"
1407 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1409 # tbb headers define different pragma lib depending on debug/release
1410 set aLibsMap(CSF_TBB) ""
1412 set aLibsMap(CSF_dl) "dl"
1413 if { "$theOS" == "mac" || "$theOS" == "ios" } {
1414 set aLibsMap(CSF_objc) "objc"
1415 if { "$theOS" == "ios" } {
1416 set aFrmsMap(CSF_Appkit) "UIKit"
1417 set aFrmsMap(CSF_OpenGlLibs) "OpenGLES"
1419 set aFrmsMap(CSF_Appkit) "AppKit"
1420 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1422 set aFrmsMap(CSF_IOKit) "IOKit"
1423 set aFrmsMap(CSF_TclLibs) "Tcl"
1424 set aLibsMap(CSF_TclLibs) ""
1425 set aFrmsMap(CSF_TclTkLibs) "Tk"
1426 set aLibsMap(CSF_TclTkLibs) ""
1427 set aLibsMap(CSF_QT) "QtCore QtGui"
1428 } elseif { "$theOS" == "android" } {
1429 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1430 set aLibsMap(CSF_androidlog) "log"
1432 set aLibsMap(CSF_fontconfig) "fontconfig"
1433 if { "$theOS" == "qnx" } {
1434 # CSF_ThreadLibs - pthread API is part of libc on QNX
1435 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1437 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1438 set aLibsMap(CSF_OpenGlLibs) "GL"
1439 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1440 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1441 set aLibsMap(CSF_MotifLibs) "X11"
1444 if { "$::HAVE_GLES2" == "true" } {
1445 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1451 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1452 proc osutils:vtkCsf {{theOS ""}} {
1455 set aPathSplitter ":"
1456 if {"$theOS" == "wnt"} {
1457 set aPathSplitter ";"
1460 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1461 foreach anIncItem $anOptIncs {
1462 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1463 set aVtkVer $aFoundVtkVer
1467 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1468 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1470 # Additional suffices for the libraries
1472 foreach anItem $aLibArray {
1473 lset aLibArray $anIdx $anItem-$aVtkVer
1477 return [join $aLibArray " "]
1480 # @param theLibsList - dependencies (libraries list)
1481 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1482 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1484 upvar $theLibsList aLibsList
1485 upvar $theFrameworks aFrameworks
1486 set aLibsList [list]
1487 set aFrameworks [list]
1489 osutils:csfList $theOS aLibsMap aFrmsMap
1491 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1492 if [info exists aLibsMap($aCsfElem)] {
1493 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1494 if { [lsearch $aLibsList $aLib] == "-1" } {
1495 lappend aLibsList $aLib
1499 if [info exists aFrmsMap($aCsfElem)] {
1500 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1501 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1502 lappend aFrameworks $aFrm
1509 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1510 proc osutils:tk:units { tkloc } {
1513 set PACKAGES "$path/src/$tkloc/PACKAGES"
1514 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1515 if {[file isdirectory "$path/src/$u"]} {
1520 ;#puts stderr "Warning. No devunit included in $tkloc"
1525 proc osutils:justwnt { listloc } {
1526 set goaway [list Xw]
1527 return [osutils:juststation $goaway $listloc]
1530 # remove from listloc OpenCascade units indesirables on NT
1531 proc osutils:juststation {goaway listloc} {
1534 foreach u $listloc {
1535 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1536 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1543 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1544 # The first list is everything in the first list that wasn't in the second,
1545 # the second list contains the intersection of the two lists, the third list contains everything
1546 # in the second list that wasn't in the first.
1547 proc osutils:intersect3 {list1 list2} {
1548 set la1(0) {} ; unset la1(0)
1549 set lai(0) {} ; unset lai(0)
1550 set la2(0) {} ; unset la2(0)
1557 foreach elem [concat $list1 $list2] {
1558 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1564 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1567 # Prepare relative path
1568 proc relativePath {thePathFrom thePathTo} {
1569 if { [file isdirectory "$thePathFrom"] == 0 } {
1573 set aPathFrom [file normalize "$thePathFrom"]
1574 set aPathTo [file normalize "$thePathTo"]
1576 set aCutedPathFrom "${aPathFrom}/dummy"
1577 set aRelatedDeepPath ""
1579 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1580 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1581 # does aPathTo contain aCutedPathFrom?
1582 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1583 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1584 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1585 set aPathTo ".${aPathTo}"
1586 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1587 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1589 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1590 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1591 return $aPathToAfterCut
1593 set aRelatedDeepPath "$aRelatedDeepPath../"
1600 proc wokUtils:EASY:bs1 { s } {
1601 regsub -all {/} $s {\\} r
1605 # Returs for a full path the liste of n last directory part
1607 # n = 2 => dir/file.c
1608 # n = 3 => sdir/dir/file.c
1610 proc wokUtils:FILES:wtail { f n } {
1611 set ll [expr [llength [set lif [file split $f]]] -$n]
1612 return [join [lrange $lif $ll end] /]
1615 # Generate entry for one source file in Visual Studio 10 project file
1616 proc osutils:vcxproj:cxxfile { theFile theParams } {
1617 if { $theParams == "" } {
1618 return " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n"
1621 set aParams [string trim ${theParams}]
1622 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1623 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1624 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1625 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1626 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
1627 append text " </ClCompile>\n"
1631 # Generate entry for one header file in Visual Studio 10 project file
1632 proc osutils:vcxproj:hxxfile { theFile } { return " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n" }
1634 # Generate Visual Studio 2010 project filters file
1635 proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
1636 upvar $theCxxFilesMap aCxxFilesMap
1637 upvar $theHxxFilesMap aHxxFilesMap
1640 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1641 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1643 # list of "filters" (units)
1644 append text " <ItemGroup>\n"
1645 append text " <Filter Include=\"Source files\">\n"
1646 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1647 append text " </Filter>\n"
1648 append text " <Filter Include=\"Header files\">\n"
1649 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1650 append text " </Filter>\n"
1651 foreach unit $aCxxFilesMap(units) {
1652 append text " <Filter Include=\"Source files\\${unit}\">\n"
1653 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1654 append text " </Filter>\n"
1656 foreach unit $aHxxFilesMap(units) {
1657 append text " <Filter Include=\"Header files\\${unit}\">\n"
1658 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1659 append text " </Filter>\n"
1661 append text " </ItemGroup>\n"
1664 append text " <ItemGroup>\n"
1665 foreach unit $aCxxFilesMap(units) {
1666 foreach file $aCxxFilesMap($unit) {
1667 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1668 append text " <Filter>Source files\\${unit}</Filter>\n"
1669 append text " </ClCompile>\n"
1672 append text " </ItemGroup>\n"
1675 append text " <ItemGroup>\n"
1676 foreach unit $aHxxFilesMap(units) {
1677 foreach file $aHxxFilesMap($unit) {
1678 append text " <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1679 append text " <Filter>Header files\\${unit}</Filter>\n"
1680 append text " </ClInclude>\n"
1683 append text " </ItemGroup>\n"
1685 append text " <ItemGroup>\n"
1686 append text " <ResourceCompile Include=\"${proj}.rc\" />\n"
1687 append text " </ItemGroup>\n"
1690 append text "</Project>"
1693 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1694 fconfigure $fp -translation crlf
1698 return ${proj}.vcxproj.filters
1701 # Generate RC file content for ToolKit from template
1702 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1703 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1704 set aBody [wokUtils:FILES:FileToString $aLoc]
1705 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1707 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1708 fconfigure $aFile -translation lf
1711 return "${theOutDir}/${theToolKit}.rc"
1714 # Generate Visual Studio project file for ToolKit
1715 proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
1716 set theProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 0]
1718 set l_compilable [osutils:compilable wnt]
1719 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1721 upvar $theGuidsMap aGuidsMap
1722 if { ! [info exists aGuidsMap($theToolKit)] } {
1723 set aGuidsMap($theToolKit) [OS:genGUID]
1725 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1727 set theProjTmpl [osutils:uwp:proj $isUWP ${theProjTmpl}]
1729 set aUsedLibs [list]
1732 lappend aUsedLibs "WindowsApp.lib"
1735 foreach tkx [osutils:commonUsedTK $theToolKit] {
1736 lappend aUsedLibs "${tkx}.lib"
1739 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1740 foreach aLibIter $aLibs {
1741 lappend aUsedLibs "${aLibIter}.lib"
1744 # correct names of referred third-party libraries that are named with suffix
1745 # depending on VC version
1746 set aVCRTVer [string range $theVcVer 0 3]
1747 regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
1749 # and put this list to project file
1750 #puts "$theToolKit requires $aUsedLibs"
1751 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1752 set aUsedLibs [join $aUsedLibs {;}]
1754 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1756 set anIncPaths "..\\..\\..\\inc"
1758 set aFilesSection ""
1759 set aVcFilesCxx(units) ""
1760 set aVcFilesHxx(units) ""
1761 set listloc [osutils:tk:units $theToolKit]
1762 if [array exists written] { unset written }
1763 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1764 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1765 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1766 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1767 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1768 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1770 foreach fxlo $listloc {
1772 set aSrcFiles [osutils:tk:cxxfiles $xlo wnt]
1773 set aHxxFiles [osutils:tk:hxxfiles $xlo wnt]
1774 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1775 if {$fxlo_cmplrs_options_cxx == ""} {
1776 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1778 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1779 if {$fxlo_cmplrs_options_c == ""} {
1780 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1782 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1783 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1784 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1785 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1786 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1787 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1789 foreach partopt $fxloparam {
1790 if {[string first "-I" $partopt] == "0"} {
1791 # this is an additional includes search path
1794 set needparam "$needparam $partopt"
1797 # Format of projects in vc10+ is different from vc7-9
1798 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1799 foreach aSrcFile [lsort $aSrcFiles] {
1800 if { ![info exists written([file tail $aSrcFile])] } {
1801 set written([file tail $aSrcFile]) 1
1802 append aFilesSection [osutils:vcxproj:cxxfile $aSrcFile $needparam]
1804 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1806 if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
1807 lappend aVcFilesCxx($xlo) $aSrcFile
1809 foreach aHxxFile [lsort $aHxxFiles] {
1810 if { ![info exists written([file tail $aHxxFile])] } {
1811 set written([file tail $aHxxFile]) 1
1812 append aFilesSection [osutils:vcxproj:hxxfile $aHxxFile]
1814 puts "Warning : in vcproj more than one occurences for [file tail $aHxxFile]"
1816 if { ! [info exists aVcFilesHxx($xlo)] } { lappend aVcFilesHxx(units) $xlo }
1817 lappend aVcFilesHxx($xlo) $aHxxFile
1820 append aFilesSection "\t\t\t<Filter\n"
1821 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1822 append aFilesSection "\t\t\t\t>\n"
1823 foreach aSrcFile [lsort $aSrcFiles] {
1824 if { ![info exists written([file tail $aSrcFile])] } {
1825 set written([file tail $aSrcFile]) 1
1826 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1828 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1831 append aFilesSection "\t\t\t</Filter>\n"
1835 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1836 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1839 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1840 fconfigure $aFile -translation crlf
1841 puts $aFile $theProjTmpl
1844 # write filters file for vc10+
1845 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1846 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesCxx aVcFilesHxx]
1849 # write resource file
1850 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1855 # for a unit returns a map containing all its file in the current
1857 # local = 1 only local files
1858 proc osutils:tk:loadunit { loc map } {
1861 catch { unset TLOC }
1862 set lfiles [_get_used_files $loc]
1867 if [info exists TLOC($t)] {
1878 # Returns the list of all files name in a toolkit within specified list of file extensions.
1879 proc osutils:tk:files { tkloc theExtensions } {
1880 set Tfiles(source,nocdlpack) {source pubinclude}
1881 set Tfiles(source,toolkit) {}
1882 set Tfiles(source,executable) {source pubinclude}
1883 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1884 #puts " listloc = $listloc"
1886 set resultloc $listloc
1888 foreach loc $resultloc {
1889 set utyp [_get_type $loc]
1890 #puts "\"$utyp\" \"$loc\""
1892 "t" { set utyp "toolkit" }
1893 "n" { set utyp "nocdlpack" }
1894 "x" { set utyp "executable" }
1895 default { error "Error: Cannot determine type of unit $loc, check adm/UDLIST!" }
1897 if [array exists map] { unset map }
1898 osutils:tk:loadunit $loc map
1899 #puts " loc = $loc === > [array names map]"
1900 set LType $Tfiles(source,${utyp})
1901 foreach typ [array names map] {
1902 if { [lsearch $LType $typ] == -1 } {
1906 foreach type [array names map] {
1908 foreach f $map($type) {
1910 if { [lsearch $theExtensions [file extension $f]] != -1 } {
1919 # Returns the list of all compilable files name in a toolkit.
1920 proc osutils:tk:cxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:compilable $thePlatform]] }
1922 # Returns the list of all header files name in a toolkit.
1923 proc osutils:tk:hxxfiles { tkloc thePlatform } { return [osutils:tk:files $tkloc [osutils:fileExtensionsHeaders $thePlatform]] }
1925 # Generate Visual Studio project file for executable
1926 proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap } {
1928 foreach f [osutils:tk:cxxfiles $theToolKit wnt] {
1929 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
1931 set aProjName [file rootname [file tail $f]]
1932 set l_compilable [osutils:compilable wnt]
1933 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1935 upvar $theGuidsMap aGuidsMap
1936 if { ! [info exists aGuidsMap($aProjName)] } {
1937 set aGuidsMap($aProjName) [OS:genGUID]
1939 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1941 set aUsedLibs [list]
1942 foreach tkx [osutils:commonUsedTK $theToolKit] {
1943 lappend aUsedLibs "${tkx}.lib"
1946 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1947 foreach aLibIter $aLibs {
1948 lappend aUsedLibs "${aLibIter}.lib"
1951 # correct names of referred third-party libraries that are named with suffix
1952 # depending on VC version
1953 set aVCRTVer [string range $theVcVer 0 3]
1954 regsub -all -- {vc[0-9]+} $aUsedLibs $aVCRTVer aUsedLibs
1956 # puts "$aProjName requires $aUsedLibs"
1957 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1958 set aUsedLibs [join $aUsedLibs {;}]
1960 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1962 set aFilesSection ""
1963 set aVcFilesCxx(units) ""
1964 set aVcFilesHxx(units) ""
1966 if { ![info exists written([file tail $f])] } {
1967 set written([file tail $f]) 1
1969 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1970 append aFilesSection [osutils:vcxproj:cxxfile $f ""]
1971 if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
1972 lappend aVcFilesCxx($theToolKit) $f
1974 append aFilesSection "\t\t\t<Filter\n"
1975 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1976 append aFilesSection "\t\t\t\t>\n"
1977 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1978 append aFilesSection "\t\t\t</Filter>"
1981 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1983 #puts "$aProjTmpl $aFilesSection"
1984 set anIncPaths "..\\..\\..\\inc"
1985 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1986 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1987 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1989 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1991 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1992 fconfigure $aFile -translation crlf
1993 puts $aFile $aProjTmpl
1996 set aCommonSettingsFile "$aVcFilePath.user"
1997 lappend aVcFiles $aVcFilePath
1999 # write filters file for vc10
2000 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
2001 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
2004 # write resource file
2005 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
2007 set aCommonSettingsFileTmpl ""
2008 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
2010 } elseif { "$theVcVer" == "vc9" } {
2011 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
2013 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
2015 if { "$aCommonSettingsFileTmpl" != "" } {
2016 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
2018 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
2019 fconfigure $aFile -translation crlf
2020 puts $aFile $aCommonSettingsFileTmpl
2023 lappend aVcFiles "$aCommonSettingsFile"
2029 # Generate entry for one source file in Visual Studio 7 - 9 project file
2030 proc osutils:vcproj:file { theVcVer theFile theOptions } {
2031 append aText "\t\t\t\t<File\n"
2032 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
2033 if { $theOptions == "" } {
2034 append aText "\t\t\t\t</File>\n"
2038 append aText "\t\t\t\t\t<FileConfiguration\n"
2039 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
2040 append aText "\t\t\t\t\t\t<Tool\n"
2041 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2042 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2043 foreach aParam $theOptions {
2044 append aText "$aParam "
2047 append aText "\t\t\t\t\t\t/>\n"
2048 append aText "\t\t\t\t\t</FileConfiguration>\n"
2050 append aText "\t\t\t\t\t<FileConfiguration\n"
2051 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
2052 append aText "\t\t\t\t\t\t<Tool\n"
2053 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2054 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2055 foreach aParam $theOptions {
2056 append aText "$aParam "
2059 append aText "\t\t\t\t\t\t/>\n"
2060 append aText "\t\t\t\t\t</FileConfiguration>\n"
2061 if { "$theVcVer" == "vc7" } {
2062 append aText "\t\t\t\t</File>\n"
2066 append aText "\t\t\t\t\t<FileConfiguration\n"
2067 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
2068 append aText "\t\t\t\t\t\t<Tool\n"
2069 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2070 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2071 foreach aParam $theOptions {
2072 append aText "$aParam "
2075 append aText "\t\t\t\t\t\t/>\n"
2076 append aText "\t\t\t\t\t</FileConfiguration>\n"
2078 append aText "\t\t\t\t\t<FileConfiguration\n"
2079 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
2080 append aText "\t\t\t\t\t\t<Tool\n"
2081 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
2082 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
2083 foreach aParam $theOptions {
2084 append aText "$aParam "
2087 append aText "\t\t\t\t\t\t/>\n"
2088 append aText "\t\t\t\t\t</FileConfiguration>\n"
2090 append aText "\t\t\t\t</File>\n"
2094 proc wokUtils:FILES:mkdir { d } {
2096 regsub -all {\.[^.]*} $tcl_version "" major
2097 if { $major == 8 } {
2100 if ![file exists $d] {
2101 if { "[info command mkdir]" == "mkdir" } {
2104 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
2108 if [file exists $d] {
2115 # remove from listloc OpenCascade units indesirables on Unix
2116 proc osutils:justunix { listloc } {
2117 if { "$::tcl_platform(os)" == "Darwin" } {
2118 set goaway [list Xw WNT]
2120 set goaway [list WNT]
2122 return [osutils:juststation $goaway $listloc]
2126 ####### CODEBLOCK ###################################################################
2127 # Function to generate Code Blocks workspace and project files
2128 proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
2129 puts stderr "Generating project files for Code Blocks"
2131 # Generate projects for toolkits and separate workspace for each module
2132 foreach aModule $theModules {
2133 OS:cworkspace $aModule $aModule $theOutDir
2134 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
2137 # Generate single workspace "OCCT" containing projects from all modules
2138 if { "$theAllSolution" != "" } {
2139 OS:cworkspace $theAllSolution $theModules $theOutDir
2142 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
2145 # Generate Code Blocks projects
2146 proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
2147 set aProjectFiles {}
2148 foreach aModule $theModules {
2149 foreach aToolKit [${aModule}:toolkits] {
2150 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
2152 foreach anExecutable [OS:executable ${aModule}] {
2153 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
2156 return $aProjectFiles
2159 # Generate Code::Blocks project file for ToolKit
2160 proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
2161 set aUsedLibs [list]
2162 set aFrameworks [list]
2163 set anIncPaths [list]
2164 set aTKDefines [list]
2165 set aTKSrcFiles [list]
2167 # collect list of referred libraries to link with
2168 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2169 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2170 foreach tkx $aDepToolkits {
2171 lappend aUsedLibs "${tkx}"
2174 lappend anIncPaths "../../../inc"
2175 set listloc [osutils:tk:units $theToolKit]
2177 if { [llength $listloc] == 0 } {
2178 set listloc $theToolKit
2181 if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2182 set resultloc [osutils:justwnt $listloc]
2184 set resultloc [osutils:justunix $listloc]
2186 if [array exists written] { unset written }
2187 foreach fxlo $resultloc {
2189 set aSrcFiles [osutils:tk:cxxfiles $xlo $thePlatform]
2190 foreach aSrcFile [lsort $aSrcFiles] {
2191 if { ![info exists written([file tail $aSrcFile])] } {
2192 set written([file tail $aSrcFile]) 1
2193 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2195 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2199 # macros for correct DLL exports
2200 # if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2201 # lappend aTKDefines "__${xlo}_DLL"
2205 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
2208 # Generates Code Blocks workspace.
2209 proc OS:cworkspace { theSolName theModules theOutDir } {
2211 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
2212 set aFile [open $aWsFilePath "w"]
2214 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2215 puts $aFile "<CodeBlocks_workspace_file>"
2216 puts $aFile "\t<Workspace title=\"${theSolName}\">"
2218 # collect list of projects to be created
2219 foreach aModule $theModules {
2221 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
2222 set aDependencies [LibToLink $aToolKit]
2223 if { [llength $aDependencies] == 0 } {
2224 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
2226 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
2227 foreach aDepTk $aDependencies {
2228 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2230 puts $aFile "\t\t</Project>"
2234 # executables, assume one project per cxx file...
2235 foreach aUnit [OS:executable ${aModule}] {
2237 set src_files [_get_used_files $aUnit false]
2239 foreach s $src_files {
2240 regexp {source ([^\s]+)} $s dummy name
2241 lappend aSrcFiles $name
2243 foreach aSrcFile $aSrcFiles {
2244 set aFileExtension [file extension $aSrcFile]
2245 if { $aFileExtension == ".cxx" } {
2246 set aPrjName [file rootname $aSrcFile]
2247 set aDependencies [list]
2248 if {[file isdirectory $path/src/$aUnitLoc]} {
2249 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
2251 set anActiveState ""
2252 if { $isActiveSet == 0 } {
2253 set anActiveState " active=\"1\""
2256 if { [llength $aDependencies] == 0 } {
2257 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
2259 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
2260 foreach aDepTk $aDependencies {
2261 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2263 puts $aFile "\t\t</Project>"
2270 puts $aFile "\t</Workspace>"
2271 puts $aFile "</CodeBlocks_workspace_file>"
2277 # Generate Code::Blocks project file for Executable
2278 proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
2280 set aWokArch "$::env(ARCH)"
2283 foreach aSrcFile [osutils:tk:cxxfiles $theToolKit $thePlatform] {
2284 # collect list of referred libraries to link with
2285 set aUsedLibs [list]
2286 set aFrameworks [list]
2287 set anIncPaths [list]
2288 set aTKDefines [list]
2289 set aTKSrcFiles [list]
2290 set aProjName [file rootname [file tail $aSrcFile]]
2292 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2294 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2295 foreach tkx $aDepToolkits {
2296 if {[_get_type $tkx] == "t"} {
2297 lappend aUsedLibs "${tkx}"
2299 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2300 lappend aUsedLibs "${tkx}"
2304 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2305 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2306 set isExecutable "false"
2308 set isExecutable "true"
2311 if { ![info exists written([file tail $aSrcFile])] } {
2312 set written([file tail $aSrcFile]) 1
2313 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2315 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2318 # macros for correct DLL exports
2319 # if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
2320 # lappend aTKDefines "__${theToolKit}_DLL"
2323 # common include paths
2324 lappend anIncPaths "../../../inc"
2326 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2332 # This function intended to generate Code::Blocks project file
2333 # @param theCmpl - the compiler (gcc or msvc)
2334 # @param theOutDir - output directory to place project file
2335 # @param theProjName - project name
2336 # @param theSrcFiles - list of source files
2337 # @param theLibsList - dependencies (libraries list)
2338 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2339 # @param theIncPaths - header search paths
2340 # @param theDefines - compiler macro definitions
2341 # @param theIsExe - flag to indicate executable / library target
2342 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2343 set aWokArch "$::env(ARCH)"
2346 set aCmplFlags [list]
2347 set aCmplFlagsRelease [list]
2348 set aCmplFlagsDebug [list]
2349 set toPassArgsByFile 0
2350 set aLibPrefix "lib"
2351 set aPlatformAndCompiler "${thePlatform}/gcc"
2352 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
2353 set aPlatformAndCompiler "${thePlatform}/clang"
2355 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" || "$thePlatform" == "qnx" } {
2356 set toPassArgsByFile 1
2358 if { "$theCmpl" == "msvc" } {
2359 set aCmplCbp "msvc8"
2363 if { "$theCmpl" == "msvc" } {
2364 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2365 set aCmplFlagsRelease "-MD -O2"
2366 set aCmplFlagsDebug "-MDd -Od -Zi"
2367 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2368 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2369 } elseif { "$theCmpl" == "gcc" } {
2370 if { "$thePlatform" != "qnx" } {
2371 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2373 set aCmplFlagsRelease "-O2"
2374 set aCmplFlagsDebug "-O0 -g"
2375 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2376 lappend aCmplFlags "-std=gnu++0x"
2377 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2379 lappend aCmplFlags "-std=c++0x"
2380 lappend aCmplFlags "-fPIC"
2381 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2383 lappend aCmplFlags "-Wall"
2384 lappend aCmplFlags "-fexceptions"
2386 lappend aCmplFlagsRelease "-DNDEBUG"
2387 lappend aCmplFlagsRelease "-DNo_Exception"
2388 lappend aCmplFlagsDebug "-D_DEBUG"
2389 if { "$thePlatform" == "qnx" } {
2390 lappend aCmplFlags "-D_QNX_SOURCE"
2393 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2394 set aLnkFileName "${theProjName}_obj.link"
2395 set aLnkDebFileName "${theProjName}_objd.link"
2396 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2397 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2398 set aFile [open $aCbpFilePath "w"]
2399 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2400 puts $aFile "<CodeBlocks_project_file>"
2401 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2402 puts $aFile "\t<Project>"
2403 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2404 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2405 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2406 puts $aFile "\t\t<Build>"
2408 # Release target configuration
2409 puts $aFile "\t\t\t<Target title=\"Release\">"
2410 if { "$theIsExe" == "true" } {
2411 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2412 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2414 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2415 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2417 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2419 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2421 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/obj\" />"
2422 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2423 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2424 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2425 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2427 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2430 # compiler options per TARGET (including defines)
2431 puts $aFile "\t\t\t\t<Compiler>"
2432 foreach aFlagIter $aCmplFlagsRelease {
2433 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2435 foreach aMacro $theDefines {
2436 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2438 puts $aFile "\t\t\t\t</Compiler>"
2440 puts $aFile "\t\t\t\t<Linker>"
2441 if { $toPassArgsByFile == 1 } {
2442 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2444 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/lib\" />"
2445 if { "$thePlatform" == "mac" } {
2446 if { [ lsearch $theLibsList X11 ] >= 0} {
2447 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2450 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2451 if { "$thePlatform" == "lin" } {
2452 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/lib\" />"
2454 puts $aFile "\t\t\t\t</Linker>"
2456 puts $aFile "\t\t\t</Target>"
2458 # Debug target configuration
2459 puts $aFile "\t\t\t<Target title=\"Debug\">"
2460 if { "$theIsExe" == "true" } {
2461 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2462 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2464 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2465 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2467 puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2469 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2471 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/objd\" />"
2472 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2473 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2474 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2475 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2477 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2480 # compiler options per TARGET (including defines)
2481 puts $aFile "\t\t\t\t<Compiler>"
2482 foreach aFlagIter $aCmplFlagsDebug {
2483 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2485 foreach aMacro $theDefines {
2486 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2488 puts $aFile "\t\t\t\t</Compiler>"
2490 puts $aFile "\t\t\t\t<Linker>"
2491 if { $toPassArgsByFile == 1 } {
2492 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2494 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/libd\" />"
2495 if { "$thePlatform" == "mac" } {
2496 if { [ lsearch $theLibsList X11 ] >= 0} {
2497 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2500 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2501 if { "$thePlatform" == "lin" } {
2502 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/libd\" />"
2504 puts $aFile "\t\t\t\t</Linker>"
2506 puts $aFile "\t\t\t</Target>"
2508 puts $aFile "\t\t</Build>"
2510 # COMMON compiler options
2511 puts $aFile "\t\t<Compiler>"
2512 foreach aFlagIter $aCmplFlags {
2513 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2515 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2516 foreach anIncPath $theIncPaths {
2517 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2519 puts $aFile "\t\t</Compiler>"
2521 # COMMON linker options
2522 puts $aFile "\t\t<Linker>"
2523 if { "$thePlatform" == "wnt" && "$theCmpl" == "gcc" } {
2524 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2526 foreach aFrameworkName $theFrameworks {
2527 if { "$aFrameworkName" != "" } {
2528 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2531 foreach aLibName $theLibsList {
2532 if { "$aLibName" != "" } {
2533 if { "$theCmpl" == "msvc" } {
2534 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2536 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2540 puts $aFile "\t\t</Linker>"
2546 set isFirstSrcFile 1
2547 if { $toPassArgsByFile == 1 } {
2548 set aFileLnkObj [open $aLnkFilePath "w"]
2549 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2552 foreach aSrcFile $theSrcFiles {
2553 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2554 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2555 puts $aFile "\t\t\t<Option compile=\"1\" />"
2556 puts $aFile "\t\t\t<Option link=\"1\" />"
2557 puts $aFile "\t\t</Unit>"
2558 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2559 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2560 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2561 puts $aFile "\t\t</Unit>"
2562 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2563 # pass at list single source file to Code::Blocks as is
2564 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2565 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2566 puts $aFile "\t\t\t<Option link=\"0\" />"
2567 puts $aFile "\t\t</Unit>"
2569 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/obj/src/"] $aSrcFile]]
2570 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/objd/src/"] $aSrcFile]]
2571 puts -nonewline $aFileLnkObj "$aFileObj "
2572 puts -nonewline $aFileLnkObjd "$aFileObjd "
2574 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2575 set isFirstSrcFile 0
2579 if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
2584 puts $aFile "\t</Project>"
2585 puts $aFile "</CodeBlocks_project_file>"
2588 return $aCbpFilePath
2591 # Define libraries to link using only EXTERNLIB file
2592 proc LibToLinkX {thePackage theDummyName} {
2593 set aToolKits [LibToLink $thePackage]
2597 # Function to generate Xcode workspace and project files
2598 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2600 puts stderr "Generating project files for Xcode"
2602 # Generate projects for toolkits and separate workspace for each module
2603 foreach aModule $theModules {
2604 OS:xcworkspace $aModule $aModule $theOutDir
2605 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2608 # Generate single workspace "OCCT" containing projects from all modules
2609 if { "$theAllSolution" != "" } {
2610 OS:xcworkspace $theAllSolution $theModules $theOutDir
2614 # Generates toolkits sections for Xcode workspace file.
2615 proc OS:xcworkspace:toolkits { theModule } {
2618 # Adding toolkits for module in workspace.
2619 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2620 append aBuff " <FileRef\n"
2621 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2622 append aBuff " </FileRef>\n"
2625 # Adding executables for module, assume one project per cxx file...
2626 foreach aUnit [OS:executable ${theModule}] {
2628 set src_files [_get_used_files $aUnit false]
2630 foreach s $src_files {
2631 regexp {source ([^\s]+)} $s dummy name
2632 lappend aSrcFiles $name
2634 foreach aSrcFile $aSrcFiles {
2635 set aFileExtension [file extension $aSrcFile]
2636 if { $aFileExtension == ".cxx" } {
2637 set aPrjName [file rootname $aSrcFile]
2638 append aBuff " <FileRef\n"
2639 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2640 append aBuff " </FileRef>\n"
2645 # Removing unnecessary newline character from the end.
2646 set aBuff [string replace $aBuff end end]
2650 # Generates workspace files for Xcode.
2651 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2652 # Creating workspace directory for Xcode.
2653 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2654 wokUtils:FILES:mkdir $aWorkspaceDir
2655 if { ! [file exists $aWorkspaceDir] } {
2656 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2660 # Creating workspace file.
2661 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2662 set aFile [open $aWsFilePath "w"]
2664 # Adding header and section for main Group.
2665 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2666 puts $aFile "<Workspace"
2667 puts $aFile " version = \"1.0\">"
2668 puts $aFile " <Group"
2669 puts $aFile " location = \"container:\""
2670 puts $aFile " name = \"${theWorkspaceName}\">"
2673 if { [llength "$theModules"] > 1 } {
2674 foreach aModule $theModules {
2675 puts $aFile " <Group"
2676 puts $aFile " location = \"container:\""
2677 puts $aFile " name = \"${aModule}\">"
2678 puts $aFile [OS:xcworkspace:toolkits $aModule]
2679 puts $aFile " </Group>"
2682 puts $aFile [OS:xcworkspace:toolkits $theModules]
2686 puts $aFile " </Group>"
2687 puts $aFile "</Workspace>"
2691 # Generates Xcode project files.
2692 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2693 upvar $theGuidsMap aGuidsMap
2696 if { "$theLibType" == "static" } {
2698 } elseif { "$thePlatform" == "ios" } {
2702 set aProjectFiles {}
2703 foreach aModule $theModules {
2704 foreach aToolKit [${aModule}:toolkits] {
2705 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2707 foreach anExecutable [OS:executable ${aModule}] {
2708 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2711 return $aProjectFiles
2714 # Generates dependencies section for Xcode project files.
2715 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids thePlatform theIsStatic} {
2716 upvar $theGuidsMap aGuidsMap
2717 upvar $theFileRefSection aFileRefSection
2718 upvar $theDepsGuids aDepsGuids
2719 upvar $theDepsRefGuids aDepsRefGuids
2721 set aBuildFileSection ""
2722 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2723 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2725 if { "$theTargetType" == "executable" } {
2726 set aFile [osutils:tk:cxxfiles $theToolKit mac]
2727 set aProjName [file rootname [file tail $aFile]]
2728 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2732 if { $theIsStatic == 1 } {
2734 if { "$theTargetType" != "executable" } {
2735 return $aBuildFileSection
2739 osutils:usedOsLibs $theToolKit $thePlatform aLibs aFrameworks
2740 set aUsedLibs [concat $aUsedLibs $aLibs]
2741 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2742 foreach tkx $aUsedLibs {
2743 set aDepLib "${tkx}_Dep"
2744 set aDepLibRef "${tkx}_DepRef"
2746 if { ! [info exists aGuidsMap($aDepLib)] } {
2747 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2749 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2750 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2753 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2754 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2755 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2757 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2759 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2760 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2763 return $aBuildFileSection
2766 # Generates PBXBuildFile and PBXGroup sections for project file.
2767 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2768 upvar $theSrcFileRefSection aSrcFileRefSection
2769 upvar $theGroupSection aGroupSection
2770 upvar $thePackageGuids aPackagesGuids
2771 upvar $theSrcFileGuids aSrcFileGuids
2772 upvar $theGuidsMap aGuidsMap
2773 upvar $theIncPaths anIncPaths
2775 set listloc [osutils:tk:units $theToolKit]
2776 set resultloc [osutils:justunix $listloc]
2777 set aBuildFileSection ""
2778 set aPackages [lsort -nocase $resultloc]
2779 if { "$theTargetType" == "executable" } {
2780 set aPackages [list "$theToolKit"]
2783 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2784 foreach fxlo $aPackages {
2786 set aPackage "${xlo}_Package"
2787 set aSrcFileRefGuids ""
2788 if { ! [info exists aGuidsMap($aPackage)] } {
2789 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2792 set aSrcFiles [osutils:tk:cxxfiles $xlo mac]
2793 foreach aSrcFile [lsort $aSrcFiles] {
2794 set aFileExt "sourcecode.cpp.cpp"
2796 if { [file extension $aSrcFile] == ".c" } {
2797 set aFileExt "sourcecode.c.c"
2798 } elseif { [file extension $aSrcFile] == ".mm" } {
2799 set aFileExt "sourcecode.cpp.objcpp"
2802 if { ! [info exists aGuidsMap($aSrcFile)] } {
2803 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2805 set aSrcFileRef "${aSrcFile}_Ref"
2806 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2807 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2809 if { ! [info exists written([file tail $aSrcFile])] } {
2810 set written([file tail $aSrcFile]) 1
2811 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2812 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"
2813 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2814 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2816 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2820 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2821 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2822 append aGroupSection "\t\t\tchildren = (\n"
2823 append aGroupSection $aSrcFileRefGuids
2824 append aGroupSection "\t\t\t);\n"
2825 append aGroupSection "\t\t\tname = $xlo;\n"
2826 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2827 append aGroupSection "\t\t\};\n"
2829 # Storing packages IDs for adding them later as a child of toolkit
2830 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2833 # Removing unnecessary newline character from the end.
2834 set aPackagesGuids [string replace $aPackagesGuids end end]
2836 return $aBuildFileSection
2839 # Creates folders structure and all necessary files for Xcode project.
2840 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2841 set aPBXBuildPhase "Headers"
2842 set aRunOnlyForDeployment "0"
2843 set aProductType "library.dynamic"
2844 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2845 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2846 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2847 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2848 if { $theIsStatic == 1 } {
2849 lappend aTKDefines "OCCT_NO_PLUGINS"
2852 if { "$theTargetType" == "executable" } {
2853 set aPBXBuildPhase "CopyFiles"
2854 set aRunOnlyForDeployment "1"
2855 set aProductType "tool"
2856 set anExecExtension ""
2858 set aWrapperExtension ""
2859 } elseif { $theIsStatic == 1 } {
2860 set aProductType "library.static"
2861 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2862 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2865 set aUsername [exec whoami]
2867 # Creation of folders for Xcode projectP.
2868 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2869 wokUtils:FILES:mkdir $aToolkitDir
2870 if { ! [file exists $aToolkitDir] } {
2871 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2875 set aUserDataDir "${aToolkitDir}/xcuserdata"
2876 wokUtils:FILES:mkdir $aUserDataDir
2877 if { ! [file exists $aUserDataDir] } {
2878 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2882 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2883 wokUtils:FILES:mkdir $aUserDataDir
2884 if { ! [file exists $aUserDataDir] } {
2885 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2889 set aSchemesDir "${aUserDataDir}/xcschemes"
2890 wokUtils:FILES:mkdir $aSchemesDir
2891 if { ! [file exists $aSchemesDir] } {
2892 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2895 # End of folders creation.
2897 # Generating GUID for tookit.
2898 upvar $theGuidsMap aGuidsMap
2899 if { ! [info exists aGuidsMap($theToolKit)] } {
2900 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2903 # Creating xcscheme file for toolkit from template.
2904 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2905 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2906 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2907 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2908 puts $aXcschemeFile $aXcschemeTmpl
2909 close $aXcschemeFile
2911 # Creating xcschememanagement.plist file for toolkit from template.
2912 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2913 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2914 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2915 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2916 puts $aPlistFile $aPlistTmpl
2919 # Creating project.pbxproj file for toolkit.
2920 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2921 puts $aPbxprojFile "// !\$*UTF8*\$!"
2922 puts $aPbxprojFile "\{"
2923 puts $aPbxprojFile "\tarchiveVersion = 1;"
2924 puts $aPbxprojFile "\tclasses = \{"
2925 puts $aPbxprojFile "\t\};"
2926 puts $aPbxprojFile "\tobjectVersion = 46;"
2927 puts $aPbxprojFile "\tobjects = \{\n"
2929 # Begin PBXBuildFile section
2930 set aPackagesGuids ""
2931 set aGroupSection ""
2932 set aSrcFileRefSection ""
2933 set aSrcFileGuids ""
2934 set aDepsFileRefSection ""
2936 set aDepsRefGuids ""
2937 set anIncPaths [list "../../../inc"]
2940 if { [info exists ::env(CSF_OPT_INC)] } {
2941 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2942 foreach anIncCfgPath $anIncCfg {
2943 lappend anIncPaths $anIncCfgPath
2946 if { [info exists ::env(CSF_OPT_LIB64)] } {
2947 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2948 foreach anLibCfgPath $anLibCfg {
2949 lappend anLibPaths $anLibCfgPath
2953 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2954 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $thePlatform $theIsStatic]
2955 # End PBXBuildFile section
2957 # Begin PBXFileReference section
2958 set aToolkitLib "lib${theToolKit}.dylib"
2959 set aPath "$aToolkitLib"
2960 if { "$theTargetType" == "executable" } {
2961 set aPath "$theToolKit"
2962 } elseif { $theIsStatic == 1 } {
2963 set aToolkitLib "lib${theToolKit}.a"
2966 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2967 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2970 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2971 puts $aPbxprojFile $aSrcFileRefSection
2972 puts $aPbxprojFile $aDepsFileRefSection
2973 # End PBXFileReference section
2976 # Begin PBXFrameworksBuildPhase section
2977 set aTkFrameworks "${theToolKit}_Frameworks"
2978 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2979 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2982 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2983 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2984 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2985 puts $aPbxprojFile "\t\t\tfiles = ("
2986 puts $aPbxprojFile $aDepsGuids
2987 puts $aPbxprojFile "\t\t\t);"
2988 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2989 puts $aPbxprojFile "\t\t\};\n"
2990 # End PBXFrameworksBuildPhase section
2992 # Begin PBXGroup section
2993 set aTkPBXGroup "${theToolKit}_PBXGroup"
2994 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2995 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2998 set aTkSrcGroup "${theToolKit}_SrcGroup"
2999 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
3000 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
3003 puts $aPbxprojFile $aGroupSection
3004 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
3005 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3006 puts $aPbxprojFile "\t\t\tchildren = ("
3007 puts $aPbxprojFile $aDepsRefGuids
3008 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
3009 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
3010 puts $aPbxprojFile "\t\t\t);"
3011 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3012 puts $aPbxprojFile "\t\t\};"
3013 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
3014 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3015 puts $aPbxprojFile "\t\t\tchildren = ("
3016 puts $aPbxprojFile $aPackagesGuids
3017 puts $aPbxprojFile "\t\t\t);"
3018 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
3019 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3020 puts $aPbxprojFile "\t\t\};\n"
3021 # End PBXGroup section
3023 # Begin PBXHeadersBuildPhase section
3024 set aTkHeaders "${theToolKit}_Headers"
3025 if { ! [info exists aGuidsMap($aTkHeaders)] } {
3026 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
3029 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
3030 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
3031 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3032 puts $aPbxprojFile "\t\t\tfiles = ("
3033 puts $aPbxprojFile "\t\t\t);"
3034 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
3035 puts $aPbxprojFile "\t\t\};\n"
3036 # End PBXHeadersBuildPhase section
3038 # Begin PBXNativeTarget section
3039 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
3040 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
3041 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
3044 set aTkSources "${theToolKit}_Sources"
3045 if { ! [info exists aGuidsMap($aTkSources)] } {
3046 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
3049 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
3050 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
3051 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
3052 puts $aPbxprojFile "\t\t\tbuildPhases = ("
3053 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
3054 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
3055 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
3056 puts $aPbxprojFile "\t\t\t);"
3057 puts $aPbxprojFile "\t\t\tbuildRules = ("
3058 puts $aPbxprojFile "\t\t\t);"
3059 puts $aPbxprojFile "\t\t\tdependencies = ("
3060 puts $aPbxprojFile "\t\t\t);"
3061 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
3062 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
3063 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
3064 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
3065 puts $aPbxprojFile "\t\t\};\n"
3066 # End PBXNativeTarget section
3068 # Begin PBXProject section
3069 set aTkProjectObj "${theToolKit}_ProjectObj"
3070 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
3071 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
3074 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
3075 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
3076 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
3079 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
3080 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
3081 puts $aPbxprojFile "\t\t\tattributes = \{"
3082 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
3083 puts $aPbxprojFile "\t\t\t\};"
3084 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
3085 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
3086 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
3087 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
3088 puts $aPbxprojFile "\t\t\tknownRegions = ("
3089 puts $aPbxprojFile "\t\t\t\ten,"
3090 puts $aPbxprojFile "\t\t\t);"
3091 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
3092 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
3093 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
3094 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
3095 puts $aPbxprojFile "\t\t\ttargets = ("
3096 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
3097 puts $aPbxprojFile "\t\t\t);"
3098 puts $aPbxprojFile "\t\t\};\n"
3099 # End PBXProject section
3101 # Begin PBXSourcesBuildPhase section
3102 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
3103 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
3104 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3105 puts $aPbxprojFile "\t\t\tfiles = ("
3106 puts $aPbxprojFile $aSrcFileGuids
3107 puts $aPbxprojFile "\t\t\t);"
3108 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3109 puts $aPbxprojFile "\t\t\};\n"
3110 # End PBXSourcesBuildPhase section
3112 # Begin XCBuildConfiguration section
3113 set aTkDebugProject "${theToolKit}_DebugProject"
3114 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
3115 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
3118 set aTkReleaseProject "${theToolKit}_ReleaseProject"
3119 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
3120 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
3123 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
3124 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
3125 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
3128 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
3129 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
3130 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
3134 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
3135 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3136 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3138 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
3139 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3140 if { "$thePlatform" == "ios" } {
3141 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3142 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3143 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3144 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3146 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3147 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3148 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
3149 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
3150 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3151 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
3152 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3153 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
3154 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3155 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
3156 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
3157 puts $aPbxprojFile "\t\t\t\t);"
3158 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
3159 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3160 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3161 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3162 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3163 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3164 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
3165 if { "$thePlatform" == "ios" } {
3166 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
3167 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3169 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
3171 puts $aPbxprojFile "\t\t\t\};"
3173 puts $aPbxprojFile "\t\t\tname = Debug;"
3174 puts $aPbxprojFile "\t\t\};"
3177 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
3178 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3179 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3181 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
3182 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3183 if { "$thePlatform" == "ios" } {
3184 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3185 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3186 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3187 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3189 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3190 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3191 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"c++0x\";"
3192 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
3193 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3194 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3195 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
3196 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
3197 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3198 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3199 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3200 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3201 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3202 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
3203 if { "$thePlatform" == "ios" } {
3204 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
3205 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3207 puts $aPbxprojFile "\t\t\t\};"
3208 puts $aPbxprojFile "\t\t\tname = Release;"
3209 puts $aPbxprojFile "\t\t\};"
3210 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
3211 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3212 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3213 puts $aPbxprojFile "${anExecExtension}"
3214 puts $aPbxprojFile "${anExecPrefix}"
3215 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3216 foreach aMacro $aTKDefines {
3217 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3219 puts $aPbxprojFile "\t\t\t\t);"
3221 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3222 foreach anIncPath $anIncPaths {
3223 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3225 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3226 puts $aPbxprojFile "\t\t\t\t);"
3228 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3229 foreach anLibPath $anLibPaths {
3230 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3232 puts $aPbxprojFile "\t\t\t\t);"
3234 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3235 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3236 puts $aPbxprojFile "\t\t\t\t);"
3237 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3238 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3239 puts $aPbxprojFile "\t\t\t\t);"
3240 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3241 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
3242 foreach anIncPath $anIncPaths {
3243 append anUserHeaderSearchPath " ${anIncPath}"
3245 append anUserHeaderSearchPath "\";"
3246 puts $aPbxprojFile $anUserHeaderSearchPath
3247 puts $aPbxprojFile "${aWrapperExtension}"
3248 puts $aPbxprojFile "\t\t\t\};"
3249 puts $aPbxprojFile "\t\t\tname = Debug;"
3250 puts $aPbxprojFile "\t\t\};"
3251 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
3252 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3253 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3254 puts $aPbxprojFile "${anExecExtension}"
3255 puts $aPbxprojFile "${anExecPrefix}"
3256 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3257 foreach aMacro $aTKDefines {
3258 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3260 puts $aPbxprojFile "\t\t\t\t);"
3261 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3262 foreach anIncPath $anIncPaths {
3263 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3265 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3266 puts $aPbxprojFile "\t\t\t\t);"
3268 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3269 foreach anLibPath $anLibPaths {
3270 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3272 puts $aPbxprojFile "\t\t\t\t);"
3274 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3275 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3276 puts $aPbxprojFile "\t\t\t\t);"
3277 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3278 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3279 puts $aPbxprojFile "\t\t\t\t);"
3280 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3281 puts $aPbxprojFile $anUserHeaderSearchPath
3282 puts $aPbxprojFile "${aWrapperExtension}"
3283 puts $aPbxprojFile "\t\t\t\};"
3284 puts $aPbxprojFile "\t\t\tname = Release;"
3285 puts $aPbxprojFile "\t\t\};\n"
3286 # End XCBuildConfiguration section
3288 # Begin XCConfigurationList section
3289 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3290 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3291 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3292 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3293 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3294 puts $aPbxprojFile "\t\t\t);"
3295 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3296 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3297 puts $aPbxprojFile "\t\t\};"
3298 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3299 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3300 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3301 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3302 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3303 puts $aPbxprojFile "\t\t\t);"
3304 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3305 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3306 puts $aPbxprojFile "\t\t\};\n"
3307 # End XCConfigurationList section
3309 puts $aPbxprojFile "\t\};"
3310 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3311 puts $aPbxprojFile "\}"
3316 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3317 set aUsername [exec whoami]
3319 # Creating folders for Xcode project file.
3320 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3321 wokUtils:FILES:mkdir $anExecutableDir
3322 if { ! [file exists $anExecutableDir] } {
3323 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3327 set aUserDataDir "${anExecutableDir}/xcuserdata"
3328 wokUtils:FILES:mkdir $aUserDataDir
3329 if { ! [file exists $aUserDataDir] } {
3330 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3334 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3335 wokUtils:FILES:mkdir $aUserDataDir
3336 if { ! [file exists $aUserDataDir] } {
3337 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3341 set aSchemesDir "${aUserDataDir}/xcschemes"
3342 wokUtils:FILES:mkdir $aSchemesDir
3343 if { ! [file exists $aSchemesDir] } {
3344 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3347 # End folders creation.
3349 # Generating GUID for tookit.
3350 upvar $theGuidsMap aGuidsMap
3351 if { ! [info exists aGuidsMap($theExecutable)] } {
3352 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3355 # Creating xcscheme file for toolkit from template.
3356 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3357 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3358 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3359 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3360 puts $aXcschemeFile $aXcschemeTmpl
3361 close $aXcschemeFile
3363 # Creating xcschememanagement.plist file for toolkit from template.
3364 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3365 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3366 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3367 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3368 puts $aPlistFile $aPlistTmpl
3372 # Returns available Windows SDKs versions
3373 proc osutils:sdk { theSdkMajorVer {isQuietMode false} {theSdkDirectories {}} } {
3374 if { ![llength ${theSdkDirectories}] } {
3375 foreach anEnvVar { "ProgramFiles" "ProgramFiles\(x86\)" "ProgramW6432" } {
3376 if {[ info exists ::env(${anEnvVar}) ]} {
3377 lappend theSdkDirectories "$::env(${anEnvVar})/Windows Kits/${theSdkMajorVer}/Include"
3383 foreach sdk_dir ${theSdkDirectories} {
3384 if { [file isdirectory ${sdk_dir}] } {
3385 lappend sdk_versions [glob -tails -directory "${sdk_dir}" -type d *]
3389 if {![llength ${sdk_versions}] && !${isQuietMode}} {
3390 error "Error : Could not find Windows SDK ${theSdkMajorVer}"
3393 return [join [lsort -unique ${sdk_versions}] " "]
3396 # Generate global properties to Visual Studio project file for UWP solution
3397 proc osutils:uwp:proj { isUWP theProjTmpl } {
3399 set uwp_properties ""
3400 set uwp_generate_metadata ""
3401 set uwp_app_container ""
3403 set format_template ""
3406 set sdk_versions [osutils:sdk 10]
3407 set sdk_max_ver [lindex ${sdk_versions} end]
3409 set uwp_properties "<DefaultLanguage>en-US</DefaultLanguage>\n \
3410 <ApplicationType>Windows Store</ApplicationType>\n \
3411 <ApplicationTypeRevision>10.0</ApplicationTypeRevision>\n \
3412 <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\n \
3413 <AppContainerApplication>true</AppContainerApplication>\n \
3414 <WindowsTargetPlatformVersion>${sdk_max_ver}</WindowsTargetPlatformVersion>\n \
3415 <WindowsTargetPlatformMinVersion>${sdk_max_ver}</WindowsTargetPlatformMinVersion>"
3417 set uwp_generate_metadata "<GenerateWindowsMetadata>false</GenerateWindowsMetadata>"
3419 regsub -all -- {[\r\n\s]*<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>} ${theProjTmpl} "" theProjTmpl
3421 set format_template "\[\\r\\n\\s\]*"
3424 regsub -all -- "${format_template}__UWP_PROPERTIES__" ${theProjTmpl} "${uwp_properties}" theProjTmpl
3425 regsub -all -- "${format_template}__UWP_GENERATE_METADATA__" ${theProjTmpl} "${uwp_generate_metadata}" theProjTmpl
3427 return ${theProjTmpl}
3430 # Report all files found in package directory but not listed in FILES
3431 proc osutils:checksrcfiles { theUnit } {
3433 set aCasRoot [file normalize ${path}]
3435 if {![file isdirectory ${aCasRoot}]} {
3436 puts "OCCT directory is not defined correctly: ${aCasRoot}"
3440 set anUnitAbsPath [file normalize "${aCasRoot}/src/${theUnit}"]
3442 if {[file exists "${anUnitAbsPath}/FILES"]} {
3443 set aFilesFile [open "${anUnitAbsPath}/FILES" rb]
3444 set aFilesFileList [split [read ${aFilesFile}] "\n"]
3447 set aFilesFileList [lsearch -inline -all -not -exact ${aFilesFileList} ""]
3449 # report all files not listed in FILES
3450 set anAllFiles [glob -tails -nocomplain -dir ${anUnitAbsPath} "*"]
3451 foreach aFile ${anAllFiles} {
3452 if { "${aFile}" == "FILES" } {
3455 if { [lsearch -exact ${aFilesFileList} ${aFile}] == -1 } {
3456 puts "Warning: file ${anUnitAbsPath}/${aFile} is not listed in ${anUnitAbsPath}/FILES!"