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
20 # "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "xcd"
23 # genproj -path=D:/occt -target=vc10
24 # genproj -target=xcd -ios -static
25 # =======================================================================
27 source [file join [file dirname [info script]] genconfdeps.tcl]
32 if { [info exists ::env(CASROOT)] } {
33 set THE_CASROOT "$::env(CASROOT)"
35 switch -exact -- "$tcl_platform(platform)" {
36 "windows" {set targetStation "wnt"}
37 "unix" {set targetStation "lin"}
40 switch -exact -- "$tcl_platform(os)" {
41 "Darwin" {set targetStation "mac"}
44 proc _get_options { platform type branch } {
46 if {[file exists "$::THE_CASROOT/adm/CMPLRS"]} {
47 set fd [open "$::THE_CASROOT/adm/CMPLRS" rb]
48 set opts [split [read $fd] "\n"]
51 if {[regexp "^${platform} ${type} ${branch} (.+)$" $line dummy res]} {
52 while {[regexp {\(([^\(\)]+) ([^\(\)]+) ([^\(\)]+)\)(.+)} $res dummy p t b oldres]} {
53 set res "[_get_options $p $t $b] $oldres"
61 proc _get_type { name } {
63 if {[file exists "$::path/adm/UDLIST"]} {
64 set fd [open "$::path/adm/UDLIST" rb]
65 set UDLIST [concat $UDLIST [split [read $fd] "\n"]]
68 if { "$::path/adm/UDLIST" != "$::THE_CASROOT/adm/UDLIST" && [file exists "$::THE_CASROOT/adm/UDLIST"] } {
69 set fd [open "$::THE_CASROOT/adm/UDLIST" rb]
70 set UDLIST [concat $UDLIST [split [read $fd] "\n"]]
74 foreach uitem $UDLIST {
75 set line [split $uitem]
76 if {[lindex $line 1] == "$name"} {
77 return [lindex $line 0]
83 proc _get_used_files { pk {inc true} {src true} } {
85 set type [_get_type $pk]
87 set pk_path "$path/src/$pk"
88 set FILES_path "$path/src/$pk/FILES"
90 if {[file exists $FILES_path]} {
91 set fd [open $FILES_path rb]
92 set FILES [split [read $fd] "\n"]
95 set FILES [lsearch -inline -all -not -exact $FILES ""]
100 if {$inc && ([regexp {([^:\s]*\.[hgl]xx)$} $line dummy name] || [regexp {([^:\s]*\.h)$} $line dummy name]) && [file exists $pk_path/$name]} {
101 lappend lret "pubinclude $name $pk_path/$name"
104 if {[regexp {:} $line]} {
105 regexp {[^:]*:+([^\s]*)} $line dummy line
107 regexp {([^\s]*)} $line dummy line
108 if {$src && [file exists $pk_path/$line]} {
109 lappend lret "source $line $pk_path/$line"
115 # return location of the path within src directory
116 proc osutils:findSrcSubPath {theSubPath} {
117 if {[file exists "$::path/src/$theSubPath"]} {
118 return "$::path/src/$theSubPath"
120 return "$::THE_CASROOT/src/$theSubPath"
123 # Wrapper-function to generate VS project files
124 proc genproj { args } {
125 global path THE_CASROOT targetStation
126 set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "xcd" }
129 # Setting default IDE.
132 switch -exact -- "$targetStation" {
133 "wnt" {set anTarget "$::env(VCVER)"}
134 "lin" {set anTarget "cbp"}
135 "mac" {set anTarget "xcd"}
138 set isTargetDefault true
139 if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
140 regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
141 set anArgs [removeAllOccurrencesOf -target=* $anArgs]
142 set isTargetDefault false
145 if { [set anIndex [lsearch -nocase $anArgs -path=*]] != -1} {
146 regsub -nocase "\\-path=" [lindex $anArgs $anIndex] "" path
147 set anArgs [removeAllOccurrencesOf -path=* $anArgs]
148 puts "Starting work with \"$path\""
151 if { [llength $anArgs] == 0 && $isTargetDefault == true } {
152 puts "the default \'$anTarget\' target has been applied"
155 set isHelpRequire false
156 if { [lsearch -nocase $anArgs -h] != -1} {
157 set anArgs [removeAllOccurrencesOf -h $anArgs]
158 set isHelpRequire true
162 set isHelpRequire true
165 set aLibType "dynamic"
166 if { [lsearch -nocase $anArgs "-static"] != -1} {
167 set anArgs [removeAllOccurrencesOf "-static" $anArgs]
168 set aLibType "static"
169 puts "static build has been selected"
170 } elseif { [lsearch -nocase $anArgs "-dynamic"] != -1} {
171 set anArgs [removeAllOccurrencesOf "-dynamic" $anArgs]
172 set aLibType "dynamic"
173 puts "dynamic build has been selected"
177 if { [lsearch -nocase $anArgs "-ios"] != -1} {
178 set anArgs [removeAllOccurrencesOf "-ios" $anArgs]
182 if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
183 puts "the \'$anTarget\' is wrong TARGET"
184 set isHelpRequire true
187 if {[llength $anArgs] > 0} {
188 set isHelpRequire true
190 foreach anArg $anArgs {
191 puts "genproj: unrecognized option \'$anArg\'"
195 if { $isHelpRequire == true } {
196 puts "usage: genproj \[ -target=<TARGET> \] \[ -path=<PATH> \]
202 vc8 - Visual Studio 2005
203 vc9 - Visual Studio 2008
204 vc10 - Visual Studio 2010
205 vc11 - Visual Studio 2012
206 vc12 - Visual Studio 2013
207 vc14 - Visual Studio 2015
213 if {!$isTargetDefault} {
214 puts "the \'$anTarget\' target has been applied"
217 set anAdmPath "$path/adm"
219 OS:MKPRC "$anAdmPath" "$anTarget" "$aLibType" "$aPlatform" "$aCmpl"
221 genprojbat "$anTarget"
224 proc genprojbat {theIDE} {
225 set aTargetPlatform "lin"
226 if { "$::tcl_platform(platform)" == "windows" } {
227 set aTargetPlatform "wnt"
230 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
231 set aTargetPlatform wnt
232 } elseif {"$theIDE" == "xcd"} {
233 set aTargetPlatform mac
236 set aTargetPlatformExt sh
237 if { "$aTargetPlatform" == "wnt" } {
238 set aTargetPlatformExt bat
241 if {"$theIDE" != "cmake"} {
242 set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
243 set anEnvTmpl [read $anEnvTmplFile]
247 if { [file normalize "$::path"] != [file normalize "$::THE_CASROOT"] } {
248 set aCasRoot [relativePath "$::path" "$::THE_CASROOT"]
251 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
253 set anEnvFile [open "$::path/env.${aTargetPlatformExt}" "w"]
254 puts $anEnvFile $anEnvTmpl
257 file copy -force -- "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
260 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
261 file copy -force -- "$::THE_CASROOT/adm/templates/msvc.bat" "$::path/msvc.bat"
263 switch -exact -- "$theIDE" {
265 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.sh" "$::path/codeblocks.sh"
266 file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.bat" "$::path/codeblocks.bat"
268 "xcd" { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh" "$::path/xcode.sh" }
273 ###### MSVC #############################################################33
274 proc removeAllOccurrencesOf { theObject theList } {
275 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
276 foreach anIndex $aSortIndices {
277 set theList [lreplace $theList $anIndex $anIndex]
282 set aTKNullKey "TKNull"
283 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
285 # Entry function to generate project files and solutions for IDE
286 # @param theOutDir Root directory for project files
287 # @param theIDE IDE code name (vc10 for Visual Studio 2010, cbp for Code::Blocks, xcd for XCode)
288 # @param theLibType Library type - dynamic or static
289 # @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
290 # @param theCmpl Compiler option (msvc or gcc)
291 proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
292 global path targetStation
293 set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "cbp" "xcd" }
295 if { [lsearch $aSupportedIDE $theIDE] < 0 } {
296 puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
300 set anOutRoot $theOutDir
301 if { $anOutRoot == "" } {
302 error "Error : \"theOutDir\" is not initialized"
305 # Create output directory
306 set aWokStation "$targetStation"
308 if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12 vc14} $theIDE] != -1 } {
309 set aWokStation "msvc"
312 set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
314 # read map of already generated GUIDs
315 set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
316 if [file exists "$aGuidsFilePath"] {
317 set aFileIn [open "$aGuidsFilePath" r]
318 set aFileDataRaw [read $aFileIn]
320 set aFileData [split $aFileDataRaw "\n"]
321 foreach aLine $aFileData {
322 set aLineSplt [split $aLine "="]
323 if { [llength $aLineSplt] == 2 } {
324 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
329 # make list of modules and platforms
330 set aModules [OS:init]
331 if { "$thePlatform" == "ios" } {
332 set goaway [list Draw]
333 set aModules [osutils:juststation $goaway $aModules]
336 # generate one solution for all projects if complete OS or VAS is processed
337 set anAllSolution "OCCT"
339 wokUtils:FILES:mkdir $anOutDir
340 if { ![file exists $anOutDir] } {
341 puts stderr "Error: Could not create output directory \"$anOutDir\""
345 # create the out dir if it does not exist
346 if (![file isdirectory $path/inc]) {
347 puts "$path/inc folder does not exists and will be created"
348 wokUtils:FILES:mkdir $path/inc
351 # collect all required header files
352 puts "Collecting required header files into $path/inc ..."
353 osutils:collectinc $aModules $path/inc $targetStation
355 # Generating project files for the selected IDE
356 switch -exact -- "$theIDE" {
363 "vc14" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE }
364 "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution $theCmpl }
366 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
367 OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
371 # Store generated GUIDs map
372 set anOutFile [open "$aGuidsFilePath" "w"]
373 fconfigure $anOutFile -translation lf
374 foreach aKey [array names ::THE_GUIDS_LIST] {
375 set aValue $::THE_GUIDS_LIST($aKey)
376 puts $anOutFile "${aKey}=${aValue}"
381 # Function to generate Visual Studio solution and project files
382 proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
384 puts stderr "Generating VS project files for $theVcVer"
386 # generate projects for toolkits and separate solution for each module
387 foreach aModule $theModules {
388 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
389 OS:vcproj $theVcVer $aModule $theOutDir ::THE_GUIDS_LIST
392 # generate single solution "OCCT" containing projects from all modules
393 if { "$theAllSolution" != "" } {
394 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
397 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
400 proc OS:init {{os {}}} {
404 set os $::tcl_platform(os)
407 if [file exists "$::path/src/VAS/Products.tcl"] {
408 source "$::path/src/VAS/Products.tcl"
409 foreach aModuleIter [VAS:Products] {
410 set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
411 if [file exists $aFileTcl] {
413 lappend aModules $aModuleIter
415 puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
421 # Load list of OCCT modules and their definitions
422 source "$::path/src/OS/Modules.tcl"
423 foreach aModuleIter [OS:Modules] {
424 set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
425 if [file exists $aFileTcl] {
427 lappend aModules $aModuleIter
429 puts stderr "Definition file for module $aModuleIter is not found in unit OS"
436 # topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
437 proc wokUtils:EASY:tsort { listofpairs } {
438 foreach x $listofpairs {
441 if ![info exists pcnt($e1)] {
444 if ![ info exists pcnt($e2)] {
449 if ![info exists scnt($e1)] {
455 if [info exists slist($e1)] {
463 foreach node [array names pcnt] {
465 if { $pcnt($node) == 0 } {
469 if ![info exists scnt($node)] {
474 for {set front 1} { $front <= $back } { incr front } {
475 lappend res [set node $q($front)]
476 for {set i 1} {$i <= $scnt($node) } { incr i } {
478 set j [expr {$i - 1}]
479 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
480 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
482 set q($back) [lindex $ll $j]
486 if { $back != $nodecnt } {
487 puts stderr "input contains a cycle"
494 proc wokUtils:LIST:Purge { l } {
497 if ![info exist tab($e)] {
505 # Read file pointed to by path
507 # 2. trim = 1 plusieurs blancs => 1 seul blanc
508 # 3. purge= not yet implemented.
509 # 4. emptl= dont process blank lines
510 proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
511 if ![ catch { set id [ open $path r ] } ] {
513 while {[gets $id line] >= 0 } {
515 regsub -all {[ ]+} $line " " line
518 if { [string length ${line}] != 0 } {
536 # retorn the list of executables in module.
537 proc OS:executable { module } {
539 foreach XXX [${module}:ressources] {
540 if { "[lindex $XXX 1]" == "x" } {
541 lappend lret [lindex $XXX 2]
547 # Topological sort of toolkits in tklm
548 proc osutils:tk:sort { tklm } {
550 foreach tkloc $tklm {
551 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
553 if { [lsearch $tklm $tkx] != -1 } {
554 lappend tkby2 [list $tkx $tkloc]
556 lappend tkby2 [list $tkloc {}]
561 foreach e [wokUtils:EASY:tsort $tkby2] {
569 # close dependencies of ltk. (full wok pathes of toolkits)
570 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
571 # (locate not performed.)
572 proc osutils:tk:close { ltk } {
576 set ids [LibToLink $dir]
577 # puts "osutils:tk:close($ltk) ids='$ids'"
578 set eated [osutils:tk:eatpk $ids]
579 set result [concat $result $eated]
580 set ids [LibToLink $dir]
581 set result [concat $result $ids]
583 foreach file $eated {
584 set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
585 if { [osutils:tk:eatpk $kds] != {} } {
586 lappend recurse $file
590 if { $recurse != {} } {
591 set result [concat $result [osutils:tk:close $recurse]]
596 proc osutils:tk:eatpk { EXTERNLIB } {
597 set l [wokUtils:FILES:FileToList $EXTERNLIB]
600 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
606 # Define libraries to link using only EXTERNLIB file
608 proc LibToLink {theTKit} {
610 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
611 set type [_get_type $theTKit]
612 if {$type != "t" && $type != "x"} {
616 set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
617 foreach anExtLib $anExtLibList {
618 set aFullPath [LocateRecur $anExtLib]
619 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
620 lappend aToolkits $anExtLib
625 # Search unit recursively
627 proc LocateRecur {theName} {
628 set theNamePath [osutils:findSrcSubPath "$theName"]
629 if {[file isdirectory $theNamePath]} {
635 proc OS:genGUID { {theIDE "vc"} } {
636 if { "$theIDE" == "vc" } {
637 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
638 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
639 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
640 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
641 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
642 return "{$p1-$p2-$p3-$p4-$p5}"
644 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
645 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
646 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
647 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
648 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
649 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
650 return "$p1$p2$p3$p4$p5$p6"
654 # collect all include file that required for theModules in theOutDir
655 proc osutils:collectinc {theModules theIncPath theTargetStation} {
658 set aCasRoot [file normalize $path]
659 set anIncPath [file normalize $theIncPath]
661 if {![file isdirectory $aCasRoot]} {
662 puts "OCCT directory is not defined correctly: $aCasRoot"
666 set anUsedToolKits {}
667 foreach aModule $theModules {
668 foreach aToolKit [${aModule}:toolkits] {
669 lappend anUsedToolKits $aToolKit
671 foreach aDependency [LibToLink $aToolKit] {
672 lappend anUsedToolKits $aDependency
675 foreach anExecutable [OS:executable ${aModule}] {
676 lappend anUsedToolKits $anExecutable
678 foreach aDependency [LibToLink $anExecutable] {
679 lappend anUsedToolKits $aDependency
683 lsort -unique $anUsedToolKits
686 foreach anUsedToolKit $anUsedToolKits {
687 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
689 lsort -unique $anUnits
691 if { [info exists ::env(SHORTCUT_HEADERS)] &&
692 $::env(SHORTCUT_HEADERS) == "true" } {
693 # template preparation
694 if { ![file exists $::THE_CASROOT/adm/templates/header.in] } {
695 puts "template file does not exist: $::THE_CASROOT/adm/templates/header.in"
698 set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
700 # relative anIncPath in connection with aCasRoot/src
701 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
703 # create and copy short-cut header files
704 foreach anUnit $anUnits {
705 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
706 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
707 set aHeaderFileName [file tail $aHeaderFile]
709 regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
711 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
712 set fp [open "$theIncPath/$aHeaderFileName" r]
713 set aHeaderContent [read $fp]
717 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
719 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
720 # remove eof from string
721 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
723 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
729 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
730 fconfigure $aShortCutHeaderFile -translation lf
731 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
732 close $aShortCutHeaderFile
737 foreach anUnit $anUnits {
738 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
739 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
740 set aHeaderFileName [file tail $aHeaderFile]
742 # copy file only if target does not exist or is older than original
743 set torig [file mtime $aHeaderFile]
744 if { ! [file isfile $anIncPath/$aHeaderFileName] } {
747 set tcopy [file mtime $anIncPath/$aHeaderFileName]
749 if { $tcopy < $torig } {
751 file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
752 } elseif { $tcopy != $torig } {
753 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
757 puts "Info: $nbcopied files updated"
761 # Generate header for VS solution file
762 proc osutils:vcsolution:header { vcversion } {
763 if { "$vcversion" == "vc7" } {
765 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
766 } elseif { "$vcversion" == "vc8" } {
768 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
769 "# Visual Studio 2005\n"
770 } elseif { "$vcversion" == "vc9" } {
772 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
773 "# Visual Studio 2008\n"
774 } elseif { "$vcversion" == "vc10" } {
776 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
777 "# Visual Studio 2010\n"
778 } elseif { "$vcversion" == "vc11" } {
780 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
781 "# Visual Studio 2012\n"
782 } elseif { "$vcversion" == "vc12" } {
784 "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
785 "# Visual Studio 2013\n"
786 } elseif { "$vcversion" == "vc14" } {
788 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
789 "# Visual Studio 14\n"
791 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
795 # Returns extension (without dot) for project files of given version of VC
797 proc osutils:vcproj:ext { vcversion } {
798 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
804 # Generate start of configuration section of VS solution file
806 proc osutils:vcsolution:config:begin { vcversion } {
807 if { "$vcversion" == "vc7" } {
810 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
811 "\t\tDebug = Debug\n" \
812 "\t\tRelease = Release\n" \
813 "\tEndGlobalSection\n" \
814 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
818 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
819 "\t\tDebug|Win32 = Debug|Win32\n" \
820 "\t\tRelease|Win32 = Release|Win32\n" \
821 "\t\tDebug|x64 = Debug|x64\n" \
822 "\t\tRelease|x64 = Release|x64\n" \
823 "\tEndGlobalSection\n" \
824 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
828 # Generate part of configuration section of VS solution file describing one project
830 proc osutils:vcsolution:config:project { vcversion guid } {
831 if { "$vcversion" == "vc7" } {
833 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
834 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
835 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
836 "\t\t$guid.Release.Build.0 = Release|Win32\n"
839 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
840 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
841 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
842 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
843 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
844 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
845 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
846 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
850 # Generate start of configuration section of VS solution file
852 proc osutils:vcsolution:config:end { vcversion } {
853 if { "$vcversion" == "vc7" } {
855 "\tEndGlobalSection\n" \
856 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
857 "\tEndGlobalSection\n" \
858 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
859 "\tEndGlobalSection\n"
862 "\tEndGlobalSection\n" \
863 "\tGlobalSection(SolutionProperties) = preSolution\n" \
864 "\t\tHideSolutionNode = FALSE\n" \
865 "\tEndGlobalSection\n"
869 # generate Visual Studio solution file
870 # if module is empty, generates one solution for all known modules
872 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
874 upvar $theGuidsMap aGuidsMap
876 # collect list of projects to be created
879 foreach aModule $theModules {
881 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
882 lappend aProjects $aToolKit
883 lappend aProjectsInModule($aModule) $aToolKit
884 lappend aDependencies [LibToLink $aToolKit]
886 # executables, assume one project per cxx file...
887 foreach aUnit [OS:executable ${aModule}] {
889 set src_files [_get_used_files $aUnit false]
891 foreach s $src_files {
892 regexp {source ([^\s]+)} $s dummy name
893 lappend aSrcFiles $name
895 foreach aSrcFile $aSrcFiles {
896 set aFileExtension [file extension $aSrcFile]
897 if { $aFileExtension == ".cxx" } {
898 set aPrjName [file rootname $aSrcFile]
899 lappend aProjects $aPrjName
900 lappend aProjectsInModule($aModule) $aPrjName
901 if {[file isdirectory $path/src/$aUnitLoc]} {
902 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
904 lappend aDependencies {}
911 # generate GUIDs for projects (unless already known)
912 foreach aProject $aProjects {
913 if { ! [info exists aGuidsMap($aProject)] } {
914 set aGuidsMap($aProject) [OS:genGUID]
918 # generate solution file
919 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
920 append aFileBuff [osutils:vcsolution:header $theVcVer]
922 # GUID identifying group projects in Visual Studio
923 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
925 # generate group projects -- one per module
926 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
927 foreach aModule $theModules {
928 if { ! [info exists aGuidsMap(_$aModule)] } {
929 set aGuidsMap(_$aModule) [OS:genGUID]
931 set aGuid $aGuidsMap(_$aModule)
932 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
936 # extension of project files
937 set aProjExt [osutils:vcproj:ext $theVcVer]
939 # GUID identifying C++ projects in Visual Studio
940 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
942 # generate normal projects
943 set aProjsNb [llength $aProjects]
944 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
945 set aProj [lindex $aProjects $aProjId]
946 set aGuid $aGuidsMap($aProj)
947 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
948 # write projects dependencies information (vc7 to vc9)
950 foreach aDepLib [lindex $aDependencies $aProjId] {
951 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
952 set depGUID $aGuidsMap($aDepLib)
953 append aDepGuids "\t\t$depGUID = $depGUID\n"
956 if { "$aDepGuids" != "" } {
957 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
958 append aFileBuff "$aDepGuids"
959 append aFileBuff "\tEndProjectSection\n"
961 append aFileBuff "EndProject\n"
964 # generate configuration section
965 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
966 foreach aProj $aProjects {
967 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
969 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
971 # write information of grouping of projects by module
972 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
973 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
974 foreach aModule $theModules {
975 if { ! [info exists aProjectsInModule($aModule)] } { continue }
976 foreach aProject $aProjectsInModule($aModule) {
977 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
980 append aFileBuff " EndGlobalSection\n"
983 # final word (footer)
984 append aFileBuff "EndGlobal"
987 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
988 fconfigure $aFile -translation crlf
989 puts $aFile $aFileBuff
991 return [file join $theOutDir ${theSolName}.sln]
993 # Generate Visual Studio projects for specified version
995 proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
996 upvar $theGuidsMap aGuidsMap
1000 foreach aModule $theModules {
1001 foreach aToolKit [${aModule}:toolkits] {
1002 lappend aProjectFiles [osutils:vcproj $theVcVer $theOutDir $aToolKit aGuidsMap]
1004 foreach anExecutable [OS:executable ${aModule}] {
1005 lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
1008 return $aProjectFiles
1010 # generate template name and load it for given version of Visual Studio and platform
1012 proc osutils:vcproj:readtemplate {theVcVer isexec} {
1014 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1018 set what "$theVcVer"
1019 set aVerExt [string range $theVcVer 2 end]
1020 set aVerExt "v${aVerExt}0"
1024 set anExt "${anExt}x"
1025 set what "$what executable"
1027 if { "$theVcVer" == "vc10" } {
1028 # SSE2 is enabled by default in vc11+, but not in vc10 for 32-bit target
1029 set aCmpl32 "\n <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>"
1031 set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
1032 regsub -all -- {__VCVER__} $aTmpl $theVcVer aTmpl
1033 regsub -all -- {__VCVEREXT__} $aTmpl $aVerExt aTmpl
1034 regsub -all -- {__VCMPL32__} $aTmpl $aCmpl32 aTmpl
1035 regsub -all -- {__VCMPL64__} $aTmpl $aCmpl64 aTmpl
1039 proc osutils:readtemplate {ext what} {
1040 set loc "$::THE_CASROOT/adm/templates/template.$ext"
1041 return [wokUtils:FILES:FileToString $loc]
1043 # Read a file in a string as is.
1045 proc wokUtils:FILES:FileToString { fin } {
1046 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1047 set strin [read $in [file size $fin]]
1054 # List extensions of compilable files in OCCT
1056 proc osutils:compilable { } {
1057 global targetStation
1058 set aWokStation "$targetStation"
1059 if { "$aWokStation" == "mac" } {
1060 return [list .c .cxx .cpp .mm]
1062 return [list .c .cxx .cpp]
1065 proc osutils:commonUsedTK { theToolKit } {
1066 set anUsedToolKits [list]
1067 set aDepToolkits [LibToLink $theToolKit]
1068 foreach tkx $aDepToolkits {
1069 if {[_get_type $tkx] == "t"} {
1070 lappend anUsedToolKits "${tkx}"
1073 return $anUsedToolKits
1076 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1077 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1078 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1081 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1088 # Collect dependencies map depending on target OS (libraries for CSF_ codenames used in EXTERNLIB) .
1089 # @param theOS - target OS
1090 # @param theCsfLibsMap - libraries map
1091 # @param theCsfFrmsMap - frameworks map, OS X specific
1092 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1093 upvar $theCsfLibsMap aLibsMap
1094 upvar $theCsfFrmsMap aFrmsMap
1099 set aLibsMap(CSF_FREETYPE) "freetype"
1100 set aLibsMap(CSF_TclLibs) "tcl8.6"
1101 set aLibsMap(CSF_TclTkLibs) "tk8.6"
1102 if { "$::HAVE_FREEIMAGE" == "true" } {
1103 if { "$theOS" == "wnt" } {
1104 set aLibsMap(CSF_FreeImagePlus) "FreeImage FreeImagePlus"
1106 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1109 if { "$::HAVE_GL2PS" == "true" } {
1110 set aLibsMap(CSF_GL2PS) "gl2ps"
1112 if { "$::HAVE_TBB" == "true" } {
1113 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1115 if { "$::HAVE_VTK" == "true" } {
1116 if { "$theOS" == "wnt" } {
1117 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1119 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1123 if { "$theOS" == "wnt" } {
1125 set aLibsMap(CSF_kernel32) "kernel32"
1126 set aLibsMap(CSF_advapi32) "advapi32"
1127 set aLibsMap(CSF_gdi32) "gdi32"
1128 set aLibsMap(CSF_user32) "user32 comdlg32"
1129 set aLibsMap(CSF_opengl32) "opengl32"
1130 set aLibsMap(CSF_wsock32) "wsock32"
1131 set aLibsMap(CSF_netapi32) "netapi32"
1132 set aLibsMap(CSF_AviLibs) "ws2_32 vfw32"
1133 set aLibsMap(CSF_OpenGlLibs) "opengl32"
1134 set aLibsMap(CSF_winspool) "Winspool"
1135 set aLibsMap(CSF_psapi) "Psapi"
1136 set aLibsMap(CSF_d3d9) "d3d9"
1138 # the naming is different on Windows
1139 set aLibsMap(CSF_TclLibs) "tcl86"
1140 set aLibsMap(CSF_TclTkLibs) "tk86"
1142 set aLibsMap(CSF_QT) "QtCore4 QtGui4"
1144 # tbb headers define different pragma lib depending on debug/release
1145 set aLibsMap(CSF_TBB) ""
1147 if { "$theOS" == "mac" } {
1148 set aLibsMap(CSF_objc) "objc"
1149 set aFrmsMap(CSF_Appkit) "Appkit"
1150 set aFrmsMap(CSF_IOKit) "IOKit"
1151 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1152 set aFrmsMap(CSF_TclLibs) "Tcl"
1153 set aLibsMap(CSF_TclLibs) ""
1154 set aFrmsMap(CSF_TclTkLibs) "Tk"
1155 set aLibsMap(CSF_TclTkLibs) ""
1157 if { "$theOS" == "qnx" } {
1158 # CSF_ThreadLibs - pthread API is part of libc on QNX
1159 set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
1161 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1162 set aLibsMap(CSF_OpenGlLibs) "GL"
1163 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1164 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1165 set aLibsMap(CSF_MotifLibs) "X11"
1171 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1172 proc osutils:vtkCsf {{theOS ""}} {
1175 set aPathSplitter ":"
1176 if {"$theOS" == "wnt"} {
1177 set aPathSplitter ";"
1180 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1181 foreach anIncItem $anOptIncs {
1182 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1183 set aVtkVer $aFoundVtkVer
1187 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1188 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1190 # Additional suffices for the libraries
1192 foreach anItem $aLibArray {
1193 lset aLibArray $anIdx $anItem-$aVtkVer
1197 return [join $aLibArray " "]
1200 # @param theLibsList - dependencies (libraries list)
1201 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1202 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1204 upvar $theLibsList aLibsList
1205 upvar $theFrameworks aFrameworks
1206 set aLibsList [list]
1207 set aFrameworks [list]
1209 osutils:csfList $theOS aLibsMap aFrmsMap
1211 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1212 if [info exists aLibsMap($aCsfElem)] {
1213 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1214 if { [lsearch $aLibsList $aLib] == "-1" } {
1215 lappend aLibsList $aLib
1219 if [info exists aFrmsMap($aCsfElem)] {
1220 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1221 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1222 lappend aFrameworks $aFrm
1229 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1230 proc osutils:tk:units { tkloc } {
1233 set PACKAGES "$path/src/$tkloc/PACKAGES"
1234 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1235 if {[file isdirectory "$path/src/$u"]} {
1240 ;#puts stderr "Warning. No devunit included in $tkloc"
1245 proc osutils:justwnt { listloc } {
1246 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1247 set goaway [list Xdps Xw ImageUtility WOKUnix]
1248 return [osutils:juststation $goaway $listloc]
1251 # remove from listloc OpenCascade units indesirables on NT
1252 proc osutils:juststation {goaway listloc} {
1255 foreach u $listloc {
1256 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1257 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1264 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1265 # The first list is everything in the first list that wasn't in the second,
1266 # the second list contains the intersection of the two lists, the third list contains everything
1267 # in the second list that wasn't in the first.
1268 proc osutils:intersect3 {list1 list2} {
1269 set la1(0) {} ; unset la1(0)
1270 set lai(0) {} ; unset lai(0)
1271 set la2(0) {} ; unset la2(0)
1278 foreach elem [concat $list1 $list2] {
1279 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1285 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1288 # Prepare relative path
1289 proc relativePath {thePathFrom thePathTo} {
1290 if { [file isdirectory "$thePathFrom"] == 0 } {
1294 set aPathFrom [file normalize "$thePathFrom"]
1295 set aPathTo [file normalize "$thePathTo"]
1297 set aCutedPathFrom "${aPathFrom}/dummy"
1298 set aRelatedDeepPath ""
1300 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1301 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1302 # does aPathTo contain aCutedPathFrom?
1303 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1304 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1305 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1306 set aPathTo ".${aPathTo}"
1307 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1308 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1310 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1311 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1312 return $aPathToAfterCut
1314 set aRelatedDeepPath "$aRelatedDeepPath../"
1321 proc wokUtils:EASY:bs1 { s } {
1322 regsub -all {/} $s {\\} r
1326 # Returs for a full path the liste of n last directory part
1328 # n = 2 => dir/file.c
1329 # n = 3 => sdir/dir/file.c
1331 proc wokUtils:FILES:wtail { f n } {
1332 set ll [expr [llength [set lif [file split $f]]] -$n]
1333 return [join [lrange $lif $ll end] /]
1336 # Generate entry for one source file in Visual Studio 10 project file
1337 proc osutils:vcxproj:file { vcversion file params } {
1338 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1339 if { $params != "" } {
1340 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1343 if { $params != "" } {
1344 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1347 if { $params != "" } {
1348 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1351 if { $params != "" } {
1352 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1355 append text " </ClCompile>\n"
1359 # Generate Visual Studio 2010 project filters file
1360 proc osutils:vcxproj: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"
1391 append text "</Project>"
1394 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1395 fconfigure $fp -translation crlf
1399 return ${proj}.vcxproj.filters
1402 # Generate Visual Studio 2011 project filters file
1403 proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1404 upvar $theFilesMap aFilesMap
1407 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1408 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1410 # list of "filters" (units)
1411 append text " <ItemGroup>\n"
1412 append text " <Filter Include=\"Source files\">\n"
1413 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1414 append text " </Filter>\n"
1415 foreach unit $aFilesMap(units) {
1416 append text " <Filter Include=\"Source files\\${unit}\">\n"
1417 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1418 append text " </Filter>\n"
1420 append text " </ItemGroup>\n"
1423 append text " <ItemGroup>\n"
1424 foreach unit $aFilesMap(units) {
1425 foreach file $aFilesMap($unit) {
1426 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1427 append text " <Filter>Source files\\${unit}</Filter>\n"
1428 append text " </ClCompile>\n"
1431 append text " </ItemGroup>\n"
1433 append text " <ItemGroup>\n"
1434 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1435 append text " </ItemGroup>\n"
1438 append text "</Project>"
1441 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1442 fconfigure $fp -translation crlf
1446 return ${proj}.vcxproj.filters
1449 # Generate RC file content for ToolKit from template
1450 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1451 set aLoc "$::THE_CASROOT/adm/templates/template_dll.rc"
1452 set aBody [wokUtils:FILES:FileToString $aLoc]
1453 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1455 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1456 fconfigure $aFile -translation lf
1459 return "${theOutDir}/${theToolKit}.rc"
1462 # Generate Visual Studio project file for ToolKit
1463 proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1464 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1466 set l_compilable [osutils:compilable]
1467 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1469 upvar $theGuidsMap aGuidsMap
1470 if { ! [info exists aGuidsMap($theToolKit)] } {
1471 set aGuidsMap($theToolKit) [OS:genGUID]
1473 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1475 set aUsedLibs [list]
1476 foreach tkx [osutils:commonUsedTK $theToolKit] {
1477 lappend aUsedLibs "${tkx}.lib"
1480 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1481 foreach aLibIter $aLibs {
1482 lappend aUsedLibs "${aLibIter}.lib"
1485 # correct names of referred third-party libraries that are named with suffix
1486 # depending on VC version
1487 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1489 # and put this list to project file
1490 #puts "$theToolKit requires $aUsedLibs"
1491 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1492 set aUsedLibs [join $aUsedLibs {;}]
1494 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
1496 set anIncPaths "..\\..\\..\\inc"
1498 set aFilesSection ""
1499 set aVcFilesX(units) ""
1500 set listloc [osutils:tk:units $theToolKit]
1501 set resultloc [osutils:justwnt $listloc]
1502 if [array exists written] { unset written }
1503 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1504 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1505 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1506 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1507 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1508 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1510 foreach fxlo $resultloc {
1512 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
1513 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1514 if {$fxlo_cmplrs_options_cxx == ""} {
1515 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1517 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1518 if {$fxlo_cmplrs_options_c == ""} {
1519 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1521 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1522 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1523 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1524 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1525 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1526 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1528 foreach partopt $fxloparam {
1529 if {[string first "-I" $partopt] == "0"} {
1530 # this is an additional includes search path
1533 set needparam "$needparam $partopt"
1536 # Format of projects in vc10+ is different from vc7-9
1537 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1538 foreach aSrcFile [lsort $aSrcFiles] {
1539 if { ![info exists written([file tail $aSrcFile])] } {
1540 set written([file tail $aSrcFile]) 1
1541 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1543 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1545 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1546 lappend aVcFilesX($xlo) $aSrcFile
1549 append aFilesSection "\t\t\t<Filter\n"
1550 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1551 append aFilesSection "\t\t\t\t>\n"
1552 foreach aSrcFile [lsort $aSrcFiles] {
1553 if { ![info exists written([file tail $aSrcFile])] } {
1554 set written([file tail $aSrcFile]) 1
1555 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1557 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1560 append aFilesSection "\t\t\t</Filter>\n"
1564 append aTKDefines ";__${xlo}_DLL"
1566 # append anIncPaths ";..\\..\\..\\src\\${xlo}"
1569 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1570 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1571 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1574 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1575 fconfigure $aFile -translation crlf
1576 puts $aFile $theProjTmpl
1579 # write filters file for vc10+
1580 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
1582 } elseif { "$theVcVer" == "vc10" } {
1583 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
1585 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1588 # write resource file
1589 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1594 # for a unit returns a map containing all its file in the current
1596 # local = 1 only local files
1597 proc osutils:tk:loadunit { loc map } {
1600 catch { unset TLOC }
1601 set lfiles [_get_used_files $loc]
1606 if [info exists TLOC($t)] {
1617 # Returns the list of all compilable files name in a toolkit, or devunit of any type
1618 # Call unit filter on units name to accept or reject a unit
1619 # Tfiles lists for each unit the type of file that can be compiled.
1620 proc osutils:tk:files { tkloc {l_compilable {} } {justail 1} {unitfilter {}} } {
1621 set Tfiles(source,nocdlpack) {source pubinclude}
1622 set Tfiles(source,toolkit) {}
1623 set Tfiles(source,executable) {source pubinclude}
1624 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1625 #puts " listloc = $listloc"
1626 if { $l_compilable == {} } {
1627 set l_comp [list .c .cxx .cpp]
1629 set l_comp [$l_compilable]
1631 if { $unitfilter == {} } {
1632 set resultloc $listloc
1634 set resultloc [$unitfilter $listloc]
1637 foreach loc $resultloc {
1638 set utyp [_get_type $loc]
1639 #puts "\"$utyp\" \"$loc\""
1641 "t" { set utyp "toolkit" }
1642 "n" { set utyp "nocdlpack" }
1643 "x" { set utyp "executable" }
1645 if [array exists map] { unset map }
1646 osutils:tk:loadunit $loc map
1647 #puts " loc = $loc === > [array names map]"
1648 set LType $Tfiles(source,${utyp})
1649 foreach typ [array names map] {
1650 if { [lsearch $LType $typ] == -1 } {
1654 foreach type [array names map] {
1656 foreach f $map($type) {
1658 if { [lsearch $l_comp [file extension $f]] != -1 } {
1659 if { $justail == 1 } {
1660 if {$type == "source"} {
1661 if {[lsearch $lret "@top_srcdir@/src/$loc/[file tail $f]"] == -1} {
1662 lappend lret @top_srcdir@/src/$loc/[file tail $f]
1675 # Generate Visual Studio project file for executable
1676 proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1678 foreach f [osutils:tk:files $theToolKit osutils:compilable 0] {
1679 if { $theProjTmpl == {} } {
1680 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1682 set aProjTmpl $theProjTmpl
1684 set aProjName [file rootname [file tail $f]]
1685 set l_compilable [osutils:compilable]
1686 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1688 upvar $theGuidsMap aGuidsMap
1689 if { ! [info exists aGuidsMap($aProjName)] } {
1690 set aGuidsMap($aProjName) [OS:genGUID]
1692 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1694 set aUsedLibs [list]
1695 foreach tkx [osutils:commonUsedTK $theToolKit] {
1696 lappend aUsedLibs "${tkx}.lib"
1699 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1700 foreach aLibIter $aLibs {
1701 lappend aUsedLibs "${aLibIter}.lib"
1704 # correct names of referred third-party libraries that are named with suffix
1705 # depending on VC version
1706 regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
1708 # puts "$aProjName requires $aUsedLibs"
1709 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1710 set aUsedLibs [join $aUsedLibs {;}]
1712 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
1714 set aFilesSection ""
1715 set aVcFilesX(units) ""
1717 if { ![info exists written([file tail $f])] } {
1718 set written([file tail $f]) 1
1720 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1721 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1722 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1723 lappend aVcFilesX($theToolKit) $f
1725 append aFilesSection "\t\t\t<Filter\n"
1726 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1727 append aFilesSection "\t\t\t\t>\n"
1728 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1729 append aFilesSection "\t\t\t</Filter>"
1732 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1734 #puts "$aProjTmpl $aFilesSection"
1735 set aTKDefines ";__${theToolKit}_DLL"
1736 set anIncPaths "..\\..\\..\\inc"
1737 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1738 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1739 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1740 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1742 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1744 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1745 fconfigure $aFile -translation crlf
1746 puts $aFile $aProjTmpl
1749 set aCommonSettingsFile "$aVcFilePath.user"
1750 lappend aVcFiles $aVcFilePath
1752 # write filters file for vc10
1753 if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
1754 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1757 set aCommonSettingsFileTmpl ""
1758 if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
1760 } elseif { "$theVcVer" == "vc9" } {
1761 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcproj.user.vc9x"]
1763 set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
1765 if { "$aCommonSettingsFileTmpl" != "" } {
1766 regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
1768 set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
1769 fconfigure $aFile -translation crlf
1770 puts $aFile $aCommonSettingsFileTmpl
1773 lappend aVcFiles "$aCommonSettingsFile"
1779 # Generate entry for one source file in Visual Studio 7 - 9 project file
1780 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1781 append aText "\t\t\t\t<File\n"
1782 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1783 if { $theOptions == "" } {
1784 append aText "\t\t\t\t</File>\n"
1788 append aText "\t\t\t\t\t<FileConfiguration\n"
1789 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1790 append aText "\t\t\t\t\t\t<Tool\n"
1791 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1792 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1793 foreach aParam $theOptions {
1794 append aText "$aParam "
1797 append aText "\t\t\t\t\t\t/>\n"
1798 append aText "\t\t\t\t\t</FileConfiguration>\n"
1800 append aText "\t\t\t\t\t<FileConfiguration\n"
1801 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1802 append aText "\t\t\t\t\t\t<Tool\n"
1803 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1804 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1805 foreach aParam $theOptions {
1806 append aText "$aParam "
1809 append aText "\t\t\t\t\t\t/>\n"
1810 append aText "\t\t\t\t\t</FileConfiguration>\n"
1811 if { "$theVcVer" == "vc7" } {
1812 append aText "\t\t\t\t</File>\n"
1816 append aText "\t\t\t\t\t<FileConfiguration\n"
1817 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1818 append aText "\t\t\t\t\t\t<Tool\n"
1819 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1820 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1821 foreach aParam $theOptions {
1822 append aText "$aParam "
1825 append aText "\t\t\t\t\t\t/>\n"
1826 append aText "\t\t\t\t\t</FileConfiguration>\n"
1828 append aText "\t\t\t\t\t<FileConfiguration\n"
1829 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1830 append aText "\t\t\t\t\t\t<Tool\n"
1831 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1832 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1833 foreach aParam $theOptions {
1834 append aText "$aParam "
1837 append aText "\t\t\t\t\t\t/>\n"
1838 append aText "\t\t\t\t\t</FileConfiguration>\n"
1840 append aText "\t\t\t\t</File>\n"
1844 proc wokUtils:FILES:mkdir { d } {
1846 regsub -all {\.[^.]*} $tcl_version "" major
1847 if { $major == 8 } {
1850 if ![file exists $d] {
1851 if { "[info command mkdir]" == "mkdir" } {
1854 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1858 if [file exists $d] {
1865 # remove from listloc OpenCascade units indesirables on Unix
1866 proc osutils:justunix { listloc } {
1867 if { "$::tcl_platform(os)" == "Darwin" } {
1868 set goaway [list Xw WNT]
1870 set goaway [list WNT]
1872 return [osutils:juststation $goaway $listloc]
1876 ####### CODEBLOCK ###################################################################
1877 # Function to generate Code Blocks workspace and project files
1878 proc OS:MKCBP { theOutDir theModules theAllSolution theCmpl } {
1879 puts stderr "Generating project files for Code Blocks"
1881 # Generate projects for toolkits and separate workspace for each module
1882 foreach aModule $theModules {
1883 OS:cworkspace $aModule $aModule $theOutDir
1884 OS:cbp $theCmpl $aModule $theOutDir
1887 # Generate single workspace "OCCT" containing projects from all modules
1888 if { "$theAllSolution" != "" } {
1889 OS:cworkspace $theAllSolution $theModules $theOutDir
1892 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
1895 # Generate Code Blocks projects
1896 proc OS:cbp { theCmpl theModules theOutDir } {
1897 set aProjectFiles {}
1898 foreach aModule $theModules {
1899 foreach aToolKit [${aModule}:toolkits] {
1900 lappend aProjectFiles [osutils:cbptk $theCmpl $theOutDir $aToolKit ]
1902 foreach anExecutable [OS:executable ${aModule}] {
1903 lappend aProjectFiles [osutils:cbpx $theCmpl $theOutDir $anExecutable]
1906 return $aProjectFiles
1909 # Generate Code::Blocks project file for ToolKit
1910 proc osutils:cbptk { theCmpl theOutDir theToolKit } {
1911 set aUsedLibs [list]
1912 set aFrameworks [list]
1913 set anIncPaths [list]
1914 set aTKDefines [list]
1915 set aTKSrcFiles [list]
1917 global path targetStation
1918 set aWokStation "$targetStation"
1920 # collect list of referred libraries to link with
1921 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedLibs aFrameworks
1922 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
1923 foreach tkx $aDepToolkits {
1924 lappend aUsedLibs "${tkx}"
1927 lappend anIncPaths "../../../inc"
1928 set listloc [osutils:tk:units $theToolKit]
1930 if { [llength $listloc] == 0 } {
1931 set listloc $theToolKit
1934 if { "$aWokStation" == "wnt" } {
1935 set resultloc [osutils:justwnt $listloc]
1937 set resultloc [osutils:justunix $listloc]
1939 if [array exists written] { unset written }
1940 foreach fxlo $resultloc {
1942 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
1943 foreach aSrcFile [lsort $aSrcFiles] {
1944 if { ![info exists written([file tail $aSrcFile])] } {
1945 set written([file tail $aSrcFile]) 1
1946 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
1948 puts "Warning : more than one occurences for [file tail $aSrcFile]"
1952 # macros for correct DLL exports
1953 if { "$aWokStation" == "wnt" } {
1954 lappend aTKDefines "__${xlo}_DLL"
1958 return [osutils:cbp $theCmpl $theOutDir $theToolKit $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
1961 # Generates Code Blocks workspace.
1962 proc OS:cworkspace { theSolName theModules theOutDir } {
1964 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
1965 set aFile [open $aWsFilePath "w"]
1967 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
1968 puts $aFile "<CodeBlocks_workspace_file>"
1969 puts $aFile "\t<Workspace title=\"${theSolName}\">"
1971 # collect list of projects to be created
1972 foreach aModule $theModules {
1974 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
1975 set aDependencies [LibToLink $aToolKit]
1976 if { [llength $aDependencies] == 0 } {
1977 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
1979 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
1980 foreach aDepTk $aDependencies {
1981 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
1983 puts $aFile "\t\t</Project>"
1987 # executables, assume one project per cxx file...
1988 foreach aUnit [OS:executable ${aModule}] {
1990 set src_files [_get_used_files $aUnit false]
1992 foreach s $src_files {
1993 regexp {source ([^\s]+)} $s dummy name
1994 lappend aSrcFiles $name
1996 foreach aSrcFile $aSrcFiles {
1997 set aFileExtension [file extension $aSrcFile]
1998 if { $aFileExtension == ".cxx" } {
1999 set aPrjName [file rootname $aSrcFile]
2000 set aDependencies [list]
2001 if {[file isdirectory $path/src/$aUnitLoc]} {
2002 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
2004 set anActiveState ""
2005 if { $isActiveSet == 0 } {
2006 set anActiveState " active=\"1\""
2009 if { [llength $aDependencies] == 0 } {
2010 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
2012 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
2013 foreach aDepTk $aDependencies {
2014 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2016 puts $aFile "\t\t</Project>"
2023 puts $aFile "\t</Workspace>"
2024 puts $aFile "</CodeBlocks_workspace_file>"
2030 # Generate Code::Blocks project file for Executable
2031 proc osutils:cbpx { theCmpl theOutDir theToolKit } {
2032 global path targetStation
2033 set aWokStation "$targetStation"
2034 set aWokArch "$::env(ARCH)"
2037 foreach aSrcFile [osutils:tk:files $theToolKit osutils:compilable 0] {
2038 # collect list of referred libraries to link with
2039 set aUsedLibs [list]
2040 set aFrameworks [list]
2041 set anIncPaths [list]
2042 set aTKDefines [list]
2043 set aTKSrcFiles [list]
2044 set aProjName [file rootname [file tail $aSrcFile]]
2046 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedLibs aFrameworks
2048 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2049 foreach tkx $aDepToolkits {
2050 if {[_get_type $tkx] == "t"} {
2051 lappend aUsedLibs "${tkx}"
2053 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2054 lappend aUsedLibs "${tkx}"
2058 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2059 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2060 set isExecutable "false"
2062 set isExecutable "true"
2065 if { ![info exists written([file tail $aSrcFile])] } {
2066 set written([file tail $aSrcFile]) 1
2067 lappend aTKSrcFiles "../../../[wokUtils:FILES:wtail $aSrcFile 3]"
2069 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2072 # macros for correct DLL exports
2073 if { "$aWokStation" == "wnt" } {
2074 lappend aTKDefines "__${theToolKit}_DLL"
2077 # common include paths
2078 lappend anIncPaths "../../../inc"
2080 lappend aCbpFiles [osutils:cbp $theCmpl $theOutDir $aProjName $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2086 # This function intended to generate Code::Blocks project file
2087 # @param theCmpl - the compiler (gcc or msvc)
2088 # @param theOutDir - output directory to place project file
2089 # @param theProjName - project name
2090 # @param theSrcFiles - list of source files
2091 # @param theLibsList - dependencies (libraries list)
2092 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2093 # @param theIncPaths - header search paths
2094 # @param theDefines - compiler macro definitions
2095 # @param theIsExe - flag to indicate executable / library target
2096 proc osutils:cbp { theCmpl theOutDir theProjName theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2097 global targetStation
2098 set aWokStation "$targetStation"
2099 set aWokArch "$::env(ARCH)"
2102 set aCmplFlags [list]
2103 set aCmplFlagsRelease [list]
2104 set aCmplFlagsDebug [list]
2105 set toPassArgsByFile 0
2106 set aLibPrefix "lib"
2107 if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
2108 set toPassArgsByFile 1
2110 if { "$theCmpl" == "msvc" } {
2111 set aCmplCbp "msvc8"
2115 if { "$theCmpl" == "msvc" } {
2116 set aCmplFlags "-arch:SSE2 -EHsc -W4 -MP"
2117 set aCmplFlagsRelease "-MD -O2"
2118 set aCmplFlagsDebug "-MDd -Od -Zi"
2119 lappend aCmplFlags "-D_CRT_SECURE_NO_WARNINGS"
2120 lappend aCmplFlags "-D_CRT_NONSTDC_NO_DEPRECATE"
2121 } elseif { "$theCmpl" == "gcc" } {
2122 if { "$aWokStation" != "qnx" } {
2123 set aCmplFlags "-mmmx -msse -msse2 -mfpmath=sse"
2125 set aCmplFlagsRelease "-O2"
2126 set aCmplFlagsDebug "-O0 -g"
2127 if { "$aWokStation" == "wnt" } {
2128 lappend aCmplFlags "-std=gnu++0x"
2129 lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
2131 lappend aCmplFlags "-std=c++0x"
2132 lappend aCmplFlags "-fPIC"
2133 lappend aCmplFlags "-DOCC_CONVERT_SIGNALS"
2135 lappend aCmplFlags "-Wall"
2136 lappend aCmplFlags "-fexceptions"
2138 lappend aCmplFlagsRelease "-DNDEBUG"
2139 lappend aCmplFlagsRelease "-DNo_Exception"
2140 lappend aCmplFlagsDebug "-D_DEBUG"
2141 if { "$aWokStation" == "qnx" } {
2142 lappend aCmplFlags "-D_QNX_SOURCE"
2145 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2146 set aLnkFileName "${theProjName}_obj.link"
2147 set aLnkDebFileName "${theProjName}_objd.link"
2148 set aLnkFilePath "${theOutDir}/${aLnkFileName}"
2149 set aLnkDebFilePath "${theOutDir}/${aLnkDebFileName}"
2150 set aFile [open $aCbpFilePath "w"]
2151 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2152 puts $aFile "<CodeBlocks_project_file>"
2153 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2154 puts $aFile "\t<Project>"
2155 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2156 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2157 puts $aFile "\t\t<Option compiler=\"$aCmplCbp\" />"
2158 puts $aFile "\t\t<Build>"
2160 # Release target configuration
2161 puts $aFile "\t\t\t<Target title=\"Release\">"
2162 if { "$theIsExe" == "true" } {
2163 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2164 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2166 if { "$aWokStation" == "wnt" } {
2167 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\" />"
2169 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2171 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2173 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2174 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2175 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2176 if { "$aWokStation" == "wnt" } {
2177 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2179 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2182 # compiler options per TARGET (including defines)
2183 puts $aFile "\t\t\t\t<Compiler>"
2184 foreach aFlagIter $aCmplFlagsRelease {
2185 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2187 foreach aMacro $theDefines {
2188 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2190 puts $aFile "\t\t\t\t</Compiler>"
2192 puts $aFile "\t\t\t\t<Linker>"
2193 if { $toPassArgsByFile == 1 } {
2194 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
2196 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2197 if { "$aWokStation" == "mac" } {
2198 if { [ lsearch $theLibsList X11 ] >= 0} {
2199 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2202 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2203 puts $aFile "\t\t\t\t</Linker>"
2205 puts $aFile "\t\t\t</Target>"
2207 # Debug target configuration
2208 puts $aFile "\t\t\t<Target title=\"Debug\">"
2209 if { "$theIsExe" == "true" } {
2210 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
2211 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2213 if { "$aWokStation" == "wnt" } {
2214 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\" />"
2216 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
2218 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2220 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2221 puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
2222 puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
2223 if { "$aWokStation" == "wnt" } {
2224 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2226 puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
2229 # compiler options per TARGET (including defines)
2230 puts $aFile "\t\t\t\t<Compiler>"
2231 foreach aFlagIter $aCmplFlagsDebug {
2232 puts $aFile "\t\t\t\t\t<Add option=\"$aFlagIter\" />"
2234 foreach aMacro $theDefines {
2235 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2237 puts $aFile "\t\t\t\t</Compiler>"
2239 puts $aFile "\t\t\t\t<Linker>"
2240 if { $toPassArgsByFile == 1 } {
2241 puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
2243 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2244 if { "$aWokStation" == "mac" } {
2245 if { [ lsearch $theLibsList X11 ] >= 0} {
2246 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2249 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2250 puts $aFile "\t\t\t\t</Linker>"
2252 puts $aFile "\t\t\t</Target>"
2254 puts $aFile "\t\t</Build>"
2256 # COMMON compiler options
2257 puts $aFile "\t\t<Compiler>"
2258 foreach aFlagIter $aCmplFlags {
2259 puts $aFile "\t\t\t<Add option=\"$aFlagIter\" />"
2261 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2262 foreach anIncPath $theIncPaths {
2263 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2265 puts $aFile "\t\t</Compiler>"
2267 # COMMON linker options
2268 puts $aFile "\t\t<Linker>"
2269 if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
2270 puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
2272 foreach aFrameworkName $theFrameworks {
2273 if { "$aFrameworkName" != "" } {
2274 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2277 foreach aLibName $theLibsList {
2278 if { "$aLibName" != "" } {
2279 if { "$theCmpl" == "msvc" } {
2280 puts $aFile "\t\t\t<Add library=\"${aLibName}.lib\" />"
2282 puts $aFile "\t\t\t<Add library=\"${aLibName}\" />"
2286 puts $aFile "\t\t</Linker>"
2292 set isFirstSrcFile 1
2293 if { $toPassArgsByFile == 1 } {
2294 set aFileLnkObj [open $aLnkFilePath "w"]
2295 set aFileLnkObjd [open $aLnkDebFilePath "w"]
2298 foreach aSrcFile $theSrcFiles {
2299 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2300 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2301 puts $aFile "\t\t\t<Option compile=\"1\" />"
2302 puts $aFile "\t\t\t<Option link=\"1\" />"
2303 puts $aFile "\t\t</Unit>"
2304 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2305 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2306 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2307 puts $aFile "\t\t</Unit>"
2308 } elseif { $toPassArgsByFile == 1 && $isFirstSrcFile == 0 && [string equal -nocase [file extension $aSrcFile] ".cxx" ] } {
2309 # pass at list single source file to Code::Blocks as is
2310 # and pack the list of other files into the dedicated file to workaround process arguments limits on systems like Windows
2311 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2312 puts $aFile "\t\t\t<Option link=\"0\" />"
2313 puts $aFile "\t\t</Unit>"
2315 set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"] $aSrcFile]]
2316 set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
2317 puts -nonewline $aFileLnkObj "$aFileObj "
2318 puts -nonewline $aFileLnkObjd "$aFileObjd "
2320 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2321 set isFirstSrcFile 0
2325 if { "$aWokStation" == "wnt" } {
2330 puts $aFile "\t</Project>"
2331 puts $aFile "</CodeBlocks_project_file>"
2334 return $aCbpFilePath
2337 # Define libraries to link using only EXTERNLIB file
2338 proc LibToLinkX {thePackage theDummyName} {
2339 set aToolKits [LibToLink $thePackage]
2343 # Function to generate Xcode workspace and project files
2344 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
2346 puts stderr "Generating project files for Xcode"
2348 # Generate projects for toolkits and separate workspace for each module
2349 foreach aModule $theModules {
2350 OS:xcworkspace $aModule $aModule $theOutDir
2351 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
2354 # Generate single workspace "OCCT" containing projects from all modules
2355 if { "$theAllSolution" != "" } {
2356 OS:xcworkspace $theAllSolution $theModules $theOutDir
2360 # Generates toolkits sections for Xcode workspace file.
2361 proc OS:xcworkspace:toolkits { theModule } {
2364 # Adding toolkits for module in workspace.
2365 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
2366 append aBuff " <FileRef\n"
2367 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
2368 append aBuff " </FileRef>\n"
2371 # Adding executables for module, assume one project per cxx file...
2372 foreach aUnit [OS:executable ${theModule}] {
2374 set src_files [_get_used_files $aUnit false]
2376 foreach s $src_files {
2377 regexp {source ([^\s]+)} $s dummy name
2378 lappend aSrcFiles $name
2380 foreach aSrcFile $aSrcFiles {
2381 set aFileExtension [file extension $aSrcFile]
2382 if { $aFileExtension == ".cxx" } {
2383 set aPrjName [file rootname $aSrcFile]
2384 append aBuff " <FileRef\n"
2385 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
2386 append aBuff " </FileRef>\n"
2391 # Removing unnecessary newline character from the end.
2392 set aBuff [string replace $aBuff end end]
2396 # Generates workspace files for Xcode.
2397 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
2398 # Creating workspace directory for Xcode.
2399 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
2400 wokUtils:FILES:mkdir $aWorkspaceDir
2401 if { ! [file exists $aWorkspaceDir] } {
2402 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
2406 # Creating workspace file.
2407 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
2408 set aFile [open $aWsFilePath "w"]
2410 # Adding header and section for main Group.
2411 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
2412 puts $aFile "<Workspace"
2413 puts $aFile " version = \"1.0\">"
2414 puts $aFile " <Group"
2415 puts $aFile " location = \"container:\""
2416 puts $aFile " name = \"${theWorkspaceName}\">"
2419 if { [llength "$theModules"] > 1 } {
2420 foreach aModule $theModules {
2421 puts $aFile " <Group"
2422 puts $aFile " location = \"container:\""
2423 puts $aFile " name = \"${aModule}\">"
2424 puts $aFile [OS:xcworkspace:toolkits $aModule]
2425 puts $aFile " </Group>"
2428 puts $aFile [OS:xcworkspace:toolkits $theModules]
2432 puts $aFile " </Group>"
2433 puts $aFile "</Workspace>"
2437 # Generates Xcode project files.
2438 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
2439 upvar $theGuidsMap aGuidsMap
2442 if { "$theLibType" == "static" } {
2444 } elseif { "$thePlatform" == "ios" } {
2448 set aProjectFiles {}
2449 foreach aModule $theModules {
2450 foreach aToolKit [${aModule}:toolkits] {
2451 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
2453 foreach anExecutable [OS:executable ${aModule}] {
2454 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
2457 return $aProjectFiles
2460 # Generates dependencies section for Xcode project files.
2461 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
2462 upvar $theGuidsMap aGuidsMap
2463 upvar $theFileRefSection aFileRefSection
2464 upvar $theDepsGuids aDepsGuids
2465 upvar $theDepsRefGuids aDepsRefGuids
2467 set aBuildFileSection ""
2468 set aUsedLibs [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2469 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
2471 if { "$theTargetType" == "executable" } {
2472 set aFile [osutils:tk:files $theToolKit osutils:compilable 0]
2473 set aProjName [file rootname [file tail $aFile]]
2474 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2478 if { $theIsStatic == 1 } {
2480 if { "$theTargetType" != "executable" } {
2481 return $aBuildFileSection
2485 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
2486 set aUsedLibs [concat $aUsedLibs $aLibs]
2487 set aUsedLibs [concat $aUsedLibs $aFrameworks]
2488 foreach tkx $aUsedLibs {
2489 set aDepLib "${tkx}_Dep"
2490 set aDepLibRef "${tkx}_DepRef"
2492 if { ! [info exists aGuidsMap($aDepLib)] } {
2493 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
2495 if { ! [info exists aGuidsMap($aDepLibRef)] } {
2496 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
2499 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
2500 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
2501 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
2503 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
2505 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
2506 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
2509 return $aBuildFileSection
2512 # Generates PBXBuildFile and PBXGroup sections for project file.
2513 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
2514 upvar $theSrcFileRefSection aSrcFileRefSection
2515 upvar $theGroupSection aGroupSection
2516 upvar $thePackageGuids aPackagesGuids
2517 upvar $theSrcFileGuids aSrcFileGuids
2518 upvar $theGuidsMap aGuidsMap
2519 upvar $theIncPaths anIncPaths
2521 set listloc [osutils:tk:units $theToolKit]
2522 set resultloc [osutils:justunix $listloc]
2523 set aBuildFileSection ""
2524 set aPackages [lsort -nocase $resultloc]
2525 if { "$theTargetType" == "executable" } {
2526 set aPackages [list "$theToolKit"]
2529 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
2530 foreach fxlo $aPackages {
2532 set aPackage "${xlo}_Package"
2533 set aSrcFileRefGuids ""
2534 if { ! [info exists aGuidsMap($aPackage)] } {
2535 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
2538 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
2539 foreach aSrcFile [lsort $aSrcFiles] {
2540 set aFileExt "sourcecode.cpp.cpp"
2542 if { [file extension $aSrcFile] == ".c" } {
2543 set aFileExt "sourcecode.c.c"
2544 } elseif { [file extension $aSrcFile] == ".mm" } {
2545 set aFileExt "sourcecode.cpp.objcpp"
2548 if { ! [info exists aGuidsMap($aSrcFile)] } {
2549 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
2551 set aSrcFileRef "${aSrcFile}_Ref"
2552 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
2553 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
2555 if { ! [info exists written([file tail $aSrcFile])] } {
2556 set written([file tail $aSrcFile]) 1
2557 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
2558 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"
2559 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
2560 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
2562 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2566 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
2567 append aGroupSection "\t\t\tisa = PBXGroup;\n"
2568 append aGroupSection "\t\t\tchildren = (\n"
2569 append aGroupSection $aSrcFileRefGuids
2570 append aGroupSection "\t\t\t);\n"
2571 append aGroupSection "\t\t\tname = $xlo;\n"
2572 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
2573 append aGroupSection "\t\t\};\n"
2575 # Storing packages IDs for adding them later as a child of toolkit
2576 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
2579 # Removing unnecessary newline character from the end.
2580 set aPackagesGuids [string replace $aPackagesGuids end end]
2582 return $aBuildFileSection
2585 # Creates folders structure and all necessary files for Xcode project.
2586 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
2587 set aPBXBuildPhase "Headers"
2588 set aRunOnlyForDeployment "0"
2589 set aProductType "library.dynamic"
2590 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
2591 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
2592 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
2593 set aTKDefines [list "OCC_CONVERT_SIGNALS"]
2595 if { "$theTargetType" == "executable" } {
2596 set aPBXBuildPhase "CopyFiles"
2597 set aRunOnlyForDeployment "1"
2598 set aProductType "tool"
2599 set anExecExtension ""
2601 set aWrapperExtension ""
2602 } elseif { $theIsStatic == 1 } {
2603 set aProductType "library.static"
2604 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
2605 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
2608 set aUsername [exec whoami]
2610 # Creation of folders for Xcode projectP.
2611 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
2612 wokUtils:FILES:mkdir $aToolkitDir
2613 if { ! [file exists $aToolkitDir] } {
2614 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
2618 set aUserDataDir "${aToolkitDir}/xcuserdata"
2619 wokUtils:FILES:mkdir $aUserDataDir
2620 if { ! [file exists $aUserDataDir] } {
2621 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
2625 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
2626 wokUtils:FILES:mkdir $aUserDataDir
2627 if { ! [file exists $aUserDataDir] } {
2628 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
2632 set aSchemesDir "${aUserDataDir}/xcschemes"
2633 wokUtils:FILES:mkdir $aSchemesDir
2634 if { ! [file exists $aSchemesDir] } {
2635 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
2638 # End of folders creation.
2640 # Generating GUID for tookit.
2641 upvar $theGuidsMap aGuidsMap
2642 if { ! [info exists aGuidsMap($theToolKit)] } {
2643 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
2646 # Creating xcscheme file for toolkit from template.
2647 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
2648 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
2649 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
2650 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
2651 puts $aXcschemeFile $aXcschemeTmpl
2652 close $aXcschemeFile
2654 # Creating xcschememanagement.plist file for toolkit from template.
2655 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
2656 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
2657 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
2658 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
2659 puts $aPlistFile $aPlistTmpl
2662 # Creating project.pbxproj file for toolkit.
2663 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
2664 puts $aPbxprojFile "// !\$*UTF8*\$!"
2665 puts $aPbxprojFile "\{"
2666 puts $aPbxprojFile "\tarchiveVersion = 1;"
2667 puts $aPbxprojFile "\tclasses = \{"
2668 puts $aPbxprojFile "\t\};"
2669 puts $aPbxprojFile "\tobjectVersion = 46;"
2670 puts $aPbxprojFile "\tobjects = \{\n"
2672 # Begin PBXBuildFile section
2673 set aPackagesGuids ""
2674 set aGroupSection ""
2675 set aSrcFileRefSection ""
2676 set aSrcFileGuids ""
2677 set aDepsFileRefSection ""
2679 set aDepsRefGuids ""
2680 set anIncPaths [list "../../../inc"]
2683 if { [info exists ::env(CSF_OPT_INC)] } {
2684 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
2685 foreach anIncCfgPath $anIncCfg {
2686 lappend anIncPaths $anIncCfgPath
2689 if { [info exists ::env(CSF_OPT_LIB64)] } {
2690 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
2691 foreach anLibCfgPath $anLibCfg {
2692 lappend anLibPaths $anLibCfgPath
2696 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
2697 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
2698 # End PBXBuildFile section
2700 # Begin PBXFileReference section
2701 set aToolkitLib "lib${theToolKit}.dylib"
2702 set aPath "$aToolkitLib"
2703 if { "$theTargetType" == "executable" } {
2704 set aPath "$theToolKit"
2705 } elseif { $theIsStatic == 1 } {
2706 set aToolkitLib "lib${theToolKit}.a"
2709 if { ! [info exists aGuidsMap($aToolkitLib)] } {
2710 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
2713 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
2714 puts $aPbxprojFile $aSrcFileRefSection
2715 puts $aPbxprojFile $aDepsFileRefSection
2716 # End PBXFileReference section
2719 # Begin PBXFrameworksBuildPhase section
2720 set aTkFrameworks "${theToolKit}_Frameworks"
2721 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
2722 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
2725 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
2726 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
2727 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2728 puts $aPbxprojFile "\t\t\tfiles = ("
2729 puts $aPbxprojFile $aDepsGuids
2730 puts $aPbxprojFile "\t\t\t);"
2731 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2732 puts $aPbxprojFile "\t\t\};\n"
2733 # End PBXFrameworksBuildPhase section
2735 # Begin PBXGroup section
2736 set aTkPBXGroup "${theToolKit}_PBXGroup"
2737 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
2738 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
2741 set aTkSrcGroup "${theToolKit}_SrcGroup"
2742 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
2743 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
2746 puts $aPbxprojFile $aGroupSection
2747 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
2748 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2749 puts $aPbxprojFile "\t\t\tchildren = ("
2750 puts $aPbxprojFile $aDepsRefGuids
2751 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
2752 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
2753 puts $aPbxprojFile "\t\t\t);"
2754 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2755 puts $aPbxprojFile "\t\t\};"
2756 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
2757 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
2758 puts $aPbxprojFile "\t\t\tchildren = ("
2759 puts $aPbxprojFile $aPackagesGuids
2760 puts $aPbxprojFile "\t\t\t);"
2761 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
2762 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
2763 puts $aPbxprojFile "\t\t\};\n"
2764 # End PBXGroup section
2766 # Begin PBXHeadersBuildPhase section
2767 set aTkHeaders "${theToolKit}_Headers"
2768 if { ! [info exists aGuidsMap($aTkHeaders)] } {
2769 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
2772 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
2773 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
2774 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2775 puts $aPbxprojFile "\t\t\tfiles = ("
2776 puts $aPbxprojFile "\t\t\t);"
2777 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
2778 puts $aPbxprojFile "\t\t\};\n"
2779 # End PBXHeadersBuildPhase section
2781 # Begin PBXNativeTarget section
2782 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
2783 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
2784 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
2787 set aTkSources "${theToolKit}_Sources"
2788 if { ! [info exists aGuidsMap($aTkSources)] } {
2789 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
2792 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
2793 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
2794 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
2795 puts $aPbxprojFile "\t\t\tbuildPhases = ("
2796 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
2797 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
2798 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
2799 puts $aPbxprojFile "\t\t\t);"
2800 puts $aPbxprojFile "\t\t\tbuildRules = ("
2801 puts $aPbxprojFile "\t\t\t);"
2802 puts $aPbxprojFile "\t\t\tdependencies = ("
2803 puts $aPbxprojFile "\t\t\t);"
2804 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
2805 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
2806 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
2807 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
2808 puts $aPbxprojFile "\t\t\};\n"
2809 # End PBXNativeTarget section
2811 # Begin PBXProject section
2812 set aTkProjectObj "${theToolKit}_ProjectObj"
2813 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
2814 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
2817 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
2818 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
2819 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
2822 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
2823 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
2824 puts $aPbxprojFile "\t\t\tattributes = \{"
2825 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
2826 puts $aPbxprojFile "\t\t\t\};"
2827 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
2828 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
2829 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
2830 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
2831 puts $aPbxprojFile "\t\t\tknownRegions = ("
2832 puts $aPbxprojFile "\t\t\t\ten,"
2833 puts $aPbxprojFile "\t\t\t);"
2834 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
2835 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
2836 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
2837 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
2838 puts $aPbxprojFile "\t\t\ttargets = ("
2839 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
2840 puts $aPbxprojFile "\t\t\t);"
2841 puts $aPbxprojFile "\t\t\};\n"
2842 # End PBXProject section
2844 # Begin PBXSourcesBuildPhase section
2845 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
2846 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
2847 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
2848 puts $aPbxprojFile "\t\t\tfiles = ("
2849 puts $aPbxprojFile $aSrcFileGuids
2850 puts $aPbxprojFile "\t\t\t);"
2851 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
2852 puts $aPbxprojFile "\t\t\};\n"
2853 # End PBXSourcesBuildPhase section
2855 # Begin XCBuildConfiguration section
2856 set aTkDebugProject "${theToolKit}_DebugProject"
2857 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
2858 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
2861 set aTkReleaseProject "${theToolKit}_ReleaseProject"
2862 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
2863 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
2866 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
2867 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
2868 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
2871 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
2872 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
2873 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
2877 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
2878 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2879 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2881 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
2882 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2883 if { "$thePlatform" == "ios" } {
2884 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2885 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2886 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2887 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2888 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2890 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2891 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2892 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
2893 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2894 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
2895 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2896 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
2897 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2898 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
2899 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
2900 puts $aPbxprojFile "\t\t\t\t);"
2901 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
2902 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2903 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2904 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2905 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2906 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2907 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
2908 if { "$thePlatform" == "ios" } {
2909 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
2910 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2912 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
2914 puts $aPbxprojFile "\t\t\t\};"
2916 puts $aPbxprojFile "\t\t\tname = Debug;"
2917 puts $aPbxprojFile "\t\t\};"
2920 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
2921 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2922 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2924 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
2925 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
2926 if { "$thePlatform" == "ios" } {
2927 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
2928 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
2929 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
2930 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
2931 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
2933 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
2934 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
2935 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
2936 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
2937 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
2938 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
2939 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
2940 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
2941 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
2942 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
2943 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
2944 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
2945 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
2946 if { "$thePlatform" == "ios" } {
2947 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
2948 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
2950 puts $aPbxprojFile "\t\t\t\};"
2951 puts $aPbxprojFile "\t\t\tname = Release;"
2952 puts $aPbxprojFile "\t\t\};"
2953 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
2954 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2955 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2956 puts $aPbxprojFile "${anExecExtension}"
2957 puts $aPbxprojFile "${anExecPrefix}"
2958 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
2959 foreach aMacro $aTKDefines {
2960 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
2962 puts $aPbxprojFile "\t\t\t\t);"
2964 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
2965 foreach anIncPath $anIncPaths {
2966 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
2968 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
2969 puts $aPbxprojFile "\t\t\t\t);"
2971 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
2972 foreach anLibPath $anLibPaths {
2973 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
2975 puts $aPbxprojFile "\t\t\t\t);"
2977 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
2978 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
2979 puts $aPbxprojFile "\t\t\t\t);"
2980 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
2981 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
2982 puts $aPbxprojFile "\t\t\t\t);"
2983 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
2984 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
2985 foreach anIncPath $anIncPaths {
2986 append anUserHeaderSearchPath " ${anIncPath}"
2988 append anUserHeaderSearchPath "\";"
2989 puts $aPbxprojFile $anUserHeaderSearchPath
2990 puts $aPbxprojFile "${aWrapperExtension}"
2991 puts $aPbxprojFile "\t\t\t\};"
2992 puts $aPbxprojFile "\t\t\tname = Debug;"
2993 puts $aPbxprojFile "\t\t\};"
2994 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
2995 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
2996 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
2997 puts $aPbxprojFile "${anExecExtension}"
2998 puts $aPbxprojFile "${anExecPrefix}"
2999 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3000 foreach aMacro $aTKDefines {
3001 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3003 puts $aPbxprojFile "\t\t\t\t);"
3004 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3005 foreach anIncPath $anIncPaths {
3006 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3008 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3009 puts $aPbxprojFile "\t\t\t\t);"
3011 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3012 foreach anLibPath $anLibPaths {
3013 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3015 puts $aPbxprojFile "\t\t\t\t);"
3017 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3018 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3019 puts $aPbxprojFile "\t\t\t\t);"
3020 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3021 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3022 puts $aPbxprojFile "\t\t\t\t);"
3023 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3024 puts $aPbxprojFile $anUserHeaderSearchPath
3025 puts $aPbxprojFile "${aWrapperExtension}"
3026 puts $aPbxprojFile "\t\t\t\};"
3027 puts $aPbxprojFile "\t\t\tname = Release;"
3028 puts $aPbxprojFile "\t\t\};\n"
3029 # End XCBuildConfiguration section
3031 # Begin XCConfigurationList section
3032 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3033 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3034 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3035 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3036 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3037 puts $aPbxprojFile "\t\t\t);"
3038 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3039 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3040 puts $aPbxprojFile "\t\t\};"
3041 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3042 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3043 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3044 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3045 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3046 puts $aPbxprojFile "\t\t\t);"
3047 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3048 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3049 puts $aPbxprojFile "\t\t\};\n"
3050 # End XCConfigurationList section
3052 puts $aPbxprojFile "\t\};"
3053 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3054 puts $aPbxprojFile "\}"
3059 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3060 set aUsername [exec whoami]
3062 # Creating folders for Xcode project file.
3063 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3064 wokUtils:FILES:mkdir $anExecutableDir
3065 if { ! [file exists $anExecutableDir] } {
3066 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3070 set aUserDataDir "${anExecutableDir}/xcuserdata"
3071 wokUtils:FILES:mkdir $aUserDataDir
3072 if { ! [file exists $aUserDataDir] } {
3073 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3077 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3078 wokUtils:FILES:mkdir $aUserDataDir
3079 if { ! [file exists $aUserDataDir] } {
3080 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3084 set aSchemesDir "${aUserDataDir}/xcschemes"
3085 wokUtils:FILES:mkdir $aSchemesDir
3086 if { ! [file exists $aSchemesDir] } {
3087 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3090 # End folders creation.
3092 # Generating GUID for tookit.
3093 upvar $theGuidsMap aGuidsMap
3094 if { ! [info exists aGuidsMap($theExecutable)] } {
3095 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3098 # Creating xcscheme file for toolkit from template.
3099 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3100 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3101 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3102 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3103 puts $aXcschemeFile $aXcschemeTmpl
3104 close $aXcschemeFile
3106 # Creating xcschememanagement.plist file for toolkit from template.
3107 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3108 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3109 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3110 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3111 puts $aPlistFile $aPlistTmpl