1 # =======================================================================
2 # This script generates project files for different IDEs:
3 # "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd"
6 # genproj -path=D:/occt -target=vc10
7 # genproj -target=xcd -ios -static
8 # =======================================================================
12 switch -exact -- "$tcl_platform(platform)" {
13 "windows" {set targetStation "wnt"}
14 "unix" {set targetStation "lin"}
17 switch -exact -- "$tcl_platform(os)" {
18 "Darwin" {set targetStation "mac"}
21 source "./adm/genconfdeps.tcl"
23 proc _get_options { platform type branch } {
26 if {[file exists "$path/adm/CMPLRS"]} {
27 set fd [open "$path/adm/CMPLRS" rb]
28 set opts [split [read $fd] "\n"]
31 if {[regexp "^${platform} ${type} ${branch} (.+)$" $line dummy res]} {
32 while {[regexp {\(([^\(\)]+) ([^\(\)]+) ([^\(\)]+)\)(.+)} $res dummy p t b oldres]} {
33 set res "[_get_options $p $t $b] $oldres"
41 proc _get_type { name } {
43 if {[file exists "$path/adm/UDLIST"]} {
44 set fd [open "$path/adm/UDLIST" rb]
45 set UDLIST [split [read $fd] "\n"]
47 foreach uitem $UDLIST {
48 set line [split $uitem]
49 if {[lindex $line 1] == "$name"} {
50 return [lindex $line 0]
57 proc _get_used_files { pk {inc true} {src true} } {
59 set type [_get_type $pk]
61 set pk_path "$path/src/$pk"
62 set FILES_path "$path/src/$pk/FILES"
64 if {[file exists $FILES_path]} {
65 set fd [open $FILES_path rb]
66 set FILES [split [read $fd] "\n"]
69 set FILES [lsearch -inline -all -not -exact $FILES ""]
74 if {$inc && ([regexp {([^:\s]*\.[hgl]xx)$} $line dummy name] || [regexp {([^:\s]*\.h)$} $line dummy name]) && [file exists $pk_path/$name]} {
75 lappend lret "pubinclude $name $pk_path/$name"
78 if {[regexp {:} $line]} {
79 regexp {[^:]*:+([^\s]*)} $line dummy line
81 regexp {([^\s]*)} $line dummy line
82 if {$src && [file exists $pk_path/$line]} {
83 lappend lret "source $line $pk_path/$line"
89 # Wrapper-function to generate VS project files
90 proc genproj { args } {
91 global path targetStation
92 set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd" }
95 # Setting default IDE.
97 switch -exact -- "$targetStation" {
98 "wnt" {set anTarget "$::env(VCVER)"}
99 "lin" {set anTarget "amk"}
100 "mac" {set anTarget "xcd"}
103 set isTargetDefault true
104 if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
105 regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
106 set anArgs [removeAllOccurrencesOf -target=* $anArgs]
107 set isTargetDefault false
110 if { [set anIndex [lsearch -nocase $anArgs -path=*]] != -1} {
111 regsub -nocase "\\-path=" [lindex $anArgs $anIndex] "" path
112 set anArgs [removeAllOccurrencesOf -path=* $anArgs]
113 puts "Starting work with \"$path\""
116 if { [llength $anArgs] == 0 && $isTargetDefault == true } {
117 puts "the default \'$anTarget\' target has been applied"
120 set isHelpRequire false
121 if { [lsearch -nocase $anArgs -h] != -1} {
122 set anArgs [removeAllOccurrencesOf -h $anArgs]
123 set isHelpRequire true
127 set isHelpRequire true
130 set aLibType "dynamic"
131 if { [lsearch -nocase $anArgs "-static"] != -1} {
132 set anArgs [removeAllOccurrencesOf "-static" $anArgs]
133 set aLibType "static"
134 puts "static build has been selected"
135 } elseif { [lsearch -nocase $anArgs "-dynamic"] != -1} {
136 set anArgs [removeAllOccurrencesOf "-dynamic" $anArgs]
137 set aLibType "dynamic"
138 puts "dynamic build has been selected"
142 if { [lsearch -nocase $anArgs "-ios"] != -1} {
143 set anArgs [removeAllOccurrencesOf "-ios" $anArgs]
147 if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
148 puts "the \'$anTarget\' is wrong TARGET"
149 set isHelpRequire true
152 if {[llength $anArgs] > 0} {
153 set isHelpRequire true
155 foreach anArg $anArgs {
156 puts "genproj: unrecognized option \'$anArg\'"
160 if { $isHelpRequire == true } {
161 puts "usage: genproj \[ -target=<TARGET> \] \[ -path=<PATH> \]
167 vc8 - Visual Studio 2005
168 vc9 - Visual Studio 2008
169 vc10 - Visual Studio 2010
170 vc11 - Visual Studio 2012
171 vc12 - Visual Studio 2013
178 if {!$isTargetDefault} {
179 puts "the \'$anTarget\' target has been applied"
182 if {"$anTarget" == "amk"} {
183 set targetStation "lin"
185 set anAdmPath "$path/adm"
187 OS:MKPRC "$anAdmPath" "$anTarget" "$aLibType" "$aPlatform"
189 genprojbat "$anAdmPath" "$anTarget"
192 proc genprojbat {thePath theIDE} {
195 set anOsIncPath "$path/src/OS"
196 set anOsRootPath "$path"
198 set aTargetPlatform "lin"
199 if { "$::tcl_platform(platform)" == "windows" } {
200 set aTargetPlatform "wnt"
203 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
204 set aTargetPlatform wnt
205 } elseif {"$theIDE" == "amk"} {
206 set aTargetPlatform lin
207 } elseif {"$theIDE" == "xcd"} {
208 set aTargetPlatform mac
211 set aTargetPlatformExt sh
212 if { "$aTargetPlatform" == "wnt" } {
213 set aTargetPlatformExt bat
216 set aBox [file normalize "$thePath/.."]
218 if {"$theIDE" != "cmake"} {
219 set anEnvTmplFile [open "$path/adm/templates/env.${aTargetPlatformExt}" "r"]
220 set anEnvTmpl [read $anEnvTmplFile]
224 if { [file normalize "$anOsRootPath"] != "$aBox" } {
225 set aCasRoot [relativePath "$aBox" "$anOsRootPath"]
227 set anOsIncPath [relativePath "$aBox" "$anOsRootPath"]
229 regsub -all -- {__CASROOT__} $anEnvTmpl "$aCasRoot" anEnvTmpl
231 set anEnvFile [open "$aBox/env.${aTargetPlatformExt}" "w"]
232 puts $anEnvFile $anEnvTmpl
235 file copy -force -- "$path/adm/templates/draw.${aTargetPlatformExt}" "$aBox/draw.${aTargetPlatformExt}"
238 if {[regexp {(vc)[0-9]*$} $theIDE] == 1} {
239 file copy -force -- "$path/adm/templates/msvc.bat" "$aBox/msvc.bat"
241 switch -exact -- "$theIDE" {
242 "cbp" { file copy -force -- "$path/adm/templates/codeblocks.sh" "$aBox/codeblocks.sh" }
243 "xcd" { file copy -force -- "$path/adm/templates/xcode.sh" "$aBox/xcode.sh" }
248 ###### MSVC #############################################################33
249 proc removeAllOccurrencesOf { theObject theList } {
250 set aSortIndices [lsort -decreasing [lsearch -all -nocase $theList $theObject]]
251 foreach anIndex $aSortIndices {
252 set theList [lreplace $theList $anIndex $anIndex]
257 set aTKNullKey "TKNull"
258 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
260 # Entry function to generate project files and solutions for IDE
261 proc OS:MKPRC { {theOutDir {}} {theIDE ""} {theLibType "dynamic"} {thePlatform ""} } {
262 global path targetStation
263 set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd" }
265 if { [lsearch $aSupportedIDE $theIDE] < 0 } {
266 puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
270 set anOutRoot $theOutDir
271 if { $anOutRoot == "" } {
272 error "Error : \"theOutDir\" is not initialized"
275 # Create output directory
276 set aWokStation "$targetStation"
278 if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12} $theIDE] != -1 } {
279 set aWokStation "msvc"
282 set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
284 # read map of already generated GUIDs
285 set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
286 if [file exists "$aGuidsFilePath"] {
287 set aFileIn [open "$aGuidsFilePath" r]
288 set aFileDataRaw [read $aFileIn]
290 set aFileData [split $aFileDataRaw "\n"]
291 foreach aLine $aFileData {
292 set aLineSplt [split $aLine "="]
293 if { [llength $aLineSplt] == 2 } {
294 set ::THE_GUIDS_LIST([lindex $aLineSplt 0]) [lindex $aLineSplt 1]
299 # make list of modules and platforms
300 set aModules [OS:init]
301 if { "$thePlatform" == "ios" } {
302 set goaway [list Draw]
303 set aModules [osutils:juststation $goaway $aModules]
306 # generate one solution for all projects if complete OS or VAS is processed
307 set anAllSolution "OCCT"
309 wokUtils:FILES:mkdir $anOutDir
310 if { ![file exists $anOutDir] } {
311 puts stderr "Error: Could not create output directory \"$anOutDir\""
315 # create the out dir if it does not exist
316 if (![file isdirectory $path/inc]) {
317 puts "$path/inc folder does not exists and will be created"
318 wokUtils:FILES:mkdir $path/inc
321 # collect all required header files
322 puts "Collecting required header files into $path/inc ..."
323 osutils:collectinc $aModules $path/inc $targetStation
325 # Generating project files for the selected IDE
326 switch -exact -- "$theIDE" {
332 "vc12" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE }
333 "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution }
334 "amk" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
336 set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
337 OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
341 # Store generated GUIDs map
342 set anOutFile [open "$aGuidsFilePath" "w"]
343 fconfigure $anOutFile -translation lf
344 foreach aKey [array names ::THE_GUIDS_LIST] {
345 set aValue $::THE_GUIDS_LIST($aKey)
346 puts $anOutFile "${aKey}=${aValue}"
351 # Function to generate Visual Studio solution and project files
352 proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
354 puts stderr "Generating VS project files for $theVcVer"
356 # generate projects for toolkits and separate solution for each module
357 foreach aModule $theModules {
358 OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
359 OS:vcproj $theVcVer $aModule $theOutDir ::THE_GUIDS_LIST
362 # generate single solution "OCCT" containing projects from all modules
363 if { "$theAllSolution" != "" } {
364 OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
367 puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
370 proc OS:init {{os {}}} {
377 set os $tcl_platform(os)
380 ;# Load list of OCCT modules and their definitions
381 source "$path/src/OS/Modules.tcl"
383 foreach module [OS:Modules] {
384 set f "$path/src/OS/${module}.tcl"
385 if [file exists $f] {
387 lappend Modules $module
389 puts stderr "Definition file for module $module is not found in unit OS"
393 # Load list of products and their definitions
394 # set Products [woklocate -p VAS:source:Products.tcl]
395 #if { "$Products" != "" } {
397 #foreach product [VAS:Products] {
398 #set f [woklocate -p VAS:source:${product}.tcl]
399 #if [file exists $f] {
402 #puts stderr "Definition file for product $product is not found in unit VAS"
410 # topological sort. returns a list { {a h} {b g} {c f} {c h} {d i} } => { d a b c i g f h }
411 proc wokUtils:EASY:tsort { listofpairs } {
412 foreach x $listofpairs {
415 if ![info exists pcnt($e1)] {
418 if ![ info exists pcnt($e2)] {
423 if ![info exists scnt($e1)] {
429 if [info exists slist($e1)] {
437 foreach node [array names pcnt] {
439 if { $pcnt($node) == 0 } {
443 if ![info exists scnt($node)] {
448 for {set front 1} { $front <= $back } { incr front } {
449 lappend res [set node $q($front)]
450 for {set i 1} {$i <= $scnt($node) } { incr i } {
452 set j [expr {$i - 1}]
453 set u [expr { $pcnt([lindex $ll $j]) - 1 }]
454 if { [set pcnt([lindex $ll $j]) $u] == 0 } {
456 set q($back) [lindex $ll $j]
460 if { $back != $nodecnt } {
461 puts stderr "input contains a cycle"
468 proc wokUtils:LIST:Purge { l } {
471 if ![info exist tab($e)] {
479 # Read file pointed to by path
481 # 2. trim = 1 plusieurs blancs => 1 seul blanc
482 # 3. purge= not yet implemented.
483 # 4. emptl= dont process blank lines
484 proc wokUtils:FILES:FileToList { path {sort 0} {trim 0} {purge 0} {emptl 1} } {
485 if ![ catch { set id [ open $path r ] } ] {
487 while {[gets $id line] >= 0 } {
489 regsub -all {[ ]+} $line " " line
492 if { [string length ${line}] != 0 } {
510 # retorn the list of executables in module.
511 proc OS:executable { module } {
513 foreach XXX [${module}:ressources] {
514 if { "[lindex $XXX 1]" == "x" } {
515 lappend lret [lindex $XXX 2]
521 # Topological sort of toolkits in tklm
522 proc osutils:tk:sort { tklm } {
524 foreach tkloc $tklm {
525 set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
527 if { [lsearch $tklm $tkx] != -1 } {
528 lappend tkby2 [list $tkx $tkloc]
530 lappend tkby2 [list $tkloc {}]
535 foreach e [wokUtils:EASY:tsort $tkby2] {
543 # close dependencies of ltk. (full wok pathes of toolkits)
544 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
545 # (locate not performed.)
546 proc osutils:tk:close { ltk } {
550 set ids [LibToLink $dir]
551 set eated [osutils:tk:eatpk $ids]
552 set result [concat $result $eated]
553 set ids [LibToLink $dir]
554 set result [concat $result $ids]
556 foreach file $eated {
557 set kds "$path/src/$file/EXTERNLIB"
558 if { [osutils:tk:eatpk $kds] != {} } {
559 lappend recurse $file
563 if { $recurse != {} } {
564 set result [concat $result [osutils:tk:close $recurse]]
569 proc osutils:tk:eatpk { EXTERNLIB } {
570 set l [wokUtils:FILES:FileToList $EXTERNLIB]
573 if ![regexp -- {(CSF_[^ ]*)} $str csf] {
579 # Define libraries to link using only EXTERNLIB file
581 proc LibToLink {theTKit} {
583 regexp {^.*:([^:]+)$} $theTKit dummy theTKit
584 set type [_get_type $theTKit]
585 if {$type != "t" && $type != "x"} {
589 set anExtLibList [osutils:tk:eatpk "$path/src/$theTKit/EXTERNLIB"]
590 foreach anExtLib $anExtLibList {
591 set aFullPath [LocateRecur $anExtLib]
592 if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
593 lappend aToolkits $anExtLib
598 # Search unit recursively
600 proc LocateRecur {theName} {
602 set theNamePath "$path/src/$theName"
603 if {[file isdirectory $theNamePath]} {
609 proc OS:genGUID { {theIDE "vc"} } {
610 if { "$theIDE" == "vc" } {
611 set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
612 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
613 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
614 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
615 set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]"
616 return "{$p1-$p2-$p3-$p4-$p5}"
618 set p1 "[format %04X [expr { int(rand() * 6536) }]]"
619 set p2 "[format %04X [expr { int(rand() * 6536) }]]"
620 set p3 "[format %04X [expr { int(rand() * 6536) }]]"
621 set p4 "[format %04X [expr { int(rand() * 6536) }]]"
622 set p5 "[format %04X [expr { int(rand() * 6536) }]]"
623 set p6 "[format %04X [expr { int(rand() * 6536) }]]"
624 return "$p1$p2$p3$p4$p5$p6"
628 # collect all include file that required for theModules in theOutDir
629 proc osutils:collectinc {theModules theIncPath theTargetStation} {
632 set aCasRoot [file normalize $path]
633 set anIncPath [file normalize $theIncPath]
635 if {![file isdirectory $aCasRoot]} {
636 puts "OCCT directory is not defined correctly: $aCasRoot"
640 set anUsedToolKits {}
641 foreach aModule $theModules {
642 foreach aToolKit [${aModule}:toolkits] {
643 lappend anUsedToolKits $aToolKit
645 foreach aDependency [LibToLink $aToolKit] {
646 lappend anUsedToolKits $aDependency
649 foreach anExecutable [OS:executable ${aModule}] {
650 lappend anUsedToolKits $anExecutable
652 foreach aDependency [LibToLink $anExecutable] {
653 lappend anUsedToolKits $aDependency
657 lsort -unique $anUsedToolKits
660 foreach anUsedToolKit $anUsedToolKits {
661 set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
663 lsort -unique $anUnits
665 if { [info exists ::env(SHORTCUT_HEADERS)] &&
666 $::env(SHORTCUT_HEADERS) == "true" } {
667 # template preparation
668 if { ![file exists $aCasRoot/adm/templates/header.in] } {
669 puts "template file does not exist: $aCasRoot/adm/templates/header.in"
672 set aHeaderTmpl [wokUtils:FILES:FileToString $aCasRoot/adm/templates/header.in]
674 # relative anIncPath in connection with aCasRoot/src
675 set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
677 # create and copy short-cut header files
678 foreach anUnit $anUnits {
679 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
680 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
681 set aHeaderFileName [file tail $aHeaderFile]
683 regsub -all -- {@OCCT_HEADER_FILE@} $aHeaderTmpl "$aFromBuildIncToSrcPath/$anUnit/$aHeaderFileName" aShortCutHeaderFileContent
685 if {[file exists "$theIncPath/$aHeaderFileName"] && [file readable "$theIncPath/$aHeaderFileName"]} {
686 set fp [open "$theIncPath/$aHeaderFileName" r]
687 set aHeaderContent [read $fp]
691 set aHeaderLenght [expr [string length $aHeaderContent] - 1]
693 if {$aHeaderLenght == [string length $aShortCutHeaderFileContent]} {
694 # remove eof from string
695 set aHeaderContent [string range $aHeaderContent 0 [expr $aHeaderLenght - 1]]
697 if {[string compare $aShortCutHeaderFileContent $aHeaderContent] == 0} {
703 set aShortCutHeaderFile [open "$theIncPath/$aHeaderFileName" "w"]
704 fconfigure $aShortCutHeaderFile -translation lf
705 puts $aShortCutHeaderFile $aShortCutHeaderFileContent
706 close $aShortCutHeaderFile
711 foreach anUnit $anUnits {
712 set aHFiles [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.h"]
713 foreach aHeaderFile [concat [glob -nocomplain -dir $aCasRoot/src/$anUnit "*.\[hgl\]xx"] $aHFiles] {
714 set aHeaderFileName [file tail $aHeaderFile]
716 # copy file only if target does not exist or is older than original
717 set torig [file mtime $aHeaderFile]
718 if { ! [file isfile $anIncPath/$aHeaderFileName] } {
721 set tcopy [file mtime $anIncPath/$aHeaderFileName]
723 if { $tcopy < $torig } {
725 file copy -force $aHeaderFile $anIncPath/$aHeaderFileName
726 } elseif { $tcopy != $torig } {
727 puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aHeaderFile, not changed!"
731 puts "Info: $nbcopied files updated"
735 # Generate header for VS solution file
736 proc osutils:vcsolution:header { vcversion } {
737 if { "$vcversion" == "vc7" } {
739 "Microsoft Visual Studio Solution File, Format Version 8.00\n"
740 } elseif { "$vcversion" == "vc8" } {
742 "Microsoft Visual Studio Solution File, Format Version 9.00\n" \
743 "# Visual Studio 2005\n"
744 } elseif { "$vcversion" == "vc9" } {
746 "Microsoft Visual Studio Solution File, Format Version 10.00\n" \
747 "# Visual Studio 2008\n"
748 } elseif { "$vcversion" == "vc10" } {
750 "Microsoft Visual Studio Solution File, Format Version 11.00\n" \
751 "# Visual Studio 2010\n"
752 } elseif { "$vcversion" == "vc11" } {
754 "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
755 "# Visual Studio 2012\n"
756 } elseif { "$vcversion" == "vc12" } {
758 "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
759 "# Visual Studio 2013\n"
761 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
765 # Returns extension (without dot) for project files of given version of VC
767 proc osutils:vcproj:ext { vcversion } {
768 if { "$vcversion" == "vc7" || "$vcversion" == "vc8" || "$vcversion" == "vc9" } {
770 } elseif { "$vcversion" == "vc10" || "$vcversion" == "vc11" || "$vcversion" == "vc12" } {
773 puts stderr "Error: Visual Studio version $vc is not supported by this function!"
776 # Generate start of configuration section of VS solution file
778 proc osutils:vcsolution:config:begin { vcversion } {
779 if { "$vcversion" == "vc7" } {
782 "\tGlobalSection(SolutionConfiguration) = preSolution\n" \
783 "\t\tDebug = Debug\n" \
784 "\t\tRelease = Release\n" \
785 "\tEndGlobalSection\n" \
786 "\tGlobalSection(ProjectConfiguration) = postSolution\n"
787 } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
788 "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
789 "$vcversion" == "vc12" } {
792 "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n" \
793 "\t\tDebug|Win32 = Debug|Win32\n" \
794 "\t\tRelease|Win32 = Release|Win32\n" \
795 "\t\tDebug|x64 = Debug|x64\n" \
796 "\t\tRelease|x64 = Release|x64\n" \
797 "\tEndGlobalSection\n" \
798 "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n"
800 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
804 # Generate part of configuration section of VS solution file describing one project
806 proc osutils:vcsolution:config:project { vcversion guid } {
807 if { "$vcversion" == "vc7" } {
809 "\t\t$guid.Debug.ActiveCfg = Debug|Win32\n" \
810 "\t\t$guid.Debug.Build.0 = Debug|Win32\n" \
811 "\t\t$guid.Release.ActiveCfg = Release|Win32\n" \
812 "\t\t$guid.Release.Build.0 = Release|Win32\n"
813 } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
814 "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
815 "$vcversion" == "vc12" } {
817 "\t\t$guid.Debug|Win32.ActiveCfg = Debug|Win32\n" \
818 "\t\t$guid.Debug|Win32.Build.0 = Debug|Win32\n" \
819 "\t\t$guid.Release|Win32.ActiveCfg = Release|Win32\n" \
820 "\t\t$guid.Release|Win32.Build.0 = Release|Win32\n" \
821 "\t\t$guid.Debug|x64.ActiveCfg = Debug|x64\n" \
822 "\t\t$guid.Debug|x64.Build.0 = Debug|x64\n" \
823 "\t\t$guid.Release|x64.ActiveCfg = Release|x64\n" \
824 "\t\t$guid.Release|x64.Build.0 = Release|x64\n"
826 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
830 # Generate start of configuration section of VS solution file
832 proc osutils:vcsolution:config:end { vcversion } {
833 if { "$vcversion" == "vc7" } {
835 "\tEndGlobalSection\n" \
836 "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" \
837 "\tEndGlobalSection\n" \
838 "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" \
839 "\tEndGlobalSection\n"
840 } elseif { "$vcversion" == "vc8" || "$vcversion" == "vc9" ||
841 "$vcversion" == "vc10" || "$vcversion" == "vc11" ||
842 "$vcversion" == "vc12" } {
844 "\tEndGlobalSection\n" \
845 "\tGlobalSection(SolutionProperties) = preSolution\n" \
846 "\t\tHideSolutionNode = FALSE\n" \
847 "\tEndGlobalSection\n"
849 puts stderr "Error: Visual Studio version $vcversion is not supported by this function!"
853 # generate Visual Studio solution file
854 # if module is empty, generates one solution for all known modules
856 proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
858 upvar $theGuidsMap aGuidsMap
860 # collect list of projects to be created
863 foreach aModule $theModules {
865 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
866 lappend aProjects $aToolKit
867 lappend aProjectsInModule($aModule) $aToolKit
868 lappend aDependencies [LibToLink $aToolKit]
870 # executables, assume one project per cxx file...
871 foreach aUnit [OS:executable ${aModule}] {
873 set src_files [_get_used_files $aUnit false]
875 foreach s $src_files {
876 regexp {source ([^\s]+)} $s dummy name
877 lappend aSrcFiles $name
879 foreach aSrcFile $aSrcFiles {
880 set aFileExtension [file extension $aSrcFile]
881 if { $aFileExtension == ".cxx" } {
882 set aPrjName [file rootname $aSrcFile]
883 lappend aProjects $aPrjName
884 lappend aProjectsInModule($aModule) $aPrjName
885 if {[file isdirectory $path/src/$aUnitLoc]} {
886 lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
888 lappend aDependencies {}
895 # generate GUIDs for projects (unless already known)
896 foreach aProject $aProjects {
897 if { ! [info exists aGuidsMap($aProject)] } {
898 set aGuidsMap($aProject) [OS:genGUID]
902 # generate solution file
903 # puts "Generating Visual Studio ($theVcVer) solution file for $theSolName ($aProjects)"
904 append aFileBuff [osutils:vcsolution:header $theVcVer]
906 # GUID identifying group projects in Visual Studio
907 set VC_GROUP_GUID "{2150E333-8FDC-42A3-9474-1A3956D46DE8}"
909 # generate group projects -- one per module
910 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
911 foreach aModule $theModules {
912 if { ! [info exists aGuidsMap(_$aModule)] } {
913 set aGuidsMap(_$aModule) [OS:genGUID]
915 set aGuid $aGuidsMap(_$aModule)
916 append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
920 # extension of project files
921 set aProjExt [osutils:vcproj:ext $theVcVer]
923 # GUID identifying C++ projects in Visual Studio
924 set VC_CPP_GUID "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
926 # generate normal projects
927 set aProjsNb [llength $aProjects]
928 for {set aProjId 0} {$aProjId < $aProjsNb} {incr aProjId} {
929 set aProj [lindex $aProjects $aProjId]
930 set aGuid $aGuidsMap($aProj)
931 append aFileBuff "Project(\"${VC_CPP_GUID}\") = \"$aProj\", \"$aProj.${aProjExt}\", \"$aGuid\"\n"
932 # write projects dependencies information (vc7 to vc9)
934 foreach aDepLib [lindex $aDependencies $aProjId] {
935 if { $aDepLib != $aProj && [lsearch $aProjects $aDepLib] != "-1" } {
936 set depGUID $aGuidsMap($aDepLib)
937 append aDepGuids "\t\t$depGUID = $depGUID\n"
940 if { "$aDepGuids" != "" } {
941 append aFileBuff "\tProjectSection(ProjectDependencies) = postProject\n"
942 append aFileBuff "$aDepGuids"
943 append aFileBuff "\tEndProjectSection\n"
945 append aFileBuff "EndProject\n"
948 # generate configuration section
949 append aFileBuff [osutils:vcsolution:config:begin $theVcVer]
950 foreach aProj $aProjects {
951 append aFileBuff [osutils:vcsolution:config:project $theVcVer $aGuidsMap($aProj)]
953 append aFileBuff [osutils:vcsolution:config:end $theVcVer]
955 # write information of grouping of projects by module
956 if { "$theVcVer" != "vc7" && [llength "$theModules"] > 1 } {
957 append aFileBuff " GlobalSection(NestedProjects) = preSolution\n"
958 foreach aModule $theModules {
959 if { ! [info exists aProjectsInModule($aModule)] } { continue }
960 foreach aProject $aProjectsInModule($aModule) {
961 append aFileBuff " $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
964 append aFileBuff " EndGlobalSection\n"
967 # final word (footer)
968 append aFileBuff "EndGlobal"
971 set aFile [open [set fdsw [file join $theOutDir ${theSolName}.sln]] w]
972 fconfigure $aFile -translation crlf
973 puts $aFile $aFileBuff
975 return [file join $theOutDir ${theSolName}.sln]
977 # Generate Visual Studio projects for specified version
979 proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
980 upvar $theGuidsMap aGuidsMap
984 foreach aModule $theModules {
985 foreach aToolKit [${aModule}:toolkits] {
986 lappend aProjectFiles [osutils:vcproj $theVcVer $theOutDir $aToolKit aGuidsMap]
988 foreach anExecutable [OS:executable ${aModule}] {
989 lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
992 return $aProjectFiles
994 # generate template name and load it for given version of Visual Studio and platform
996 proc osutils:vcproj:readtemplate {vc isexec} {
1001 set what "$what executable"
1003 return [osutils:readtemplate $ext "MS VC++ project ($what)"]
1006 proc osutils:readtemplate {ext what} {
1009 set loc "$path/adm/templates/template.$ext"
1010 return [wokUtils:FILES:FileToString $loc]
1012 # Read a file in a string as is.
1014 proc wokUtils:FILES:FileToString { fin } {
1015 if { [catch { set in [ open $fin r ] } errin] == 0 } {
1016 set strin [read $in [file size $fin]]
1023 # List extensions of compilable files in OCCT
1025 proc osutils:compilable { } {
1026 global targetStation
1027 set aWokStation "$targetStation"
1028 if { "$aWokStation" == "mac" } {
1029 return [list .c .cxx .cpp .mm]
1031 return [list .c .cxx .cpp]
1034 proc osutils:commonUsedTK { theToolKit } {
1036 set anUsedToolKits [list]
1037 set aDepToolkits [LibToLink $theToolKit]
1038 foreach tkx $aDepToolkits {
1039 if {[_get_type $tkx] == "t"} {
1040 lappend anUsedToolKits "${tkx}"
1043 return $anUsedToolKits
1046 # Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
1047 proc osutils:tk:csfInExternlib { EXTERNLIB } {
1048 set l [wokUtils:FILES:FileToList $EXTERNLIB]
1051 if [regexp -- {(CSF_[^ ]*)} $str csf] {
1058 # @param theCsfLibsMap - libraries map
1059 # @param theCsfFrmsMap - frameworks map, OS X specific
1060 proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
1061 upvar $theCsfLibsMap aLibsMap
1062 upvar $theCsfFrmsMap aFrmsMap
1067 if { "$theOS" == "wnt" } {
1069 set aLibsMap(CSF_kernel32) "kernel32.lib"
1070 set aLibsMap(CSF_advapi32) "advapi32.lib"
1071 set aLibsMap(CSF_gdi32) "gdi32.lib"
1072 set aLibsMap(CSF_user32) "user32.lib"
1073 set aLibsMap(CSF_glu32) "glu32.lib"
1074 set aLibsMap(CSF_opengl32) "opengl32.lib"
1075 set aLibsMap(CSF_wsock32) "wsock32.lib"
1076 set aLibsMap(CSF_netapi32) "netapi32.lib"
1077 set aLibsMap(CSF_AviLibs) "ws2_32.lib vfw32.lib"
1078 set aLibsMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib"
1080 set aLibsMap(CSF_QT) "QtCore4.lib QtGui4.lib"
1083 set aLibsMap(CSF_VTK) [osutils:vtkCsf "wnt"]
1085 set aLibsMap(CSF_FREETYPE) "freetype"
1086 if { "$theOS" == "mac" } {
1087 set aLibsMap(CSF_objc) "objc"
1088 set aFrmsMap(CSF_Appkit) "Appkit"
1089 set aFrmsMap(CSF_IOKit) "IOKit"
1090 set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
1091 set aFrmsMap(CSF_TclLibs) "Tcl"
1092 set aFrmsMap(CSF_TclTkLibs) "Tk"
1094 set aLibsMap(CSF_ThreadLibs) "pthread rt"
1095 set aLibsMap(CSF_OpenGlLibs) "GLU GL"
1096 set aLibsMap(CSF_TclLibs) "tcl8.6"
1097 set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
1098 set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
1099 set aLibsMap(CSF_MotifLibs) "X11"
1102 # optional 3rd-parties
1103 if { "$::HAVE_TBB" == "true" } {
1104 set aLibsMap(CSF_TBB) "tbb tbbmalloc"
1106 if { "$::HAVE_FREEIMAGE" == "true" } {
1107 set aLibsMap(CSF_FreeImagePlus) "freeimage"
1109 if { "$::HAVE_GL2PS" == "true" } {
1110 set aLibsMap(CSF_GL2PS) "gl2ps"
1112 if { "$::HAVE_VTK" == "true" } {
1113 set aLibsMap(CSF_VTK) [osutils:vtkCsf "unix"]
1118 # Returns string of library dependencies for generation of Visual Studio project or make lists.
1119 proc osutils:vtkCsf {{theOS ""}} {
1123 set aPathSplitter ":"
1125 if {"$theOS" == "wnt"} {
1126 set aPathSplitter ";"
1127 set aLibSuffix ".lib"
1130 set anOptIncs [split $::env(CSF_OPT_INC) "$aPathSplitter"]
1131 foreach anIncItem $anOptIncs {
1132 if {[regexp -- "vtk-(.*)$" [file tail $anIncItem] dummy aFoundVtkVer]} {
1133 set aVtkVer $aFoundVtkVer
1137 set aLibArray [list vtkCommonCore vtkCommonDataModel vtkCommonExecutionModel vtkCommonMath vtkCommonTransforms vtkRenderingCore \
1138 vtkRenderingOpenGL vtkFiltersGeneral vtkIOCore vtkIOImage vtkImagingCore vtkInteractionStyle]
1140 # Additional suffices for the libraries
1142 foreach anItem $aLibArray {
1143 lset aLibArray $anIdx $anItem-$aVtkVer$aLibSuffix
1147 return [join $aLibArray " "]
1150 # @param theLibsList - dependencies (libraries list)
1151 # @param theFrameworks - dependencies (frameworks list, OS X specific)
1152 proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
1154 upvar $theLibsList aLibsList
1155 upvar $theFrameworks aFrameworks
1156 set aLibsList [list]
1157 set aFrameworks [list]
1159 osutils:csfList $theOS aLibsMap aFrmsMap
1161 foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
1162 if [info exists aLibsMap($aCsfElem)] {
1163 foreach aLib [split "$aLibsMap($aCsfElem)"] {
1164 if { [lsearch $aLibsList $aLib] == "-1" } {
1165 lappend aLibsList $aLib
1169 if [info exists aFrmsMap($aCsfElem)] {
1170 foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
1171 if { [lsearch $aFrameworks $aFrm] == "-1" } {
1172 lappend aFrameworks $aFrm
1179 # Returns liste of UD in a toolkit. tkloc is a full path wok.
1180 proc osutils:tk:units { tkloc } {
1183 set PACKAGES "$path/src/$tkloc/PACKAGES"
1184 foreach u [wokUtils:FILES:FileToList $PACKAGES] {
1185 if {[file isdirectory "$path/src/$u"]} {
1190 ;#puts stderr "Warning. No devunit included in $tkloc"
1195 proc osutils:justwnt { listloc } {
1196 # ImageUtility is required for support for old (<6.5.4) versions of OCCT
1197 set goaway [list Xdps Xw ImageUtility WOKUnix]
1198 return [osutils:juststation $goaway $listloc]
1201 # remove from listloc OpenCascade units indesirables on NT
1202 proc osutils:juststation {goaway listloc} {
1205 foreach u $listloc {
1206 if {([file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 )
1207 || (![file isdirectory "$path/src/$u"] && [lsearch $goaway $u] == -1 ) } {
1214 # intersect3 - perform the intersecting of two lists, returning a list containing three lists.
1215 # The first list is everything in the first list that wasn't in the second,
1216 # the second list contains the intersection of the two lists, the third list contains everything
1217 # in the second list that wasn't in the first.
1218 proc osutils:intersect3 {list1 list2} {
1219 set la1(0) {} ; unset la1(0)
1220 set lai(0) {} ; unset lai(0)
1221 set la2(0) {} ; unset la2(0)
1228 foreach elem [concat $list1 $list2] {
1229 if {[info exists la1($elem)] && [info exists la2($elem)]} {
1235 list [lsort [array names la1]] [lsort [array names lai]] [lsort [array names la2]]
1238 # Prepare relative path
1239 proc relativePath {thePathFrom thePathTo} {
1240 if { [file isdirectory "$thePathFrom"] == 0 } {
1244 set aPathFrom [file normalize "$thePathFrom"]
1245 set aPathTo [file normalize "$thePathTo"]
1247 set aCutedPathFrom "${aPathFrom}/dummy"
1248 set aRelatedDeepPath ""
1250 while { "$aCutedPathFrom" != [file normalize "$aCutedPathFrom/.."] } {
1251 set aCutedPathFrom [file normalize "$aCutedPathFrom/.."]
1252 # does aPathTo contain aCutedPathFrom?
1253 regsub -all $aCutedPathFrom $aPathTo "" aPathFromAfterCut
1254 if { "$aPathFromAfterCut" != "$aPathTo" } { # if so
1255 if { "$aCutedPathFrom" == "$aPathFrom" } { # just go higher, for example, ./somefolder/someotherfolder
1256 set aPathTo ".${aPathTo}"
1257 } elseif { "$aCutedPathFrom" == "$aPathTo" } { # remove the last "/"
1258 set aRelatedDeepPath [string replace $aRelatedDeepPath end end ""]
1260 regsub -all $aCutedPathFrom $aPathTo $aRelatedDeepPath aPathToAfterCut
1261 regsub -all "//" $aPathToAfterCut "/" aPathToAfterCut
1262 return $aPathToAfterCut
1264 set aRelatedDeepPath "$aRelatedDeepPath../"
1271 proc wokUtils:EASY:bs1 { s } {
1272 regsub -all {/} $s {\\} r
1276 # Returs for a full path the liste of n last directory part
1278 # n = 2 => dir/file.c
1279 # n = 3 => sdir/dir/file.c
1281 proc wokUtils:FILES:wtail { f n } {
1282 set ll [expr [llength [set lif [file split $f]]] -$n]
1283 return [join [lrange $lif $ll end] /]
1286 # Generate entry for one source file in Visual Studio 10 project file
1287 proc osutils:vcxproj:file { vcversion file params } {
1288 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1289 if { $params != "" } {
1290 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1293 if { $params != "" } {
1294 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1297 if { $params != "" } {
1298 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1301 if { $params != "" } {
1302 append text " <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}] %(AdditionalOptions)</AdditionalOptions>\n"
1305 append text " </ClCompile>\n"
1309 # Generate Visual Studio 2010 project filters file
1310 proc osutils:vcxproj:filters { dir proj theFilesMap } {
1311 upvar $theFilesMap aFilesMap
1314 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1315 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1317 # list of "filters" (units)
1318 append text " <ItemGroup>\n"
1319 append text " <Filter Include=\"Source files\">\n"
1320 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1321 append text " </Filter>\n"
1322 foreach unit $aFilesMap(units) {
1323 append text " <Filter Include=\"Source files\\${unit}\">\n"
1324 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1325 append text " </Filter>\n"
1327 append text " </ItemGroup>\n"
1330 append text " <ItemGroup>\n"
1331 foreach unit $aFilesMap(units) {
1332 foreach file $aFilesMap($unit) {
1333 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1334 append text " <Filter>Source files\\${unit}</Filter>\n"
1335 append text " </ClCompile>\n"
1338 append text " </ItemGroup>\n"
1341 append text "</Project>"
1344 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1345 fconfigure $fp -translation crlf
1349 return ${proj}.vcxproj.filters
1352 # Generate Visual Studio 2011 project filters file
1353 proc osutils:vcx1proj:filters { dir proj theFilesMap } {
1354 upvar $theFilesMap aFilesMap
1357 append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1358 append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
1360 # list of "filters" (units)
1361 append text " <ItemGroup>\n"
1362 append text " <Filter Include=\"Source files\">\n"
1363 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1364 append text " </Filter>\n"
1365 foreach unit $aFilesMap(units) {
1366 append text " <Filter Include=\"Source files\\${unit}\">\n"
1367 append text " <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
1368 append text " </Filter>\n"
1370 append text " </ItemGroup>\n"
1373 append text " <ItemGroup>\n"
1374 foreach unit $aFilesMap(units) {
1375 foreach file $aFilesMap($unit) {
1376 append text " <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
1377 append text " <Filter>Source files\\${unit}</Filter>\n"
1378 append text " </ClCompile>\n"
1381 append text " </ItemGroup>\n"
1383 append text " <ItemGroup>\n"
1384 append text " <ResourceCompile Include=\"${proj}.rc\" />"
1385 append text " </ItemGroup>\n"
1388 append text "</Project>"
1391 set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
1392 fconfigure $fp -translation crlf
1396 return ${proj}.vcxproj.filters
1399 # Generate RC file content for ToolKit from template
1400 proc osutils:readtemplate:rc {theOutDir theToolKit} {
1402 set aLoc "$path/adm/templates/template_dll.rc"
1403 set aBody [wokUtils:FILES:FileToString $aLoc]
1404 regsub -all -- {__TKNAM__} $aBody $theToolKit aBody
1406 set aFile [open "${theOutDir}/${theToolKit}.rc" "w"]
1407 fconfigure $aFile -translation lf
1410 return "${theOutDir}/${theToolKit}.rc"
1413 # Generate Visual Studio project file for ToolKit
1414 proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1415 if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
1417 set l_compilable [osutils:compilable]
1418 regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
1420 upvar $theGuidsMap aGuidsMap
1421 if { ! [info exists aGuidsMap($theToolKit)] } {
1422 set aGuidsMap($theToolKit) [OS:genGUID]
1424 regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
1426 set aCommonUsedTK [list]
1427 foreach tkx [osutils:commonUsedTK $theToolKit] {
1428 lappend aCommonUsedTK "${tkx}.lib"
1431 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1432 set aUsedToolKits [concat $aCommonUsedTK $aLibs]
1434 # correct names of referred third-party libraries that are named with suffix
1435 # depending on VC version
1436 regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
1438 # and put this list to project file
1439 #puts "$theToolKit requires $aUsedToolKits"
1440 if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1441 set aUsedToolKits [join $aUsedToolKits {;}]
1443 regsub -all -- {__TKDEP__} $theProjTmpl $aUsedToolKits theProjTmpl
1445 set anIncPaths "..\\..\\..\\inc"
1447 set aFilesSection ""
1448 set aVcFilesX(units) ""
1449 set listloc [osutils:tk:units $theToolKit]
1450 set resultloc [osutils:justwnt $listloc]
1451 if [array exists written] { unset written }
1452 #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
1453 #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
1454 #puts "\t1 [wokparam -v %CMPLRS_C_Options [w_info -f]] father"
1455 #puts "\t2 [wokparam -v %CMPLRS_C_Options] branch"
1456 set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
1457 set fxloparamfc [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
1459 foreach fxlo $resultloc {
1461 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
1462 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
1463 if {$fxlo_cmplrs_options_cxx == ""} {
1464 set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
1466 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c $fxlo]
1467 if {$fxlo_cmplrs_options_c == ""} {
1468 set fxlo_cmplrs_options_c [_get_options wnt cmplrs_c b]
1470 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx b] $fxlo_cmplrs_options_cxx] 2]"
1471 set fxloparam "$fxloparam [lindex [osutils:intersect3 [_get_options wnt cmplrs_c b] $fxlo_cmplrs_options_c] 2]"
1472 #puts "\t3 [wokparam -v %CMPLRS_CXX_Options] branch CXX "
1473 #puts "\t4 [wokparam -v %CMPLRS_CXX_Options $fxlo] $fxlo CXX"
1474 #puts "\t5 [wokparam -v %CMPLRS_C_Options] branch C"
1475 #puts "\t6 [wokparam -v %CMPLRS_C_Options $fxlo] $fxlo C"
1477 foreach partopt $fxloparam {
1478 if {[string first "-I" $partopt] == "0"} {
1479 # this is an additional includes search path
1482 set needparam "$needparam $partopt"
1485 # Format of projects in vc10 and vc11 is different from vc7-9
1486 if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1487 foreach aSrcFile [lsort $aSrcFiles] {
1488 if { ![info exists written([file tail $aSrcFile])] } {
1489 set written([file tail $aSrcFile]) 1
1490 append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
1492 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1494 if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
1495 lappend aVcFilesX($xlo) $aSrcFile
1498 append aFilesSection "\t\t\t<Filter\n"
1499 append aFilesSection "\t\t\t\tName=\"${xlo}\"\n"
1500 append aFilesSection "\t\t\t\t>\n"
1501 foreach aSrcFile [lsort $aSrcFiles] {
1502 if { ![info exists written([file tail $aSrcFile])] } {
1503 set written([file tail $aSrcFile]) 1
1504 append aFilesSection [osutils:vcproj:file $theVcVer $aSrcFile $needparam]
1506 puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
1509 append aFilesSection "\t\t\t</Filter>\n"
1513 append aTKDefines ";__${xlo}_DLL"
1515 # append anIncPaths ";..\\..\\..\\src\\${xlo}"
1518 regsub -all -- {__TKINC__} $theProjTmpl $anIncPaths theProjTmpl
1519 regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
1520 regsub -all -- {__FILES__} $theProjTmpl $aFilesSection theProjTmpl
1523 set aFile [open [set aVcFiles [file join $theOutDir ${theToolKit}.[osutils:vcproj:ext $theVcVer]]] w]
1524 fconfigure $aFile -translation crlf
1525 puts $aFile $theProjTmpl
1528 # write filters file for vc10 and vc11
1529 if { "$theVcVer" == "vc10" } {
1530 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
1531 } elseif { "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1532 lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
1535 # write resource file
1536 lappend aVcFiles [osutils:readtemplate:rc $theOutDir $theToolKit]
1541 # for a unit returns a map containing all its file in the current
1543 # local = 1 only local files
1544 proc osutils:tk:loadunit { loc map } {
1547 catch { unset TLOC }
1548 set lfiles [_get_used_files $loc]
1553 if [info exists TLOC($t)] {
1564 # Returns the list of all compilable files name in a toolkit, or devunit of any type
1565 # Call unit filter on units name to accept or reject a unit
1566 # Tfiles lists for each unit the type of file that can be compiled.
1567 proc osutils:tk:files { tkloc {l_compilable {} } {justail 1} {unitfilter {}} } {
1569 set Tfiles(source,nocdlpack) {source pubinclude}
1570 set Tfiles(source,toolkit) {}
1571 set Tfiles(source,executable) {source pubinclude}
1572 set listloc [concat [osutils:tk:units $tkloc] $tkloc]
1573 #puts " listloc = $listloc"
1574 if { $l_compilable == {} } {
1575 set l_comp [list .c .cxx .cpp]
1577 set l_comp [$l_compilable]
1579 if { $unitfilter == {} } {
1580 set resultloc $listloc
1582 set resultloc [$unitfilter $listloc]
1585 foreach loc $resultloc {
1586 set utyp [_get_type $loc]
1587 #puts "\"$utyp\" \"$loc\""
1589 "t" { set utyp "toolkit" }
1590 "n" { set utyp "nocdlpack" }
1591 "x" { set utyp "executable" }
1593 if [array exists map] { unset map }
1594 osutils:tk:loadunit $loc map
1595 #puts " loc = $loc === > [array names map]"
1596 set LType $Tfiles(source,${utyp})
1597 foreach typ [array names map] {
1598 if { [lsearch $LType $typ] == -1 } {
1602 foreach type [array names map] {
1604 foreach f $map($type) {
1606 if { [lsearch $l_comp [file extension $f]] != -1 } {
1607 if { $justail == 1 } {
1608 if {$type == "source"} {
1609 if {[lsearch $lret "@top_srcdir@/src/$loc/[file tail $f]"] == -1} {
1610 lappend lret @top_srcdir@/src/$loc/[file tail $f]
1623 # Generate Visual Studio project file for executable
1624 proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
1627 foreach f [osutils:tk:files $theToolKit osutils:compilable 0] {
1628 if { $theProjTmpl == {} } {
1629 set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
1631 set aProjTmpl $theProjTmpl
1633 set aProjName [file rootname [file tail $f]]
1634 set l_compilable [osutils:compilable]
1635 regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
1637 upvar $theGuidsMap aGuidsMap
1638 if { ! [info exists aGuidsMap($aProjName)] } {
1639 set aGuidsMap($aProjName) [OS:genGUID]
1641 regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
1643 set aCommonUsedTK [list]
1644 foreach tkx [osutils:commonUsedTK $theToolKit] {
1645 lappend aCommonUsedTK "${tkx}.lib"
1648 osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
1649 set aUsedToolKits [concat $aCommonUsedTK $aLibs]
1651 # correct names of referred third-party libraries that are named with suffix
1652 # depending on VC version
1653 regsub -all -- {vc[0-9]+} $aUsedToolKits $theVcVer aUsedToolKits
1655 # puts "$aProjName requires $aUsedToolKits"
1656 if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1657 set aUsedToolKits [join $aUsedToolKits {;}]
1659 regsub -all -- {__TKDEP__} $aProjTmpl $aUsedToolKits aProjTmpl
1661 set aFilesSection ""
1662 set aVcFilesX(units) ""
1664 if { ![info exists written([file tail $f])] } {
1665 set written([file tail $f]) 1
1667 if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1668 append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
1669 if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
1670 lappend aVcFilesX($theToolKit) $f
1672 append aFilesSection "\t\t\t<Filter\n"
1673 append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
1674 append aFilesSection "\t\t\t\t>\n"
1675 append aFilesSection [osutils:vcproj:file $theVcVer $f ""]
1676 append aFilesSection "\t\t\t</Filter>"
1679 puts "Warning : in vcproj there are than one occurences for [file tail $f]"
1681 #puts "$aProjTmpl $aFilesSection"
1682 set aTKDefines ";__${theToolKit}_DLL"
1683 set anIncPaths "..\\..\\..\\inc"
1684 regsub -all -- {__TKINC__} $aProjTmpl $anIncPaths aProjTmpl
1685 regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines aProjTmpl
1686 regsub -all -- {__FILES__} $aProjTmpl $aFilesSection aProjTmpl
1687 regsub -all -- {__CONF__} $aProjTmpl Application aProjTmpl
1689 regsub -all -- {__XQTEXT__} $aProjTmpl "exe" aProjTmpl
1691 set aFile [open [set aVcFilePath [file join $theOutDir ${aProjName}.[osutils:vcproj:ext $theVcVer]]] w]
1692 fconfigure $aFile -translation crlf
1693 puts $aFile $aProjTmpl
1696 set aCommonSettingsFile "$aVcFilePath.user"
1697 lappend aVcFiles $aVcFilePath
1699 # write filters file for vc10
1700 if { "$theVcVer" == "vc10" || "$theVcVer" == "vc11" || "$theVcVer" == "vc12" } {
1701 lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
1704 set aCommonSettingsFileTmpl ""
1705 if { "$theVcVer" == "vc9" } {
1706 set aCommonSettingsFileTmpl "$path/adm/templates/vcproj.user.vc9x"
1707 } elseif { "$theVcVer" == "vc10" } {
1708 set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc10x"
1709 } elseif { "$theVcVer" == "vc11" } {
1710 set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc11x"
1711 } elseif { "$theVcVer" == "vc12" } {
1712 set aCommonSettingsFileTmpl "$path/adm/templates/vcxproj.user.vc12x"
1714 if { "$aCommonSettingsFileTmpl" != "" } {
1715 file copy -force -- "$aCommonSettingsFileTmpl" "$aCommonSettingsFile"
1716 lappend aVcFiles "$aCommonSettingsFile"
1722 # Generate entry for one source file in Visual Studio 7 - 9 project file
1723 proc osutils:vcproj:file { theVcVer theFile theOptions } {
1724 append aText "\t\t\t\t<File\n"
1725 append aText "\t\t\t\t\tRelativePath=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
1726 if { $theOptions == "" } {
1727 append aText "\t\t\t\t</File>\n"
1731 append aText "\t\t\t\t\t<FileConfiguration\n"
1732 append aText "\t\t\t\t\t\tName=\"Release\|Win32\">\n"
1733 append aText "\t\t\t\t\t\t<Tool\n"
1734 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1735 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1736 foreach aParam $theOptions {
1737 append aText "$aParam "
1740 append aText "\t\t\t\t\t\t/>\n"
1741 append aText "\t\t\t\t\t</FileConfiguration>\n"
1743 append aText "\t\t\t\t\t<FileConfiguration\n"
1744 append aText "\t\t\t\t\t\tName=\"Debug\|Win32\">\n"
1745 append aText "\t\t\t\t\t\t<Tool\n"
1746 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1747 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1748 foreach aParam $theOptions {
1749 append aText "$aParam "
1752 append aText "\t\t\t\t\t\t/>\n"
1753 append aText "\t\t\t\t\t</FileConfiguration>\n"
1754 if { "$theVcVer" == "vc7" } {
1755 append aText "\t\t\t\t</File>\n"
1759 append aText "\t\t\t\t\t<FileConfiguration\n"
1760 append aText "\t\t\t\t\t\tName=\"Release\|x64\">\n"
1761 append aText "\t\t\t\t\t\t<Tool\n"
1762 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1763 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1764 foreach aParam $theOptions {
1765 append aText "$aParam "
1768 append aText "\t\t\t\t\t\t/>\n"
1769 append aText "\t\t\t\t\t</FileConfiguration>\n"
1771 append aText "\t\t\t\t\t<FileConfiguration\n"
1772 append aText "\t\t\t\t\t\tName=\"Debug\|x64\">\n"
1773 append aText "\t\t\t\t\t\t<Tool\n"
1774 append aText "\t\t\t\t\t\t\tName=\"VCCLCompilerTool\"\n"
1775 append aText "\t\t\t\t\t\t\tAdditionalOptions=\""
1776 foreach aParam $theOptions {
1777 append aText "$aParam "
1780 append aText "\t\t\t\t\t\t/>\n"
1781 append aText "\t\t\t\t\t</FileConfiguration>\n"
1783 append aText "\t\t\t\t</File>\n"
1787 ### AUTOMAKE ###############################################################################
1788 proc OS:MKAMK { theOutDir {theModules {}} theSubPath} {
1790 wokUtils:FILES:mkdir $theOutDir
1792 foreach aModule $theModules {
1793 foreach aToolKit [$aModule:toolkits] {
1794 puts " toolkit: $aToolKit ==> $path/src/$aToolKit/EXTERNLIB"
1795 wokUtils:FILES:rmdir $theOutDir/$aToolKit
1796 wokUtils:FILES:mkdir $theOutDir/$aToolKit
1797 osutils:tk:mkam $theOutDir/$aToolKit $aToolKit
1799 foreach anExecutable [OS:executable $aModule] {
1800 wokUtils:FILES:rmdir $theOutDir/$anExecutable
1801 wokUtils:FILES:mkdir $theOutDir/$anExecutable
1802 osutils:tk:mkamx $theOutDir/$anExecutable $anExecutable
1805 osutils:am:adm $theOutDir $theModules
1806 osutils:am:root $path $theSubPath $theModules
1808 puts "The automake files are stored in the $theOutDir directory"
1811 proc wokUtils:FILES:rmdir { d } {
1813 global tcl_platform tcl_version
1814 regsub -all {\.[^.]*} $tcl_version "" major
1815 if { $major == 8 } {
1816 file delete -force $d
1818 if { "$tcl_platform(platform)" == "unix" } {
1819 catch { exec rm -rf $d}
1827 proc wokUtils:FILES:mkdir { d } {
1829 regsub -all {\.[^.]*} $tcl_version "" major
1830 if { $major == 8 } {
1833 if ![file exists $d] {
1834 if { "[info command mkdir]" == "mkdir" } {
1837 puts stderr "wokUtils:FILES:mkdir : Error unable to find a mkdir command."
1841 if [file exists $d] {
1848 # "Nice letter: %s" { a b c } => {Nice letter: %a} {Nice letter: %b} ..
1849 # as a string without backslash
1850 proc wokUtils:EASY:FmtSimple1 { fmt l {backslh 1} } {
1853 append str [format $fmt $e] "\n"
1855 append str [format $fmt $e]
1861 # edit_last is performed ONCE fmt has been applied.
1862 proc wokUtils:EASY:FmtString2 { fmt l {yes_for_last 0} {edit_last {}} } {
1863 set ldeb [lrange $l 0 [expr [llength $l] -2]]
1864 set last [lrange $l end end]
1866 append str [format $fmt $e $e] " \\" "\n"
1869 if {$edit_last != {} } {
1870 set slast [$edit_last [format $fmt $last $last]]
1872 set slast [format $fmt $last $last]
1875 if { $yes_for_last } {
1876 append str $slast " \\" "\n"
1878 append str $slast "\n"
1884 # { a.x b.c c.v } => { a b c}
1885 proc wokUtils:LIST:sanspoint { l } {
1888 lappend rr [file root $x]
1893 # remove from listloc OpenCascade units indesirables on Unix
1894 proc osutils:justunix { listloc } {
1895 if { "$::tcl_platform(os)" == "Darwin" } {
1896 set goaway [list Xw WNT]
1898 set goaway [list WNT]
1900 return [osutils:juststation $goaway $listloc]
1903 # remove ":" from last item of dependencies list in target VPATH of Makefile.am
1904 proc osutils:am:__VPATH__lastoccur { str } {
1905 if { [regsub {:$} $str "" u] != 0 } {
1910 # ((((((((((((( Formats in Makefile.am )))))))))))))
1911 # Used to replace the string __VPATH__ in Makefile.am
1912 # l is the list of the units in a toolkit.
1913 proc osutils:am:__VPATH__ { l } {
1914 set fmt "@top_srcdir@/src/%s:"
1915 return [wokUtils:EASY:FmtString2 $fmt $l 0 osutils:am:__VPATH__lastoccur]
1918 # Used to replace the string __INCLUDES__ in Makefile.am
1919 # l is the list of packages in a toolkit.
1920 proc osutils:am:__INCLUDES__ { l } {
1921 set fmt "-I@top_srcdir@/src/%s"
1922 return [wokUtils:EASY:FmtString2 $fmt $l]
1925 # Used to replace the string __LIBADD__ in Makefile.am
1926 # l is the toolkit closure list of a toolkit.
1927 proc osutils:am:__LIBADD__ { theIncToolkits {final 0} } {
1930 set aFatherModules ""
1931 set aCurrentWorkBench [file tail $path]
1932 if { $fBranch != "" } {
1933 set fd [open $fBranch/adm/UDLIST rb]
1934 set fileContent [split [read $fd] "\n"]
1936 set ftoolkits [lsearch -all -inline $fileContent "t *"]
1937 foreach ft $ftoolkits {
1938 set aFatherModules "$aFatherModules [string range $ft 2 end]"
1942 foreach aIncToolkit $theIncToolkits {
1943 if { [lsearch [split $aFatherModules " "] $aIncToolkit] != -1} {
1944 append aLibString " \\\n-l$aIncToolkit"
1946 append aLibString " \\\n../$aIncToolkit/lib$aIncToolkit.la"
1952 # Used to replace the string __SOURCES__ in Makefile.am
1953 # l is the list of all compilable files in a toolkit.
1954 proc osutils:am:__SOURCES__ { l } {
1956 return [wokUtils:EASY:FmtString1 $fmt $l]
1959 proc osutils:am:__CXXFLAG__ { l } {
1961 return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCXXOption $l]]
1964 proc osutils:am:PkCXXOption { ppk } {
1966 #puts "\t 1 [lindex [wokparam -e %CMPLRS_CXX_Options [wokcd]] 0]"
1967 set CXXCOMMON [_get_options lin cmplrs_cxx b]
1968 #puts "\t 2 [wokparam -v %CMPLRS_CXX_Options [w_info -f]]"
1969 #puts "\t 3 [wokparam -v %CMPLRS_CXX_Options]"
1970 set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_cxx f]] [split [_get_options lin cmplrs_cxx b]] ] 2]"
1973 if {![file isdirectory $path/src/$pk]} {
1976 set src_files [_get_used_files $pk false]
1977 set only_src_files {}
1978 foreach s $src_files {
1979 regexp {source ([^\s]+)} $s dummy name
1980 lappend only_src_files $name
1982 if {[lsearch $only_src_files ${pk}_CMPLRS.edl] != "-1"} {
1983 set pk_cmplrs_cxx [_get_options lin cmplrs_cxx $pk]
1984 if {$pk_cmplrs_cxx == ""} {
1985 set pk_cmplrs_cxx [_get_options lin cmplrs_cxx b]
1987 set CXXStr $pk_cmplrs_cxx
1988 #puts "\t 4 [wokparam -e %CMPLRS_CXX_Options [woklocate -u $pk]] $pk"
1989 set LastIndex [expr {[string length $CXXCOMMON ] - 1}]
1990 if {[string equal $CXXCOMMON [string range $CXXStr 0 $LastIndex]]} {
1993 set CXXOption [string range $CXXStr 0 [expr {[string last $CXXCOMMON $CXXStr] - 1}]]
1995 if {$CXXOption != " " && $CXXOption != "" && $CXXOption != " " && $CXXOption != " "} {
1996 set FoundList [split $CXXOption " "]
1997 foreach elem $FoundList {
1999 if {[string first "-I" $elem] == "-1" } {
2000 if {[string first $elem $FoundFlag] == "-1"} {
2001 set FoundFlag "$FoundFlag $elem"
2012 # Create in dir the Makefile.am associated with toolkit tkloc.
2013 # Returns the full path of the created file.
2014 proc osutils:tk:mkam { dir tkloc } {
2016 set pkgs $path/src/${tkloc}/PACKAGES
2017 if { ![file exists $pkgs] } {
2018 puts stderr "osutils:tk:mkam : Error. File PACKAGES not found for toolkit $tkloc."
2022 set tmplat [osutils:readtemplate mam "Makefile.am"]
2023 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
2024 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2025 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2026 set lobj [wokUtils:LIST:sanspoint $lsrc]
2028 set lcsf [osutils:tk:csfInExternlib $path/src/${tkloc}/EXTERNLIB]
2033 if { $lcsf != {} } {
2035 set fmtinc "\$(%s_INCLUDES) "
2036 set fmtlib "\$(%s_LIB) "
2037 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2038 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2041 regsub -all -- {__TKNAM__} $tmplat $tkloc tmplat
2042 set vpath [osutils:am:__VPATH__ $lpkgs]
2043 regsub -all -- {__VPATH__} $tmplat $vpath tmplat
2044 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2045 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2046 if { $close != {} } {
2047 set libadd [osutils:am:__LIBADD__ $close $final]
2051 regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
2052 set source [osutils:am:__SOURCES__ $lsrc]
2053 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2054 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2055 set CXXFl [osutils:am:__CXXFLAG__ $lpkgs]
2056 regsub -all -- {__CXXFLAG__} $tmplat $CXXFl tmplat
2057 set CFl [osutils:am:__CFLAG__ $lpkgs]
2058 regsub -all -- {__CFLAG__} $tmplat $CFl tmplat
2060 regsub -all -- {__EXTERNLIB__} $tmplat $externlib tmplat
2062 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2066 # Write a string in a file
2067 proc wokUtils:FILES:StringToFile { str path } {
2068 if { [catch { set out [ open $path w ] } errout] == 0 } {
2069 puts -nonewline $out $str
2077 # Create in dir the Makefile.am associated with toolkit tkloc.
2078 # Returns the full path of the created file.
2079 proc osutils:tk:mkamx { dir tkloc } {
2081 set src_files [_get_used_files $tkloc false]
2082 set only_src_files {}
2083 foreach s $src_files {
2084 regexp {source ([^\s]+)} $s dummy name
2085 lappend only_src_files $name
2087 if { [lsearch $only_src_files ${tkloc}_WOKSteps.edl] != "-1"} {
2088 set pkgs "$path/src/${tkloc}/EXTERNLIB"
2089 if { $pkgs == {} } {
2090 puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
2093 set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
2094 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2095 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2096 set lobj [wokUtils:LIST:sanspoint $lsrc]
2098 foreach SourceFile $only_src_files {
2099 if {[file extension $SourceFile] == ".cxx"} {
2100 lappend CXXList [file rootname $SourceFile]
2103 set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
2104 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
2106 #set lcsf [osutils:tk:csfInExternlib [woklocate -p ${tkloc}:source:EXTERNLIB [wokcd]]]
2110 foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
2111 if {[lsearch $lcsf $element] == "-1"} {
2112 set lcsf [concat $lcsf $element]
2119 if { $lcsf != {} } {
2121 set fmtinc "\$(%s_INCLUDES) "
2122 set fmtlib "\$(%s_LIB) "
2123 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2124 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2126 regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
2127 set tmplat "$tmplat \nlib_LTLIBRARIES="
2128 foreach entity $CXXList {
2129 set tmplat "$tmplat lib${entity}.la"
2131 set tmplat "$tmplat\n"
2132 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2133 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2134 if { $pkgs != {} } {
2135 set libadd [osutils:am:__LIBADD__ $pkgs $final]
2139 regsub -all -- {__LIBADD__} $tmplat $libadd tmplat
2140 set source [osutils:am:__SOURCES__ $CXXList]
2141 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2142 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2143 foreach entity $CXXList {
2144 set tmplat "$tmplat lib${entity}_la_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
2146 foreach entity $CXXList {
2147 set tmplat "$tmplat lib${entity}_la_LIBADD = $libadd $externlib \n"
2149 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2156 set pkgs "$path/src/${tkloc}/EXTERNLIB"
2157 if { $pkgs == {} } {
2158 puts stderr "osutils:tk:mkamx : Error. File EXTERNLIB not found for executable $tkloc."
2161 set tmplat [osutils:readtemplate mamx "Makefile.am (executable)"]
2162 set close [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
2163 set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
2164 set lobj [wokUtils:LIST:sanspoint $lsrc]
2166 foreach SourceFile $only_src_files {
2167 if {[file extension $SourceFile] == ".cxx"} {
2168 lappend CXXList [file rootname $SourceFile]
2171 set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
2172 set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
2173 set lcsf [osutils:tk:csfInExternlib "$path/src/${tkloc}/EXTERNLIB"]
2177 foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
2178 if {[lsearch $lcsf $element] == "-1"} {
2179 set lcsf [concat $lcsf $element]
2186 if { $lcsf != {} } {
2188 set fmtinc "\$(%s_INCLUDES) "
2189 set fmtlib "\$(%s_LIB) "
2190 set externinc [wokUtils:EASY:FmtSimple1 $fmtinc $lcsf 0]
2191 set externlib [wokUtils:EASY:FmtSimple1 $fmtlib $lcsf 0]
2193 regsub -all -- {__XQTNAM__} $tmplat $tkloc tmplat
2194 set tmplat "$tmplat \nbin_PROGRAMS="
2195 foreach entity $CXXList {
2196 set tmplat "${tmplat} ${entity}"
2199 set tmplat "${tmplat}\n"
2200 set inclu [osutils:am:__INCLUDES__ $lpkgs]
2201 regsub -all -- {__INCLUDES__} $tmplat $inclu tmplat
2202 if { $pkgs != {} } {
2203 set libadd [osutils:am:__LIBADD__ $pkgs $final]
2207 set source [osutils:am:__SOURCES__ $CXXList]
2208 regsub -all -- {__SOURCES__} $tmplat $source tmplat
2209 regsub -all -- {__EXTERNINC__} $tmplat $externinc tmplat
2210 foreach entity $CXXList {
2211 set tmplat "$tmplat ${entity}_SOURCES = @top_srcdir@/src/${tkloc}/${entity}.cxx \n"
2213 foreach entity $CXXList {
2214 set tmplat "$tmplat ${entity}_LDADD = $libadd $externlib \n"
2216 wokUtils:FILES:StringToFile $tmplat [set fmam [file join $dir Makefile.am]]
2222 # Create in dir the Makefile.am in $dir directory.
2223 # Returns the full path of the created file.
2224 proc osutils:am:adm { dir {lesmodules {}} } {
2225 set amstring "srcdir = @srcdir@\n\n"
2226 set subdirs "SUBDIRS ="
2227 set vpath "VPATH = @srcdir@ ${dir}: "
2230 foreach theModule $lesmodules {
2231 set units [osutils:tk:sort [$theModule:toolkits]]
2232 set units [concat $units [OS:executable $theModule]]
2233 append amstring "${theModule}_PKGS ="
2235 foreach unit $units {
2236 append amstring " ${unit}"
2237 append vpath "${dir}/${unit}: "
2240 if { [info procs ${theModule}:alias] != "" } {
2241 set up [${theModule}:alias]
2243 set up [string toupper ${up}]
2244 append amstring "\n\nif ENABLE_${up}\n"
2245 append amstring " ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
2246 append amstring "else\n"
2247 append amstring " ${theModule}_DIRS = \n"
2248 append amstring "endif\n\n"
2249 append subdirs " \$(${theModule}_DIRS)"
2250 append make "${theModule}:\n"
2251 append make "\tfor d in \$(${theModule}_PKGS); do \\\n"
2252 append make "\t\tcd \$\$d; \$(MAKE) \$(AM_MAKEFLAGS) lib\$\$d.la; cd ..; \\\n"
2253 append make "\tdone\n\n"
2254 append phony " ${theModule}"
2256 append amstring "$subdirs\n\n"
2257 append amstring "$vpath\n\n"
2258 append amstring $make
2259 append amstring $phony
2260 wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
2264 # retourne la liste de dependances de module.
2265 proc OS:lsdep { m } {
2267 set l [${m}:depends]
2269 set res [concat $res $l]
2271 set res [concat $res [OS:lsdep ${h}]]
2277 # Create in dir the Makefile.am and configure.ac in CASROOT directory.
2278 # Returns the full path of the created file.
2279 proc osutils:am:root { dir theSubPath {lesmodules {}} } {
2281 set amstring "srcdir = @srcdir@\n\n"
2282 append amstring "SUBDIRS = ${theSubPath}\n\n"
2283 append amstring "VPATH = @srcdir@ @top_srcdir@/${theSubPath}: @top_srcdir@/${theSubPath}:\n\n"
2287 set acstring [osutils:readtemplate ac "Makefile.am"]
2294 set exelocal "install-exec-local:\n"
2295 append exelocal "\t"
2296 append exelocal {$(INSTALL) -d $(prefix)/$(platform)}
2297 append exelocal "\n"
2298 foreach d {bin lib} {
2299 append exelocal "\t"
2300 append exelocal "if \[ -e \$(prefix)/${d} -a ! -e \$(prefix)/\$(platform)/${d} \]; then \\\n"
2301 append exelocal "\t\tcd \$(prefix)/\$(platform) && ln -s ../${d} ${d}; \\\n"
2302 append exelocal "\tfi\n"
2304 append exelocal "\t"
2305 append exelocal {buildd=`pwd`; cd $(top_srcdir); sourced=`pwd`; cd $(prefix); installd=`pwd`; cd $$buildd;}
2306 append exelocal " \\\n"
2307 append exelocal "\t"
2308 append exelocal {if [ "$$installd" != "$$sourced" ]; then}
2309 append exelocal " \\\n"
2310 append exelocal "\t\t"
2311 append exelocal {$(INSTALL) -d $(prefix)/src;}
2312 append exelocal " \\\n"
2313 append exelocal "\t\t"
2314 append exelocal {cp -frL $(top_srcdir)/src $(prefix);}
2315 append exelocal " \\\n"
2316 append exelocal "\t\t"
2317 append exelocal {cp -frL $$buildd/config.h $(prefix);}
2318 append exelocal " \\\n"
2319 append exelocal "\t\tfor d in "
2321 foreach theModule $lesmodules {
2322 append amstring "${theModule}_PKGS ="
2323 foreach r [${theModule}:ressources] {
2324 if { "[lindex $r 1]" == "r" } {
2325 append amstring " [lindex $r 2]"
2329 if { [info procs ${theModule}:alias] != "" } {
2330 set up [${theModule}:alias]
2332 set up [string toupper ${up}]
2333 set lower ${theModule}
2334 if { [info procs ${theModule}:alias] != "" } {
2335 set lower [${theModule}:alias]
2337 set lower [string tolower ${lower}]
2339 append amstring "\n\nif ENABLE_${up}\n"
2340 append amstring " ${theModule}_DIRS = \$(${theModule}_PKGS)\n"
2341 append amstring "else\n"
2342 append amstring " ${theModule}_DIRS = \n"
2343 append amstring "endif\n\n"
2344 append amstring "${theModule}:\n"
2345 append amstring "\tcd \$(top_builddir)/${theSubPath} && \$(MAKE) \$(AM_MAKEFLAGS) ${theModule}\n\n"
2346 append phony " ${theModule}"
2348 append exelocal " \$(${theModule}_DIRS)"
2350 append enablestr "AC_ARG_ENABLE(\[${lower}\],\n"
2351 append enablestr " \[AS_HELP_STRING(\[--disable-${lower}\],\[Disable ${theModule} components\])\],\n"
2352 append enablestr " \[ENABLE_${up}=\${enableval}\],\[ENABLE_${up}=yes\])\n"
2354 set deplist [OS:lsdep ${theModule}]
2356 if { [info procs ${theModule}:acdepends] != "" } {
2357 set acdeplist [${theModule}:acdepends]
2360 if { [llength $deplist] > 0 || [llength $acdeplist] > 0} {
2361 append confstr "if test \"xyes\" = \"x\$ENABLE_${up}\"; then\n"
2363 append confstr "if test \"xyes\" != \"x\$ENABLE_${up}\"; then\n"
2365 foreach dep $deplist {
2367 if { [info procs ${dep}:alias] != "" } {
2368 set dup [${dep}:alias]
2370 set dup [string toupper ${dup}]
2371 append confstr " if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$ENABLE_${dup}\"; then\n"
2372 append confstr " AC_MSG_NOTICE(\[Disabling ${theModule}: not building ${dep} component\])\n"
2373 append confstr " DISABLE_${up}_REASON=\"(${dep} component disabled)\"\n"
2374 append confstr " ENABLE_${up}=no\n"
2375 append confstr " fi\n"
2377 foreach dep $acdeplist {
2378 append confstr " if test \"xyes\" = \"x\$ENABLE_${up}\" -a \"xyes\" != \"x\$HAVE_${dep}\"; then\n"
2379 append confstr " AC_MSG_NOTICE(\[Disabling ${theModule}: ${dep} not found\])\n"
2380 append confstr " DISABLE_${up}_REASON=\"(${dep} not found)\"\n"
2381 append confstr " ENABLE_${up}=no\n"
2382 append confstr " fi\n"
2384 if { [llength $deplist] > 0 || [llength $acdeplist] > 0 } {
2385 append confstr "else\n"
2387 append confstr " DISABLE_${up}_REASON=\"(Disabled)\"\n"
2388 append confstr "fi\n"
2390 append condstr "AM_CONDITIONAL(\[ENABLE_${up}\], \[test \"xyes\" = \"x\$ENABLE_${up}\"\])\n"
2391 append repstr [format "echo \"%-*s \$ENABLE_${up} \$DISABLE_${up}_REASON\"" 26 ${theModule}]
2394 set units [$theModule:toolkits]
2395 set units [concat $units [OS:executable $theModule]]
2396 foreach unit $units {
2397 append acconfstr "${theSubPath}/${unit}/Makefile \\\n"
2401 append exelocal "; do \\\n"
2402 append exelocal "\t\t\t"
2403 append exelocal {$(INSTALL) -d $(prefix)/src/$$d;}
2404 append exelocal " \\\n"
2405 append exelocal "\t\t\t"
2406 append exelocal {cp -frL $(top_srcdir)/src/$$d $(prefix)/src;}
2407 append exelocal " \\\n"
2408 append exelocal "\t\tdone; \\\n"
2409 append exelocal "\tfi\n"
2410 append exelocal "\t"
2411 append exelocal {if [ -e $(prefix)/src/config.h ]; then}
2412 append exelocal " \\\n"
2413 append exelocal "\t\t"
2414 append exelocal {unlink $(prefix)/src/config.h;}
2415 append exelocal " \\\n"
2416 append exelocal "\tfi\n"
2417 append exelocal "\t"
2418 append exelocal {cd $(prefix)/src && ln -s ../config.h config.h}
2419 append exelocal "\n"
2420 append exelocal "\t"
2421 append exelocal {cd $(top_srcdir) && cp *.sh $(prefix)}
2422 append exelocal "\n"
2423 append exelocal "\n"
2425 append amstring $exelocal
2426 append amstring $phony
2428 regsub -all -- {__ENABLEMODULES__} $acstring $enablestr acstring
2429 regsub -all -- {__CONFMODULES__} $acstring $confstr acstring
2430 regsub -all -- {__CONDMODULES__} $acstring $condstr acstring
2431 regsub -all -- {__REPMODULES__} $acstring $repstr acstring
2432 regsub -all -- {__ACCONFMODULES__} $acstring $acconfstr acstring
2434 wokUtils:FILES:StringToFile $amstring [set fmam [file join $dir Makefile.am]]
2435 wokUtils:FILES:StringToFile $acstring [set fmam [file join $dir configure.ac]]
2436 file copy -force -- [file join $path/adm/templates build_configure] [file join $dir build_configure]
2437 file copy -force -- [file join $path/adm/templates acinclude.m4] [file join $dir acinclude.m4]
2438 file copy -force -- [file join $path/adm/templates custom.sh.in] [file join $dir custom.sh.in]
2442 proc wokUtils:EASY:FmtString1 { fmt l {yes_for_last 0} {edit_last {}} } {
2443 set ldeb [lrange $l 0 [expr [llength $l] -2]]
2444 set last [lrange $l end end]
2446 append str [format $fmt $e] " \\" "\n"
2449 if {$edit_last != {} } {
2450 set slast [$edit_last [format $fmt $last]]
2452 set slast [format $fmt $last]
2455 if { $yes_for_last } {
2456 append str $slast " \\" "\n"
2458 append str $slast "\n"
2463 # Used to replace the string __CFLAG__ in Makefile.am
2464 # l is the list of all compilable files in a toolkit.
2465 proc osutils:am:__CFLAG__ { l } {
2467 return [wokUtils:EASY:FmtString1 $fmt [osutils:am:PkCOption $l]]
2470 proc osutils:am:PkCOption { ppk } {
2473 #puts "\t 5 [lindex [wokparam -e %CMPLRS_C_Options [wokcd]] 0]"
2474 set CCOMMON [_get_options lin cmplrs_c b]
2475 #puts "\t 6 [lindex [wokparam -v %CMPLRS_C_Options [w_info -f]] 0]"
2476 set FoundFlag "[lindex [osutils:intersect3 [split [_get_options lin cmplrs_c f]] [split [_get_options lin cmplrs_c b]]] 2]"
2478 if {![file isdirectory $path/src/$pk]} {
2481 set src_files [_get_used_files $pk false]
2482 set only_src_files {}
2483 foreach s $src_files {
2484 regexp {source ([^\s]+)} $s dummy name
2485 lappend only_src_files $name
2487 if {[lsearch $src_files ${pk}_CMPLRS.edl] != "-1"} {
2488 #puts "\t 7 [lindex [wokparam -e %CMPLRS_C_Options [woklocate -u $pk]] 0] $pk"
2489 set aPkList [split "[_get_options lin cmplrs_c $pk]" " "]
2490 set aCcomList [split "$CCOMMON" " "]
2492 foreach aPkItem $aPkList {
2493 if { [lsearch aCcomList $aPkItem] != -1 } {
2494 if {[string first "-I" $aPkItem] == "-1" } {
2495 set FoundFlag "$FoundFlag $aPkItem"
2504 proc osutils:tksrcfiles { theUnits theRelatedPath {theCompatible {}} } {
2505 set aTKSrcFiles [list]
2507 if [array exists written] { unset written }
2508 foreach anUnit $theUnits {
2510 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
2512 if { $theCompatible != {} } {
2513 set aSrcFiles [osutils:tk:files $xlo $theCompatible 0]
2516 foreach aSrcFile [lsort $aSrcFiles] {
2517 if { ![info exists written([file tail $aSrcFile])] } {
2518 set written([file tail $aSrcFile]) 1
2519 lappend aTKSrcFiles "${theRelatedPath}/[wokUtils:FILES:wtail $aSrcFile 3]"
2521 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2529 proc osutils:mm_compilable { } {
2533 proc osutils:tkdefs { theUnits } {
2534 set aTKDefines [list]
2536 foreach anUnit $theUnits {
2537 lappend aTKDefines "__${anUnit}_DLL"
2543 proc osutils:fileGroupName { theSrcFile } {
2544 set path [file dirname [file normalize ${theSrcFile}]]
2545 regsub -all [file normalize "${path}/.."] ${path} "" aGroupName
2551 ####### CODEBLOCK ###################################################################
2552 # Function to generate Code Blocks workspace and project files
2553 proc OS:MKCBP { theOutDir {theModules {}} {theAllSolution ""} } {
2554 puts stderr "Generating project files for Code Blocks"
2556 # Generate projects for toolkits and separate workspace for each module
2557 foreach aModule $theModules {
2558 OS:cworkspace $aModule $aModule $theOutDir
2559 OS:cbp $aModule $theOutDir
2562 # Generate single workspace "OCCT" containing projects from all modules
2563 if { "$theAllSolution" != "" } {
2564 OS:cworkspace $theAllSolution $theModules $theOutDir
2567 puts "The Code Blocks workspace and project files are stored in the $theOutDir directory"
2570 # Generate Code Blocks projects
2571 proc OS:cbp { theModules theOutDir } {
2572 set aProjectFiles {}
2573 foreach aModule $theModules {
2574 foreach aToolKit [${aModule}:toolkits] {
2575 lappend aProjectFiles [osutils:cbptk $theOutDir $aToolKit ]
2577 foreach anExecutable [OS:executable ${aModule}] {
2578 lappend aProjectFiles [osutils:cbpx $theOutDir $anExecutable]
2581 return $aProjectFiles
2584 # Generate Code::Blocks project file for ToolKit
2585 proc osutils:cbptk { theOutDir theToolKit } {
2586 set aUsedToolKits [list]
2587 set aFrameworks [list]
2588 set anIncPaths [list]
2589 set aTKDefines [list]
2590 set aTKSrcFiles [list]
2592 osutils:tkinfo "../../.." $theToolKit aUsedToolKits aFrameworks anIncPaths aTKDefines aTKSrcFiles
2594 return [osutils:cbp $theOutDir $theToolKit $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines]
2597 # Generates Code Blocks workspace.
2598 proc OS:cworkspace { theSolName theModules theOutDir } {
2600 set aWsFilePath "${theOutDir}/${theSolName}.workspace"
2601 set aFile [open $aWsFilePath "w"]
2603 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2604 puts $aFile "<CodeBlocks_workspace_file>"
2605 puts $aFile "\t<Workspace title=\"${theSolName}\">"
2607 # collect list of projects to be created
2608 foreach aModule $theModules {
2610 foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
2611 set aDependencies [LibToLink $aToolKit]
2612 if { [llength $aDependencies] == 0 } {
2613 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
2615 puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" >"
2616 foreach aDepTk $aDependencies {
2617 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2619 puts $aFile "\t\t</Project>"
2623 # executables, assume one project per cxx file...
2624 foreach aUnit [OS:executable ${aModule}] {
2626 set src_files [_get_used_files $aUnit false]
2628 foreach s $src_files {
2629 regexp {source ([^\s]+)} $s dummy name
2630 lappend aSrcFiles $name
2632 foreach aSrcFile $aSrcFiles {
2633 set aFileExtension [file extension $aSrcFile]
2634 if { $aFileExtension == ".cxx" } {
2635 set aPrjName [file rootname $aSrcFile]
2636 set aDependencies [list]
2637 if {[file isdirectory $path/src/$aUnitLoc]} {
2638 set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
2640 set anActiveState ""
2641 if { $isActiveSet == 0 } {
2642 set anActiveState " active=\"1\""
2645 if { [llength $aDependencies] == 0 } {
2646 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}/>"
2648 puts $aFile "\t\t<Project filename=\"${aPrjName}.cbp\"${anActiveState}>"
2649 foreach aDepTk $aDependencies {
2650 puts $aFile "\t\t\t<Depends filename=\"${aDepTk}.cbp\" />"
2652 puts $aFile "\t\t</Project>"
2659 puts $aFile "\t</Workspace>"
2660 puts $aFile "</CodeBlocks_workspace_file>"
2666 # Generate Code::Blocks project file for Executable
2667 proc osutils:cbpx { theOutDir theToolKit } {
2668 global path targetStation
2669 set aWokStation "$targetStation"
2670 set aWokArch "$::env(ARCH)"
2673 foreach aSrcFile [osutils:tk:files $theToolKit osutils:compilable 0] {
2674 # collect list of referred libraries to link with
2675 set aUsedToolKits [list]
2676 set aFrameworks [list]
2677 set anIncPaths [list]
2678 set aTKDefines [list]
2679 set aTKSrcFiles [list]
2680 set aProjName [file rootname [file tail $aSrcFile]]
2682 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedToolKits aFrameworks
2683 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
2684 foreach tkx $aDepToolkits {
2685 if {[_get_type $tkx] == "t"} {
2686 lappend aUsedToolKits "${tkx}"
2688 if {[lsearch [glob -tails -directory "$path/src" -types d *] $tkx] == "-1"} {
2689 lappend aUsedToolKits "${tkx}"
2693 set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
2694 if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
2695 set isExecutable "false"
2697 set isExecutable "true"
2700 if { ![info exists written([file tail $aSrcFile])] } {
2701 set written([file tail $aSrcFile]) 1
2702 lappend aTKSrcFiles $aSrcFile
2704 puts "Warning : in cbp there are more than one occurences for [file tail $aSrcFile]"
2707 # macros for correct DLL exports
2708 if { "$aWokStation" == "wnt" } {
2709 lappend aTKDefines "__${theToolKit}_DLL"
2712 # common include paths
2713 lappend anIncPaths "../../../inc"
2716 lappend aTKDefines "CSFDB"
2717 if { "$aWokStation" == "wnt" } {
2718 lappend aTKDefines "WNT"
2719 lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
2721 if { "$aWokStation" == "lin" } {
2722 lappend aTKDefines "LIN"
2724 lappend aTKDefines "OCC_CONVERT_SIGNALS"
2725 #lappend aTKDefines "_GNU_SOURCE=1"
2728 lappend aCbpFiles [osutils:cbp $theOutDir $aProjName $aTKSrcFiles $aUsedToolKits $aFrameworks $anIncPaths $aTKDefines $isExecutable]
2734 proc osutils:optinal_libs { } {
2735 return [list tbb.lib tbbmalloc.lib FreeImage.lib FreeImagePlus.lib gl2ps.lib]
2738 # This function intended to generate Code::Blocks project file
2739 # @param theOutDir - output directory to place project file
2740 # @param theProjName - project name
2741 # @param theSrcFiles - list of source files
2742 # @param theLibsList - dependencies (libraries list)
2743 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2744 # @param theIncPaths - header search paths
2745 # @param theDefines - compiler macro definitions
2746 # @param theIsExe - flag to indicate executable / library target
2747 proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
2748 global targetStation
2749 set aWokStation "$targetStation"
2750 set aWokArch "$::env(ARCH)"
2752 set aCbpFilePath "${theOutDir}/${theProjName}.cbp"
2753 set aFile [open $aCbpFilePath "w"]
2754 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>"
2755 puts $aFile "<CodeBlocks_project_file>"
2756 puts $aFile "\t<FileVersion major=\"1\" minor=\"6\" />"
2757 puts $aFile "\t<Project>"
2758 puts $aFile "\t\t<Option title=\"$theProjName\" />"
2759 puts $aFile "\t\t<Option pch_mode=\"2\" />"
2760 if { "$aWokStation" == "wnt" } {
2761 puts $aFile "\t\t<Option compiler=\"msvc8\" />"
2763 puts $aFile "\t\t<Option compiler=\"gcc\" />"
2765 puts $aFile "\t\t<Build>"
2767 # Release target configuration
2768 puts $aFile "\t\t\t<Target title=\"Release\">"
2769 if { "$theIsExe" == "true" } {
2770 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2771 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2773 if { "$aWokStation" == "wnt" } {
2774 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2776 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2778 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2780 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
2781 if { "$aWokStation" == "wnt" } {
2782 puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
2784 puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
2786 puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
2787 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2789 # compiler options per TARGET (including defines)
2790 puts $aFile "\t\t\t\t<Compiler>"
2791 if { "$aWokStation" == "wnt" } {
2792 puts $aFile "\t\t\t\t\t<Add option=\"-MD\" />"
2793 puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
2794 puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
2795 puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
2796 puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
2797 puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
2799 puts $aFile "\t\t\t\t\t<Add option=\"-O2\" />"
2800 puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
2801 puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
2802 puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
2803 puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
2805 foreach aMacro $theDefines {
2806 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2808 puts $aFile "\t\t\t\t\t<Add option=\"-DNDEBUG\" />"
2809 puts $aFile "\t\t\t\t\t<Add option=\"-DNo_Exception\" />"
2811 puts $aFile "\t\t\t\t</Compiler>"
2813 puts $aFile "\t\t\t\t<Linker>"
2814 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
2815 if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
2816 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2818 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
2819 puts $aFile "\t\t\t\t</Linker>"
2821 puts $aFile "\t\t\t</Target>"
2823 # Debug target configuration
2824 puts $aFile "\t\t\t<Target title=\"Debug\">"
2825 if { "$theIsExe" == "true" } {
2826 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2827 puts $aFile "\t\t\t\t<Option type=\"1\" />"
2829 if { "$aWokStation" == "wnt" } {
2830 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2832 puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}\" prefix_auto=\"1\" extension_auto=\"1\" />"
2834 puts $aFile "\t\t\t\t<Option type=\"3\" />"
2836 puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
2837 if { "$aWokStation" == "wnt" } {
2838 puts $aFile "\t\t\t\t<Option compiler=\"msvc8\" />"
2840 puts $aFile "\t\t\t\t<Option compiler=\"gcc\" />"
2842 puts $aFile "\t\t\t\t<Option createDefFile=\"1\" />"
2843 puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
2845 # compiler options per TARGET (including defines)
2846 puts $aFile "\t\t\t\t<Compiler>"
2847 if { "$aWokStation" == "wnt" } {
2848 puts $aFile "\t\t\t\t\t<Add option=\"-MDd\" />"
2849 puts $aFile "\t\t\t\t\t<Add option=\"-arch:SSE2\" />"
2850 puts $aFile "\t\t\t\t\t<Add option=\"-EHsc\" />"
2851 puts $aFile "\t\t\t\t\t<Add option=\"-Od\" />"
2852 puts $aFile "\t\t\t\t\t<Add option=\"-Zi\" />"
2853 puts $aFile "\t\t\t\t\t<Add option=\"-W4\" />"
2854 puts $aFile "\t\t\t\t\t<Add option=\"-MP\" />"
2856 puts $aFile "\t\t\t\t\t<Add option=\"-O0\" />"
2857 puts $aFile "\t\t\t\t\t<Add option=\"-g\" />"
2858 puts $aFile "\t\t\t\t\t<Add option=\"-mmmx\" />"
2859 puts $aFile "\t\t\t\t\t<Add option=\"-msse\" />"
2860 puts $aFile "\t\t\t\t\t<Add option=\"-msse2\" />"
2861 puts $aFile "\t\t\t\t\t<Add option=\"-mfpmath=sse\" />"
2863 foreach aMacro $theDefines {
2864 puts $aFile "\t\t\t\t\t<Add option=\"-D${aMacro}\" />"
2866 puts $aFile "\t\t\t\t\t<Add option=\"-D_DEBUG\" />"
2867 puts $aFile "\t\t\t\t\t<Add option=\"-DDEB\" />"
2868 puts $aFile "\t\t\t\t</Compiler>"
2870 puts $aFile "\t\t\t\t<Linker>"
2871 puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
2872 if { "$aWokStation" == "mac" && [ lsearch $theLibsList X11 ] >= 0} {
2873 puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
2875 puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
2876 puts $aFile "\t\t\t\t</Linker>"
2878 puts $aFile "\t\t\t</Target>"
2880 puts $aFile "\t\t</Build>"
2882 # COMMON compiler options
2883 puts $aFile "\t\t<Compiler>"
2884 puts $aFile "\t\t\t<Add option=\"-Wall\" />"
2885 puts $aFile "\t\t\t<Add option=\"-fexceptions\" />"
2886 puts $aFile "\t\t\t<Add option=\"-fPIC\" />"
2887 puts $aFile "\t\t\t<Add option=\"\$(CSF_OPT_CMPL)\" />"
2888 foreach anIncPath $theIncPaths {
2889 puts $aFile "\t\t\t<Add directory=\"$anIncPath\" />"
2891 puts $aFile "\t\t</Compiler>"
2893 # COMMON linker options
2894 puts $aFile "\t\t<Linker>"
2895 foreach aFrameworkName $theFrameworks {
2896 if { "$aFrameworkName" != "" } {
2897 puts $aFile "\t\t\t<Add option=\"-framework $aFrameworkName\" />"
2900 foreach aLibName $theLibsList {
2901 if { "$aLibName" != "" } {
2902 puts $aFile "\t\t\t<Add library=\"$aLibName\" />"
2905 puts $aFile "\t\t</Linker>"
2908 foreach aSrcFile $theSrcFiles {
2909 if {[string equal -nocase [file extension $aSrcFile] ".mm"]} {
2910 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2911 puts $aFile "\t\t\t<Option compile=\"1\" />"
2912 puts $aFile "\t\t\t<Option link=\"1\" />"
2913 puts $aFile "\t\t</Unit>"
2914 } elseif {[string equal -nocase [file extension $aSrcFile] ".c"]} {
2915 puts $aFile "\t\t<Unit filename=\"$aSrcFile\">"
2916 puts $aFile "\t\t\t<Option compilerVar=\"CC\" />"
2917 puts $aFile "\t\t</Unit>"
2919 puts $aFile "\t\t<Unit filename=\"$aSrcFile\" />"
2923 puts $aFile "\t</Project>"
2924 puts $aFile "</CodeBlocks_project_file>"
2927 return $aCbpFilePath
2930 # Auxiliary function to achieve complete information to build Toolkit
2931 # @param theRelativePath - relative path to CASROOT
2932 # @param theToolKit - Toolkit name
2933 # @param theUsedLib - dependencies (libraries list)
2934 # @param theFrameworks - dependencies (frameworks list, Mac OS X specific)
2935 # @param theIncPaths - header search paths
2936 # @param theTKDefines - compiler macro definitions
2937 # @param theTKSrcFiles - list of source files
2938 proc osutils:tkinfo { theRelativePath theToolKit theUsedLib theFrameworks theIncPaths theTKDefines theTKSrcFiles } {
2939 global path targetStation
2940 set aWokStation "$targetStation"
2942 # collect list of referred libraries to link with
2943 upvar $theUsedLib aUsedLibs
2944 upvar $theFrameworks aFrameworks
2945 upvar $theIncPaths anIncPaths
2946 upvar $theTKDefines aTKDefines
2947 upvar $theTKSrcFiles aTKSrcFiles
2949 osutils:usedOsLibs $theToolKit "$aWokStation" aUsedLibs aFrameworks
2950 set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
2951 foreach tkx $aDepToolkits {
2952 lappend aUsedLibs "${tkx}"
2955 lappend anIncPaths "$theRelativePath/inc"
2956 set listloc [osutils:tk:units $theToolKit]
2958 if { [llength $listloc] == 0 } {
2959 set listloc $theToolKit
2962 if { "$aWokStation" == "wnt" } {
2963 set resultloc [osutils:justwnt $listloc]
2965 set resultloc [osutils:justunix $listloc]
2967 if [array exists written] { unset written }
2968 foreach fxlo $resultloc {
2970 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
2971 foreach aSrcFile [lsort $aSrcFiles] {
2972 if { ![info exists written([file tail $aSrcFile])] } {
2973 set written([file tail $aSrcFile]) 1
2974 lappend aTKSrcFiles "${theRelativePath}/[wokUtils:FILES:wtail $aSrcFile 3]"
2976 puts "Warning : more than one occurences for [file tail $aSrcFile]"
2980 # macros for correct DLL exports
2981 if { "$aWokStation" == "wnt" } {
2982 lappend aTKDefines "__${xlo}_DLL"
2985 # common include paths
2986 # lappend anIncPaths "${theRelativePath}/src/${xlo}"
2990 lappend aTKDefines "CSFDB"
2991 if { "$aWokStation" == "wnt" } {
2992 lappend aTKDefines "WNT"
2993 lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
2995 if { "$aWokStation" == "lin" } {
2996 lappend aTKDefines "LIN"
2998 lappend aTKDefines "OCC_CONVERT_SIGNALS"
2999 #lappend aTKDefines "_GNU_SOURCE=1"
3003 # Define libraries to link using only EXTERNLIB file
3004 proc LibToLinkX {thePackage theDummyName} {
3005 set aToolKits [LibToLink $thePackage]
3009 # Function to generate Xcode workspace and project files
3010 proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
3012 puts stderr "Generating project files for Xcode"
3014 # Generate projects for toolkits and separate workspace for each module
3015 foreach aModule $theModules {
3016 OS:xcworkspace $aModule $aModule $theOutDir
3017 OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
3020 # Generate single workspace "OCCT" containing projects from all modules
3021 if { "$theAllSolution" != "" } {
3022 OS:xcworkspace $theAllSolution $theModules $theOutDir
3026 # Generates toolkits sections for Xcode workspace file.
3027 proc OS:xcworkspace:toolkits { theModule } {
3030 # Adding toolkits for module in workspace.
3031 foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
3032 append aBuff " <FileRef\n"
3033 append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
3034 append aBuff " </FileRef>\n"
3037 # Adding executables for module, assume one project per cxx file...
3038 foreach aUnit [OS:executable ${theModule}] {
3040 set src_files [_get_used_files $aUnit false]
3042 foreach s $src_files {
3043 regexp {source ([^\s]+)} $s dummy name
3044 lappend aSrcFiles $name
3046 foreach aSrcFile $aSrcFiles {
3047 set aFileExtension [file extension $aSrcFile]
3048 if { $aFileExtension == ".cxx" } {
3049 set aPrjName [file rootname $aSrcFile]
3050 append aBuff " <FileRef\n"
3051 append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
3052 append aBuff " </FileRef>\n"
3057 # Removing unnecessary newline character from the end.
3058 set aBuff [string replace $aBuff end end]
3062 # Generates workspace files for Xcode.
3063 proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
3064 # Creating workspace directory for Xcode.
3065 set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
3066 wokUtils:FILES:mkdir $aWorkspaceDir
3067 if { ! [file exists $aWorkspaceDir] } {
3068 puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
3072 # Creating workspace file.
3073 set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
3074 set aFile [open $aWsFilePath "w"]
3076 # Adding header and section for main Group.
3077 puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
3078 puts $aFile "<Workspace"
3079 puts $aFile " version = \"1.0\">"
3080 puts $aFile " <Group"
3081 puts $aFile " location = \"container:\""
3082 puts $aFile " name = \"${theWorkspaceName}\">"
3085 if { [llength "$theModules"] > 1 } {
3086 foreach aModule $theModules {
3087 puts $aFile " <Group"
3088 puts $aFile " location = \"container:\""
3089 puts $aFile " name = \"${aModule}\">"
3090 puts $aFile [OS:xcworkspace:toolkits $aModule]
3091 puts $aFile " </Group>"
3094 puts $aFile [OS:xcworkspace:toolkits $theModules]
3098 puts $aFile " </Group>"
3099 puts $aFile "</Workspace>"
3103 # Generates Xcode project files.
3104 proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
3105 upvar $theGuidsMap aGuidsMap
3108 if { "$theLibType" == "static" } {
3110 } elseif { "$thePlatform" == "ios" } {
3114 set aProjectFiles {}
3115 foreach aModule $theModules {
3116 foreach aToolKit [${aModule}:toolkits] {
3117 lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
3119 foreach anExecutable [OS:executable ${aModule}] {
3120 lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
3123 return $aProjectFiles
3126 # Generates dependencies section for Xcode project files.
3127 proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
3129 upvar $theGuidsMap aGuidsMap
3130 upvar $theFileRefSection aFileRefSection
3131 upvar $theDepsGuids aDepsGuids
3132 upvar $theDepsRefGuids aDepsRefGuids
3134 set aBuildFileSection ""
3135 set aUsedToolKits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
3136 set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
3138 if { "$theTargetType" == "executable" } {
3139 set aFile [osutils:tk:files $theToolKit osutils:compilable 0]
3140 set aProjName [file rootname [file tail $aFile]]
3141 set aDepToolkits [LibToLinkX $theToolKit $aProjName]
3145 if { $theIsStatic == 1 } {
3147 if { "$theTargetType" != "executable" } {
3148 return $aBuildFileSection
3152 osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
3153 set aUsedToolKits [concat $aUsedToolKits $aLibs]
3154 set aUsedToolKits [concat $aUsedToolKits $aFrameworks]
3155 foreach tkx $aUsedToolKits {
3156 set aDepLib "${tkx}_Dep"
3157 set aDepLibRef "${tkx}_DepRef"
3159 if { ! [info exists aGuidsMap($aDepLib)] } {
3160 set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
3162 if { ! [info exists aGuidsMap($aDepLibRef)] } {
3163 set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
3166 append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
3167 if {[lsearch -nocase $aFrameworks $tkx] == -1} {
3168 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
3170 append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
3172 append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
3173 append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
3176 return $aBuildFileSection
3179 # Generates PBXBuildFile and PBXGroup sections for project file.
3180 proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
3181 upvar $theSrcFileRefSection aSrcFileRefSection
3182 upvar $theGroupSection aGroupSection
3183 upvar $thePackageGuids aPackagesGuids
3184 upvar $theSrcFileGuids aSrcFileGuids
3185 upvar $theGuidsMap aGuidsMap
3186 upvar $theIncPaths anIncPaths
3188 set listloc [osutils:tk:units $theToolKit]
3189 set resultloc [osutils:justunix $listloc]
3190 set aBuildFileSection ""
3191 set aPackages [lsort -nocase $resultloc]
3192 if { "$theTargetType" == "executable" } {
3193 set aPackages [list "$theToolKit"]
3196 # Generating PBXBuildFile, PBXGroup sections and groups for each package.
3197 foreach fxlo $aPackages {
3199 set aPackage "${xlo}_Package"
3200 set aSrcFileRefGuids ""
3201 if { ! [info exists aGuidsMap($aPackage)] } {
3202 set aGuidsMap($aPackage) [OS:genGUID "xcd"]
3205 set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
3206 foreach aSrcFile [lsort $aSrcFiles] {
3207 set aFileExt "sourcecode.cpp.cpp"
3209 if { [file extension $aSrcFile] == ".c" } {
3210 set aFileExt "sourcecode.c.c"
3211 } elseif { [file extension $aSrcFile] == ".mm" } {
3212 set aFileExt "sourcecode.cpp.objcpp"
3215 if { ! [info exists aGuidsMap($aSrcFile)] } {
3216 set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
3218 set aSrcFileRef "${aSrcFile}_Ref"
3219 if { ! [info exists aGuidsMap($aSrcFileRef)] } {
3220 set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
3222 if { ! [info exists written([file tail $aSrcFile])] } {
3223 set written([file tail $aSrcFile]) 1
3224 append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
3225 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"
3226 append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
3227 append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
3229 puts "Warning : more than one occurences for [file tail $aSrcFile]"
3233 append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
3234 append aGroupSection "\t\t\tisa = PBXGroup;\n"
3235 append aGroupSection "\t\t\tchildren = (\n"
3236 append aGroupSection $aSrcFileRefGuids
3237 append aGroupSection "\t\t\t);\n"
3238 append aGroupSection "\t\t\tname = $xlo;\n"
3239 append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
3240 append aGroupSection "\t\t\};\n"
3242 # Storing packages IDs for adding them later as a child of toolkit
3243 append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
3246 # Removing unnecessary newline character from the end.
3247 set aPackagesGuids [string replace $aPackagesGuids end end]
3249 return $aBuildFileSection
3252 # Creates folders structure and all necessary files for Xcode project.
3253 proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
3254 set aPBXBuildPhase "Headers"
3255 set aRunOnlyForDeployment "0"
3256 set aProductType "library.dynamic"
3257 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
3258 set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
3259 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
3260 set aTKDefines [list "CSFDB" "OCC_CONVERT_SIGNALS"]
3262 if { "$theTargetType" == "executable" } {
3263 set aPBXBuildPhase "CopyFiles"
3264 set aRunOnlyForDeployment "1"
3265 set aProductType "tool"
3266 set anExecExtension ""
3268 set aWrapperExtension ""
3269 } elseif { $theIsStatic == 1 } {
3270 set aProductType "library.static"
3271 set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
3272 set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
3275 set aUsername [exec whoami]
3277 # Creation of folders for Xcode projectP.
3278 set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
3279 wokUtils:FILES:mkdir $aToolkitDir
3280 if { ! [file exists $aToolkitDir] } {
3281 puts stderr "Error: Could not create project directory \"$aToolkitDir\""
3285 set aUserDataDir "${aToolkitDir}/xcuserdata"
3286 wokUtils:FILES:mkdir $aUserDataDir
3287 if { ! [file exists $aUserDataDir] } {
3288 puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
3292 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3293 wokUtils:FILES:mkdir $aUserDataDir
3294 if { ! [file exists $aUserDataDir] } {
3295 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
3299 set aSchemesDir "${aUserDataDir}/xcschemes"
3300 wokUtils:FILES:mkdir $aSchemesDir
3301 if { ! [file exists $aSchemesDir] } {
3302 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3305 # End of folders creation.
3307 # Generating GUID for tookit.
3308 upvar $theGuidsMap aGuidsMap
3309 if { ! [info exists aGuidsMap($theToolKit)] } {
3310 set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
3313 # Creating xcscheme file for toolkit from template.
3314 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
3315 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
3316 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
3317 set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
3318 puts $aXcschemeFile $aXcschemeTmpl
3319 close $aXcschemeFile
3321 # Creating xcschememanagement.plist file for toolkit from template.
3322 set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
3323 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
3324 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
3325 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3326 puts $aPlistFile $aPlistTmpl
3329 # Creating project.pbxproj file for toolkit.
3330 set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
3331 puts $aPbxprojFile "// !\$*UTF8*\$!"
3332 puts $aPbxprojFile "\{"
3333 puts $aPbxprojFile "\tarchiveVersion = 1;"
3334 puts $aPbxprojFile "\tclasses = \{"
3335 puts $aPbxprojFile "\t\};"
3336 puts $aPbxprojFile "\tobjectVersion = 46;"
3337 puts $aPbxprojFile "\tobjects = \{\n"
3339 # Begin PBXBuildFile section
3340 set aPackagesGuids ""
3341 set aGroupSection ""
3342 set aSrcFileRefSection ""
3343 set aSrcFileGuids ""
3344 set aDepsFileRefSection ""
3346 set aDepsRefGuids ""
3347 set anIncPaths [list "../../../inc"]
3350 if { [info exists ::env(CSF_OPT_INC)] } {
3351 set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
3352 foreach anIncCfgPath $anIncCfg {
3353 lappend anIncPaths $anIncCfgPath
3356 if { [info exists ::env(CSF_OPT_LIB64)] } {
3357 set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
3358 foreach anLibCfgPath $anLibCfg {
3359 lappend anLibPaths $anLibCfgPath
3363 puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
3364 puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
3365 # End PBXBuildFile section
3367 # Begin PBXFileReference section
3368 set aToolkitLib "lib${theToolKit}.dylib"
3369 set aPath "$aToolkitLib"
3370 if { "$theTargetType" == "executable" } {
3371 set aPath "$theToolKit"
3372 } elseif { $theIsStatic == 1 } {
3373 set aToolkitLib "lib${theToolKit}.a"
3376 if { ! [info exists aGuidsMap($aToolkitLib)] } {
3377 set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
3380 puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
3381 puts $aPbxprojFile $aSrcFileRefSection
3382 puts $aPbxprojFile $aDepsFileRefSection
3383 # End PBXFileReference section
3386 # Begin PBXFrameworksBuildPhase section
3387 set aTkFrameworks "${theToolKit}_Frameworks"
3388 if { ! [info exists aGuidsMap($aTkFrameworks)] } {
3389 set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
3392 puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
3393 puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
3394 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3395 puts $aPbxprojFile "\t\t\tfiles = ("
3396 puts $aPbxprojFile $aDepsGuids
3397 puts $aPbxprojFile "\t\t\t);"
3398 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3399 puts $aPbxprojFile "\t\t\};\n"
3400 # End PBXFrameworksBuildPhase section
3402 # Begin PBXGroup section
3403 set aTkPBXGroup "${theToolKit}_PBXGroup"
3404 if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
3405 set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
3408 set aTkSrcGroup "${theToolKit}_SrcGroup"
3409 if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
3410 set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
3413 puts $aPbxprojFile $aGroupSection
3414 puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
3415 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3416 puts $aPbxprojFile "\t\t\tchildren = ("
3417 puts $aPbxprojFile $aDepsRefGuids
3418 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
3419 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
3420 puts $aPbxprojFile "\t\t\t);"
3421 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3422 puts $aPbxprojFile "\t\t\};"
3423 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
3424 puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
3425 puts $aPbxprojFile "\t\t\tchildren = ("
3426 puts $aPbxprojFile $aPackagesGuids
3427 puts $aPbxprojFile "\t\t\t);"
3428 puts $aPbxprojFile "\t\t\tname = \"Source files\";"
3429 puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
3430 puts $aPbxprojFile "\t\t\};\n"
3431 # End PBXGroup section
3433 # Begin PBXHeadersBuildPhase section
3434 set aTkHeaders "${theToolKit}_Headers"
3435 if { ! [info exists aGuidsMap($aTkHeaders)] } {
3436 set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
3439 puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
3440 puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
3441 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3442 puts $aPbxprojFile "\t\t\tfiles = ("
3443 puts $aPbxprojFile "\t\t\t);"
3444 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
3445 puts $aPbxprojFile "\t\t\};\n"
3446 # End PBXHeadersBuildPhase section
3448 # Begin PBXNativeTarget section
3449 set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
3450 if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
3451 set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
3454 set aTkSources "${theToolKit}_Sources"
3455 if { ! [info exists aGuidsMap($aTkSources)] } {
3456 set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
3459 puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
3460 puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
3461 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
3462 puts $aPbxprojFile "\t\t\tbuildPhases = ("
3463 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
3464 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
3465 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
3466 puts $aPbxprojFile "\t\t\t);"
3467 puts $aPbxprojFile "\t\t\tbuildRules = ("
3468 puts $aPbxprojFile "\t\t\t);"
3469 puts $aPbxprojFile "\t\t\tdependencies = ("
3470 puts $aPbxprojFile "\t\t\t);"
3471 puts $aPbxprojFile "\t\t\tname = $theToolKit;"
3472 puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
3473 puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
3474 puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
3475 puts $aPbxprojFile "\t\t\};\n"
3476 # End PBXNativeTarget section
3478 # Begin PBXProject section
3479 set aTkProjectObj "${theToolKit}_ProjectObj"
3480 if { ! [info exists aGuidsMap($aTkProjectObj)] } {
3481 set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
3484 set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
3485 if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
3486 set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
3489 puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
3490 puts $aPbxprojFile "\t\t\tisa = PBXProject;"
3491 puts $aPbxprojFile "\t\t\tattributes = \{"
3492 puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
3493 puts $aPbxprojFile "\t\t\t\};"
3494 puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
3495 puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
3496 puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
3497 puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
3498 puts $aPbxprojFile "\t\t\tknownRegions = ("
3499 puts $aPbxprojFile "\t\t\t\ten,"
3500 puts $aPbxprojFile "\t\t\t);"
3501 puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
3502 puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
3503 puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
3504 puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
3505 puts $aPbxprojFile "\t\t\ttargets = ("
3506 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
3507 puts $aPbxprojFile "\t\t\t);"
3508 puts $aPbxprojFile "\t\t\};\n"
3509 # End PBXProject section
3511 # Begin PBXSourcesBuildPhase section
3512 puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
3513 puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
3514 puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
3515 puts $aPbxprojFile "\t\t\tfiles = ("
3516 puts $aPbxprojFile $aSrcFileGuids
3517 puts $aPbxprojFile "\t\t\t);"
3518 puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
3519 puts $aPbxprojFile "\t\t\};\n"
3520 # End PBXSourcesBuildPhase section
3522 # Begin XCBuildConfiguration section
3523 set aTkDebugProject "${theToolKit}_DebugProject"
3524 if { ! [info exists aGuidsMap($aTkDebugProject)] } {
3525 set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
3528 set aTkReleaseProject "${theToolKit}_ReleaseProject"
3529 if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
3530 set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
3533 set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
3534 if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
3535 set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
3538 set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
3539 if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
3540 set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
3544 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
3545 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3546 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3548 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
3549 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3550 if { "$thePlatform" == "ios" } {
3551 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3552 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3553 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3554 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3555 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3557 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3558 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
3559 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
3560 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3561 puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
3562 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3563 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
3564 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3565 puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
3566 puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
3567 puts $aPbxprojFile "\t\t\t\t);"
3568 puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
3569 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3570 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3571 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3572 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3573 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3574 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
3575 if { "$thePlatform" == "ios" } {
3576 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
3577 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3579 puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
3581 puts $aPbxprojFile "\t\t\t\};"
3583 puts $aPbxprojFile "\t\t\tname = Debug;"
3584 puts $aPbxprojFile "\t\t\};"
3587 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
3588 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3589 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3591 puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
3592 puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
3593 if { "$thePlatform" == "ios" } {
3594 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
3595 puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
3596 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
3597 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
3598 puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
3600 puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
3601 puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
3602 puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
3603 puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
3604 puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
3605 puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
3606 puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
3607 puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
3608 puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
3609 puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
3610 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
3611 puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
3612 puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
3613 if { "$thePlatform" == "ios" } {
3614 puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
3615 puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
3617 puts $aPbxprojFile "\t\t\t\};"
3618 puts $aPbxprojFile "\t\t\tname = Release;"
3619 puts $aPbxprojFile "\t\t\};"
3620 puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
3621 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3622 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3623 puts $aPbxprojFile "${anExecExtension}"
3624 puts $aPbxprojFile "${anExecPrefix}"
3625 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3626 foreach aMacro $aTKDefines {
3627 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3629 puts $aPbxprojFile "\t\t\t\t);"
3631 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3632 foreach anIncPath $anIncPaths {
3633 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3635 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3636 puts $aPbxprojFile "\t\t\t\t);"
3638 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3639 foreach anLibPath $anLibPaths {
3640 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3642 puts $aPbxprojFile "\t\t\t\t);"
3644 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3645 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3646 puts $aPbxprojFile "\t\t\t\t);"
3647 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3648 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3649 puts $aPbxprojFile "\t\t\t\t);"
3650 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3651 set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
3652 foreach anIncPath $anIncPaths {
3653 append anUserHeaderSearchPath " ${anIncPath}"
3655 append anUserHeaderSearchPath "\";"
3656 puts $aPbxprojFile $anUserHeaderSearchPath
3657 puts $aPbxprojFile "${aWrapperExtension}"
3658 puts $aPbxprojFile "\t\t\t\};"
3659 puts $aPbxprojFile "\t\t\tname = Debug;"
3660 puts $aPbxprojFile "\t\t\};"
3661 puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
3662 puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
3663 puts $aPbxprojFile "\t\t\tbuildSettings = \{"
3664 puts $aPbxprojFile "${anExecExtension}"
3665 puts $aPbxprojFile "${anExecPrefix}"
3666 puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
3667 foreach aMacro $aTKDefines {
3668 puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
3670 puts $aPbxprojFile "\t\t\t\t);"
3671 puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
3672 foreach anIncPath $anIncPaths {
3673 puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
3675 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
3676 puts $aPbxprojFile "\t\t\t\t);"
3678 puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
3679 foreach anLibPath $anLibPaths {
3680 puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
3682 puts $aPbxprojFile "\t\t\t\t);"
3684 puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
3685 puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
3686 puts $aPbxprojFile "\t\t\t\t);"
3687 puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
3688 puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
3689 puts $aPbxprojFile "\t\t\t\t);"
3690 puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
3691 puts $aPbxprojFile $anUserHeaderSearchPath
3692 puts $aPbxprojFile "${aWrapperExtension}"
3693 puts $aPbxprojFile "\t\t\t\};"
3694 puts $aPbxprojFile "\t\t\tname = Release;"
3695 puts $aPbxprojFile "\t\t\};\n"
3696 # End XCBuildConfiguration section
3698 # Begin XCConfigurationList section
3699 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
3700 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3701 puts $aPbxprojFile "\t\tbuildConfigurations = ("
3702 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
3703 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
3704 puts $aPbxprojFile "\t\t\t);"
3705 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3706 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3707 puts $aPbxprojFile "\t\t\};"
3708 puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
3709 puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
3710 puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
3711 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
3712 puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
3713 puts $aPbxprojFile "\t\t\t);"
3714 puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
3715 puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
3716 puts $aPbxprojFile "\t\t\};\n"
3717 # End XCConfigurationList section
3719 puts $aPbxprojFile "\t\};"
3720 puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
3721 puts $aPbxprojFile "\}"
3726 proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
3727 set aUsername [exec whoami]
3729 # Creating folders for Xcode project file.
3730 set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
3731 wokUtils:FILES:mkdir $anExecutableDir
3732 if { ! [file exists $anExecutableDir] } {
3733 puts stderr "Error: Could not create project directory \"$anExecutableDir\""
3737 set aUserDataDir "${anExecutableDir}/xcuserdata"
3738 wokUtils:FILES:mkdir $aUserDataDir
3739 if { ! [file exists $aUserDataDir] } {
3740 puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
3744 set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
3745 wokUtils:FILES:mkdir $aUserDataDir
3746 if { ! [file exists $aUserDataDir] } {
3747 puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
3751 set aSchemesDir "${aUserDataDir}/xcschemes"
3752 wokUtils:FILES:mkdir $aSchemesDir
3753 if { ! [file exists $aSchemesDir] } {
3754 puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
3757 # End folders creation.
3759 # Generating GUID for tookit.
3760 upvar $theGuidsMap aGuidsMap
3761 if { ! [info exists aGuidsMap($theExecutable)] } {
3762 set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
3765 # Creating xcscheme file for toolkit from template.
3766 set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
3767 regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
3768 regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
3769 set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
3770 puts $aXcschemeFile $aXcschemeTmpl
3771 close $aXcschemeFile
3773 # Creating xcschememanagement.plist file for toolkit from template.
3774 set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
3775 regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
3776 regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
3777 set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
3778 puts $aPlistFile $aPlistTmpl