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 "$::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 # Wrapper-function to generate VS project files
112 proc genproj {theIDE args} {
113 set aSupportedIDEs { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "xcd" }
114 set aSupportedPlatforms { "wnt" "lin" "mac" "ios" "qnx" }
115 set isHelpRequire false
118 if { $theIDE == "-h" || $theIDE == "-help" || $theIDE == "--help" } {
119 set isHelpRequire true
120 } elseif { [lsearch -exact $aSupportedIDEs $theIDE] < 0 } {
121 puts "Error: genproj: unrecognized IDE \"$theIDE\""
122 set isHelpRequire true
125 # choice of compiler for Code::Blocks, currently hard-coded
128 # Determine default platform: wnt for vc*, mac for xcd, current for cbp
129 if { [regexp "^vc" $theIDE] } {
131 } elseif { $theIDE == "xcd" || $::tcl_platform(os) == "Darwin" } {
133 } elseif { $::tcl_platform(platform) == "windows" } {
135 } elseif { $::tcl_platform(platform) == "unix" } {
139 # Check optional arguments
140 set aLibType "dynamic"
142 if { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
143 set isHelpRequire true
144 } elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
146 } elseif { $arg == "-static" } {
147 set aLibType "static"
148 puts "Static build has been selected"
149 } elseif { $arg == "-dynamic" } {
150 set aLibType "dynamic"
151 puts "Dynamic build has been selected"
153 puts "Error: genproj: unrecognized option \"$arg\""
154 set isHelpRequire true
158 if { $isHelpRequire == true } {
159 puts "usage: genproj IDE \[Platform\] \[-static\] \[-h|-help|--help\]
162 vc8 - Visual Studio 2005
163 vc9 - Visual Studio 2008
164 vc10 - Visual Studio 2010
165 vc11 - Visual Studio 2012
166 vc12 - Visual Studio 2013
167 vc14 - Visual Studio 2015
171 Platform (optional, only for CodeBlocks and XCode):
178 Option -static can be used with XCode to build static libraries
183 if { ! [info exists aPlatform] } {
184 puts "Error: genproj: Cannon identify default platform, please specify!"
188 puts "Preparing to generate $theIDE projects for $aPlatform platform..."
190 # path to where to generate projects, hardcoded from current dir
191 set anAdmPath [file normalize "${::path}/adm"]
193 OS:MKPRC "$anAdmPath" "$theIDE" "$aLibType" "$aPlatform" "$aCmpl"
195 genprojbat "$theIDE" $aPlatform
198 proc genprojbat {theIDE thePlatform} {
199 set aTargetPlatformExt sh
200 if { $thePlatform == "wnt" } {
201 set aTargetPlatformExt bat
204 if {"$theIDE" != "cmake"} {
205 # copy env.bat/sh only if not yet present
206 if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
207 set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
208 set anEnvTmpl [read $anEnvTmplFile]
212 if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
213 set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
216 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
218 set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
219 puts $anEnvFile $anEnvTmpl
223 file copy -force -- "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
226 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
227 file copy -force -- "$::THE_CASROOT/adm/templates/msvc.bat" "$::path/msvc.bat"
229 switch -exact -- "$theIDE" {
231 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.sh" "$::path/codeblocks.sh"
232 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.bat" "$::path/codeblocks.bat"
233 # Code::Blocks 16.01 does not create directory for import libs, help him
234 file mkdir "$::path/$thePlatform/cbp/lib"
235 file mkdir "$::path/$thePlatform/cbp/libd"
237 "xcd" { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh" "$::path/xcode.sh" }
242 ###### MSVC #############################################################33
243 proc removeAllOccurrencesOf { theObject theList } {
244 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
245 foreach anIndex $aSortIndices {
246 set theList [lreplace $theList $anIndex $anIndex]
251 set aTKNullKey "TKNull"
252 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
254 # Entry function to generate project files and solutions for IDE
255 # @param theOutDir Root directory for project files
256 # @param theIDE IDE code name (vc10 for Visual Studio 2010, cbp for Code::Blocks, xcd for XCode)
257 # @param theLibType Library type - dynamic or static
258 # @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
259 # @param theCmpl Compiler option (msvc or gcc)
260 proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
262 set anOutRoot $theOutDir
263 if { $anOutRoot == "" } {
264 error "Error : \"theOutDir\" is not initialized"
267 # Create output directory
268 set aWokStation "$thePlatform"
269 if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12 vc14} $theIDE] != -1 } {
270 set aWokStation "msvc"
273 set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
275 # read map of already generated GUIDs
276 set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
277 if [file exists "$aGuidsFilePath"] {
278 set aFileIn [open "$aGuidsFilePath" r]
279 set aFileDataRaw [read $aFileIn]
281 set aFileData [split $aFileDataRaw "\n"]
282 foreach aLine $aFileData {
283 set aLineSplt [split $aLine "="]
284 if { [llength $aLineSplt] == 2 } {
285 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
290 # make list of modules and platforms
291 set aModules [OS:init]
292 if { "$thePlatform" == "ios" } {
293 set goaway [list Draw]
294 set aModules [osutils:juststation $goaway $aModules]
297 # generate one solution for all projects if complete OS or VAS is processed
298 set anAllSolution "OCCT"
300 wokUtils:FILES:mkdir $anOutDir
301 if { ![file exists $anOutDir] } {
302 puts stderr "Error: Could not create output directory \"$anOutDir\""
306 # create the out dir if it does not exist
307 if (![file isdirectory $path/inc]) {
308 puts "$path/inc folder does not exists and will be created"
309 wokUtils:FILES:mkdir $path/inc
312 # collect all required header files
313 puts "Collecting required header files into $path/inc ..."
314 osutils:collectinc $aModules $path/inc
316 # Generating project files for the selected IDE
317 switch -exact -- "$theIDE" {
324 "vc14" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE }
325 "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution $thePlatform $theCmpl }
327 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
328 OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
332 # Store generated GUIDs map
333 set anOutFile [open "$aGuidsFilePath" "w"]
334 fconfigure $anOutFile -translation lf
335 foreach aKey [array names ::THE_GUIDS_LIST] {
336 set aValue $::THE_GUIDS_LIST($aKey)
337 puts $anOutFile "${aKey}=${aValue}"
342 # Function to generate Visual Studio solution and project files
343 proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
345 puts stderr "Generating VS project files for $theVcVer"
347 # generate projects for toolkits and separate solution for each module
348 foreach aModule $theModules {
349 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
350 OS:vcproj $theVcVer $aModule $theOutDir ::THE_GUIDS_LIST
353 # generate single solution "OCCT" containing projects from all modules
354 if { "$theAllSolution" != "" } {
355 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
358 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
361 proc OS:init {{os {}}} {
365 set os $::tcl_platform(os)
368 if [file exists "$::path/src/VAS/Products.tcl"] {
369 source "$::path/src/VAS/Products.tcl"
370 foreach aModuleIter [VAS:Products] {
371 set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
372 if [file exists $aFileTcl] {
374 lappend aModules $aModuleIter
376 puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
382 # Load list of OCCT modules and their definitions
383 source "$::path/src/OS/Modules.tcl"
384 foreach aModuleIter [OS:Modules] {
385 set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
386 if [file exists $aFileTcl] {
388 lappend aModules $aModuleIter
390 puts stderr "Definition file for module $aModuleIter is not found in unit OS"
397 # topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
398 proc wokUtils:EASY:tsort { listofpairs } {
399 foreach x $listofpairs {
402 if ![info exists pcnt($e1)] {
405 if ![ info exists pcnt($e2)] {
410 if ![info exists scnt($e1)] {
416 if [info exists slist($e1)] {
424 foreach node [array names pcnt] {
426 if { $pcnt($node) == 0 } {
430 if ![info exists scnt($node)] {
435 for {set front 1} { $front <= $back } { incr front } {
436 lappend res [set node $q($front)]
437 for {set i 1} {$i <= $scnt($node) } { incr i } {
439 set j [expr {$i - 1}]
440 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
441 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
443 set q($back) [lindex $ll $j]
447 if { $back != $nodecnt } {
448 puts stderr "input contains a cycle"
455 proc wokUtils:LIST:Purge { l } {
458 if ![info exist tab($e)] {
466 # Read file pointed to by path
468 # 2. trim = 1 plusieurs blancs => 1 seul blanc
469 # 3. purge= not yet implemented.
470 # 4. emptl= dont process blank lines
471 proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
472 if ![ catch { set id [ open $path r ] } ] {
474 while {[gets $id line] >= 0 } {
476 regsub -all {[ ]+} $line " " line
479 if { [string length ${line}] != 0 } {
497 # retorn the list of executables in module.
498 proc OS:executable { module } {
500 foreach XXX [${module}:ressources] {
501 if { "[lindex $XXX 1]" == "x" } {
502 lappend lret [lindex $XXX 2]
508 # Topological sort of toolkits in tklm
509 proc osutils:tk:sort { tklm } {
511 foreach tkloc $tklm {
512 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
514 if { [lsearch $tklm $tkx] != -1 } {
515 lappend tkby2 [list $tkx $tkloc]
517 lappend tkby2 [list $tkloc {}]
522 foreach e [wokUtils:EASY:tsort $tkby2] {
530 # close dependencies of ltk. (full wok pathes of toolkits)
531 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
532 # (locate not performed.)
533 proc osutils:tk:close { ltk } {
537 set ids [LibToLink $dir]
538 # puts "osutils:tk:close($ltk) ids='$ids'"
539 set eated [osutils:tk:eatpk $ids]
540 set result [concat $result $eated]
541 set ids [LibToLink $dir]
542 set result [concat $result $ids]
544 foreach file $eated {
545 set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
546 if { [osutils:tk:eatpk $kds] != {} } {
547 lappend recurse $file
551 if { $recurse != {} } {
552 set result [concat $result [osutils:tk:close $recurse]]
557 proc osutils:tk:eatpk { EXTERNLIB } {
558 set l [wokUtils:FILES:FileToList $EXTERNLIB]
561 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
567 # Define libraries to link using only EXTERNLIB file
569 proc LibToLink {theTKit} {
570 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
571 set type [_get_type $theTKit]
572 if {$type != "t" && $type != "x"} {
576 set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
577 foreach anExtLib $anExtLibList {
578 set aFullPath [LocateRecur $anExtLib]
579 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
580 lappend aToolkits $anExtLib
585 # Search unit recursively
587 proc LocateRecur {theName} {
588 set theNamePath [osutils:findSrcSubPath "$theName"]
589 if {[file isdirectory $theNamePath]} {
595 proc OS:genGUID { {theIDE "vc"} } {
596 if { "$theIDE" == "vc" } {
597 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
598 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
599 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
600 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
601 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
602 return "{$p1-$p2-$p3-$p4-$p5}"
604 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
605 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
606 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
607 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
608 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
609 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
610 return "$p1$p2$p3$p4$p5$p6"
614 # collect all include file that required for theModules in theOutDir
615 proc osutils:collectinc {theModules theIncPath} {
617 set aCasRoot [file normalize $path]
618 set anIncPath [file normalize $theIncPath]
620 if {![file isdirectory $aCasRoot]} {
621 puts "OCCT directory is not defined correctly: $aCasRoot"
625 set anUsedToolKits {}
626 foreach aModule $theModules {
627 foreach aToolKit [${aModule}:toolkits] {
628 lappend anUsedToolKits $aToolKit
630 foreach aDependency [LibToLink $aToolKit] {
631 lappend anUsedToolKits $aDependency
634 foreach anExecutable [OS:executable ${aModule}] {
635 lappend anUsedToolKits $anExecutable
637 foreach aDependency [LibToLink $anExecutable] {
638 lappend anUsedToolKits $aDependency
642 set anUsedToolKits [lsort -unique $anUsedToolKits]
645 foreach anUsedToolKit $anUsedToolKits {
646 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
648 set anUnits [lsort -unique $anUnits]
650 # define copying style
652 if { [info exists ::env(SHORTCUT_HEADERS)] } {
653 if { [string equal -nocase $::env(SHORTCUT_HEADERS) "hard"]
654 || [string equal -nocase $::env(SHORTCUT_HEADERS) "hardlink"] } {
655 set aCopyType "hardlink"
656 } elseif { [string equal -nocase $::env(SHORTCUT_HEADERS) "true"]
657 || [string equal -nocase $::env(SHORTCUT_HEADERS) "shortcut"] } {
658 set aCopyType "shortcut"
662 if { $aCopyType == "shortcut" } {
663 # template preparation
664 if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
665 puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
668 set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
670 # relative anIncPath in connection with aCasRoot/src
671 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
673 # create and copy short-cut header files
674 foreach anUnit $anUnits {
675 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
676 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
677 set aHeaderFileName [file tail $aHeaderFile]
679 regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
681 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
682 set fp [open "$theIncPath/$aHeaderFileName" r]
683 set aHeaderContent [read $fp]
687 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
689 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
690 # remove eof from string
691 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
693 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
697 file delete -force "$theIncPath/$aHeaderFileName"
700 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
701 fconfigure $aShortCutHeaderFile -translation lf
702 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
703 close $aShortCutHeaderFile
708 foreach anUnit $anUnits {
709 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
710 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
711 set aHeaderFileName [file tail $aHeaderFile]
713 # copy file only if target does not exist or is older than original
714 set torig [file mtime $aHeaderFile]
716 if { [file isfile $anIncPath/$aHeaderFileName] } {
717 set tcopy [file mtime $anIncPath/$aHeaderFileName]
719 if { $tcopy < $torig } {
721 if { $aCopyType == "hardlink" } {
723 file delete -force "$theIncPath/$aHeaderFileName"
725 file link -hard $anIncPath/$aHeaderFileName $aHeaderFile
727 file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
729 } elseif { $tcopy != $torig } {
730 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
734 puts "Info: $nbcopied files updated"
738 # Generate header for VS solution file
739 proc osutils:vcsolution:header { vcversion } {
740 if { "$vcversion" == "vc7" } {
742 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
743 } elseif { "$vcversion" == "vc8" } {
745 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
746 "# Visual Studio 2005\n"
747 } elseif { "$vcversion" == "vc9" } {
749 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
750 "# Visual Studio 2008\n"
751 } elseif { "$vcversion" == "vc10" } {
753 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
754 "# Visual Studio 2010\n"
755 } elseif { "$vcversion" == "vc11" } {
757 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
758 "# Visual Studio 2012\n"
759 } elseif { "$vcversion" == "vc12" } {
761 "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
762 "# Visual Studio 2013\n"
763 } elseif { "$vcversion" == "vc14" } {
765 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
766 "# Visual Studio 14\n"
768 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
772 # Returns extension (without dot) for project files of given version of VC
774 proc osutils:vcproj:ext { vcversion } {
775 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
781 # Generate start of configuration section of VS solution file
783 proc osutils:vcsolution:config:begin { vcversion } {
784 if { "$vcversion" == "vc7" } {
787 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
788 "\t\tDebug = Debug\n" \
789 "\t\tRelease = Release\n" \
790 "\tEndGlobalSection\n" \
791 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
795 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
796 "\t\tDebug|Win32 = Debug|Win32\n" \
797 "\t\tRelease|Win32 = Release|Win32\n" \
798 "\t\tDebug|x64 = Debug|x64\n" \
799 "\t\tRelease|x64 = Release|x64\n" \
800 "\tEndGlobalSection\n" \
801 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
805 # Generate part of configuration section of VS solution file describing one project
807 proc osutils:vcsolution:config:project { vcversion guid } {
808 if { "$vcversion" == "vc7" } {
810 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
811 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
812 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
813 "\t\t$guid.Release.Build.0 = Release|Win32\n"
816 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
817 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
818 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
819 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
820 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
821 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
822 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
823 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
827 # Generate start of configuration section of VS solution file
829 proc osutils:vcsolution:config:end { vcversion } {
830 if { "$vcversion" == "vc7" } {
832 "\tEndGlobalSection\n" \
833 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
834 "\tEndGlobalSection\n" \
835 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
836 "\tEndGlobalSection\n"
839 "\tEndGlobalSection\n" \
840 "\tGlobalSection(SolutionProperties) = preSolution\n" \
841 "\t\tHideSolutionNode = FALSE\n" \
842 "\tEndGlobalSection\n"
846 # generate Visual Studio solution file
847 # if module is empty, generates one solution for all known modules
849 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
851 upvar $theGuidsMap aGuidsMap
853 # collect list of projects to be created
856 foreach aModule $theModules {
858 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
859 lappend aProjects $aToolKit
860 lappend aProjectsInModule($aModule) $aToolKit
861 lappend aDependencies [LibToLink $aToolKit]
863 # executables, assume one project per cxx file...
864 foreach aUnit [OS:executable ${aModule}] {
866 set src_files [_get_used_files $aUnit false]
868 foreach s $src_files {
869 regexp {source ([^\s]+)} $s dummy name
870 lappend aSrcFiles $name
872 foreach aSrcFile $aSrcFiles {
873 set aFileExtension [file extension $aSrcFile]
874 if { $aFileExtension == ".cxx" } {
875 set aPrjName [file rootname $aSrcFile]
876 lappend aProjects $aPrjName
877 lappend aProjectsInModule($aModule) $aPrjName
878 if {[file isdirectory $path/src/$aUnitLoc]} {
879 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
881 lappend aDependencies {}
888 # generate GUIDs for projects (unless already known)
889 foreach aProject $aProjects {
890 if { ! [info exists aGuidsMap($aProject)] } {
891 set aGuidsMap($aProject) [OS:genGUID]
895 # generate solution file
896 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
897 append aFileBuff [osutils:vcsolution:header $theVcVer]
899 # GUID identifying group projects in Visual Studio
900 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
902 # generate group projects -- one per module
903 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
904 foreach aModule $theModules {
905 if { ! [info exists aGuidsMap(_$aModule)] } {
906 set aGuidsMap(_$aModule) [OS:genGUID]
908 set aGuid $aGuidsMap(_$aModule)
909 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
913 # extension of project files
914 set aProjExt [osutils:vcproj:ext $theVcVer]
916 # GUID identifying C++ projects in Visual Studio
917 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
919 # generate normal projects
920 set aProjsNb [llength $aProjects]
921 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
922 set aProj [lindex $aProjects $aProjId]
923 set aGuid $aGuidsMap($aProj)
924 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
925 # write projects dependencies information (vc7 to vc9)
927 foreach aDepLib [lindex $aDependencies $aProjId] {
928 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
929 set depGUID $aGuidsMap($aDepLib)
930 append aDepGuids "\t\t$depGUID = $depGUID\n"
933 if { "$aDepGuids" != "" } {
934 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
935 append aFileBuff "$aDepGuids"
936 append aFileBuff "\tEndProjectSection\n"
938 append aFileBuff "EndProject\n"
941 # generate configuration section
942 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
943 foreach aProj $aProjects {
944 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
946 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
948 # write information of grouping of projects by module
949 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
950 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
951 foreach aModule $theModules {
952 if { ! [info exists aProjectsInModule($aModule)] } { continue }
953 foreach aProject $aProjectsInModule($aModule) {
954 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
957 append aFileBuff " EndGlobalSection\n"
960 # final word (footer)
961 append aFileBuff "EndGlobal"
964 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
965 fconfigure $aFile -translation crlf
966 puts $aFile $aFileBuff
968 return [file join $theOutDir ${theSolName}.sln]
970 # Generate Visual Studio projects for specified version
972 proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
973 upvar $theGuidsMap aGuidsMap
977 foreach aModule $theModules {
978 foreach aToolKit [${aModule}:toolkits] {
979 lappend aProjectFiles [osutils:vcproj $theVcVer $theOutDir $aToolKit aGuidsMap]
981 foreach anExecutable [OS:executable ${aModule}] {
982 lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
985 return $aProjectFiles
987 # generate template name and load it for given version of Visual Studio and platform
989 proc osutils:vcproj:readtemplate {theVcVer isexec} {
991 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
996 set aVerExt [string range $theVcVer 2 end]
997 set aVerExt "v${aVerExt}0"
1001 set anExt "${anExt}x"
1002 set what "$what executable"
1004 if { "$theVcVer" == "vc10" } {
1005 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
1006 set aCmpl32 "\n <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
1008 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
1009 regsub -all -- {__VCVER__} $aTmpl $theVcVer aTmpl
1010 regsub -all -- {__VCVEREXT__} $aTmpl $aVerExt aTmpl
1011 regsub -all -- {__VCMPL32__} $aTmpl $aCmpl32 aTmpl
1012 regsub -all -- {__VCMPL64__} $aTmpl $aCmpl64 aTmpl
1016 proc osutils:readtemplate {ext what} {
1017 set loc "$::THE_CASROOT/adm/templates/template.$ext"
1018 return [wokUtils:FILES:FileToString $loc]
1020 # Read a file in a string as is.
1022 proc wokUtils:FILES:FileToString { fin } {
1023 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1024 set strin [read $in [file size $fin]]
1032 # List extensions of compilable files in OCCT
1033 proc osutils:compilable {thePlatform} {
1034 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
1035 return [list .c .cxx .cpp .mm]
1037 return [list .c .cxx .cpp]
1040 proc osutils:commonUsedTK { theToolKit } {
1041 set anUsedToolKits [list]
1042 set aDepToolkits [LibToLink $theToolKit]
1043 foreach tkx $aDepToolkits {
1044 if {[_get_type $tkx] == "t"} {
1045 lappend anUsedToolKits "${tkx}"
1048 return $anUsedToolKits
1051 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1052 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1053 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1056 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1063 # Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
1064 # @param theOS - target OS
1065 # @param theCsfLibsMap - libraries map
1066 # @param theCsfFrmsMap - frameworks map, OS X specific
1067 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1068 upvar $theCsfLibsMap aLibsMap
1069 upvar $theCsfFrmsMap aFrmsMap
1074 set aLibsMap(CSF_FREETYPE) "freetype"
1075 set aLibsMap(CSF_TclLibs) "tcl8.6"
1076 set aLibsMap(CSF_TclTkLibs) "tk8.6"
1077 if { "$::HAVE_FREEIMAGE" == "true" } {
1078 if { "$theOS" == "wnt" } {
1079 set aLibsMap(CSF_FreeImagePlus) "FreeImage FreeImagePlus"
1081 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1084 if { "$::HAVE_GL2PS" == "true" } {
1085 set aLibsMap(CSF_GL2PS) "gl2ps"
1087 if { "$::HAVE_TBB" == "true" } {
1088 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1090 if { "$::HAVE_VTK" == "true" } {
1091 if { "$theOS" == "wnt" } {
1092 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1094 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1098 if { "$theOS" == "wnt" } {
1100 set aLibsMap(CSF_kernel32) "kernel32"
1101 set aLibsMap(CSF_advapi32) "advapi32"
1102 set aLibsMap(CSF_gdi32) "gdi32"
1103 set aLibsMap(CSF_user32) "user32 comdlg32"
1104 set aLibsMap(CSF_opengl32) "opengl32"
1105 set aLibsMap(CSF_wsock32) "wsock32"
1106 set aLibsMap(CSF_netapi32) "netapi32"
1107 set aLibsMap(CSF_AviLibs) "ws2_32 vfw32"
1108 set aLibsMap(CSF_OpenGlLibs) "opengl32"
1109 set aLibsMap(CSF_winspool) "Winspool"
1110 set aLibsMap(CSF_psapi) "Psapi"
1111 set aLibsMap(CSF_d3d9) "d3d9"
1113 # the naming is different on Windows
1114 set aLibsMap(CSF_TclLibs) "tcl86"
1115 set aLibsMap(CSF_TclTkLibs) "tk86"
1117 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1119 # tbb headers define different pragma lib depending on debug/release
1120 set aLibsMap(CSF_TBB) ""
1122 if { "$theOS" == "mac" } {
1123 set aLibsMap(CSF_objc) "objc"
1124 set aFrmsMap(CSF_Appkit) "Appkit"
1125 set aFrmsMap(CSF_IOKit) "IOKit"
1126 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1127 set aFrmsMap(CSF_TclLibs) "Tcl"
1128 set aLibsMap(CSF_TclLibs) ""
1129 set aFrmsMap(CSF_TclTkLibs) "Tk"
1130 set aLibsMap(CSF_TclTkLibs) ""
1132 if { "$theOS" == "qnx" } {
1133 # CSF_ThreadLibs - pthread API is part of libc on QNX
1134 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1136 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1137 set aLibsMap(CSF_OpenGlLibs) "GL"
1138 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1139 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1140 set aLibsMap(CSF_MotifLibs) "X11"
1146 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1147 proc osutils:vtkCsf {{theOS ""}} {
1150 set aPathSplitter ":"
1151 if {"$theOS" == "wnt"} {
1152 set aPathSplitter ";"
1155 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1156 foreach anIncItem $anOptIncs {
1157 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1158 set aVtkVer $aFoundVtkVer
1162 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1163 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1165 # Additional suffices for the libraries
1167 foreach anItem $aLibArray {
1168 lset aLibArray $anIdx $anItem-$aVtkVer
1172 return [join $aLibArray " "]
1175 # @param theLibsList - dependencies (libraries list)
1176 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1177 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1179 upvar $theLibsList aLibsList
1180 upvar $theFrameworks aFrameworks
1181 set aLibsList [list]
1182 set aFrameworks [list]
1184 osutils:csfList $theOS aLibsMap aFrmsMap
1186 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1187 if [info exists aLibsMap($aCsfElem)] {
1188 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1189 if { [lsearch $aLibsList $aLib] == "-1" } {
1190 lappend aLibsList $aLib
1194 if [info exists aFrmsMap($aCsfElem)] {
1195 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1196 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1197 lappend aFrameworks $aFrm
1204 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1205 proc osutils:tk:units { tkloc } {
1208 set PACKAGES "$path/src/$tkloc/PACKAGES"
1209 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1210 if {[file isdirectory "$path/src/$u"]} {
1215 ;#puts stderr "Warning. No devunit included in $tkloc"
1220 proc osutils:justwnt { listloc } {
1221 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1222 set goaway [list Xdps Xw ImageUtility WOKUnix]
1223 return [osutils:juststation $goaway $listloc]
1226 # remove from listloc OpenCascade units indesirables on NT
1227 proc osutils:juststation {goaway listloc} {
1230 foreach u $listloc {
1231 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1232 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1239 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1240 # The first list is everything in the first list that wasn't in the second,
1241 # the second list contains the intersection of the two lists, the third list contains everything
1242 # in the second list that wasn't in the first.
1243 proc osutils:intersect3 {list1 list2} {
1244 set la1(0) {} ; unset la1(0)
1245 set lai(0) {} ; unset lai(0)
1246 set la2(0) {} ; unset la2(0)
1253 foreach elem [concat $list1 $list2] {
1254 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1260 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1263 # Prepare relative path
1264 proc relativePath {thePathFrom thePathTo} {
1265 if { [file isdirectory "$thePathFrom"] == 0 } {
1269 set aPathFrom [file normalize "$thePathFrom"]
1270 set aPathTo [file normalize "$thePathTo"]
1272 set aCutedPathFrom "${aPathFrom}/dummy"
1273 set aRelatedDeepPath ""
1275 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1276 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1277 # does aPathTo contain aCutedPathFrom?
1278 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1279 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1280 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1281 set aPathTo ".${aPathTo}"
1282 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1283 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1285 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1286 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1287 return $aPathToAfterCut
1289 set aRelatedDeepPath "$aRelatedDeepPath../"
1296 proc wokUtils:EASY:bs1 { s } {
1297 regsub -all {/} $s {\\} r
1301 # Returs for a full path the liste of n last directory part
1303 # n = 2 => dir/file.c
1304 # n = 3 => sdir/dir/file.c
1306 proc wokUtils:FILES:wtail { f n } {
1307 set ll [expr [llength [set lif [file split $f]]] -$n]
1308 return [join [lrange $lif $ll end] /]
1311 # Generate entry for one source file in Visual Studio 10 project file
1312 proc osutils:vcxproj:file { vcversion file params } {
1313 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1314 if { $params != "" } {
1315 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1318 if { $params != "" } {
1319 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1322 if { $params != "" } {
1323 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1326 if { $params != "" } {
1327 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1330 append text " </ClCompile>\n"
1334 # Generate Visual Studio 2010 project filters file
1335 proc osutils:vcxproj:filters { dir proj theFilesMap } {
1336 upvar $theFilesMap aFilesMap
1339 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1340 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1342 # list of "filters" (units)
1343 append text " <ItemGroup>\n"
1344 append text " <Filter Include=\"Source files\">\n"
1345 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1346 append text " </Filter>\n"
1347 foreach unit $aFilesMap(units) {
1348 append text " <Filter Include=\"Source files\\${unit}\">\n"
1349 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1350 append text " </Filter>\n"
1352 append text " </ItemGroup>\n"
1355 append text " <ItemGroup>\n"
1356 foreach unit $aFilesMap(units) {
1357 foreach file $aFilesMap($unit) {
1358 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1359 append text " <Filter>Source files\\${unit}</Filter>\n"
1360 append text " </ClCompile>\n"
1363 append text " </ItemGroup>\n"
1366 append text "</Project>"
1369 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1370 fconfigure $fp -translation crlf
1374 return ${proj}.vcxproj.filters
1377 # Generate Visual Studio 2011 project filters file
1378 proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1379 upvar $theFilesMap aFilesMap
1382 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1383 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1385 # list of "filters" (units)
1386 append text " <ItemGroup>\n"
1387 append text " <Filter Include=\"Source files\">\n"
1388 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1389 append text " </Filter>\n"
1390 foreach unit $aFilesMap(units) {
1391 append text " <Filter Include=\"Source files\\${unit}\">\n"
1392 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1393 append text " </Filter>\n"
1395 append text " </ItemGroup>\n"
1398 append text " <ItemGroup>\n"
1399 foreach unit $aFilesMap(units) {
1400 foreach file $aFilesMap($unit) {
1401 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1402 append text " <Filter>Source files\\${unit}</Filter>\n"
1403 append text " </ClCompile>\n"
1406 append text " </ItemGroup>\n"
1408 append text " <ItemGroup>\n"
1409 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1410 append text " </ItemGroup>\n"
1413 append text "</Project>"
1416 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1417 fconfigure $fp -translation crlf
1421 return ${proj}.vcxproj.filters
1424 # Generate RC file content for ToolKit from template
1425 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1426 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1427 set aBody [wokUtils:FILES:FileToString $aLoc]
1428 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1430 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1431 fconfigure $aFile -translation lf
1434 return "${theOutDir}/${theToolKit}.rc"
1437 # Generate Visual Studio project file for ToolKit
1438 proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1439 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1441 set l_compilable [osutils:compilable wnt]
1442 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1444 upvar $theGuidsMap aGuidsMap
1445 if { ! [info exists aGuidsMap($theToolKit)] } {
1446 set aGuidsMap($theToolKit) [OS:genGUID]
1448 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1450 set aUsedLibs [list]
1451 foreach tkx [osutils:commonUsedTK $theToolKit] {
1452 lappend aUsedLibs "${tkx}.lib"
1455 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1456 foreach aLibIter $aLibs {
1457 lappend aUsedLibs "${aLibIter}.lib"
1460 # correct names of referred third-party libraries that are named with suffix
1461 # depending on VC version
1462 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1464 # and put this list to project file
1465 #puts "$theToolKit requires $aUsedLibs"
1466 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1467 set aUsedLibs [join $aUsedLibs {;}]
1469 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1471 set anIncPaths "..\\..\\..\\inc"
1473 set aFilesSection ""
1474 set aVcFilesX(units) ""
1475 set listloc [osutils:tk:units $theToolKit]
1476 set resultloc [osutils:justwnt $listloc]
1477 if [array exists written] { unset written }
1478 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1479 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1480 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1481 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1482 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1483 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1485 foreach fxlo $resultloc {
1487 set aSrcFiles [osutils:tk:files $xlo wnt]
1488 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1489 if {$fxlo_cmplrs_options_cxx == ""} {
1490 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1492 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1493 if {$fxlo_cmplrs_options_c == ""} {
1494 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1496 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1497 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1498 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1499 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1500 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1501 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1503 foreach partopt $fxloparam {
1504 if {[string first "-I" $partopt] == "0"} {
1505 # this is an additional includes search path
1508 set needparam "$needparam $partopt"
1511 # Format of projects in vc10+ is different from vc7-9
1512 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1513 foreach aSrcFile [lsort $aSrcFiles] {
1514 if { ![info exists written([file tail $aSrcFile])] } {
1515 set written([file tail $aSrcFile]) 1
1516 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1518 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1520 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1521 lappend aVcFilesX($xlo) $aSrcFile
1524 append aFilesSection "\t\t\t<Filter\n"
1525 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1526 append aFilesSection "\t\t\t\t>\n"
1527 foreach aSrcFile [lsort $aSrcFiles] {
1528 if { ![info exists written([file tail $aSrcFile])] } {
1529 set written([file tail $aSrcFile]) 1
1530 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1532 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1535 append aFilesSection "\t\t\t</Filter>\n"
1539 append aTKDefines ";__${xlo}_DLL"
1541 # append anIncPaths ";..\\..\\..\\src\\${xlo}"
1544 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1545 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1546 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1549 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1550 fconfigure $aFile -translation crlf
1551 puts $aFile $theProjTmpl
1554 # write filters file for vc10+
1555 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1557 } elseif { "$theVcVer" == "vc10" } {
1558 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
1560 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1563 # write resource file
1564 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1569 # for a unit returns a map containing all its file in the current
1571 # local = 1 only local files
1572 proc osutils:tk:loadunit { loc map } {
1575 catch { unset TLOC }
1576 set lfiles [_get_used_files $loc]
1581 if [info exists TLOC($t)] {
1592 # Returns the list of all compilable files name in a toolkit, or devunit of any type
1593 # Tfiles lists for each unit the type of file that can be compiled.
1594 proc osutils:tk:files { tkloc thePlatform } {
1595 set Tfiles(source,nocdlpack) {source pubinclude}
1596 set Tfiles(source,toolkit) {}
1597 set Tfiles(source,executable) {source pubinclude}
1598 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1599 #puts " listloc = $listloc"
1601 set l_comp [osutils:compilable $thePlatform]
1602 set resultloc $listloc
1604 foreach loc $resultloc {
1605 set utyp [_get_type $loc]
1606 #puts "\"$utyp\" \"$loc\""
1608 "t" { set utyp "toolkit" }
1609 "n" { set utyp "nocdlpack" }
1610 "x" { set utyp "executable" }
1612 if [array exists map] { unset map }
1613 osutils:tk:loadunit $loc map
1614 #puts " loc = $loc === > [array names map]"
1615 set LType $Tfiles(source,${utyp})
1616 foreach typ [array names map] {
1617 if { [lsearch $LType $typ] == -1 } {
1621 foreach type [array names map] {
1623 foreach f $map($type) {
1625 if { [lsearch $l_comp [file extension $f]] != -1 } {
1634 # Generate Visual Studio project file for executable
1635 proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1637 foreach f [osutils:tk:files $theToolKit wnt] {
1638 if { $theProjTmpl == {} } {
1639 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1641 set aProjTmpl $theProjTmpl
1643 set aProjName [file rootname [file tail $f]]
1644 set l_compilable [osutils:compilable wnt]
1645 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1647 upvar $theGuidsMap aGuidsMap
1648 if { ! [info exists aGuidsMap($aProjName)] } {
1649 set aGuidsMap($aProjName) [OS:genGUID]
1651 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1653 set aUsedLibs [list]
1654 foreach tkx [osutils:commonUsedTK $theToolKit] {
1655 lappend aUsedLibs "${tkx}.lib"
1658 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1659 foreach aLibIter $aLibs {
1660 lappend aUsedLibs "${aLibIter}.lib"
1663 # correct names of referred third-party libraries that are named with suffix
1664 # depending on VC version
1665 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1667 # puts "$aProjName requires $aUsedLibs"
1668 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1669 set aUsedLibs [join $aUsedLibs {;}]
1671 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1673 set aFilesSection ""
1674 set aVcFilesX(units) ""
1676 if { ![info exists written([file tail $f])] } {
1677 set written([file tail $f]) 1
1679 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1680 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1681 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1682 lappend aVcFilesX($theToolKit) $f
1684 append aFilesSection "\t\t\t<Filter\n"
1685 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1686 append aFilesSection "\t\t\t\t>\n"
1687 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1688 append aFilesSection "\t\t\t</Filter>"
1691 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1693 #puts "$aProjTmpl $aFilesSection"
1694 set aTKDefines ";__${theToolKit}_DLL"
1695 set anIncPaths "..\\..\\..\\inc"
1696 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1697 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1698 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1699 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1701 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1703 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1704 fconfigure $aFile -translation crlf
1705 puts $aFile $aProjTmpl
1708 set aCommonSettingsFile "$aVcFilePath.user"
1709 lappend aVcFiles $aVcFilePath
1711 # write filters file for vc10
1712 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1713 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1716 set aCommonSettingsFileTmpl ""
1717 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1719 } elseif { "$theVcVer" == "vc9" } {
1720 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
1722 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
1724 if { "$aCommonSettingsFileTmpl" != "" } {
1725 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1727 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1728 fconfigure $aFile -translation crlf
1729 puts $aFile $aCommonSettingsFileTmpl
1732 lappend aVcFiles "$aCommonSettingsFile"
1738 # Generate entry for one source file in Visual Studio 7 - 9 project file
1739 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1740 append aText "\t\t\t\t<File\n"
1741 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1742 if { $theOptions == "" } {
1743 append aText "\t\t\t\t</File>\n"
1747 append aText "\t\t\t\t\t<FileConfiguration\n"
1748 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1749 append aText "\t\t\t\t\t\t<Tool\n"
1750 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1751 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1752 foreach aParam $theOptions {
1753 append aText "$aParam "
1756 append aText "\t\t\t\t\t\t/>\n"
1757 append aText "\t\t\t\t\t</FileConfiguration>\n"
1759 append aText "\t\t\t\t\t<FileConfiguration\n"
1760 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1761 append aText "\t\t\t\t\t\t<Tool\n"
1762 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1763 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1764 foreach aParam $theOptions {
1765 append aText "$aParam "
1768 append aText "\t\t\t\t\t\t/>\n"
1769 append aText "\t\t\t\t\t</FileConfiguration>\n"
1770 if { "$theVcVer" == "vc7" } {
1771 append aText "\t\t\t\t</File>\n"
1775 append aText "\t\t\t\t\t<FileConfiguration\n"
1776 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1777 append aText "\t\t\t\t\t\t<Tool\n"
1778 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1779 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1780 foreach aParam $theOptions {
1781 append aText "$aParam "
1784 append aText "\t\t\t\t\t\t/>\n"
1785 append aText "\t\t\t\t\t</FileConfiguration>\n"
1787 append aText "\t\t\t\t\t<FileConfiguration\n"
1788 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1789 append aText "\t\t\t\t\t\t<Tool\n"
1790 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1791 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1792 foreach aParam $theOptions {
1793 append aText "$aParam "
1796 append aText "\t\t\t\t\t\t/>\n"
1797 append aText "\t\t\t\t\t</FileConfiguration>\n"
1799 append aText "\t\t\t\t</File>\n"
1803 proc wokUtils:FILES:mkdir { d } {
1805 regsub -all {\.[^.]*} $tcl_version "" major
1806 if { $major == 8 } {
1809 if ![file exists $d] {
1810 if { "[info command mkdir]" == "mkdir" } {
1813 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1817 if [file exists $d] {
1824 # remove from listloc OpenCascade units indesirables on Unix
1825 proc osutils:justunix { listloc } {
1826 if { "$::tcl_platform(os)" == "Darwin" } {
1827 set goaway [list Xw WNT]
1829 set goaway [list WNT]
1831 return [osutils:juststation $goaway $listloc]
1835 ####### CODEBLOCK ###################################################################
1836 # Function to generate Code Blocks workspace and project files
1837 proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
1838 puts stderr "Generating project files for Code Blocks"
1840 # Generate projects for toolkits and separate workspace for each module
1841 foreach aModule $theModules {
1842 OS:cworkspace $aModule $aModule $theOutDir
1843 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
1846 # Generate single workspace "OCCT" containing projects from all modules
1847 if { "$theAllSolution" != "" } {
1848 OS:cworkspace $theAllSolution $theModules $theOutDir
1851 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
1854 # Generate Code Blocks projects
1855 proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
1856 set aProjectFiles {}
1857 foreach aModule $theModules {
1858 foreach aToolKit [${aModule}:toolkits] {
1859 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
1861 foreach anExecutable [OS:executable ${aModule}] {
1862 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
1865 return $aProjectFiles
1868 # Generate Code::Blocks project file for ToolKit
1869 proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
1870 set aUsedLibs [list]
1871 set aFrameworks [list]
1872 set anIncPaths [list]
1873 set aTKDefines [list]
1874 set aTKSrcFiles [list]
1876 # collect list of referred libraries to link with
1877 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
1878 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
1879 foreach tkx $aDepToolkits {
1880 lappend aUsedLibs "${tkx}"
1883 lappend anIncPaths "../../../inc"
1884 set listloc [osutils:tk:units $theToolKit]
1886 if { [llength $listloc] == 0 } {
1887 set listloc $theToolKit
1890 if { $thePlatform == "wnt" } {
1891 set resultloc [osutils:justwnt $listloc]
1893 set resultloc [osutils:justunix $listloc]
1895 if [array exists written] { unset written }
1896 foreach fxlo $resultloc {
1898 set aSrcFiles [osutils:tk:files $xlo $thePlatform]
1899 foreach aSrcFile [lsort $aSrcFiles] {
1900 if { ![info exists written([file tail $aSrcFile])] } {
1901 set written([file tail $aSrcFile]) 1
1902 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
1904 puts "Warning : more than one occurences for [file tail $aSrcFile]"
1908 # macros for correct DLL exports
1909 if { $thePlatform == "wnt" } {
1910 lappend aTKDefines "__${xlo}_DLL"
1914 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
1917 # Generates Code Blocks workspace.
1918 proc OS:cworkspace { theSolName theModules theOutDir } {
1920 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
1921 set aFile [open $aWsFilePath "w"]
1923 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
1924 puts $aFile "<CodeBlocks_workspace_file>"
1925 puts $aFile "\t<Workspace title=\"${theSolName}\">"
1927 # collect list of projects to be created
1928 foreach aModule $theModules {
1930 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1931 set aDependencies [LibToLink $aToolKit]
1932 if { [llength $aDependencies] == 0 } {
1933 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
1935 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
1936 foreach aDepTk $aDependencies {
1937 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1939 puts $aFile "\t\t</Project>"
1943 # executables, assume one project per cxx file...
1944 foreach aUnit [OS:executable ${aModule}] {
1946 set src_files [_get_used_files $aUnit false]
1948 foreach s $src_files {
1949 regexp {source ([^\s]+)} $s dummy name
1950 lappend aSrcFiles $name
1952 foreach aSrcFile $aSrcFiles {
1953 set aFileExtension [file extension $aSrcFile]
1954 if { $aFileExtension == ".cxx" } {
1955 set aPrjName [file rootname $aSrcFile]
1956 set aDependencies [list]
1957 if {[file isdirectory $path/src/$aUnitLoc]} {
1958 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1960 set anActiveState ""
1961 if { $isActiveSet == 0 } {
1962 set anActiveState " active=\"1\""
1965 if { [llength $aDependencies] == 0 } {
1966 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
1968 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
1969 foreach aDepTk $aDependencies {
1970 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1972 puts $aFile "\t\t</Project>"
1979 puts $aFile "\t</Workspace>"
1980 puts $aFile "</CodeBlocks_workspace_file>"
1986 # Generate Code::Blocks project file for Executable
1987 proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
1989 set aWokArch "$::env(ARCH)"
1992 foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
1993 # collect list of referred libraries to link with
1994 set aUsedLibs [list]
1995 set aFrameworks [list]
1996 set anIncPaths [list]
1997 set aTKDefines [list]
1998 set aTKSrcFiles [list]
1999 set aProjName [file rootname [file tail $aSrcFile]]
2001 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2003 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2004 foreach tkx $aDepToolkits {
2005 if {[_get_type $tkx] == "t"} {
2006 lappend aUsedLibs "${tkx}"
2008 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2009 lappend aUsedLibs "${tkx}"
2013 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2014 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2015 set isExecutable "false"
2017 set isExecutable "true"
2020 if { ![info exists written([file tail $aSrcFile])] } {
2021 set written([file tail $aSrcFile]) 1
2022 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2024 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2027 # macros for correct DLL exports
2028 if { $thePlatform == "wnt" } {
2029 lappend aTKDefines "__${theToolKit}_DLL"
2032 # common include paths
2033 lappend anIncPaths "../../../inc"
2035 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2041 # This function intended to generate Code::Blocks project file
2042 # @param theCmpl - the compiler (gcc or msvc)
2043 # @param theOutDir - output directory to place project file
2044 # @param theProjName - project name
2045 # @param theSrcFiles - list of source files
2046 # @param theLibsList - dependencies (libraries list)
2047 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2048 # @param theIncPaths - header search paths
2049 # @param theDefines - compiler macro definitions
2050 # @param theIsExe - flag to indicate executable / library target
2051 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2052 set aWokStation $thePlatform
2053 set aWokArch "$::env(ARCH)"
2056 set aCmplFlags [list]
2057 set aCmplFlagsRelease [list]
2058 set aCmplFlagsDebug [list]
2059 set toPassArgsByFile 0
2060 set aLibPrefix "lib"
2061 if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
2062 set toPassArgsByFile 1
2064 if { "$theCmpl" == "msvc" } {
2065 set aCmplCbp "msvc8"
2069 if { "$theCmpl" == "msvc" } {
2070 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2071 set aCmplFlagsRelease "-MD -O2"
2072 set aCmplFlagsDebug "-MDd -Od -Zi"
2073 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2074 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2075 } elseif { "$theCmpl" == "gcc" } {
2076 if { "$aWokStation" != "qnx" } {
2077 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2079 set aCmplFlagsRelease "-O2"
2080 set aCmplFlagsDebug "-O0 -g"
2081 if { "$aWokStation" == "wnt" } {
2082 lappend aCmplFlags "-std=gnu++0x"
2083 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2085 lappend aCmplFlags "-std=c++0x"
2086 lappend aCmplFlags "-fPIC"
2087 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2089 lappend aCmplFlags "-Wall"
2090 lappend aCmplFlags "-fexceptions"
2092 lappend aCmplFlagsRelease "-DNDEBUG"
2093 lappend aCmplFlagsRelease "-DNo_Exception"
2094 lappend aCmplFlagsDebug "-D_DEBUG"
2095 if { "$aWokStation" == "qnx" } {
2096 lappend aCmplFlags "-D_QNX_SOURCE"
2099 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2100 set aLnkFileName "${theProjName}_obj.link"
2101 set aLnkDebFileName "${theProjName}_objd.link"
2102 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2103 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2104 set aFile [open $aCbpFilePath "w"]
2105 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2106 puts $aFile "<CodeBlocks_project_file>"
2107 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2108 puts $aFile "\t<Project>"
2109 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2110 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2111 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2112 puts $aFile "\t\t<Build>"
2114 # Release target configuration
2115 puts $aFile "\t\t\t<Target title=\"Release\">"
2116 if { "$theIsExe" == "true" } {
2117 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2118 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2120 if { "$aWokStation" == "wnt" } {
2121 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aWokStation}/cbp/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2123 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2125 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2127 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2128 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2129 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2130 if { "$aWokStation" == "wnt" } {
2131 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2133 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2136 # compiler options per TARGET (including defines)
2137 puts $aFile "\t\t\t\t<Compiler>"
2138 foreach aFlagIter $aCmplFlagsRelease {
2139 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2141 foreach aMacro $theDefines {
2142 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2144 puts $aFile "\t\t\t\t</Compiler>"
2146 puts $aFile "\t\t\t\t<Linker>"
2147 if { $toPassArgsByFile == 1 } {
2148 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2150 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2151 if { "$aWokStation" == "mac" } {
2152 if { [ lsearch $theLibsList X11 ] >= 0} {
2153 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2156 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2157 if { "$aWokStation" == "lin" } {
2158 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/lib\" />"
2160 puts $aFile "\t\t\t\t</Linker>"
2162 puts $aFile "\t\t\t</Target>"
2164 # Debug target configuration
2165 puts $aFile "\t\t\t<Target title=\"Debug\">"
2166 if { "$theIsExe" == "true" } {
2167 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2168 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2170 if { "$aWokStation" == "wnt" } {
2171 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aWokStation}/cbp/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
2173 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2175 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2177 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2178 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2179 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2180 if { "$aWokStation" == "wnt" } {
2181 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2183 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2186 # compiler options per TARGET (including defines)
2187 puts $aFile "\t\t\t\t<Compiler>"
2188 foreach aFlagIter $aCmplFlagsDebug {
2189 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2191 foreach aMacro $theDefines {
2192 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2194 puts $aFile "\t\t\t\t</Compiler>"
2196 puts $aFile "\t\t\t\t<Linker>"
2197 if { $toPassArgsByFile == 1 } {
2198 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2200 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2201 if { "$aWokStation" == "mac" } {
2202 if { [ lsearch $theLibsList X11 ] >= 0} {
2203 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2206 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2207 if { "$aWokStation" == "lin" } {
2208 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/libd\" />"
2210 puts $aFile "\t\t\t\t</Linker>"
2212 puts $aFile "\t\t\t</Target>"
2214 puts $aFile "\t\t</Build>"
2216 # COMMON compiler options
2217 puts $aFile "\t\t<Compiler>"
2218 foreach aFlagIter $aCmplFlags {
2219 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2221 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2222 foreach anIncPath $theIncPaths {
2223 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2225 puts $aFile "\t\t</Compiler>"
2227 # COMMON linker options
2228 puts $aFile "\t\t<Linker>"
2229 if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
2230 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2232 foreach aFrameworkName $theFrameworks {
2233 if { "$aFrameworkName" != "" } {
2234 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2237 foreach aLibName $theLibsList {
2238 if { "$aLibName" != "" } {
2239 if { "$theCmpl" == "msvc" } {
2240 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2242 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2246 puts $aFile "\t\t</Linker>"
2252 set isFirstSrcFile 1
2253 if { $toPassArgsByFile == 1 } {
2254 set aFileLnkObj [open $aLnkFilePath "w"]
2255 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2258 foreach aSrcFile $theSrcFiles {
2259 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2260 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2261 puts $aFile "\t\t\t<Option compile=\"1\" />"
2262 puts $aFile "\t\t\t<Option link=\"1\" />"
2263 puts $aFile "\t\t</Unit>"
2264 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2265 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2266 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2267 puts $aFile "\t\t</Unit>"
2268 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2269 # pass at list single source file to Code::Blocks as is
2270 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2271 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2272 puts $aFile "\t\t\t<Option link=\"0\" />"
2273 puts $aFile "\t\t</Unit>"
2275 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"] $aSrcFile]]
2276 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
2277 puts -nonewline $aFileLnkObj "$aFileObj "
2278 puts -nonewline $aFileLnkObjd "$aFileObjd "
2280 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2281 set isFirstSrcFile 0
2285 if { "$aWokStation" == "wnt" } {
2290 puts $aFile "\t</Project>"
2291 puts $aFile "</CodeBlocks_project_file>"
2294 return $aCbpFilePath
2297 # Define libraries to link using only EXTERNLIB file
2298 proc LibToLinkX {thePackage theDummyName} {
2299 set aToolKits [LibToLink $thePackage]
2303 # Function to generate Xcode workspace and project files
2304 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2306 puts stderr "Generating project files for Xcode"
2308 # Generate projects for toolkits and separate workspace for each module
2309 foreach aModule $theModules {
2310 OS:xcworkspace $aModule $aModule $theOutDir
2311 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2314 # Generate single workspace "OCCT" containing projects from all modules
2315 if { "$theAllSolution" != "" } {
2316 OS:xcworkspace $theAllSolution $theModules $theOutDir
2320 # Generates toolkits sections for Xcode workspace file.
2321 proc OS:xcworkspace:toolkits { theModule } {
2324 # Adding toolkits for module in workspace.
2325 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2326 append aBuff " <FileRef\n"
2327 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2328 append aBuff " </FileRef>\n"
2331 # Adding executables for module, assume one project per cxx file...
2332 foreach aUnit [OS:executable ${theModule}] {
2334 set src_files [_get_used_files $aUnit false]
2336 foreach s $src_files {
2337 regexp {source ([^\s]+)} $s dummy name
2338 lappend aSrcFiles $name
2340 foreach aSrcFile $aSrcFiles {
2341 set aFileExtension [file extension $aSrcFile]
2342 if { $aFileExtension == ".cxx" } {
2343 set aPrjName [file rootname $aSrcFile]
2344 append aBuff " <FileRef\n"
2345 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2346 append aBuff " </FileRef>\n"
2351 # Removing unnecessary newline character from the end.
2352 set aBuff [string replace $aBuff end end]
2356 # Generates workspace files for Xcode.
2357 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2358 # Creating workspace directory for Xcode.
2359 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2360 wokUtils:FILES:mkdir $aWorkspaceDir
2361 if { ! [file exists $aWorkspaceDir] } {
2362 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2366 # Creating workspace file.
2367 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2368 set aFile [open $aWsFilePath "w"]
2370 # Adding header and section for main Group.
2371 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2372 puts $aFile "<Workspace"
2373 puts $aFile " version = \"1.0\">"
2374 puts $aFile " <Group"
2375 puts $aFile " location = \"container:\""
2376 puts $aFile " name = \"${theWorkspaceName}\">"
2379 if { [llength "$theModules"] > 1 } {
2380 foreach aModule $theModules {
2381 puts $aFile " <Group"
2382 puts $aFile " location = \"container:\""
2383 puts $aFile " name = \"${aModule}\">"
2384 puts $aFile [OS:xcworkspace:toolkits $aModule]
2385 puts $aFile " </Group>"
2388 puts $aFile [OS:xcworkspace:toolkits $theModules]
2392 puts $aFile " </Group>"
2393 puts $aFile "</Workspace>"
2397 # Generates Xcode project files.
2398 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2399 upvar $theGuidsMap aGuidsMap
2402 if { "$theLibType" == "static" } {
2404 } elseif { "$thePlatform" == "ios" } {
2408 set aProjectFiles {}
2409 foreach aModule $theModules {
2410 foreach aToolKit [${aModule}:toolkits] {
2411 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2413 foreach anExecutable [OS:executable ${aModule}] {
2414 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2417 return $aProjectFiles
2420 # Generates dependencies section for Xcode project files.
2421 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
2422 upvar $theGuidsMap aGuidsMap
2423 upvar $theFileRefSection aFileRefSection
2424 upvar $theDepsGuids aDepsGuids
2425 upvar $theDepsRefGuids aDepsRefGuids
2427 set aBuildFileSection ""
2428 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2429 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2431 if { "$theTargetType" == "executable" } {
2432 set aFile [osutils:tk:files $theToolKit mac]
2433 set aProjName [file rootname [file tail $aFile]]
2434 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2438 if { $theIsStatic == 1 } {
2440 if { "$theTargetType" != "executable" } {
2441 return $aBuildFileSection
2445 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
2446 set aUsedLibs [concat $aUsedLibs $aLibs]
2447 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2448 foreach tkx $aUsedLibs {
2449 set aDepLib "${tkx}_Dep"
2450 set aDepLibRef "${tkx}_DepRef"
2452 if { ! [info exists aGuidsMap($aDepLib)] } {
2453 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2455 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2456 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2459 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2460 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2461 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2463 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2465 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2466 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2469 return $aBuildFileSection
2472 # Generates PBXBuildFile and PBXGroup sections for project file.
2473 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2474 upvar $theSrcFileRefSection aSrcFileRefSection
2475 upvar $theGroupSection aGroupSection
2476 upvar $thePackageGuids aPackagesGuids
2477 upvar $theSrcFileGuids aSrcFileGuids
2478 upvar $theGuidsMap aGuidsMap
2479 upvar $theIncPaths anIncPaths
2481 set listloc [osutils:tk:units $theToolKit]
2482 set resultloc [osutils:justunix $listloc]
2483 set aBuildFileSection ""
2484 set aPackages [lsort -nocase $resultloc]
2485 if { "$theTargetType" == "executable" } {
2486 set aPackages [list "$theToolKit"]
2489 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2490 foreach fxlo $aPackages {
2492 set aPackage "${xlo}_Package"
2493 set aSrcFileRefGuids ""
2494 if { ! [info exists aGuidsMap($aPackage)] } {
2495 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2498 set aSrcFiles [osutils:tk:files $xlo mac]
2499 foreach aSrcFile [lsort $aSrcFiles] {
2500 set aFileExt "sourcecode.cpp.cpp"
2502 if { [file extension $aSrcFile] == ".c" } {
2503 set aFileExt "sourcecode.c.c"
2504 } elseif { [file extension $aSrcFile] == ".mm" } {
2505 set aFileExt "sourcecode.cpp.objcpp"
2508 if { ! [info exists aGuidsMap($aSrcFile)] } {
2509 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2511 set aSrcFileRef "${aSrcFile}_Ref"
2512 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2513 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2515 if { ! [info exists written([file tail $aSrcFile])] } {
2516 set written([file tail $aSrcFile]) 1
2517 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2518 append aSrcFileRefSection "\t\t$aGuidsMap($aSrcFileRef) = \{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = ${aFileExt}; name = [wokUtils:FILES:wtail $aSrcFile 1]; path = ../../../[wokUtils:FILES:wtail $aSrcFile 3]; sourceTree = \"<group>\"; \};\n"
2519 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2520 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2522 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2526 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2527 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2528 append aGroupSection "\t\t\tchildren = (\n"
2529 append aGroupSection $aSrcFileRefGuids
2530 append aGroupSection "\t\t\t);\n"
2531 append aGroupSection "\t\t\tname = $xlo;\n"
2532 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2533 append aGroupSection "\t\t\};\n"
2535 # Storing packages IDs for adding them later as a child of toolkit
2536 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2539 # Removing unnecessary newline character from the end.
2540 set aPackagesGuids [string replace $aPackagesGuids end end]
2542 return $aBuildFileSection
2545 # Creates folders structure and all necessary files for Xcode project.
2546 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2547 set aPBXBuildPhase "Headers"
2548 set aRunOnlyForDeployment "0"
2549 set aProductType "library.dynamic"
2550 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2551 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2552 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2553 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2554 if { $theIsStatic == 1 } {
2555 lappend aTKDefines "OCCT_NO_PLUGINS"
2558 if { "$theTargetType" == "executable" } {
2559 set aPBXBuildPhase "CopyFiles"
2560 set aRunOnlyForDeployment "1"
2561 set aProductType "tool"
2562 set anExecExtension ""
2564 set aWrapperExtension ""
2565 } elseif { $theIsStatic == 1 } {
2566 set aProductType "library.static"
2567 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2568 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2571 set aUsername [exec whoami]
2573 # Creation of folders for Xcode projectP.
2574 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2575 wokUtils:FILES:mkdir $aToolkitDir
2576 if { ! [file exists $aToolkitDir] } {
2577 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2581 set aUserDataDir "${aToolkitDir}/xcuserdata"
2582 wokUtils:FILES:mkdir $aUserDataDir
2583 if { ! [file exists $aUserDataDir] } {
2584 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2588 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2589 wokUtils:FILES:mkdir $aUserDataDir
2590 if { ! [file exists $aUserDataDir] } {
2591 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2595 set aSchemesDir "${aUserDataDir}/xcschemes"
2596 wokUtils:FILES:mkdir $aSchemesDir
2597 if { ! [file exists $aSchemesDir] } {
2598 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2601 # End of folders creation.
2603 # Generating GUID for tookit.
2604 upvar $theGuidsMap aGuidsMap
2605 if { ! [info exists aGuidsMap($theToolKit)] } {
2606 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2609 # Creating xcscheme file for toolkit from template.
2610 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2611 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2612 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2613 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2614 puts $aXcschemeFile $aXcschemeTmpl
2615 close $aXcschemeFile
2617 # Creating xcschememanagement.plist file for toolkit from template.
2618 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2619 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2620 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2621 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2622 puts $aPlistFile $aPlistTmpl
2625 # Creating project.pbxproj file for toolkit.
2626 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2627 puts $aPbxprojFile "// !\$*UTF8*\$!"
2628 puts $aPbxprojFile "\{"
2629 puts $aPbxprojFile "\tarchiveVersion = 1;"
2630 puts $aPbxprojFile "\tclasses = \{"
2631 puts $aPbxprojFile "\t\};"
2632 puts $aPbxprojFile "\tobjectVersion = 46;"
2633 puts $aPbxprojFile "\tobjects = \{\n"
2635 # Begin PBXBuildFile section
2636 set aPackagesGuids ""
2637 set aGroupSection ""
2638 set aSrcFileRefSection ""
2639 set aSrcFileGuids ""
2640 set aDepsFileRefSection ""
2642 set aDepsRefGuids ""
2643 set anIncPaths [list "../../../inc"]
2646 if { [info exists ::env(CSF_OPT_INC)] } {
2647 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2648 foreach anIncCfgPath $anIncCfg {
2649 lappend anIncPaths $anIncCfgPath
2652 if { [info exists ::env(CSF_OPT_LIB64)] } {
2653 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2654 foreach anLibCfgPath $anLibCfg {
2655 lappend anLibPaths $anLibCfgPath
2659 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2660 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2661 # End PBXBuildFile section
2663 # Begin PBXFileReference section
2664 set aToolkitLib "lib${theToolKit}.dylib"
2665 set aPath "$aToolkitLib"
2666 if { "$theTargetType" == "executable" } {
2667 set aPath "$theToolKit"
2668 } elseif { $theIsStatic == 1 } {
2669 set aToolkitLib "lib${theToolKit}.a"
2672 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2673 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2676 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2677 puts $aPbxprojFile $aSrcFileRefSection
2678 puts $aPbxprojFile $aDepsFileRefSection
2679 # End PBXFileReference section
2682 # Begin PBXFrameworksBuildPhase section
2683 set aTkFrameworks "${theToolKit}_Frameworks"
2684 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2685 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2688 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2689 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2690 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2691 puts $aPbxprojFile "\t\t\tfiles = ("
2692 puts $aPbxprojFile $aDepsGuids
2693 puts $aPbxprojFile "\t\t\t);"
2694 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2695 puts $aPbxprojFile "\t\t\};\n"
2696 # End PBXFrameworksBuildPhase section
2698 # Begin PBXGroup section
2699 set aTkPBXGroup "${theToolKit}_PBXGroup"
2700 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2701 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2704 set aTkSrcGroup "${theToolKit}_SrcGroup"
2705 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2706 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2709 puts $aPbxprojFile $aGroupSection
2710 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2711 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2712 puts $aPbxprojFile "\t\t\tchildren = ("
2713 puts $aPbxprojFile $aDepsRefGuids
2714 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2715 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2716 puts $aPbxprojFile "\t\t\t);"
2717 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2718 puts $aPbxprojFile "\t\t\};"
2719 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2720 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2721 puts $aPbxprojFile "\t\t\tchildren = ("
2722 puts $aPbxprojFile $aPackagesGuids
2723 puts $aPbxprojFile "\t\t\t);"
2724 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2725 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2726 puts $aPbxprojFile "\t\t\};\n"
2727 # End PBXGroup section
2729 # Begin PBXHeadersBuildPhase section
2730 set aTkHeaders "${theToolKit}_Headers"
2731 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2732 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2735 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2736 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2737 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2738 puts $aPbxprojFile "\t\t\tfiles = ("
2739 puts $aPbxprojFile "\t\t\t);"
2740 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2741 puts $aPbxprojFile "\t\t\};\n"
2742 # End PBXHeadersBuildPhase section
2744 # Begin PBXNativeTarget section
2745 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2746 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2747 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2750 set aTkSources "${theToolKit}_Sources"
2751 if { ! [info exists aGuidsMap($aTkSources)] } {
2752 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2755 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2756 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2757 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2758 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2759 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2760 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2761 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2762 puts $aPbxprojFile "\t\t\t);"
2763 puts $aPbxprojFile "\t\t\tbuildRules = ("
2764 puts $aPbxprojFile "\t\t\t);"
2765 puts $aPbxprojFile "\t\t\tdependencies = ("
2766 puts $aPbxprojFile "\t\t\t);"
2767 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
2768 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
2769 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
2770 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
2771 puts $aPbxprojFile "\t\t\};\n"
2772 # End PBXNativeTarget section
2774 # Begin PBXProject section
2775 set aTkProjectObj "${theToolKit}_ProjectObj"
2776 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
2777 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
2780 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
2781 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
2782 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
2785 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
2786 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
2787 puts $aPbxprojFile "\t\t\tattributes = \{"
2788 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
2789 puts $aPbxprojFile "\t\t\t\};"
2790 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
2791 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
2792 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
2793 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
2794 puts $aPbxprojFile "\t\t\tknownRegions = ("
2795 puts $aPbxprojFile "\t\t\t\ten,"
2796 puts $aPbxprojFile "\t\t\t);"
2797 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
2798 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
2799 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
2800 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
2801 puts $aPbxprojFile "\t\t\ttargets = ("
2802 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
2803 puts $aPbxprojFile "\t\t\t);"
2804 puts $aPbxprojFile "\t\t\};\n"
2805 # End PBXProject section
2807 # Begin PBXSourcesBuildPhase section
2808 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
2809 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
2810 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2811 puts $aPbxprojFile "\t\t\tfiles = ("
2812 puts $aPbxprojFile $aSrcFileGuids
2813 puts $aPbxprojFile "\t\t\t);"
2814 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2815 puts $aPbxprojFile "\t\t\};\n"
2816 # End PBXSourcesBuildPhase section
2818 # Begin XCBuildConfiguration section
2819 set aTkDebugProject "${theToolKit}_DebugProject"
2820 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
2821 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
2824 set aTkReleaseProject "${theToolKit}_ReleaseProject"
2825 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
2826 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
2829 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
2830 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
2831 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
2834 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
2835 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
2836 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
2840 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
2841 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2842 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2844 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
2845 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2846 if { "$thePlatform" == "ios" } {
2847 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2848 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2849 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2850 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2851 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2853 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2854 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2855 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
2856 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2857 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
2858 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2859 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
2860 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2861 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
2862 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
2863 puts $aPbxprojFile "\t\t\t\t);"
2864 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
2865 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2866 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2867 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2868 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2869 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2870 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
2871 if { "$thePlatform" == "ios" } {
2872 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
2873 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2875 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
2877 puts $aPbxprojFile "\t\t\t\};"
2879 puts $aPbxprojFile "\t\t\tname = Debug;"
2880 puts $aPbxprojFile "\t\t\};"
2883 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
2884 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2885 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2887 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
2888 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2889 if { "$thePlatform" == "ios" } {
2890 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2891 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2892 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2893 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2894 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2896 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2897 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2898 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
2899 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2900 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2901 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
2902 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
2903 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2904 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2905 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2906 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2907 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2908 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
2909 if { "$thePlatform" == "ios" } {
2910 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
2911 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2913 puts $aPbxprojFile "\t\t\t\};"
2914 puts $aPbxprojFile "\t\t\tname = Release;"
2915 puts $aPbxprojFile "\t\t\};"
2916 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
2917 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2918 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2919 puts $aPbxprojFile "${anExecExtension}"
2920 puts $aPbxprojFile "${anExecPrefix}"
2921 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2922 foreach aMacro $aTKDefines {
2923 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2925 puts $aPbxprojFile "\t\t\t\t);"
2927 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2928 foreach anIncPath $anIncPaths {
2929 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2931 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2932 puts $aPbxprojFile "\t\t\t\t);"
2934 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2935 foreach anLibPath $anLibPaths {
2936 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2938 puts $aPbxprojFile "\t\t\t\t);"
2940 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2941 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2942 puts $aPbxprojFile "\t\t\t\t);"
2943 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2944 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2945 puts $aPbxprojFile "\t\t\t\t);"
2946 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2947 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
2948 foreach anIncPath $anIncPaths {
2949 append anUserHeaderSearchPath " ${anIncPath}"
2951 append anUserHeaderSearchPath "\";"
2952 puts $aPbxprojFile $anUserHeaderSearchPath
2953 puts $aPbxprojFile "${aWrapperExtension}"
2954 puts $aPbxprojFile "\t\t\t\};"
2955 puts $aPbxprojFile "\t\t\tname = Debug;"
2956 puts $aPbxprojFile "\t\t\};"
2957 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
2958 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2959 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2960 puts $aPbxprojFile "${anExecExtension}"
2961 puts $aPbxprojFile "${anExecPrefix}"
2962 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2963 foreach aMacro $aTKDefines {
2964 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2966 puts $aPbxprojFile "\t\t\t\t);"
2967 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2968 foreach anIncPath $anIncPaths {
2969 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2971 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2972 puts $aPbxprojFile "\t\t\t\t);"
2974 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2975 foreach anLibPath $anLibPaths {
2976 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2978 puts $aPbxprojFile "\t\t\t\t);"
2980 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2981 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2982 puts $aPbxprojFile "\t\t\t\t);"
2983 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2984 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2985 puts $aPbxprojFile "\t\t\t\t);"
2986 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2987 puts $aPbxprojFile $anUserHeaderSearchPath
2988 puts $aPbxprojFile "${aWrapperExtension}"
2989 puts $aPbxprojFile "\t\t\t\};"
2990 puts $aPbxprojFile "\t\t\tname = Release;"
2991 puts $aPbxprojFile "\t\t\};\n"
2992 # End XCBuildConfiguration section
2994 # Begin XCConfigurationList section
2995 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
2996 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
2997 puts $aPbxprojFile "\t\tbuildConfigurations = ("
2998 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
2999 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3000 puts $aPbxprojFile "\t\t\t);"
3001 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3002 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3003 puts $aPbxprojFile "\t\t\};"
3004 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3005 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3006 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3007 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3008 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3009 puts $aPbxprojFile "\t\t\t);"
3010 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3011 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3012 puts $aPbxprojFile "\t\t\};\n"
3013 # End XCConfigurationList section
3015 puts $aPbxprojFile "\t\};"
3016 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3017 puts $aPbxprojFile "\}"
3022 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3023 set aUsername [exec whoami]
3025 # Creating folders for Xcode project file.
3026 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3027 wokUtils:FILES:mkdir $anExecutableDir
3028 if { ! [file exists $anExecutableDir] } {
3029 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3033 set aUserDataDir "${anExecutableDir}/xcuserdata"
3034 wokUtils:FILES:mkdir $aUserDataDir
3035 if { ! [file exists $aUserDataDir] } {
3036 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3040 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3041 wokUtils:FILES:mkdir $aUserDataDir
3042 if { ! [file exists $aUserDataDir] } {
3043 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3047 set aSchemesDir "${aUserDataDir}/xcschemes"
3048 wokUtils:FILES:mkdir $aSchemesDir
3049 if { ! [file exists $aSchemesDir] } {
3050 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3053 # End folders creation.
3055 # Generating GUID for tookit.
3056 upvar $theGuidsMap aGuidsMap
3057 if { ! [info exists aGuidsMap($theExecutable)] } {
3058 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3061 # Creating xcscheme file for toolkit from template.
3062 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3063 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3064 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3065 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3066 puts $aXcschemeFile $aXcschemeTmpl
3067 close $aXcschemeFile
3069 # Creating xcschememanagement.plist file for toolkit from template.
3070 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3071 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3072 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3073 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3074 puts $aPlistFile $aPlistTmpl