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 lsort -unique $anUsedToolKits
645 foreach anUsedToolKit $anUsedToolKits {
646 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
648 lsort -unique $anUnits
650 if { [info exists ::env(SHORTCUT_HEADERS)] &&
651 $::env(SHORTCUT_HEADERS) == "true" } {
652 # template preparation
653 if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
654 puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
657 set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
659 # relative anIncPath in connection with aCasRoot/src
660 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
662 # create and copy short-cut header files
663 foreach anUnit $anUnits {
664 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
665 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
666 set aHeaderFileName [file tail $aHeaderFile]
668 regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
670 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
671 set fp [open "$theIncPath/$aHeaderFileName" r]
672 set aHeaderContent [read $fp]
676 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
678 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
679 # remove eof from string
680 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
682 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
688 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
689 fconfigure $aShortCutHeaderFile -translation lf
690 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
691 close $aShortCutHeaderFile
696 foreach anUnit $anUnits {
697 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
698 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
699 set aHeaderFileName [file tail $aHeaderFile]
701 # copy file only if target does not exist or is older than original
702 set torig [file mtime $aHeaderFile]
703 if { ! [file isfile $anIncPath/$aHeaderFileName] } {
706 set tcopy [file mtime $anIncPath/$aHeaderFileName]
708 if { $tcopy < $torig } {
710 file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
711 } elseif { $tcopy != $torig } {
712 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
716 puts "Info: $nbcopied files updated"
720 # Generate header for VS solution file
721 proc osutils:vcsolution:header { vcversion } {
722 if { "$vcversion" == "vc7" } {
724 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
725 } elseif { "$vcversion" == "vc8" } {
727 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
728 "# Visual Studio 2005\n"
729 } elseif { "$vcversion" == "vc9" } {
731 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
732 "# Visual Studio 2008\n"
733 } elseif { "$vcversion" == "vc10" } {
735 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
736 "# Visual Studio 2010\n"
737 } elseif { "$vcversion" == "vc11" } {
739 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
740 "# Visual Studio 2012\n"
741 } elseif { "$vcversion" == "vc12" } {
743 "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
744 "# Visual Studio 2013\n"
745 } elseif { "$vcversion" == "vc14" } {
747 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
748 "# Visual Studio 14\n"
750 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
754 # Returns extension (without dot) for project files of given version of VC
756 proc osutils:vcproj:ext { vcversion } {
757 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
763 # Generate start of configuration section of VS solution file
765 proc osutils:vcsolution:config:begin { vcversion } {
766 if { "$vcversion" == "vc7" } {
769 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
770 "\t\tDebug = Debug\n" \
771 "\t\tRelease = Release\n" \
772 "\tEndGlobalSection\n" \
773 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
777 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
778 "\t\tDebug|Win32 = Debug|Win32\n" \
779 "\t\tRelease|Win32 = Release|Win32\n" \
780 "\t\tDebug|x64 = Debug|x64\n" \
781 "\t\tRelease|x64 = Release|x64\n" \
782 "\tEndGlobalSection\n" \
783 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
787 # Generate part of configuration section of VS solution file describing one project
789 proc osutils:vcsolution:config:project { vcversion guid } {
790 if { "$vcversion" == "vc7" } {
792 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
793 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
794 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
795 "\t\t$guid.Release.Build.0 = Release|Win32\n"
798 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
799 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
800 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
801 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
802 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
803 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
804 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
805 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
809 # Generate start of configuration section of VS solution file
811 proc osutils:vcsolution:config:end { vcversion } {
812 if { "$vcversion" == "vc7" } {
814 "\tEndGlobalSection\n" \
815 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
816 "\tEndGlobalSection\n" \
817 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
818 "\tEndGlobalSection\n"
821 "\tEndGlobalSection\n" \
822 "\tGlobalSection(SolutionProperties) = preSolution\n" \
823 "\t\tHideSolutionNode = FALSE\n" \
824 "\tEndGlobalSection\n"
828 # generate Visual Studio solution file
829 # if module is empty, generates one solution for all known modules
831 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
833 upvar $theGuidsMap aGuidsMap
835 # collect list of projects to be created
838 foreach aModule $theModules {
840 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
841 lappend aProjects $aToolKit
842 lappend aProjectsInModule($aModule) $aToolKit
843 lappend aDependencies [LibToLink $aToolKit]
845 # executables, assume one project per cxx file...
846 foreach aUnit [OS:executable ${aModule}] {
848 set src_files [_get_used_files $aUnit false]
850 foreach s $src_files {
851 regexp {source ([^\s]+)} $s dummy name
852 lappend aSrcFiles $name
854 foreach aSrcFile $aSrcFiles {
855 set aFileExtension [file extension $aSrcFile]
856 if { $aFileExtension == ".cxx" } {
857 set aPrjName [file rootname $aSrcFile]
858 lappend aProjects $aPrjName
859 lappend aProjectsInModule($aModule) $aPrjName
860 if {[file isdirectory $path/src/$aUnitLoc]} {
861 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
863 lappend aDependencies {}
870 # generate GUIDs for projects (unless already known)
871 foreach aProject $aProjects {
872 if { ! [info exists aGuidsMap($aProject)] } {
873 set aGuidsMap($aProject) [OS:genGUID]
877 # generate solution file
878 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
879 append aFileBuff [osutils:vcsolution:header $theVcVer]
881 # GUID identifying group projects in Visual Studio
882 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
884 # generate group projects -- one per module
885 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
886 foreach aModule $theModules {
887 if { ! [info exists aGuidsMap(_$aModule)] } {
888 set aGuidsMap(_$aModule) [OS:genGUID]
890 set aGuid $aGuidsMap(_$aModule)
891 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
895 # extension of project files
896 set aProjExt [osutils:vcproj:ext $theVcVer]
898 # GUID identifying C++ projects in Visual Studio
899 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
901 # generate normal projects
902 set aProjsNb [llength $aProjects]
903 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
904 set aProj [lindex $aProjects $aProjId]
905 set aGuid $aGuidsMap($aProj)
906 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
907 # write projects dependencies information (vc7 to vc9)
909 foreach aDepLib [lindex $aDependencies $aProjId] {
910 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
911 set depGUID $aGuidsMap($aDepLib)
912 append aDepGuids "\t\t$depGUID = $depGUID\n"
915 if { "$aDepGuids" != "" } {
916 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
917 append aFileBuff "$aDepGuids"
918 append aFileBuff "\tEndProjectSection\n"
920 append aFileBuff "EndProject\n"
923 # generate configuration section
924 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
925 foreach aProj $aProjects {
926 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
928 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
930 # write information of grouping of projects by module
931 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
932 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
933 foreach aModule $theModules {
934 if { ! [info exists aProjectsInModule($aModule)] } { continue }
935 foreach aProject $aProjectsInModule($aModule) {
936 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
939 append aFileBuff " EndGlobalSection\n"
942 # final word (footer)
943 append aFileBuff "EndGlobal"
946 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
947 fconfigure $aFile -translation crlf
948 puts $aFile $aFileBuff
950 return [file join $theOutDir ${theSolName}.sln]
952 # Generate Visual Studio projects for specified version
954 proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
955 upvar $theGuidsMap aGuidsMap
959 foreach aModule $theModules {
960 foreach aToolKit [${aModule}:toolkits] {
961 lappend aProjectFiles [osutils:vcproj $theVcVer $theOutDir $aToolKit aGuidsMap]
963 foreach anExecutable [OS:executable ${aModule}] {
964 lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
967 return $aProjectFiles
969 # generate template name and load it for given version of Visual Studio and platform
971 proc osutils:vcproj:readtemplate {theVcVer isexec} {
973 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
978 set aVerExt [string range $theVcVer 2 end]
979 set aVerExt "v${aVerExt}0"
983 set anExt "${anExt}x"
984 set what "$what executable"
986 if { "$theVcVer" == "vc10" } {
987 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
988 set aCmpl32 "\n <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
990 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
991 regsub -all -- {__VCVER__} $aTmpl $theVcVer aTmpl
992 regsub -all -- {__VCVEREXT__} $aTmpl $aVerExt aTmpl
993 regsub -all -- {__VCMPL32__} $aTmpl $aCmpl32 aTmpl
994 regsub -all -- {__VCMPL64__} $aTmpl $aCmpl64 aTmpl
998 proc osutils:readtemplate {ext what} {
999 set loc "$::THE_CASROOT/adm/templates/template.$ext"
1000 return [wokUtils:FILES:FileToString $loc]
1002 # Read a file in a string as is.
1004 proc wokUtils:FILES:FileToString { fin } {
1005 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1006 set strin [read $in [file size $fin]]
1014 # List extensions of compilable files in OCCT
1015 proc osutils:compilable {thePlatform} {
1016 if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
1017 return [list .c .cxx .cpp .mm]
1019 return [list .c .cxx .cpp]
1022 proc osutils:commonUsedTK { theToolKit } {
1023 set anUsedToolKits [list]
1024 set aDepToolkits [LibToLink $theToolKit]
1025 foreach tkx $aDepToolkits {
1026 if {[_get_type $tkx] == "t"} {
1027 lappend anUsedToolKits "${tkx}"
1030 return $anUsedToolKits
1033 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1034 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1035 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1038 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1045 # Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
1046 # @param theOS - target OS
1047 # @param theCsfLibsMap - libraries map
1048 # @param theCsfFrmsMap - frameworks map, OS X specific
1049 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1050 upvar $theCsfLibsMap aLibsMap
1051 upvar $theCsfFrmsMap aFrmsMap
1056 set aLibsMap(CSF_FREETYPE) "freetype"
1057 set aLibsMap(CSF_TclLibs) "tcl8.6"
1058 set aLibsMap(CSF_TclTkLibs) "tk8.6"
1059 if { "$::HAVE_FREEIMAGE" == "true" } {
1060 if { "$theOS" == "wnt" } {
1061 set aLibsMap(CSF_FreeImagePlus) "FreeImage FreeImagePlus"
1063 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1066 if { "$::HAVE_GL2PS" == "true" } {
1067 set aLibsMap(CSF_GL2PS) "gl2ps"
1069 if { "$::HAVE_TBB" == "true" } {
1070 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1072 if { "$::HAVE_VTK" == "true" } {
1073 if { "$theOS" == "wnt" } {
1074 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1076 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1080 if { "$theOS" == "wnt" } {
1082 set aLibsMap(CSF_kernel32) "kernel32"
1083 set aLibsMap(CSF_advapi32) "advapi32"
1084 set aLibsMap(CSF_gdi32) "gdi32"
1085 set aLibsMap(CSF_user32) "user32 comdlg32"
1086 set aLibsMap(CSF_opengl32) "opengl32"
1087 set aLibsMap(CSF_wsock32) "wsock32"
1088 set aLibsMap(CSF_netapi32) "netapi32"
1089 set aLibsMap(CSF_AviLibs) "ws2_32 vfw32"
1090 set aLibsMap(CSF_OpenGlLibs) "opengl32"
1091 set aLibsMap(CSF_winspool) "Winspool"
1092 set aLibsMap(CSF_psapi) "Psapi"
1093 set aLibsMap(CSF_d3d9) "d3d9"
1095 # the naming is different on Windows
1096 set aLibsMap(CSF_TclLibs) "tcl86"
1097 set aLibsMap(CSF_TclTkLibs) "tk86"
1099 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1101 # tbb headers define different pragma lib depending on debug/release
1102 set aLibsMap(CSF_TBB) ""
1104 if { "$theOS" == "mac" } {
1105 set aLibsMap(CSF_objc) "objc"
1106 set aFrmsMap(CSF_Appkit) "Appkit"
1107 set aFrmsMap(CSF_IOKit) "IOKit"
1108 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1109 set aFrmsMap(CSF_TclLibs) "Tcl"
1110 set aLibsMap(CSF_TclLibs) ""
1111 set aFrmsMap(CSF_TclTkLibs) "Tk"
1112 set aLibsMap(CSF_TclTkLibs) ""
1114 if { "$theOS" == "qnx" } {
1115 # CSF_ThreadLibs - pthread API is part of libc on QNX
1116 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1118 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1119 set aLibsMap(CSF_OpenGlLibs) "GL"
1120 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1121 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1122 set aLibsMap(CSF_MotifLibs) "X11"
1128 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1129 proc osutils:vtkCsf {{theOS ""}} {
1132 set aPathSplitter ":"
1133 if {"$theOS" == "wnt"} {
1134 set aPathSplitter ";"
1137 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1138 foreach anIncItem $anOptIncs {
1139 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1140 set aVtkVer $aFoundVtkVer
1144 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1145 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1147 # Additional suffices for the libraries
1149 foreach anItem $aLibArray {
1150 lset aLibArray $anIdx $anItem-$aVtkVer
1154 return [join $aLibArray " "]
1157 # @param theLibsList - dependencies (libraries list)
1158 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1159 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1161 upvar $theLibsList aLibsList
1162 upvar $theFrameworks aFrameworks
1163 set aLibsList [list]
1164 set aFrameworks [list]
1166 osutils:csfList $theOS aLibsMap aFrmsMap
1168 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1169 if [info exists aLibsMap($aCsfElem)] {
1170 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1171 if { [lsearch $aLibsList $aLib] == "-1" } {
1172 lappend aLibsList $aLib
1176 if [info exists aFrmsMap($aCsfElem)] {
1177 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1178 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1179 lappend aFrameworks $aFrm
1186 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1187 proc osutils:tk:units { tkloc } {
1190 set PACKAGES "$path/src/$tkloc/PACKAGES"
1191 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1192 if {[file isdirectory "$path/src/$u"]} {
1197 ;#puts stderr "Warning. No devunit included in $tkloc"
1202 proc osutils:justwnt { listloc } {
1203 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1204 set goaway [list Xdps Xw ImageUtility WOKUnix]
1205 return [osutils:juststation $goaway $listloc]
1208 # remove from listloc OpenCascade units indesirables on NT
1209 proc osutils:juststation {goaway listloc} {
1212 foreach u $listloc {
1213 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1214 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1221 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1222 # The first list is everything in the first list that wasn't in the second,
1223 # the second list contains the intersection of the two lists, the third list contains everything
1224 # in the second list that wasn't in the first.
1225 proc osutils:intersect3 {list1 list2} {
1226 set la1(0) {} ; unset la1(0)
1227 set lai(0) {} ; unset lai(0)
1228 set la2(0) {} ; unset la2(0)
1235 foreach elem [concat $list1 $list2] {
1236 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1242 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1245 # Prepare relative path
1246 proc relativePath {thePathFrom thePathTo} {
1247 if { [file isdirectory "$thePathFrom"] == 0 } {
1251 set aPathFrom [file normalize "$thePathFrom"]
1252 set aPathTo [file normalize "$thePathTo"]
1254 set aCutedPathFrom "${aPathFrom}/dummy"
1255 set aRelatedDeepPath ""
1257 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1258 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1259 # does aPathTo contain aCutedPathFrom?
1260 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1261 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1262 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1263 set aPathTo ".${aPathTo}"
1264 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1265 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1267 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1268 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1269 return $aPathToAfterCut
1271 set aRelatedDeepPath "$aRelatedDeepPath../"
1278 proc wokUtils:EASY:bs1 { s } {
1279 regsub -all {/} $s {\\} r
1283 # Returs for a full path the liste of n last directory part
1285 # n = 2 => dir/file.c
1286 # n = 3 => sdir/dir/file.c
1288 proc wokUtils:FILES:wtail { f n } {
1289 set ll [expr [llength [set lif [file split $f]]] -$n]
1290 return [join [lrange $lif $ll end] /]
1293 # Generate entry for one source file in Visual Studio 10 project file
1294 proc osutils:vcxproj:file { vcversion file params } {
1295 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1296 if { $params != "" } {
1297 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1300 if { $params != "" } {
1301 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1304 if { $params != "" } {
1305 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1308 if { $params != "" } {
1309 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1312 append text " </ClCompile>\n"
1316 # Generate Visual Studio 2010 project filters file
1317 proc osutils:vcxproj:filters { dir proj theFilesMap } {
1318 upvar $theFilesMap aFilesMap
1321 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1322 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1324 # list of "filters" (units)
1325 append text " <ItemGroup>\n"
1326 append text " <Filter Include=\"Source files\">\n"
1327 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1328 append text " </Filter>\n"
1329 foreach unit $aFilesMap(units) {
1330 append text " <Filter Include=\"Source files\\${unit}\">\n"
1331 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1332 append text " </Filter>\n"
1334 append text " </ItemGroup>\n"
1337 append text " <ItemGroup>\n"
1338 foreach unit $aFilesMap(units) {
1339 foreach file $aFilesMap($unit) {
1340 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1341 append text " <Filter>Source files\\${unit}</Filter>\n"
1342 append text " </ClCompile>\n"
1345 append text " </ItemGroup>\n"
1348 append text "</Project>"
1351 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1352 fconfigure $fp -translation crlf
1356 return ${proj}.vcxproj.filters
1359 # Generate Visual Studio 2011 project filters file
1360 proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1361 upvar $theFilesMap aFilesMap
1364 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1365 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1367 # list of "filters" (units)
1368 append text " <ItemGroup>\n"
1369 append text " <Filter Include=\"Source files\">\n"
1370 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1371 append text " </Filter>\n"
1372 foreach unit $aFilesMap(units) {
1373 append text " <Filter Include=\"Source files\\${unit}\">\n"
1374 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1375 append text " </Filter>\n"
1377 append text " </ItemGroup>\n"
1380 append text " <ItemGroup>\n"
1381 foreach unit $aFilesMap(units) {
1382 foreach file $aFilesMap($unit) {
1383 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1384 append text " <Filter>Source files\\${unit}</Filter>\n"
1385 append text " </ClCompile>\n"
1388 append text " </ItemGroup>\n"
1390 append text " <ItemGroup>\n"
1391 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1392 append text " </ItemGroup>\n"
1395 append text "</Project>"
1398 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1399 fconfigure $fp -translation crlf
1403 return ${proj}.vcxproj.filters
1406 # Generate RC file content for ToolKit from template
1407 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1408 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1409 set aBody [wokUtils:FILES:FileToString $aLoc]
1410 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1412 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1413 fconfigure $aFile -translation lf
1416 return "${theOutDir}/${theToolKit}.rc"
1419 # Generate Visual Studio project file for ToolKit
1420 proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1421 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1423 set l_compilable [osutils:compilable wnt]
1424 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1426 upvar $theGuidsMap aGuidsMap
1427 if { ! [info exists aGuidsMap($theToolKit)] } {
1428 set aGuidsMap($theToolKit) [OS:genGUID]
1430 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1432 set aUsedLibs [list]
1433 foreach tkx [osutils:commonUsedTK $theToolKit] {
1434 lappend aUsedLibs "${tkx}.lib"
1437 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1438 foreach aLibIter $aLibs {
1439 lappend aUsedLibs "${aLibIter}.lib"
1442 # correct names of referred third-party libraries that are named with suffix
1443 # depending on VC version
1444 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1446 # and put this list to project file
1447 #puts "$theToolKit requires $aUsedLibs"
1448 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1449 set aUsedLibs [join $aUsedLibs {;}]
1451 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1453 set anIncPaths "..\\..\\..\\inc"
1455 set aFilesSection ""
1456 set aVcFilesX(units) ""
1457 set listloc [osutils:tk:units $theToolKit]
1458 set resultloc [osutils:justwnt $listloc]
1459 if [array exists written] { unset written }
1460 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1461 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1462 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1463 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1464 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1465 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1467 foreach fxlo $resultloc {
1469 set aSrcFiles [osutils:tk:files $xlo wnt]
1470 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1471 if {$fxlo_cmplrs_options_cxx == ""} {
1472 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1474 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1475 if {$fxlo_cmplrs_options_c == ""} {
1476 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1478 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1479 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1480 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1481 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1482 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1483 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1485 foreach partopt $fxloparam {
1486 if {[string first "-I" $partopt] == "0"} {
1487 # this is an additional includes search path
1490 set needparam "$needparam $partopt"
1493 # Format of projects in vc10+ is different from vc7-9
1494 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1495 foreach aSrcFile [lsort $aSrcFiles] {
1496 if { ![info exists written([file tail $aSrcFile])] } {
1497 set written([file tail $aSrcFile]) 1
1498 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1500 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1502 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1503 lappend aVcFilesX($xlo) $aSrcFile
1506 append aFilesSection "\t\t\t<Filter\n"
1507 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1508 append aFilesSection "\t\t\t\t>\n"
1509 foreach aSrcFile [lsort $aSrcFiles] {
1510 if { ![info exists written([file tail $aSrcFile])] } {
1511 set written([file tail $aSrcFile]) 1
1512 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1514 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1517 append aFilesSection "\t\t\t</Filter>\n"
1521 append aTKDefines ";__${xlo}_DLL"
1523 # append anIncPaths ";..\\..\\..\\src\\${xlo}"
1526 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1527 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1528 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1531 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1532 fconfigure $aFile -translation crlf
1533 puts $aFile $theProjTmpl
1536 # write filters file for vc10+
1537 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1539 } elseif { "$theVcVer" == "vc10" } {
1540 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
1542 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1545 # write resource file
1546 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1551 # for a unit returns a map containing all its file in the current
1553 # local = 1 only local files
1554 proc osutils:tk:loadunit { loc map } {
1557 catch { unset TLOC }
1558 set lfiles [_get_used_files $loc]
1563 if [info exists TLOC($t)] {
1574 # Returns the list of all compilable files name in a toolkit, or devunit of any type
1575 # Tfiles lists for each unit the type of file that can be compiled.
1576 proc osutils:tk:files { tkloc thePlatform } {
1577 set Tfiles(source,nocdlpack) {source pubinclude}
1578 set Tfiles(source,toolkit) {}
1579 set Tfiles(source,executable) {source pubinclude}
1580 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1581 #puts " listloc = $listloc"
1583 set l_comp [osutils:compilable $thePlatform]
1584 set resultloc $listloc
1586 foreach loc $resultloc {
1587 set utyp [_get_type $loc]
1588 #puts "\"$utyp\" \"$loc\""
1590 "t" { set utyp "toolkit" }
1591 "n" { set utyp "nocdlpack" }
1592 "x" { set utyp "executable" }
1594 if [array exists map] { unset map }
1595 osutils:tk:loadunit $loc map
1596 #puts " loc = $loc === > [array names map]"
1597 set LType $Tfiles(source,${utyp})
1598 foreach typ [array names map] {
1599 if { [lsearch $LType $typ] == -1 } {
1603 foreach type [array names map] {
1605 foreach f $map($type) {
1607 if { [lsearch $l_comp [file extension $f]] != -1 } {
1616 # Generate Visual Studio project file for executable
1617 proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1619 foreach f [osutils:tk:files $theToolKit wnt] {
1620 if { $theProjTmpl == {} } {
1621 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1623 set aProjTmpl $theProjTmpl
1625 set aProjName [file rootname [file tail $f]]
1626 set l_compilable [osutils:compilable wnt]
1627 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1629 upvar $theGuidsMap aGuidsMap
1630 if { ! [info exists aGuidsMap($aProjName)] } {
1631 set aGuidsMap($aProjName) [OS:genGUID]
1633 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1635 set aUsedLibs [list]
1636 foreach tkx [osutils:commonUsedTK $theToolKit] {
1637 lappend aUsedLibs "${tkx}.lib"
1640 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1641 foreach aLibIter $aLibs {
1642 lappend aUsedLibs "${aLibIter}.lib"
1645 # correct names of referred third-party libraries that are named with suffix
1646 # depending on VC version
1647 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1649 # puts "$aProjName requires $aUsedLibs"
1650 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1651 set aUsedLibs [join $aUsedLibs {;}]
1653 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1655 set aFilesSection ""
1656 set aVcFilesX(units) ""
1658 if { ![info exists written([file tail $f])] } {
1659 set written([file tail $f]) 1
1661 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1662 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1663 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1664 lappend aVcFilesX($theToolKit) $f
1666 append aFilesSection "\t\t\t<Filter\n"
1667 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1668 append aFilesSection "\t\t\t\t>\n"
1669 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1670 append aFilesSection "\t\t\t</Filter>"
1673 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1675 #puts "$aProjTmpl $aFilesSection"
1676 set aTKDefines ";__${theToolKit}_DLL"
1677 set anIncPaths "..\\..\\..\\inc"
1678 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1679 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1680 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1681 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1683 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1685 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1686 fconfigure $aFile -translation crlf
1687 puts $aFile $aProjTmpl
1690 set aCommonSettingsFile "$aVcFilePath.user"
1691 lappend aVcFiles $aVcFilePath
1693 # write filters file for vc10
1694 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1695 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1698 set aCommonSettingsFileTmpl ""
1699 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1701 } elseif { "$theVcVer" == "vc9" } {
1702 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
1704 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
1706 if { "$aCommonSettingsFileTmpl" != "" } {
1707 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1709 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1710 fconfigure $aFile -translation crlf
1711 puts $aFile $aCommonSettingsFileTmpl
1714 lappend aVcFiles "$aCommonSettingsFile"
1720 # Generate entry for one source file in Visual Studio 7 - 9 project file
1721 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1722 append aText "\t\t\t\t<File\n"
1723 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1724 if { $theOptions == "" } {
1725 append aText "\t\t\t\t</File>\n"
1729 append aText "\t\t\t\t\t<FileConfiguration\n"
1730 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1731 append aText "\t\t\t\t\t\t<Tool\n"
1732 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1733 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1734 foreach aParam $theOptions {
1735 append aText "$aParam "
1738 append aText "\t\t\t\t\t\t/>\n"
1739 append aText "\t\t\t\t\t</FileConfiguration>\n"
1741 append aText "\t\t\t\t\t<FileConfiguration\n"
1742 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1743 append aText "\t\t\t\t\t\t<Tool\n"
1744 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1745 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1746 foreach aParam $theOptions {
1747 append aText "$aParam "
1750 append aText "\t\t\t\t\t\t/>\n"
1751 append aText "\t\t\t\t\t</FileConfiguration>\n"
1752 if { "$theVcVer" == "vc7" } {
1753 append aText "\t\t\t\t</File>\n"
1757 append aText "\t\t\t\t\t<FileConfiguration\n"
1758 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1759 append aText "\t\t\t\t\t\t<Tool\n"
1760 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1761 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1762 foreach aParam $theOptions {
1763 append aText "$aParam "
1766 append aText "\t\t\t\t\t\t/>\n"
1767 append aText "\t\t\t\t\t</FileConfiguration>\n"
1769 append aText "\t\t\t\t\t<FileConfiguration\n"
1770 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1771 append aText "\t\t\t\t\t\t<Tool\n"
1772 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1773 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1774 foreach aParam $theOptions {
1775 append aText "$aParam "
1778 append aText "\t\t\t\t\t\t/>\n"
1779 append aText "\t\t\t\t\t</FileConfiguration>\n"
1781 append aText "\t\t\t\t</File>\n"
1785 proc wokUtils:FILES:mkdir { d } {
1787 regsub -all {\.[^.]*} $tcl_version "" major
1788 if { $major == 8 } {
1791 if ![file exists $d] {
1792 if { "[info command mkdir]" == "mkdir" } {
1795 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1799 if [file exists $d] {
1806 # remove from listloc OpenCascade units indesirables on Unix
1807 proc osutils:justunix { listloc } {
1808 if { "$::tcl_platform(os)" == "Darwin" } {
1809 set goaway [list Xw WNT]
1811 set goaway [list WNT]
1813 return [osutils:juststation $goaway $listloc]
1817 ####### CODEBLOCK ###################################################################
1818 # Function to generate Code Blocks workspace and project files
1819 proc OS:MKCBP { theOutDir theModules theAllSolution thePlatform theCmpl } {
1820 puts stderr "Generating project files for Code Blocks"
1822 # Generate projects for toolkits and separate workspace for each module
1823 foreach aModule $theModules {
1824 OS:cworkspace $aModule $aModule $theOutDir
1825 OS:cbp $theCmpl $aModule $theOutDir $thePlatform
1828 # Generate single workspace "OCCT" containing projects from all modules
1829 if { "$theAllSolution" != "" } {
1830 OS:cworkspace $theAllSolution $theModules $theOutDir
1833 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
1836 # Generate Code Blocks projects
1837 proc OS:cbp { theCmpl theModules theOutDir thePlatform } {
1838 set aProjectFiles {}
1839 foreach aModule $theModules {
1840 foreach aToolKit [${aModule}:toolkits] {
1841 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit $thePlatform]
1843 foreach anExecutable [OS:executable ${aModule}] {
1844 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable $thePlatform]
1847 return $aProjectFiles
1850 # Generate Code::Blocks project file for ToolKit
1851 proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
1852 set aUsedLibs [list]
1853 set aFrameworks [list]
1854 set anIncPaths [list]
1855 set aTKDefines [list]
1856 set aTKSrcFiles [list]
1858 # collect list of referred libraries to link with
1859 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
1860 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
1861 foreach tkx $aDepToolkits {
1862 lappend aUsedLibs "${tkx}"
1865 lappend anIncPaths "../../../inc"
1866 set listloc [osutils:tk:units $theToolKit]
1868 if { [llength $listloc] == 0 } {
1869 set listloc $theToolKit
1872 if { $thePlatform == "wnt" } {
1873 set resultloc [osutils:justwnt $listloc]
1875 set resultloc [osutils:justunix $listloc]
1877 if [array exists written] { unset written }
1878 foreach fxlo $resultloc {
1880 set aSrcFiles [osutils:tk:files $xlo $thePlatform]
1881 foreach aSrcFile [lsort $aSrcFiles] {
1882 if { ![info exists written([file tail $aSrcFile])] } {
1883 set written([file tail $aSrcFile]) 1
1884 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
1886 puts "Warning : more than one occurences for [file tail $aSrcFile]"
1890 # macros for correct DLL exports
1891 if { $thePlatform == "wnt" } {
1892 lappend aTKDefines "__${xlo}_DLL"
1896 return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
1899 # Generates Code Blocks workspace.
1900 proc OS:cworkspace { theSolName theModules theOutDir } {
1902 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
1903 set aFile [open $aWsFilePath "w"]
1905 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
1906 puts $aFile "<CodeBlocks_workspace_file>"
1907 puts $aFile "\t<Workspace title=\"${theSolName}\">"
1909 # collect list of projects to be created
1910 foreach aModule $theModules {
1912 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1913 set aDependencies [LibToLink $aToolKit]
1914 if { [llength $aDependencies] == 0 } {
1915 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
1917 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
1918 foreach aDepTk $aDependencies {
1919 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1921 puts $aFile "\t\t</Project>"
1925 # executables, assume one project per cxx file...
1926 foreach aUnit [OS:executable ${aModule}] {
1928 set src_files [_get_used_files $aUnit false]
1930 foreach s $src_files {
1931 regexp {source ([^\s]+)} $s dummy name
1932 lappend aSrcFiles $name
1934 foreach aSrcFile $aSrcFiles {
1935 set aFileExtension [file extension $aSrcFile]
1936 if { $aFileExtension == ".cxx" } {
1937 set aPrjName [file rootname $aSrcFile]
1938 set aDependencies [list]
1939 if {[file isdirectory $path/src/$aUnitLoc]} {
1940 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
1942 set anActiveState ""
1943 if { $isActiveSet == 0 } {
1944 set anActiveState " active=\"1\""
1947 if { [llength $aDependencies] == 0 } {
1948 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
1950 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
1951 foreach aDepTk $aDependencies {
1952 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1954 puts $aFile "\t\t</Project>"
1961 puts $aFile "\t</Workspace>"
1962 puts $aFile "</CodeBlocks_workspace_file>"
1968 # Generate Code::Blocks project file for Executable
1969 proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
1971 set aWokArch "$::env(ARCH)"
1974 foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
1975 # collect list of referred libraries to link with
1976 set aUsedLibs [list]
1977 set aFrameworks [list]
1978 set anIncPaths [list]
1979 set aTKDefines [list]
1980 set aTKSrcFiles [list]
1981 set aProjName [file rootname [file tail $aSrcFile]]
1983 osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
1985 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
1986 foreach tkx $aDepToolkits {
1987 if {[_get_type $tkx] == "t"} {
1988 lappend aUsedLibs "${tkx}"
1990 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
1991 lappend aUsedLibs "${tkx}"
1995 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
1996 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
1997 set isExecutable "false"
1999 set isExecutable "true"
2002 if { ![info exists written([file tail $aSrcFile])] } {
2003 set written([file tail $aSrcFile]) 1
2004 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2006 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2009 # macros for correct DLL exports
2010 if { $thePlatform == "wnt" } {
2011 lappend aTKDefines "__${theToolKit}_DLL"
2014 # common include paths
2015 lappend anIncPaths "../../../inc"
2017 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2023 # This function intended to generate Code::Blocks project file
2024 # @param theCmpl - the compiler (gcc or msvc)
2025 # @param theOutDir - output directory to place project file
2026 # @param theProjName - project name
2027 # @param theSrcFiles - list of source files
2028 # @param theLibsList - dependencies (libraries list)
2029 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2030 # @param theIncPaths - header search paths
2031 # @param theDefines - compiler macro definitions
2032 # @param theIsExe - flag to indicate executable / library target
2033 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2034 set aWokStation $thePlatform
2035 set aWokArch "$::env(ARCH)"
2038 set aCmplFlags [list]
2039 set aCmplFlagsRelease [list]
2040 set aCmplFlagsDebug [list]
2041 set toPassArgsByFile 0
2042 set aLibPrefix "lib"
2043 if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
2044 set toPassArgsByFile 1
2046 if { "$theCmpl" == "msvc" } {
2047 set aCmplCbp "msvc8"
2051 if { "$theCmpl" == "msvc" } {
2052 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2053 set aCmplFlagsRelease "-MD -O2"
2054 set aCmplFlagsDebug "-MDd -Od -Zi"
2055 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2056 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2057 } elseif { "$theCmpl" == "gcc" } {
2058 if { "$aWokStation" != "qnx" } {
2059 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2061 set aCmplFlagsRelease "-O2"
2062 set aCmplFlagsDebug "-O0 -g"
2063 if { "$aWokStation" == "wnt" } {
2064 lappend aCmplFlags "-std=gnu++0x"
2065 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2067 lappend aCmplFlags "-std=c++0x"
2068 lappend aCmplFlags "-fPIC"
2069 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2071 lappend aCmplFlags "-Wall"
2072 lappend aCmplFlags "-fexceptions"
2074 lappend aCmplFlagsRelease "-DNDEBUG"
2075 lappend aCmplFlagsRelease "-DNo_Exception"
2076 lappend aCmplFlagsDebug "-D_DEBUG"
2077 if { "$aWokStation" == "qnx" } {
2078 lappend aCmplFlags "-D_QNX_SOURCE"
2081 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2082 set aLnkFileName "${theProjName}_obj.link"
2083 set aLnkDebFileName "${theProjName}_objd.link"
2084 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2085 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2086 set aFile [open $aCbpFilePath "w"]
2087 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2088 puts $aFile "<CodeBlocks_project_file>"
2089 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2090 puts $aFile "\t<Project>"
2091 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2092 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2093 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2094 puts $aFile "\t\t<Build>"
2096 # Release target configuration
2097 puts $aFile "\t\t\t<Target title=\"Release\">"
2098 if { "$theIsExe" == "true" } {
2099 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2100 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2102 if { "$aWokStation" == "wnt" } {
2103 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\" />"
2105 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2107 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2109 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2110 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2111 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2112 if { "$aWokStation" == "wnt" } {
2113 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2115 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2118 # compiler options per TARGET (including defines)
2119 puts $aFile "\t\t\t\t<Compiler>"
2120 foreach aFlagIter $aCmplFlagsRelease {
2121 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2123 foreach aMacro $theDefines {
2124 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2126 puts $aFile "\t\t\t\t</Compiler>"
2128 puts $aFile "\t\t\t\t<Linker>"
2129 if { $toPassArgsByFile == 1 } {
2130 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2132 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2133 if { "$aWokStation" == "mac" } {
2134 if { [ lsearch $theLibsList X11 ] >= 0} {
2135 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2138 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2139 puts $aFile "\t\t\t\t</Linker>"
2141 puts $aFile "\t\t\t</Target>"
2143 # Debug target configuration
2144 puts $aFile "\t\t\t<Target title=\"Debug\">"
2145 if { "$theIsExe" == "true" } {
2146 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2147 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2149 if { "$aWokStation" == "wnt" } {
2150 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\" />"
2152 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2154 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2156 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2157 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2158 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2159 if { "$aWokStation" == "wnt" } {
2160 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2162 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2165 # compiler options per TARGET (including defines)
2166 puts $aFile "\t\t\t\t<Compiler>"
2167 foreach aFlagIter $aCmplFlagsDebug {
2168 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2170 foreach aMacro $theDefines {
2171 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2173 puts $aFile "\t\t\t\t</Compiler>"
2175 puts $aFile "\t\t\t\t<Linker>"
2176 if { $toPassArgsByFile == 1 } {
2177 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2179 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2180 if { "$aWokStation" == "mac" } {
2181 if { [ lsearch $theLibsList X11 ] >= 0} {
2182 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2185 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2186 puts $aFile "\t\t\t\t</Linker>"
2188 puts $aFile "\t\t\t</Target>"
2190 puts $aFile "\t\t</Build>"
2192 # COMMON compiler options
2193 puts $aFile "\t\t<Compiler>"
2194 foreach aFlagIter $aCmplFlags {
2195 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2197 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2198 foreach anIncPath $theIncPaths {
2199 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2201 puts $aFile "\t\t</Compiler>"
2203 # COMMON linker options
2204 puts $aFile "\t\t<Linker>"
2205 if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
2206 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2208 foreach aFrameworkName $theFrameworks {
2209 if { "$aFrameworkName" != "" } {
2210 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2213 foreach aLibName $theLibsList {
2214 if { "$aLibName" != "" } {
2215 if { "$theCmpl" == "msvc" } {
2216 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2218 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2222 puts $aFile "\t\t</Linker>"
2228 set isFirstSrcFile 1
2229 if { $toPassArgsByFile == 1 } {
2230 set aFileLnkObj [open $aLnkFilePath "w"]
2231 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2234 foreach aSrcFile $theSrcFiles {
2235 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2236 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2237 puts $aFile "\t\t\t<Option compile=\"1\" />"
2238 puts $aFile "\t\t\t<Option link=\"1\" />"
2239 puts $aFile "\t\t</Unit>"
2240 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2241 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2242 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2243 puts $aFile "\t\t</Unit>"
2244 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2245 # pass at list single source file to Code::Blocks as is
2246 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2247 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2248 puts $aFile "\t\t\t<Option link=\"0\" />"
2249 puts $aFile "\t\t</Unit>"
2251 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"] $aSrcFile]]
2252 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
2253 puts -nonewline $aFileLnkObj "$aFileObj "
2254 puts -nonewline $aFileLnkObjd "$aFileObjd "
2256 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2257 set isFirstSrcFile 0
2261 if { "$aWokStation" == "wnt" } {
2266 puts $aFile "\t</Project>"
2267 puts $aFile "</CodeBlocks_project_file>"
2270 return $aCbpFilePath
2273 # Define libraries to link using only EXTERNLIB file
2274 proc LibToLinkX {thePackage theDummyName} {
2275 set aToolKits [LibToLink $thePackage]
2279 # Function to generate Xcode workspace and project files
2280 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2282 puts stderr "Generating project files for Xcode"
2284 # Generate projects for toolkits and separate workspace for each module
2285 foreach aModule $theModules {
2286 OS:xcworkspace $aModule $aModule $theOutDir
2287 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2290 # Generate single workspace "OCCT" containing projects from all modules
2291 if { "$theAllSolution" != "" } {
2292 OS:xcworkspace $theAllSolution $theModules $theOutDir
2296 # Generates toolkits sections for Xcode workspace file.
2297 proc OS:xcworkspace:toolkits { theModule } {
2300 # Adding toolkits for module in workspace.
2301 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2302 append aBuff " <FileRef\n"
2303 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2304 append aBuff " </FileRef>\n"
2307 # Adding executables for module, assume one project per cxx file...
2308 foreach aUnit [OS:executable ${theModule}] {
2310 set src_files [_get_used_files $aUnit false]
2312 foreach s $src_files {
2313 regexp {source ([^\s]+)} $s dummy name
2314 lappend aSrcFiles $name
2316 foreach aSrcFile $aSrcFiles {
2317 set aFileExtension [file extension $aSrcFile]
2318 if { $aFileExtension == ".cxx" } {
2319 set aPrjName [file rootname $aSrcFile]
2320 append aBuff " <FileRef\n"
2321 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2322 append aBuff " </FileRef>\n"
2327 # Removing unnecessary newline character from the end.
2328 set aBuff [string replace $aBuff end end]
2332 # Generates workspace files for Xcode.
2333 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2334 # Creating workspace directory for Xcode.
2335 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2336 wokUtils:FILES:mkdir $aWorkspaceDir
2337 if { ! [file exists $aWorkspaceDir] } {
2338 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2342 # Creating workspace file.
2343 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2344 set aFile [open $aWsFilePath "w"]
2346 # Adding header and section for main Group.
2347 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2348 puts $aFile "<Workspace"
2349 puts $aFile " version = \"1.0\">"
2350 puts $aFile " <Group"
2351 puts $aFile " location = \"container:\""
2352 puts $aFile " name = \"${theWorkspaceName}\">"
2355 if { [llength "$theModules"] > 1 } {
2356 foreach aModule $theModules {
2357 puts $aFile " <Group"
2358 puts $aFile " location = \"container:\""
2359 puts $aFile " name = \"${aModule}\">"
2360 puts $aFile [OS:xcworkspace:toolkits $aModule]
2361 puts $aFile " </Group>"
2364 puts $aFile [OS:xcworkspace:toolkits $theModules]
2368 puts $aFile " </Group>"
2369 puts $aFile "</Workspace>"
2373 # Generates Xcode project files.
2374 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2375 upvar $theGuidsMap aGuidsMap
2378 if { "$theLibType" == "static" } {
2380 } elseif { "$thePlatform" == "ios" } {
2384 set aProjectFiles {}
2385 foreach aModule $theModules {
2386 foreach aToolKit [${aModule}:toolkits] {
2387 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2389 foreach anExecutable [OS:executable ${aModule}] {
2390 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2393 return $aProjectFiles
2396 # Generates dependencies section for Xcode project files.
2397 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
2398 upvar $theGuidsMap aGuidsMap
2399 upvar $theFileRefSection aFileRefSection
2400 upvar $theDepsGuids aDepsGuids
2401 upvar $theDepsRefGuids aDepsRefGuids
2403 set aBuildFileSection ""
2404 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2405 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2407 if { "$theTargetType" == "executable" } {
2408 set aFile [osutils:tk:files $theToolKit mac]
2409 set aProjName [file rootname [file tail $aFile]]
2410 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2414 if { $theIsStatic == 1 } {
2416 if { "$theTargetType" != "executable" } {
2417 return $aBuildFileSection
2421 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
2422 set aUsedLibs [concat $aUsedLibs $aLibs]
2423 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2424 foreach tkx $aUsedLibs {
2425 set aDepLib "${tkx}_Dep"
2426 set aDepLibRef "${tkx}_DepRef"
2428 if { ! [info exists aGuidsMap($aDepLib)] } {
2429 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2431 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2432 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2435 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2436 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2437 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2439 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2441 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2442 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2445 return $aBuildFileSection
2448 # Generates PBXBuildFile and PBXGroup sections for project file.
2449 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2450 upvar $theSrcFileRefSection aSrcFileRefSection
2451 upvar $theGroupSection aGroupSection
2452 upvar $thePackageGuids aPackagesGuids
2453 upvar $theSrcFileGuids aSrcFileGuids
2454 upvar $theGuidsMap aGuidsMap
2455 upvar $theIncPaths anIncPaths
2457 set listloc [osutils:tk:units $theToolKit]
2458 set resultloc [osutils:justunix $listloc]
2459 set aBuildFileSection ""
2460 set aPackages [lsort -nocase $resultloc]
2461 if { "$theTargetType" == "executable" } {
2462 set aPackages [list "$theToolKit"]
2465 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2466 foreach fxlo $aPackages {
2468 set aPackage "${xlo}_Package"
2469 set aSrcFileRefGuids ""
2470 if { ! [info exists aGuidsMap($aPackage)] } {
2471 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2474 set aSrcFiles [osutils:tk:files $xlo mac]
2475 foreach aSrcFile [lsort $aSrcFiles] {
2476 set aFileExt "sourcecode.cpp.cpp"
2478 if { [file extension $aSrcFile] == ".c" } {
2479 set aFileExt "sourcecode.c.c"
2480 } elseif { [file extension $aSrcFile] == ".mm" } {
2481 set aFileExt "sourcecode.cpp.objcpp"
2484 if { ! [info exists aGuidsMap($aSrcFile)] } {
2485 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2487 set aSrcFileRef "${aSrcFile}_Ref"
2488 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2489 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2491 if { ! [info exists written([file tail $aSrcFile])] } {
2492 set written([file tail $aSrcFile]) 1
2493 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2494 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"
2495 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2496 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2498 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2502 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2503 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2504 append aGroupSection "\t\t\tchildren = (\n"
2505 append aGroupSection $aSrcFileRefGuids
2506 append aGroupSection "\t\t\t);\n"
2507 append aGroupSection "\t\t\tname = $xlo;\n"
2508 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2509 append aGroupSection "\t\t\};\n"
2511 # Storing packages IDs for adding them later as a child of toolkit
2512 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2515 # Removing unnecessary newline character from the end.
2516 set aPackagesGuids [string replace $aPackagesGuids end end]
2518 return $aBuildFileSection
2521 # Creates folders structure and all necessary files for Xcode project.
2522 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2523 set aPBXBuildPhase "Headers"
2524 set aRunOnlyForDeployment "0"
2525 set aProductType "library.dynamic"
2526 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2527 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2528 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2529 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2531 if { "$theTargetType" == "executable" } {
2532 set aPBXBuildPhase "CopyFiles"
2533 set aRunOnlyForDeployment "1"
2534 set aProductType "tool"
2535 set anExecExtension ""
2537 set aWrapperExtension ""
2538 } elseif { $theIsStatic == 1 } {
2539 set aProductType "library.static"
2540 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2541 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2544 set aUsername [exec whoami]
2546 # Creation of folders for Xcode projectP.
2547 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2548 wokUtils:FILES:mkdir $aToolkitDir
2549 if { ! [file exists $aToolkitDir] } {
2550 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2554 set aUserDataDir "${aToolkitDir}/xcuserdata"
2555 wokUtils:FILES:mkdir $aUserDataDir
2556 if { ! [file exists $aUserDataDir] } {
2557 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2561 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2562 wokUtils:FILES:mkdir $aUserDataDir
2563 if { ! [file exists $aUserDataDir] } {
2564 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2568 set aSchemesDir "${aUserDataDir}/xcschemes"
2569 wokUtils:FILES:mkdir $aSchemesDir
2570 if { ! [file exists $aSchemesDir] } {
2571 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2574 # End of folders creation.
2576 # Generating GUID for tookit.
2577 upvar $theGuidsMap aGuidsMap
2578 if { ! [info exists aGuidsMap($theToolKit)] } {
2579 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2582 # Creating xcscheme file for toolkit from template.
2583 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2584 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2585 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2586 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2587 puts $aXcschemeFile $aXcschemeTmpl
2588 close $aXcschemeFile
2590 # Creating xcschememanagement.plist file for toolkit from template.
2591 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2592 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2593 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2594 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2595 puts $aPlistFile $aPlistTmpl
2598 # Creating project.pbxproj file for toolkit.
2599 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2600 puts $aPbxprojFile "// !\$*UTF8*\$!"
2601 puts $aPbxprojFile "\{"
2602 puts $aPbxprojFile "\tarchiveVersion = 1;"
2603 puts $aPbxprojFile "\tclasses = \{"
2604 puts $aPbxprojFile "\t\};"
2605 puts $aPbxprojFile "\tobjectVersion = 46;"
2606 puts $aPbxprojFile "\tobjects = \{\n"
2608 # Begin PBXBuildFile section
2609 set aPackagesGuids ""
2610 set aGroupSection ""
2611 set aSrcFileRefSection ""
2612 set aSrcFileGuids ""
2613 set aDepsFileRefSection ""
2615 set aDepsRefGuids ""
2616 set anIncPaths [list "../../../inc"]
2619 if { [info exists ::env(CSF_OPT_INC)] } {
2620 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2621 foreach anIncCfgPath $anIncCfg {
2622 lappend anIncPaths $anIncCfgPath
2625 if { [info exists ::env(CSF_OPT_LIB64)] } {
2626 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2627 foreach anLibCfgPath $anLibCfg {
2628 lappend anLibPaths $anLibCfgPath
2632 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2633 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2634 # End PBXBuildFile section
2636 # Begin PBXFileReference section
2637 set aToolkitLib "lib${theToolKit}.dylib"
2638 set aPath "$aToolkitLib"
2639 if { "$theTargetType" == "executable" } {
2640 set aPath "$theToolKit"
2641 } elseif { $theIsStatic == 1 } {
2642 set aToolkitLib "lib${theToolKit}.a"
2645 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2646 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2649 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2650 puts $aPbxprojFile $aSrcFileRefSection
2651 puts $aPbxprojFile $aDepsFileRefSection
2652 # End PBXFileReference section
2655 # Begin PBXFrameworksBuildPhase section
2656 set aTkFrameworks "${theToolKit}_Frameworks"
2657 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2658 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2661 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2662 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2663 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2664 puts $aPbxprojFile "\t\t\tfiles = ("
2665 puts $aPbxprojFile $aDepsGuids
2666 puts $aPbxprojFile "\t\t\t);"
2667 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2668 puts $aPbxprojFile "\t\t\};\n"
2669 # End PBXFrameworksBuildPhase section
2671 # Begin PBXGroup section
2672 set aTkPBXGroup "${theToolKit}_PBXGroup"
2673 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2674 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2677 set aTkSrcGroup "${theToolKit}_SrcGroup"
2678 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2679 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2682 puts $aPbxprojFile $aGroupSection
2683 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2684 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2685 puts $aPbxprojFile "\t\t\tchildren = ("
2686 puts $aPbxprojFile $aDepsRefGuids
2687 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2688 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2689 puts $aPbxprojFile "\t\t\t);"
2690 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2691 puts $aPbxprojFile "\t\t\};"
2692 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2693 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2694 puts $aPbxprojFile "\t\t\tchildren = ("
2695 puts $aPbxprojFile $aPackagesGuids
2696 puts $aPbxprojFile "\t\t\t);"
2697 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2698 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2699 puts $aPbxprojFile "\t\t\};\n"
2700 # End PBXGroup section
2702 # Begin PBXHeadersBuildPhase section
2703 set aTkHeaders "${theToolKit}_Headers"
2704 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2705 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2708 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2709 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2710 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2711 puts $aPbxprojFile "\t\t\tfiles = ("
2712 puts $aPbxprojFile "\t\t\t);"
2713 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2714 puts $aPbxprojFile "\t\t\};\n"
2715 # End PBXHeadersBuildPhase section
2717 # Begin PBXNativeTarget section
2718 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2719 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2720 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2723 set aTkSources "${theToolKit}_Sources"
2724 if { ! [info exists aGuidsMap($aTkSources)] } {
2725 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2728 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2729 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2730 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2731 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2732 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2733 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2734 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2735 puts $aPbxprojFile "\t\t\t);"
2736 puts $aPbxprojFile "\t\t\tbuildRules = ("
2737 puts $aPbxprojFile "\t\t\t);"
2738 puts $aPbxprojFile "\t\t\tdependencies = ("
2739 puts $aPbxprojFile "\t\t\t);"
2740 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
2741 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
2742 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
2743 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
2744 puts $aPbxprojFile "\t\t\};\n"
2745 # End PBXNativeTarget section
2747 # Begin PBXProject section
2748 set aTkProjectObj "${theToolKit}_ProjectObj"
2749 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
2750 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
2753 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
2754 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
2755 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
2758 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
2759 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
2760 puts $aPbxprojFile "\t\t\tattributes = \{"
2761 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
2762 puts $aPbxprojFile "\t\t\t\};"
2763 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
2764 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
2765 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
2766 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
2767 puts $aPbxprojFile "\t\t\tknownRegions = ("
2768 puts $aPbxprojFile "\t\t\t\ten,"
2769 puts $aPbxprojFile "\t\t\t);"
2770 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
2771 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
2772 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
2773 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
2774 puts $aPbxprojFile "\t\t\ttargets = ("
2775 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
2776 puts $aPbxprojFile "\t\t\t);"
2777 puts $aPbxprojFile "\t\t\};\n"
2778 # End PBXProject section
2780 # Begin PBXSourcesBuildPhase section
2781 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
2782 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
2783 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2784 puts $aPbxprojFile "\t\t\tfiles = ("
2785 puts $aPbxprojFile $aSrcFileGuids
2786 puts $aPbxprojFile "\t\t\t);"
2787 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2788 puts $aPbxprojFile "\t\t\};\n"
2789 # End PBXSourcesBuildPhase section
2791 # Begin XCBuildConfiguration section
2792 set aTkDebugProject "${theToolKit}_DebugProject"
2793 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
2794 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
2797 set aTkReleaseProject "${theToolKit}_ReleaseProject"
2798 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
2799 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
2802 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
2803 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
2804 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
2807 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
2808 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
2809 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
2813 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
2814 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2815 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2817 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
2818 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2819 if { "$thePlatform" == "ios" } {
2820 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2821 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2822 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2823 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2824 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2826 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2827 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2828 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
2829 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2830 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
2831 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2832 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
2833 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2834 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
2835 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
2836 puts $aPbxprojFile "\t\t\t\t);"
2837 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
2838 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2839 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2840 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2841 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2842 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2843 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
2844 if { "$thePlatform" == "ios" } {
2845 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
2846 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2848 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
2850 puts $aPbxprojFile "\t\t\t\};"
2852 puts $aPbxprojFile "\t\t\tname = Debug;"
2853 puts $aPbxprojFile "\t\t\};"
2856 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
2857 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2858 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2860 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
2861 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2862 if { "$thePlatform" == "ios" } {
2863 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2864 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2865 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2866 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2867 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2869 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2870 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2871 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
2872 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2873 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2874 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
2875 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
2876 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2877 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2878 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2879 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2880 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2881 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
2882 if { "$thePlatform" == "ios" } {
2883 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
2884 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2886 puts $aPbxprojFile "\t\t\t\};"
2887 puts $aPbxprojFile "\t\t\tname = Release;"
2888 puts $aPbxprojFile "\t\t\};"
2889 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
2890 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2891 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2892 puts $aPbxprojFile "${anExecExtension}"
2893 puts $aPbxprojFile "${anExecPrefix}"
2894 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2895 foreach aMacro $aTKDefines {
2896 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2898 puts $aPbxprojFile "\t\t\t\t);"
2900 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2901 foreach anIncPath $anIncPaths {
2902 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2904 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2905 puts $aPbxprojFile "\t\t\t\t);"
2907 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2908 foreach anLibPath $anLibPaths {
2909 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2911 puts $aPbxprojFile "\t\t\t\t);"
2913 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2914 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2915 puts $aPbxprojFile "\t\t\t\t);"
2916 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2917 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2918 puts $aPbxprojFile "\t\t\t\t);"
2919 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2920 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
2921 foreach anIncPath $anIncPaths {
2922 append anUserHeaderSearchPath " ${anIncPath}"
2924 append anUserHeaderSearchPath "\";"
2925 puts $aPbxprojFile $anUserHeaderSearchPath
2926 puts $aPbxprojFile "${aWrapperExtension}"
2927 puts $aPbxprojFile "\t\t\t\};"
2928 puts $aPbxprojFile "\t\t\tname = Debug;"
2929 puts $aPbxprojFile "\t\t\};"
2930 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
2931 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2932 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2933 puts $aPbxprojFile "${anExecExtension}"
2934 puts $aPbxprojFile "${anExecPrefix}"
2935 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2936 foreach aMacro $aTKDefines {
2937 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2939 puts $aPbxprojFile "\t\t\t\t);"
2940 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2941 foreach anIncPath $anIncPaths {
2942 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2944 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2945 puts $aPbxprojFile "\t\t\t\t);"
2947 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2948 foreach anLibPath $anLibPaths {
2949 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2951 puts $aPbxprojFile "\t\t\t\t);"
2953 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2954 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2955 puts $aPbxprojFile "\t\t\t\t);"
2956 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2957 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2958 puts $aPbxprojFile "\t\t\t\t);"
2959 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2960 puts $aPbxprojFile $anUserHeaderSearchPath
2961 puts $aPbxprojFile "${aWrapperExtension}"
2962 puts $aPbxprojFile "\t\t\t\};"
2963 puts $aPbxprojFile "\t\t\tname = Release;"
2964 puts $aPbxprojFile "\t\t\};\n"
2965 # End XCBuildConfiguration section
2967 # Begin XCConfigurationList section
2968 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
2969 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
2970 puts $aPbxprojFile "\t\tbuildConfigurations = ("
2971 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
2972 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
2973 puts $aPbxprojFile "\t\t\t);"
2974 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
2975 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
2976 puts $aPbxprojFile "\t\t\};"
2977 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
2978 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
2979 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
2980 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
2981 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
2982 puts $aPbxprojFile "\t\t\t);"
2983 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
2984 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
2985 puts $aPbxprojFile "\t\t\};\n"
2986 # End XCConfigurationList section
2988 puts $aPbxprojFile "\t\};"
2989 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
2990 puts $aPbxprojFile "\}"
2995 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
2996 set aUsername [exec whoami]
2998 # Creating folders for Xcode project file.
2999 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3000 wokUtils:FILES:mkdir $anExecutableDir
3001 if { ! [file exists $anExecutableDir] } {
3002 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3006 set aUserDataDir "${anExecutableDir}/xcuserdata"
3007 wokUtils:FILES:mkdir $aUserDataDir
3008 if { ! [file exists $aUserDataDir] } {
3009 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3013 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3014 wokUtils:FILES:mkdir $aUserDataDir
3015 if { ! [file exists $aUserDataDir] } {
3016 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3020 set aSchemesDir "${aUserDataDir}/xcschemes"
3021 wokUtils:FILES:mkdir $aSchemesDir
3022 if { ! [file exists $aSchemesDir] } {
3023 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3026 # End folders creation.
3028 # Generating GUID for tookit.
3029 upvar $theGuidsMap aGuidsMap
3030 if { ! [info exists aGuidsMap($theExecutable)] } {
3031 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3034 # Creating xcscheme file for toolkit from template.
3035 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3036 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3037 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3038 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3039 puts $aXcschemeFile $aXcschemeTmpl
3040 close $aXcschemeFile
3042 # Creating xcschememanagement.plist file for toolkit from template.
3043 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3044 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3045 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3046 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3047 puts $aPlistFile $aPlistTmpl