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"
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 if { "$::HAVE_GLES2" == "true" } {
1110 set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2"
1112 set aLibsMap(CSF_winspool) "Winspool"
1113 set aLibsMap(CSF_psapi) "Psapi"
1114 set aLibsMap(CSF_d3d9) "d3d9"
1116 # the naming is different on Windows
1117 set aLibsMap(CSF_TclLibs) "tcl86"
1118 set aLibsMap(CSF_TclTkLibs) "tk86"
1120 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1122 # tbb headers define different pragma lib depending on debug/release
1123 set aLibsMap(CSF_TBB) ""
1125 if { "$theOS" == "mac" } {
1126 set aLibsMap(CSF_objc) "objc"
1127 set aFrmsMap(CSF_Appkit) "Appkit"
1128 set aFrmsMap(CSF_IOKit) "IOKit"
1129 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1130 set aFrmsMap(CSF_TclLibs) "Tcl"
1131 set aLibsMap(CSF_TclLibs) ""
1132 set aFrmsMap(CSF_TclTkLibs) "Tk"
1133 set aLibsMap(CSF_TclTkLibs) ""
1135 if { "$theOS" == "qnx" } {
1136 # CSF_ThreadLibs - pthread API is part of libc on QNX
1137 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1139 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1140 set aLibsMap(CSF_OpenGlLibs) "GL"
1141 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1142 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1143 set aLibsMap(CSF_MotifLibs) "X11"
1146 if { "$::HAVE_GLES2" == "true" } {
1147 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1153 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1154 proc osutils:vtkCsf {{theOS ""}} {
1157 set aPathSplitter ":"
1158 if {"$theOS" == "wnt"} {
1159 set aPathSplitter ";"
1162 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1163 foreach anIncItem $anOptIncs {
1164 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1165 set aVtkVer $aFoundVtkVer
1169 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1170 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1172 # Additional suffices for the libraries
1174 foreach anItem $aLibArray {
1175 lset aLibArray $anIdx $anItem-$aVtkVer
1179 return [join $aLibArray " "]
1182 # @param theLibsList - dependencies (libraries list)
1183 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1184 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1186 upvar $theLibsList aLibsList
1187 upvar $theFrameworks aFrameworks
1188 set aLibsList [list]
1189 set aFrameworks [list]
1191 osutils:csfList $theOS aLibsMap aFrmsMap
1193 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1194 if [info exists aLibsMap($aCsfElem)] {
1195 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1196 if { [lsearch $aLibsList $aLib] == "-1" } {
1197 lappend aLibsList $aLib
1201 if [info exists aFrmsMap($aCsfElem)] {
1202 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1203 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1204 lappend aFrameworks $aFrm
1211 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1212 proc osutils:tk:units { tkloc } {
1215 set PACKAGES "$path/src/$tkloc/PACKAGES"
1216 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1217 if {[file isdirectory "$path/src/$u"]} {
1222 ;#puts stderr "Warning. No devunit included in $tkloc"
1227 proc osutils:justwnt { listloc } {
1228 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1229 set goaway [list Xdps Xw ImageUtility WOKUnix]
1230 return [osutils:juststation $goaway $listloc]
1233 # remove from listloc OpenCascade units indesirables on NT
1234 proc osutils:juststation {goaway listloc} {
1237 foreach u $listloc {
1238 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1239 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1246 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1247 # The first list is everything in the first list that wasn't in the second,
1248 # the second list contains the intersection of the two lists, the third list contains everything
1249 # in the second list that wasn't in the first.
1250 proc osutils:intersect3 {list1 list2} {
1251 set la1(0) {} ; unset la1(0)
1252 set lai(0) {} ; unset lai(0)
1253 set la2(0) {} ; unset la2(0)
1260 foreach elem [concat $list1 $list2] {
1261 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1267 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1270 # Prepare relative path
1271 proc relativePath {thePathFrom thePathTo} {
1272 if { [file isdirectory "$thePathFrom"] == 0 } {
1276 set aPathFrom [file normalize "$thePathFrom"]
1277 set aPathTo [file normalize "$thePathTo"]
1279 set aCutedPathFrom "${aPathFrom}/dummy"
1280 set aRelatedDeepPath ""
1282 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1283 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1284 # does aPathTo contain aCutedPathFrom?
1285 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1286 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1287 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1288 set aPathTo ".${aPathTo}"
1289 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1290 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1292 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1293 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1294 return $aPathToAfterCut
1296 set aRelatedDeepPath "$aRelatedDeepPath../"
1303 proc wokUtils:EASY:bs1 { s } {
1304 regsub -all {/} $s {\\} r
1308 # Returs for a full path the liste of n last directory part
1310 # n = 2 => dir/file.c
1311 # n = 3 => sdir/dir/file.c
1313 proc wokUtils:FILES:wtail { f n } {
1314 set ll [expr [llength [set lif [file split $f]]] -$n]
1315 return [join [lrange $lif $ll end] /]
1318 # Generate entry for one source file in Visual Studio 10 project file
1319 proc osutils:vcxproj:file { vcversion file params } {
1320 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1321 if { $params != "" } {
1322 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1325 if { $params != "" } {
1326 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1329 if { $params != "" } {
1330 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1333 if { $params != "" } {
1334 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1337 append text " </ClCompile>\n"
1341 # Generate Visual Studio 2010 project filters file
1342 proc osutils:vcxproj:filters { dir proj theFilesMap } {
1343 upvar $theFilesMap aFilesMap
1346 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1347 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1349 # list of "filters" (units)
1350 append text " <ItemGroup>\n"
1351 append text " <Filter Include=\"Source files\">\n"
1352 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1353 append text " </Filter>\n"
1354 foreach unit $aFilesMap(units) {
1355 append text " <Filter Include=\"Source files\\${unit}\">\n"
1356 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1357 append text " </Filter>\n"
1359 append text " </ItemGroup>\n"
1362 append text " <ItemGroup>\n"
1363 foreach unit $aFilesMap(units) {
1364 foreach file $aFilesMap($unit) {
1365 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1366 append text " <Filter>Source files\\${unit}</Filter>\n"
1367 append text " </ClCompile>\n"
1370 append text " </ItemGroup>\n"
1373 append text "</Project>"
1376 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1377 fconfigure $fp -translation crlf
1381 return ${proj}.vcxproj.filters
1384 # Generate Visual Studio 2011 project filters file
1385 proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1386 upvar $theFilesMap aFilesMap
1389 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1390 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1392 # list of "filters" (units)
1393 append text " <ItemGroup>\n"
1394 append text " <Filter Include=\"Source files\">\n"
1395 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1396 append text " </Filter>\n"
1397 foreach unit $aFilesMap(units) {
1398 append text " <Filter Include=\"Source files\\${unit}\">\n"
1399 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1400 append text " </Filter>\n"
1402 append text " </ItemGroup>\n"
1405 append text " <ItemGroup>\n"
1406 foreach unit $aFilesMap(units) {
1407 foreach file $aFilesMap($unit) {
1408 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1409 append text " <Filter>Source files\\${unit}</Filter>\n"
1410 append text " </ClCompile>\n"
1413 append text " </ItemGroup>\n"
1415 append text " <ItemGroup>\n"
1416 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1417 append text " </ItemGroup>\n"
1420 append text "</Project>"
1423 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1424 fconfigure $fp -translation crlf
1428 return ${proj}.vcxproj.filters
1431 # Generate RC file content for ToolKit from template
1432 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1433 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1434 set aBody [wokUtils:FILES:FileToString $aLoc]
1435 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1437 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1438 fconfigure $aFile -translation lf
1441 return "${theOutDir}/${theToolKit}.rc"
1444 # Generate Visual Studio project file for ToolKit
1445 proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1446 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1448 set l_compilable [osutils:compilable wnt]
1449 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1451 upvar $theGuidsMap aGuidsMap
1452 if { ! [info exists aGuidsMap($theToolKit)] } {
1453 set aGuidsMap($theToolKit) [OS:genGUID]
1455 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1457 set aUsedLibs [list]
1458 foreach tkx [osutils:commonUsedTK $theToolKit] {
1459 lappend aUsedLibs "${tkx}.lib"
1462 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1463 foreach aLibIter $aLibs {
1464 lappend aUsedLibs "${aLibIter}.lib"
1467 # correct names of referred third-party libraries that are named with suffix
1468 # depending on VC version
1469 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1471 # and put this list to project file
1472 #puts "$theToolKit requires $aUsedLibs"
1473 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1474 set aUsedLibs [join $aUsedLibs {;}]
1476 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1478 set anIncPaths "..\\..\\..\\inc"
1480 set aFilesSection ""
1481 set aVcFilesX(units) ""
1482 set listloc [osutils:tk:units $theToolKit]
1483 set resultloc [osutils:justwnt $listloc]
1484 if [array exists written] { unset written }
1485 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1486 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1487 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1488 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1489 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1490 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1492 foreach fxlo $resultloc {
1494 set aSrcFiles [osutils:tk:files $xlo wnt]
1495 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1496 if {$fxlo_cmplrs_options_cxx == ""} {
1497 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1499 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1500 if {$fxlo_cmplrs_options_c == ""} {
1501 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1503 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1504 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1505 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1506 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1507 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1508 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1510 foreach partopt $fxloparam {
1511 if {[string first "-I" $partopt] == "0"} {
1512 # this is an additional includes search path
1515 set needparam "$needparam $partopt"
1518 # Format of projects in vc10+ is different from vc7-9
1519 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1520 foreach aSrcFile [lsort $aSrcFiles] {
1521 if { ![info exists written([file tail $aSrcFile])] } {
1522 set written([file tail $aSrcFile]) 1
1523 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1525 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1527 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1528 lappend aVcFilesX($xlo) $aSrcFile
1531 append aFilesSection "\t\t\t<Filter\n"
1532 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1533 append aFilesSection "\t\t\t\t>\n"
1534 foreach aSrcFile [lsort $aSrcFiles] {
1535 if { ![info exists written([file tail $aSrcFile])] } {
1536 set written([file tail $aSrcFile]) 1
1537 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1539 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1542 append aFilesSection "\t\t\t</Filter>\n"
1546 append aTKDefines ";__${xlo}_DLL"
1548 # append anIncPaths ";..\\..\\..\\src\\${xlo}"
1551 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1552 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1553 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1556 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1557 fconfigure $aFile -translation crlf
1558 puts $aFile $theProjTmpl
1561 # write filters file for vc10+
1562 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1564 } elseif { "$theVcVer" == "vc10" } {
1565 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
1567 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1570 # write resource file
1571 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1576 # for a unit returns a map containing all its file in the current
1578 # local = 1 only local files
1579 proc osutils:tk:loadunit { loc map } {
1582 catch { unset TLOC }
1583 set lfiles [_get_used_files $loc]
1588 if [info exists TLOC($t)] {
1599 # Returns the list of all compilable files name in a toolkit, or devunit of any type
1600 # Tfiles lists for each unit the type of file that can be compiled.
1601 proc osutils:tk:files { tkloc thePlatform } {
1602 set Tfiles(source,nocdlpack) {source pubinclude}
1603 set Tfiles(source,toolkit) {}
1604 set Tfiles(source,executable) {source pubinclude}
1605 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1606 #puts " listloc = $listloc"
1608 set l_comp [osutils:compilable $thePlatform]
1609 set resultloc $listloc
1611 foreach loc $resultloc {
1612 set utyp [_get_type $loc]
1613 #puts "\"$utyp\" \"$loc\""
1615 "t" { set utyp "toolkit" }
1616 "n" { set utyp "nocdlpack" }
1617 "x" { set utyp "executable" }
1619 if [array exists map] { unset map }
1620 osutils:tk:loadunit $loc map
1621 #puts " loc = $loc === > [array names map]"
1622 set LType $Tfiles(source,${utyp})
1623 foreach typ [array names map] {
1624 if { [lsearch $LType $typ] == -1 } {
1628 foreach type [array names map] {
1630 foreach f $map($type) {
1632 if { [lsearch $l_comp [file extension $f]] != -1 } {
1641 # Generate Visual Studio project file for executable
1642 proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1644 foreach f [osutils:tk:files $theToolKit wnt] {
1645 if { $theProjTmpl == {} } {
1646 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1648 set aProjTmpl $theProjTmpl
1650 set aProjName [file rootname [file tail $f]]
1651 set l_compilable [osutils:compilable wnt]
1652 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1654 upvar $theGuidsMap aGuidsMap
1655 if { ! [info exists aGuidsMap($aProjName)] } {
1656 set aGuidsMap($aProjName) [OS:genGUID]
1658 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1660 set aUsedLibs [list]
1661 foreach tkx [osutils:commonUsedTK $theToolKit] {
1662 lappend aUsedLibs "${tkx}.lib"
1665 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1666 foreach aLibIter $aLibs {
1667 lappend aUsedLibs "${aLibIter}.lib"
1670 # correct names of referred third-party libraries that are named with suffix
1671 # depending on VC version
1672 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1674 # puts "$aProjName requires $aUsedLibs"
1675 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1676 set aUsedLibs [join $aUsedLibs {;}]
1678 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1680 set aFilesSection ""
1681 set aVcFilesX(units) ""
1683 if { ![info exists written([file tail $f])] } {
1684 set written([file tail $f]) 1
1686 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1687 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1688 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1689 lappend aVcFilesX($theToolKit) $f
1691 append aFilesSection "\t\t\t<Filter\n"
1692 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1693 append aFilesSection "\t\t\t\t>\n"
1694 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1695 append aFilesSection "\t\t\t</Filter>"
1698 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1700 #puts "$aProjTmpl $aFilesSection"
1701 set aTKDefines ";__${theToolKit}_DLL"
1702 set anIncPaths "..\\..\\..\\inc"
1703 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1704 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1705 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1706 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1708 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1710 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1711 fconfigure $aFile -translation crlf
1712 puts $aFile $aProjTmpl
1715 set aCommonSettingsFile "$aVcFilePath.user"
1716 lappend aVcFiles $aVcFilePath
1718 # write filters file for vc10
1719 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1720 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1723 set aCommonSettingsFileTmpl ""
1724 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1726 } elseif { "$theVcVer" == "vc9" } {
1727 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
1729 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
1731 if { "$aCommonSettingsFileTmpl" != "" } {
1732 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1734 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1735 fconfigure $aFile -translation crlf
1736 puts $aFile $aCommonSettingsFileTmpl
1739 lappend aVcFiles "$aCommonSettingsFile"
1745 # Generate entry for one source file in Visual Studio 7 - 9 project file
1746 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1747 append aText "\t\t\t\t<File\n"
1748 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1749 if { $theOptions == "" } {
1750 append aText "\t\t\t\t</File>\n"
1754 append aText "\t\t\t\t\t<FileConfiguration\n"
1755 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1756 append aText "\t\t\t\t\t\t<Tool\n"
1757 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1758 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1759 foreach aParam $theOptions {
1760 append aText "$aParam "
1763 append aText "\t\t\t\t\t\t/>\n"
1764 append aText "\t\t\t\t\t</FileConfiguration>\n"
1766 append aText "\t\t\t\t\t<FileConfiguration\n"
1767 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1768 append aText "\t\t\t\t\t\t<Tool\n"
1769 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1770 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1771 foreach aParam $theOptions {
1772 append aText "$aParam "
1775 append aText "\t\t\t\t\t\t/>\n"
1776 append aText "\t\t\t\t\t</FileConfiguration>\n"
1777 if { "$theVcVer" == "vc7" } {
1778 append aText "\t\t\t\t</File>\n"
1782 append aText "\t\t\t\t\t<FileConfiguration\n"
1783 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1784 append aText "\t\t\t\t\t\t<Tool\n"
1785 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1786 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1787 foreach aParam $theOptions {
1788 append aText "$aParam "
1791 append aText "\t\t\t\t\t\t/>\n"
1792 append aText "\t\t\t\t\t</FileConfiguration>\n"
1794 append aText "\t\t\t\t\t<FileConfiguration\n"
1795 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1796 append aText "\t\t\t\t\t\t<Tool\n"
1797 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1798 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1799 foreach aParam $theOptions {
1800 append aText "$aParam "
1803 append aText "\t\t\t\t\t\t/>\n"
1804 append aText "\t\t\t\t\t</FileConfiguration>\n"
1806 append aText "\t\t\t\t</File>\n"
1810 proc wokUtils:FILES:mkdir { d } {
1812 regsub -all {\.[^.]*} $tcl_version "" major
1813 if { $major == 8 } {
1816 if ![file exists $d] {
1817 if { "[info command mkdir]" == "mkdir" } {
1820 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1824 if [file exists $d] {
1831 # remove from listloc OpenCascade units indesirables on Unix
1832 proc osutils:justunix { listloc } {
1833 if { "$::tcl_platform(os)" == "Darwin" } {
1834 set goaway [list Xw WNT]
1836 set goaway [list WNT]
1838 return [osutils:juststation $goaway $listloc]
1842 ####### CODEBLOCK ###################################################################
1843 # Function to generate Code Blocks workspace and project files
1844 proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
1845 puts stderr "Generating project files for Code Blocks"
1847 # Generate projects for toolkits and separate workspace for each module
1848 foreach aModule $theModules {
1849 OS:cworkspace $aModule $aModule $theOutDir
1850 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
1853 # Generate single workspace "OCCT" containing projects from all modules
1854 if { "$theAllSolution" != "" } {
1855 OS:cworkspace $theAllSolution $theModules $theOutDir
1858 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
1861 # Generate Code Blocks projects
1862 proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
1863 set aProjectFiles {}
1864 foreach aModule $theModules {
1865 foreach aToolKit [${aModule}:toolkits] {
1866 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
1868 foreach anExecutable [OS:executable ${aModule}] {
1869 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
1872 return $aProjectFiles
1875 # Generate Code::Blocks project file for ToolKit
1876 proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
1877 set aUsedLibs [list]
1878 set aFrameworks [list]
1879 set anIncPaths [list]
1880 set aTKDefines [list]
1881 set aTKSrcFiles [list]
1883 # collect list of referred libraries to link with
1884 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
1885 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
1886 foreach tkx $aDepToolkits {
1887 lappend aUsedLibs "${tkx}"
1890 lappend anIncPaths "../../../inc"
1891 set listloc [osutils:tk:units $theToolKit]
1893 if { [llength $listloc] == 0 } {
1894 set listloc $theToolKit
1897 if { $thePlatform == "wnt" } {
1898 set resultloc [osutils:justwnt $listloc]
1900 set resultloc [osutils:justunix $listloc]
1902 if [array exists written] { unset written }
1903 foreach fxlo $resultloc {
1905 set aSrcFiles [osutils:tk:files $xlo $thePlatform]
1906 foreach aSrcFile [lsort $aSrcFiles] {
1907 if { ![info exists written([file tail $aSrcFile])] } {
1908 set written([file tail $aSrcFile]) 1
1909 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
1911 puts "Warning : more than one occurences for [file tail $aSrcFile]"
1915 # macros for correct DLL exports
1916 if { $thePlatform == "wnt" } {
1917 lappend aTKDefines "__${xlo}_DLL"
1921 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
1924 # Generates Code Blocks workspace.
1925 proc OS:cworkspace { theSolName theModules theOutDir } {
1927 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
1928 set aFile [open $aWsFilePath "w"]
1930 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
1931 puts $aFile "<CodeBlocks_workspace_file>"
1932 puts $aFile "\t<Workspace title=\"${theSolName}\">"
1934 # collect list of projects to be created
1935 foreach aModule $theModules {
1937 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1938 set aDependencies [LibToLink $aToolKit]
1939 if { [llength $aDependencies] == 0 } {
1940 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
1942 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
1943 foreach aDepTk $aDependencies {
1944 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1946 puts $aFile "\t\t</Project>"
1950 # executables, assume one project per cxx file...
1951 foreach aUnit [OS:executable ${aModule}] {
1953 set src_files [_get_used_files $aUnit false]
1955 foreach s $src_files {
1956 regexp {source ([^\s]+)} $s dummy name
1957 lappend aSrcFiles $name
1959 foreach aSrcFile $aSrcFiles {
1960 set aFileExtension [file extension $aSrcFile]
1961 if { $aFileExtension == ".cxx" } {
1962 set aPrjName [file rootname $aSrcFile]
1963 set aDependencies [list]
1964 if {[file isdirectory $path/src/$aUnitLoc]} {
1965 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1967 set anActiveState ""
1968 if { $isActiveSet == 0 } {
1969 set anActiveState " active=\"1\""
1972 if { [llength $aDependencies] == 0 } {
1973 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
1975 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
1976 foreach aDepTk $aDependencies {
1977 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1979 puts $aFile "\t\t</Project>"
1986 puts $aFile "\t</Workspace>"
1987 puts $aFile "</CodeBlocks_workspace_file>"
1993 # Generate Code::Blocks project file for Executable
1994 proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
1996 set aWokArch "$::env(ARCH)"
1999 foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
2000 # collect list of referred libraries to link with
2001 set aUsedLibs [list]
2002 set aFrameworks [list]
2003 set anIncPaths [list]
2004 set aTKDefines [list]
2005 set aTKSrcFiles [list]
2006 set aProjName [file rootname [file tail $aSrcFile]]
2008 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
2010 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2011 foreach tkx $aDepToolkits {
2012 if {[_get_type $tkx] == "t"} {
2013 lappend aUsedLibs "${tkx}"
2015 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2016 lappend aUsedLibs "${tkx}"
2020 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2021 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2022 set isExecutable "false"
2024 set isExecutable "true"
2027 if { ![info exists written([file tail $aSrcFile])] } {
2028 set written([file tail $aSrcFile]) 1
2029 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2031 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2034 # macros for correct DLL exports
2035 if { $thePlatform == "wnt" } {
2036 lappend aTKDefines "__${theToolKit}_DLL"
2039 # common include paths
2040 lappend anIncPaths "../../../inc"
2042 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2048 # This function intended to generate Code::Blocks project file
2049 # @param theCmpl - the compiler (gcc or msvc)
2050 # @param theOutDir - output directory to place project file
2051 # @param theProjName - project name
2052 # @param theSrcFiles - list of source files
2053 # @param theLibsList - dependencies (libraries list)
2054 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2055 # @param theIncPaths - header search paths
2056 # @param theDefines - compiler macro definitions
2057 # @param theIsExe - flag to indicate executable / library target
2058 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2059 set aWokStation $thePlatform
2060 set aWokArch "$::env(ARCH)"
2063 set aCmplFlags [list]
2064 set aCmplFlagsRelease [list]
2065 set aCmplFlagsDebug [list]
2066 set toPassArgsByFile 0
2067 set aLibPrefix "lib"
2068 if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
2069 set toPassArgsByFile 1
2071 if { "$theCmpl" == "msvc" } {
2072 set aCmplCbp "msvc8"
2076 if { "$theCmpl" == "msvc" } {
2077 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2078 set aCmplFlagsRelease "-MD -O2"
2079 set aCmplFlagsDebug "-MDd -Od -Zi"
2080 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2081 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2082 } elseif { "$theCmpl" == "gcc" } {
2083 if { "$aWokStation" != "qnx" } {
2084 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2086 set aCmplFlagsRelease "-O2"
2087 set aCmplFlagsDebug "-O0 -g"
2088 if { "$aWokStation" == "wnt" } {
2089 lappend aCmplFlags "-std=gnu++0x"
2090 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2092 lappend aCmplFlags "-std=c++0x"
2093 lappend aCmplFlags "-fPIC"
2094 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2096 lappend aCmplFlags "-Wall"
2097 lappend aCmplFlags "-fexceptions"
2099 lappend aCmplFlagsRelease "-DNDEBUG"
2100 lappend aCmplFlagsRelease "-DNo_Exception"
2101 lappend aCmplFlagsDebug "-D_DEBUG"
2102 if { "$aWokStation" == "qnx" } {
2103 lappend aCmplFlags "-D_QNX_SOURCE"
2106 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2107 set aLnkFileName "${theProjName}_obj.link"
2108 set aLnkDebFileName "${theProjName}_objd.link"
2109 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2110 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2111 set aFile [open $aCbpFilePath "w"]
2112 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2113 puts $aFile "<CodeBlocks_project_file>"
2114 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2115 puts $aFile "\t<Project>"
2116 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2117 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2118 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2119 puts $aFile "\t\t<Build>"
2121 # Release target configuration
2122 puts $aFile "\t\t\t<Target title=\"Release\">"
2123 if { "$theIsExe" == "true" } {
2124 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2125 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2127 if { "$aWokStation" == "wnt" } {
2128 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\" />"
2130 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2132 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2134 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2135 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2136 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2137 if { "$aWokStation" == "wnt" } {
2138 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2140 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2143 # compiler options per TARGET (including defines)
2144 puts $aFile "\t\t\t\t<Compiler>"
2145 foreach aFlagIter $aCmplFlagsRelease {
2146 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2148 foreach aMacro $theDefines {
2149 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2151 puts $aFile "\t\t\t\t</Compiler>"
2153 puts $aFile "\t\t\t\t<Linker>"
2154 if { $toPassArgsByFile == 1 } {
2155 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2157 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2158 if { "$aWokStation" == "mac" } {
2159 if { [ lsearch $theLibsList X11 ] >= 0} {
2160 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2163 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2164 if { "$aWokStation" == "lin" } {
2165 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/lib\" />"
2167 puts $aFile "\t\t\t\t</Linker>"
2169 puts $aFile "\t\t\t</Target>"
2171 # Debug target configuration
2172 puts $aFile "\t\t\t<Target title=\"Debug\">"
2173 if { "$theIsExe" == "true" } {
2174 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2175 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2177 if { "$aWokStation" == "wnt" } {
2178 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\" />"
2180 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2182 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2184 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2185 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2186 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2187 if { "$aWokStation" == "wnt" } {
2188 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2190 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2193 # compiler options per TARGET (including defines)
2194 puts $aFile "\t\t\t\t<Compiler>"
2195 foreach aFlagIter $aCmplFlagsDebug {
2196 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2198 foreach aMacro $theDefines {
2199 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2201 puts $aFile "\t\t\t\t</Compiler>"
2203 puts $aFile "\t\t\t\t<Linker>"
2204 if { $toPassArgsByFile == 1 } {
2205 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2207 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2208 if { "$aWokStation" == "mac" } {
2209 if { [ lsearch $theLibsList X11 ] >= 0} {
2210 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2213 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2214 if { "$aWokStation" == "lin" } {
2215 puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/libd\" />"
2217 puts $aFile "\t\t\t\t</Linker>"
2219 puts $aFile "\t\t\t</Target>"
2221 puts $aFile "\t\t</Build>"
2223 # COMMON compiler options
2224 puts $aFile "\t\t<Compiler>"
2225 foreach aFlagIter $aCmplFlags {
2226 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2228 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2229 foreach anIncPath $theIncPaths {
2230 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2232 puts $aFile "\t\t</Compiler>"
2234 # COMMON linker options
2235 puts $aFile "\t\t<Linker>"
2236 if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
2237 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2239 foreach aFrameworkName $theFrameworks {
2240 if { "$aFrameworkName" != "" } {
2241 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2244 foreach aLibName $theLibsList {
2245 if { "$aLibName" != "" } {
2246 if { "$theCmpl" == "msvc" } {
2247 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2249 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2253 puts $aFile "\t\t</Linker>"
2259 set isFirstSrcFile 1
2260 if { $toPassArgsByFile == 1 } {
2261 set aFileLnkObj [open $aLnkFilePath "w"]
2262 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2265 foreach aSrcFile $theSrcFiles {
2266 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2267 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2268 puts $aFile "\t\t\t<Option compile=\"1\" />"
2269 puts $aFile "\t\t\t<Option link=\"1\" />"
2270 puts $aFile "\t\t</Unit>"
2271 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2272 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2273 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2274 puts $aFile "\t\t</Unit>"
2275 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2276 # pass at list single source file to Code::Blocks as is
2277 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2278 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2279 puts $aFile "\t\t\t<Option link=\"0\" />"
2280 puts $aFile "\t\t</Unit>"
2282 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"] $aSrcFile]]
2283 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
2284 puts -nonewline $aFileLnkObj "$aFileObj "
2285 puts -nonewline $aFileLnkObjd "$aFileObjd "
2287 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2288 set isFirstSrcFile 0
2292 if { "$aWokStation" == "wnt" } {
2297 puts $aFile "\t</Project>"
2298 puts $aFile "</CodeBlocks_project_file>"
2301 return $aCbpFilePath
2304 # Define libraries to link using only EXTERNLIB file
2305 proc LibToLinkX {thePackage theDummyName} {
2306 set aToolKits [LibToLink $thePackage]
2310 # Function to generate Xcode workspace and project files
2311 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2313 puts stderr "Generating project files for Xcode"
2315 # Generate projects for toolkits and separate workspace for each module
2316 foreach aModule $theModules {
2317 OS:xcworkspace $aModule $aModule $theOutDir
2318 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2321 # Generate single workspace "OCCT" containing projects from all modules
2322 if { "$theAllSolution" != "" } {
2323 OS:xcworkspace $theAllSolution $theModules $theOutDir
2327 # Generates toolkits sections for Xcode workspace file.
2328 proc OS:xcworkspace:toolkits { theModule } {
2331 # Adding toolkits for module in workspace.
2332 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2333 append aBuff " <FileRef\n"
2334 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2335 append aBuff " </FileRef>\n"
2338 # Adding executables for module, assume one project per cxx file...
2339 foreach aUnit [OS:executable ${theModule}] {
2341 set src_files [_get_used_files $aUnit false]
2343 foreach s $src_files {
2344 regexp {source ([^\s]+)} $s dummy name
2345 lappend aSrcFiles $name
2347 foreach aSrcFile $aSrcFiles {
2348 set aFileExtension [file extension $aSrcFile]
2349 if { $aFileExtension == ".cxx" } {
2350 set aPrjName [file rootname $aSrcFile]
2351 append aBuff " <FileRef\n"
2352 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2353 append aBuff " </FileRef>\n"
2358 # Removing unnecessary newline character from the end.
2359 set aBuff [string replace $aBuff end end]
2363 # Generates workspace files for Xcode.
2364 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2365 # Creating workspace directory for Xcode.
2366 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2367 wokUtils:FILES:mkdir $aWorkspaceDir
2368 if { ! [file exists $aWorkspaceDir] } {
2369 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2373 # Creating workspace file.
2374 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2375 set aFile [open $aWsFilePath "w"]
2377 # Adding header and section for main Group.
2378 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2379 puts $aFile "<Workspace"
2380 puts $aFile " version = \"1.0\">"
2381 puts $aFile " <Group"
2382 puts $aFile " location = \"container:\""
2383 puts $aFile " name = \"${theWorkspaceName}\">"
2386 if { [llength "$theModules"] > 1 } {
2387 foreach aModule $theModules {
2388 puts $aFile " <Group"
2389 puts $aFile " location = \"container:\""
2390 puts $aFile " name = \"${aModule}\">"
2391 puts $aFile [OS:xcworkspace:toolkits $aModule]
2392 puts $aFile " </Group>"
2395 puts $aFile [OS:xcworkspace:toolkits $theModules]
2399 puts $aFile " </Group>"
2400 puts $aFile "</Workspace>"
2404 # Generates Xcode project files.
2405 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2406 upvar $theGuidsMap aGuidsMap
2409 if { "$theLibType" == "static" } {
2411 } elseif { "$thePlatform" == "ios" } {
2415 set aProjectFiles {}
2416 foreach aModule $theModules {
2417 foreach aToolKit [${aModule}:toolkits] {
2418 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2420 foreach anExecutable [OS:executable ${aModule}] {
2421 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2424 return $aProjectFiles
2427 # Generates dependencies section for Xcode project files.
2428 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
2429 upvar $theGuidsMap aGuidsMap
2430 upvar $theFileRefSection aFileRefSection
2431 upvar $theDepsGuids aDepsGuids
2432 upvar $theDepsRefGuids aDepsRefGuids
2434 set aBuildFileSection ""
2435 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2436 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2438 if { "$theTargetType" == "executable" } {
2439 set aFile [osutils:tk:files $theToolKit mac]
2440 set aProjName [file rootname [file tail $aFile]]
2441 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2445 if { $theIsStatic == 1 } {
2447 if { "$theTargetType" != "executable" } {
2448 return $aBuildFileSection
2452 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
2453 set aUsedLibs [concat $aUsedLibs $aLibs]
2454 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2455 foreach tkx $aUsedLibs {
2456 set aDepLib "${tkx}_Dep"
2457 set aDepLibRef "${tkx}_DepRef"
2459 if { ! [info exists aGuidsMap($aDepLib)] } {
2460 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2462 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2463 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2466 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2467 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2468 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2470 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2472 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2473 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2476 return $aBuildFileSection
2479 # Generates PBXBuildFile and PBXGroup sections for project file.
2480 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2481 upvar $theSrcFileRefSection aSrcFileRefSection
2482 upvar $theGroupSection aGroupSection
2483 upvar $thePackageGuids aPackagesGuids
2484 upvar $theSrcFileGuids aSrcFileGuids
2485 upvar $theGuidsMap aGuidsMap
2486 upvar $theIncPaths anIncPaths
2488 set listloc [osutils:tk:units $theToolKit]
2489 set resultloc [osutils:justunix $listloc]
2490 set aBuildFileSection ""
2491 set aPackages [lsort -nocase $resultloc]
2492 if { "$theTargetType" == "executable" } {
2493 set aPackages [list "$theToolKit"]
2496 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2497 foreach fxlo $aPackages {
2499 set aPackage "${xlo}_Package"
2500 set aSrcFileRefGuids ""
2501 if { ! [info exists aGuidsMap($aPackage)] } {
2502 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2505 set aSrcFiles [osutils:tk:files $xlo mac]
2506 foreach aSrcFile [lsort $aSrcFiles] {
2507 set aFileExt "sourcecode.cpp.cpp"
2509 if { [file extension $aSrcFile] == ".c" } {
2510 set aFileExt "sourcecode.c.c"
2511 } elseif { [file extension $aSrcFile] == ".mm" } {
2512 set aFileExt "sourcecode.cpp.objcpp"
2515 if { ! [info exists aGuidsMap($aSrcFile)] } {
2516 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2518 set aSrcFileRef "${aSrcFile}_Ref"
2519 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2520 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2522 if { ! [info exists written([file tail $aSrcFile])] } {
2523 set written([file tail $aSrcFile]) 1
2524 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2525 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"
2526 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2527 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2529 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2533 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2534 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2535 append aGroupSection "\t\t\tchildren = (\n"
2536 append aGroupSection $aSrcFileRefGuids
2537 append aGroupSection "\t\t\t);\n"
2538 append aGroupSection "\t\t\tname = $xlo;\n"
2539 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2540 append aGroupSection "\t\t\};\n"
2542 # Storing packages IDs for adding them later as a child of toolkit
2543 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2546 # Removing unnecessary newline character from the end.
2547 set aPackagesGuids [string replace $aPackagesGuids end end]
2549 return $aBuildFileSection
2552 # Creates folders structure and all necessary files for Xcode project.
2553 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2554 set aPBXBuildPhase "Headers"
2555 set aRunOnlyForDeployment "0"
2556 set aProductType "library.dynamic"
2557 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2558 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2559 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2560 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2561 if { $theIsStatic == 1 } {
2562 lappend aTKDefines "OCCT_NO_PLUGINS"
2565 if { "$theTargetType" == "executable" } {
2566 set aPBXBuildPhase "CopyFiles"
2567 set aRunOnlyForDeployment "1"
2568 set aProductType "tool"
2569 set anExecExtension ""
2571 set aWrapperExtension ""
2572 } elseif { $theIsStatic == 1 } {
2573 set aProductType "library.static"
2574 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2575 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2578 set aUsername [exec whoami]
2580 # Creation of folders for Xcode projectP.
2581 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2582 wokUtils:FILES:mkdir $aToolkitDir
2583 if { ! [file exists $aToolkitDir] } {
2584 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2588 set aUserDataDir "${aToolkitDir}/xcuserdata"
2589 wokUtils:FILES:mkdir $aUserDataDir
2590 if { ! [file exists $aUserDataDir] } {
2591 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2595 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2596 wokUtils:FILES:mkdir $aUserDataDir
2597 if { ! [file exists $aUserDataDir] } {
2598 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2602 set aSchemesDir "${aUserDataDir}/xcschemes"
2603 wokUtils:FILES:mkdir $aSchemesDir
2604 if { ! [file exists $aSchemesDir] } {
2605 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2608 # End of folders creation.
2610 # Generating GUID for tookit.
2611 upvar $theGuidsMap aGuidsMap
2612 if { ! [info exists aGuidsMap($theToolKit)] } {
2613 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2616 # Creating xcscheme file for toolkit from template.
2617 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2618 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2619 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2620 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2621 puts $aXcschemeFile $aXcschemeTmpl
2622 close $aXcschemeFile
2624 # Creating xcschememanagement.plist file for toolkit from template.
2625 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2626 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2627 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2628 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2629 puts $aPlistFile $aPlistTmpl
2632 # Creating project.pbxproj file for toolkit.
2633 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2634 puts $aPbxprojFile "// !\$*UTF8*\$!"
2635 puts $aPbxprojFile "\{"
2636 puts $aPbxprojFile "\tarchiveVersion = 1;"
2637 puts $aPbxprojFile "\tclasses = \{"
2638 puts $aPbxprojFile "\t\};"
2639 puts $aPbxprojFile "\tobjectVersion = 46;"
2640 puts $aPbxprojFile "\tobjects = \{\n"
2642 # Begin PBXBuildFile section
2643 set aPackagesGuids ""
2644 set aGroupSection ""
2645 set aSrcFileRefSection ""
2646 set aSrcFileGuids ""
2647 set aDepsFileRefSection ""
2649 set aDepsRefGuids ""
2650 set anIncPaths [list "../../../inc"]
2653 if { [info exists ::env(CSF_OPT_INC)] } {
2654 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2655 foreach anIncCfgPath $anIncCfg {
2656 lappend anIncPaths $anIncCfgPath
2659 if { [info exists ::env(CSF_OPT_LIB64)] } {
2660 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2661 foreach anLibCfgPath $anLibCfg {
2662 lappend anLibPaths $anLibCfgPath
2666 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2667 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2668 # End PBXBuildFile section
2670 # Begin PBXFileReference section
2671 set aToolkitLib "lib${theToolKit}.dylib"
2672 set aPath "$aToolkitLib"
2673 if { "$theTargetType" == "executable" } {
2674 set aPath "$theToolKit"
2675 } elseif { $theIsStatic == 1 } {
2676 set aToolkitLib "lib${theToolKit}.a"
2679 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2680 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2683 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2684 puts $aPbxprojFile $aSrcFileRefSection
2685 puts $aPbxprojFile $aDepsFileRefSection
2686 # End PBXFileReference section
2689 # Begin PBXFrameworksBuildPhase section
2690 set aTkFrameworks "${theToolKit}_Frameworks"
2691 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2692 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2695 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2696 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2697 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2698 puts $aPbxprojFile "\t\t\tfiles = ("
2699 puts $aPbxprojFile $aDepsGuids
2700 puts $aPbxprojFile "\t\t\t);"
2701 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2702 puts $aPbxprojFile "\t\t\};\n"
2703 # End PBXFrameworksBuildPhase section
2705 # Begin PBXGroup section
2706 set aTkPBXGroup "${theToolKit}_PBXGroup"
2707 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2708 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2711 set aTkSrcGroup "${theToolKit}_SrcGroup"
2712 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2713 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2716 puts $aPbxprojFile $aGroupSection
2717 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2718 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2719 puts $aPbxprojFile "\t\t\tchildren = ("
2720 puts $aPbxprojFile $aDepsRefGuids
2721 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2722 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2723 puts $aPbxprojFile "\t\t\t);"
2724 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2725 puts $aPbxprojFile "\t\t\};"
2726 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2727 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2728 puts $aPbxprojFile "\t\t\tchildren = ("
2729 puts $aPbxprojFile $aPackagesGuids
2730 puts $aPbxprojFile "\t\t\t);"
2731 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2732 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2733 puts $aPbxprojFile "\t\t\};\n"
2734 # End PBXGroup section
2736 # Begin PBXHeadersBuildPhase section
2737 set aTkHeaders "${theToolKit}_Headers"
2738 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2739 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2742 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2743 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2744 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2745 puts $aPbxprojFile "\t\t\tfiles = ("
2746 puts $aPbxprojFile "\t\t\t);"
2747 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2748 puts $aPbxprojFile "\t\t\};\n"
2749 # End PBXHeadersBuildPhase section
2751 # Begin PBXNativeTarget section
2752 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2753 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2754 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2757 set aTkSources "${theToolKit}_Sources"
2758 if { ! [info exists aGuidsMap($aTkSources)] } {
2759 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2762 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2763 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2764 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2765 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2766 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2767 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2768 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2769 puts $aPbxprojFile "\t\t\t);"
2770 puts $aPbxprojFile "\t\t\tbuildRules = ("
2771 puts $aPbxprojFile "\t\t\t);"
2772 puts $aPbxprojFile "\t\t\tdependencies = ("
2773 puts $aPbxprojFile "\t\t\t);"
2774 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
2775 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
2776 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
2777 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
2778 puts $aPbxprojFile "\t\t\};\n"
2779 # End PBXNativeTarget section
2781 # Begin PBXProject section
2782 set aTkProjectObj "${theToolKit}_ProjectObj"
2783 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
2784 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
2787 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
2788 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
2789 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
2792 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
2793 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
2794 puts $aPbxprojFile "\t\t\tattributes = \{"
2795 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
2796 puts $aPbxprojFile "\t\t\t\};"
2797 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
2798 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
2799 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
2800 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
2801 puts $aPbxprojFile "\t\t\tknownRegions = ("
2802 puts $aPbxprojFile "\t\t\t\ten,"
2803 puts $aPbxprojFile "\t\t\t);"
2804 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
2805 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
2806 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
2807 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
2808 puts $aPbxprojFile "\t\t\ttargets = ("
2809 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
2810 puts $aPbxprojFile "\t\t\t);"
2811 puts $aPbxprojFile "\t\t\};\n"
2812 # End PBXProject section
2814 # Begin PBXSourcesBuildPhase section
2815 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
2816 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
2817 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2818 puts $aPbxprojFile "\t\t\tfiles = ("
2819 puts $aPbxprojFile $aSrcFileGuids
2820 puts $aPbxprojFile "\t\t\t);"
2821 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2822 puts $aPbxprojFile "\t\t\};\n"
2823 # End PBXSourcesBuildPhase section
2825 # Begin XCBuildConfiguration section
2826 set aTkDebugProject "${theToolKit}_DebugProject"
2827 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
2828 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
2831 set aTkReleaseProject "${theToolKit}_ReleaseProject"
2832 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
2833 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
2836 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
2837 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
2838 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
2841 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
2842 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
2843 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
2847 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
2848 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2849 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2851 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
2852 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2853 if { "$thePlatform" == "ios" } {
2854 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2855 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2856 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2857 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2858 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2860 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2861 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2862 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
2863 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2864 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
2865 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2866 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
2867 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2868 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
2869 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
2870 puts $aPbxprojFile "\t\t\t\t);"
2871 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
2872 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2873 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2874 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2875 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2876 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2877 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
2878 if { "$thePlatform" == "ios" } {
2879 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
2880 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2882 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
2884 puts $aPbxprojFile "\t\t\t\};"
2886 puts $aPbxprojFile "\t\t\tname = Debug;"
2887 puts $aPbxprojFile "\t\t\};"
2890 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
2891 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2892 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2894 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
2895 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2896 if { "$thePlatform" == "ios" } {
2897 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2898 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2899 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2900 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2901 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2903 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2904 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2905 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
2906 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2907 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2908 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
2909 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
2910 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2911 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2912 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2913 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2914 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2915 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
2916 if { "$thePlatform" == "ios" } {
2917 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
2918 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2920 puts $aPbxprojFile "\t\t\t\};"
2921 puts $aPbxprojFile "\t\t\tname = Release;"
2922 puts $aPbxprojFile "\t\t\};"
2923 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
2924 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2925 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2926 puts $aPbxprojFile "${anExecExtension}"
2927 puts $aPbxprojFile "${anExecPrefix}"
2928 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2929 foreach aMacro $aTKDefines {
2930 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2932 puts $aPbxprojFile "\t\t\t\t);"
2934 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2935 foreach anIncPath $anIncPaths {
2936 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2938 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2939 puts $aPbxprojFile "\t\t\t\t);"
2941 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2942 foreach anLibPath $anLibPaths {
2943 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2945 puts $aPbxprojFile "\t\t\t\t);"
2947 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2948 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2949 puts $aPbxprojFile "\t\t\t\t);"
2950 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2951 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2952 puts $aPbxprojFile "\t\t\t\t);"
2953 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2954 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
2955 foreach anIncPath $anIncPaths {
2956 append anUserHeaderSearchPath " ${anIncPath}"
2958 append anUserHeaderSearchPath "\";"
2959 puts $aPbxprojFile $anUserHeaderSearchPath
2960 puts $aPbxprojFile "${aWrapperExtension}"
2961 puts $aPbxprojFile "\t\t\t\};"
2962 puts $aPbxprojFile "\t\t\tname = Debug;"
2963 puts $aPbxprojFile "\t\t\};"
2964 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
2965 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2966 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2967 puts $aPbxprojFile "${anExecExtension}"
2968 puts $aPbxprojFile "${anExecPrefix}"
2969 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2970 foreach aMacro $aTKDefines {
2971 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2973 puts $aPbxprojFile "\t\t\t\t);"
2974 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2975 foreach anIncPath $anIncPaths {
2976 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2978 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2979 puts $aPbxprojFile "\t\t\t\t);"
2981 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2982 foreach anLibPath $anLibPaths {
2983 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2985 puts $aPbxprojFile "\t\t\t\t);"
2987 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2988 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2989 puts $aPbxprojFile "\t\t\t\t);"
2990 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2991 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2992 puts $aPbxprojFile "\t\t\t\t);"
2993 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2994 puts $aPbxprojFile $anUserHeaderSearchPath
2995 puts $aPbxprojFile "${aWrapperExtension}"
2996 puts $aPbxprojFile "\t\t\t\};"
2997 puts $aPbxprojFile "\t\t\tname = Release;"
2998 puts $aPbxprojFile "\t\t\};\n"
2999 # End XCBuildConfiguration section
3001 # Begin XCConfigurationList section
3002 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3003 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3004 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3005 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3006 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3007 puts $aPbxprojFile "\t\t\t);"
3008 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3009 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3010 puts $aPbxprojFile "\t\t\};"
3011 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3012 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3013 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3014 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3015 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3016 puts $aPbxprojFile "\t\t\t);"
3017 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3018 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3019 puts $aPbxprojFile "\t\t\};\n"
3020 # End XCConfigurationList section
3022 puts $aPbxprojFile "\t\};"
3023 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3024 puts $aPbxprojFile "\}"
3029 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3030 set aUsername [exec whoami]
3032 # Creating folders for Xcode project file.
3033 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3034 wokUtils:FILES:mkdir $anExecutableDir
3035 if { ! [file exists $anExecutableDir] } {
3036 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3040 set aUserDataDir "${anExecutableDir}/xcuserdata"
3041 wokUtils:FILES:mkdir $aUserDataDir
3042 if { ! [file exists $aUserDataDir] } {
3043 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3047 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3048 wokUtils:FILES:mkdir $aUserDataDir
3049 if { ! [file exists $aUserDataDir] } {
3050 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3054 set aSchemesDir "${aUserDataDir}/xcschemes"
3055 wokUtils:FILES:mkdir $aSchemesDir
3056 if { ! [file exists $aSchemesDir] } {
3057 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3060 # End folders creation.
3062 # Generating GUID for tookit.
3063 upvar $theGuidsMap aGuidsMap
3064 if { ! [info exists aGuidsMap($theExecutable)] } {
3065 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3068 # Creating xcscheme file for toolkit from template.
3069 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3070 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3071 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3072 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3073 puts $aXcschemeFile $aXcschemeTmpl
3074 close $aXcschemeFile
3076 # Creating xcschememanagement.plist file for toolkit from template.
3077 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3078 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3079 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3080 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3081 puts $aPlistFile $aPlistTmpl