# =======================================================================
# This script generates project files for different IDEs:
-# "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk"
+# "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd"
#
# Example:
# genproj -path=D:/occt -target=vc10
+# genproj -target=xcd -ios -static
# =======================================================================
set path ""
set fBranch ""
switch -exact -- "$tcl_platform(platform)" {
- "windows" {set targetStation "wnt"}
- "unix" {set targetStation "lin"}
- #"macos" {set targetStation "wnt"}
+ "windows" {set targetStation "wnt"}
+ "unix" {set targetStation "lin"}
}
+switch -exact -- "$tcl_platform(os)" {
+ "Darwin" {set targetStation "mac"}
+}
+
+source "./adm/genconfdeps.tcl"
+
proc _get_options { platform type branch } {
global path
set res ""
# Wrapper-function to generate VS project files
proc genproj { args } {
global path targetStation
- set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" }
+ set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd" }
set anArgs $args
# Setting default IDE.
switch -exact -- "$targetStation" {
"wnt" {set anTarget "$::env(VCVER)"}
"lin" {set anTarget "amk"}
- "mac" {set anTarget "cbp"}
+ "mac" {set anTarget "xcd"}
}
set isTargetDefault true
-
if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
set anArgs [removeAllOccurrencesOf -target=* $anArgs]
set isHelpRequire true
}
+ set aLibType "dynamic"
+ if { [lsearch -nocase $anArgs "-static"] != -1} {
+ set anArgs [removeAllOccurrencesOf "-static" $anArgs]
+ set aLibType "static"
+ puts "static build has been selected"
+ } elseif { [lsearch -nocase $anArgs "-dynamic"] != -1} {
+ set anArgs [removeAllOccurrencesOf "-dynamic" $anArgs]
+ set aLibType "dynamic"
+ puts "dynamic build has been selected"
+ }
+
+ set aPlatform ""
+ if { [lsearch -nocase $anArgs "-ios"] != -1} {
+ set anArgs [removeAllOccurrencesOf "-ios" $anArgs]
+ set aPlatform "ios"
+ }
+
if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
puts "the \'$anTarget\' is wrong TARGET"
set isHelpRequire true
vc11 - Visual Studio 2012
vc12 - Visual Studio 2013
cbp - CodeBlocks
+ xcd - XCode
amk - AutoMake"
return
}
}
set anAdmPath "$path/adm"
- OS:MKPRC "$anAdmPath" "$anTarget"
+ OS:MKPRC "$anAdmPath" "$anTarget" "$aLibType" "$aPlatform"
genprojbat "$anAdmPath" "$anTarget"
}
set aTargetPlatform wnt
} elseif {"$theIDE" == "amk"} {
set aTargetPlatform lin
+ } elseif {"$theIDE" == "xcd"} {
+ set aTargetPlatform mac
}
set aTargetPlatformExt sh
set aBox [file normalize "$thePath/.."]
- if { "$aTargetPlatform" != "wnt" } {
- file copy -force -- "$path/adm/templates/config.h" "$aBox/src/config.h"
- }
-
if {"$theIDE" != "cmake"} {
set anEnvTmplFile [open "$path/adm/templates/env.${aTargetPlatformExt}" "r"]
set anEnvTmpl [read $anEnvTmplFile]
} else {
switch -exact -- "$theIDE" {
"cbp" { file copy -force -- "$path/adm/templates/codeblocks.sh" "$aBox/codeblocks.sh" }
+ "xcd" { file copy -force -- "$path/adm/templates/xcode.sh" "$aBox/xcode.sh" }
}
}
}
return $theList
}
-proc OS:mkdir { d } {
- global tcl_version
- if ![file exists $d] {
- if { "$tcl_version" == "7.5" } {
- mkdir -path $d
- } else {
- file mkdir $d
- }
- if [file exists $d] {
- return $d
- } else {
- return {}
- }
- } else {
- return $d
- }
-}
+set aTKNullKey "TKNull"
+set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
# Entry function to generate project files and solutions for IDE
-proc OS:MKPRC { {theOutDir {}} {theIDE ""} } {
+proc OS:MKPRC { {theOutDir {}} {theIDE ""} {theLibType "dynamic"} {thePlatform ""} } {
global path targetStation
- set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" }
+ set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "amk" "xcd" }
if { [lsearch $aSupportedIDE $theIDE] < 0 } {
puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]"
# make list of modules and platforms
set aModules [OS:init]
+ if { "$thePlatform" == "ios" } {
+ set goaway [list Draw]
+ set aModules [osutils:juststation $goaway $aModules]
+ }
# generate one solution for all projects if complete OS or VAS is processed
set anAllSolution "OCCT"
- OS:mkdir $anOutDir
+ wokUtils:FILES:mkdir $anOutDir
if { ![file exists $anOutDir] } {
puts stderr "Error: Could not create output directory \"$anOutDir\""
return
"vc12" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE }
"cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution }
"amk" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
+ "xcd" {
+ set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
+ OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
+ }
}
- # generate config.txt file
- #if { ${anAllSolution} == "Products" && "$targetStation" == "wnt" } {
- # osutils:mkCollectScript "collect_binary.cfg" "$anOutRoot/../" ${theIDE} $::env(ARCH) "release"
- #}
# Store generated GUIDs map
set anOutFile [open "$aGuidsFilePath" "w"]
}
return $anUsedToolKits
}
-# Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
-proc osutils:tk:hascsf { EXTERNLIB } {
+# Return the list of name *CSF_ in a EXTERNLIB description of a toolkit
+proc osutils:tk:csfInExternlib { EXTERNLIB } {
set l [wokUtils:FILES:FileToList $EXTERNLIB]
set lret {STLPort}
foreach str $l {
return $lret
}
-proc osutils:csfList { theOS theCsfMap } {
- upvar $theCsfMap aCsfMap
+# @param theCsfLibsMap - libraries map
+# @param theCsfFrmsMap - frameworks map, OS X specific
+proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
+ upvar $theCsfLibsMap aLibsMap
+ upvar $theCsfFrmsMap aFrmsMap
- unset theCsfMap
+ unset theCsfLibsMap
+ unset theCsfFrmsMap
if { "$theOS" == "wnt" } {
- # -- WinAPI libraries
- set aCsfMap(CSF_kernel32) "kernel32.lib"
- set aCsfMap(CSF_advapi32) "advapi32.lib"
- set aCsfMap(CSF_gdi32) "gdi32.lib"
- set aCsfMap(CSF_user32) "user32.lib"
- set aCsfMap(CSF_glu32) "glu32.lib"
- set aCsfMap(CSF_opengl32) "opengl32.lib"
- set aCsfMap(CSF_wsock32) "wsock32.lib"
- set aCsfMap(CSF_netapi32) "netapi32.lib"
- set aCsfMap(CSF_AviLibs) "ws2_32.lib vfw32.lib"
- set aCsfMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib"
-
- # -- 3rd-parties precompiled libraries
- # Note: Tcl library name depends on version and is chosen by #pragma
- set aCsfMap(CSF_QT) "QtCore4.lib QtGui4.lib"
-
- #-- VTK
+ # WinAPI libraries
+ set aLibsMap(CSF_kernel32) "kernel32.lib"
+ set aLibsMap(CSF_advapi32) "advapi32.lib"
+ set aLibsMap(CSF_gdi32) "gdi32.lib"
+ set aLibsMap(CSF_user32) "user32.lib"
+ set aLibsMap(CSF_glu32) "glu32.lib"
+ set aLibsMap(CSF_opengl32) "opengl32.lib"
+ set aLibsMap(CSF_wsock32) "wsock32.lib"
+ set aLibsMap(CSF_netapi32) "netapi32.lib"
+ set aLibsMap(CSF_AviLibs) "ws2_32.lib vfw32.lib"
+ set aLibsMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib"
+
+ set aLibsMap(CSF_QT) "QtCore4.lib QtGui4.lib"
+
+ # VTK
set aCsfMap(CSF_VTK) [osutils:vtkCsf "wnt"]
-
} else {
-
- #-- Tcl/Tk configuration
- set aCsfMap(CSF_TclLibs) "tcl8.6"
- set aCsfMap(CSF_TclTkLibs) "X11 tk8.6"
-
- if { "$theOS" == "lin" } {
- set aCsfMap(CSF_ThreadLibs) "pthread rt"
- set aCsfMap(CSF_OpenGlLibs) "GLU GL"
-
- } elseif { "$theOS" == "mac" } {
- set aCsfMap(CSF_objc) "objc"
-
- # frameworks
- set aCsfMap(CSF_Appkit) "Appkit"
- set aCsfMap(CSF_IOKit) "IOKit"
- set aCsfMap(CSF_OpenGlLibs) "OpenGL"
- set aCsfMap(CSF_TclLibs) "Tcl"
- set aCsfMap(CSF_TclTkLibs) "Tk"
+ set aLibsMap(CSF_FREETYPE) "freetype"
+ if { "$theOS" == "mac" } {
+ set aLibsMap(CSF_objc) "objc"
+ set aFrmsMap(CSF_Appkit) "Appkit"
+ set aFrmsMap(CSF_IOKit) "IOKit"
+ set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
+ set aFrmsMap(CSF_TclLibs) "Tcl"
+ set aFrmsMap(CSF_TclTkLibs) "Tk"
+ } else {
+ set aLibsMap(CSF_ThreadLibs) "pthread rt"
+ set aLibsMap(CSF_OpenGlLibs) "GLU GL"
+ set aLibsMap(CSF_TclLibs) "tcl8.6"
+ set aLibsMap(CSF_TclTkLibs) "X11 tk8.6"
+ set aLibsMap(CSF_XwLibs) "X11 Xext Xmu Xi"
+ set aLibsMap(CSF_MotifLibs) "X11"
}
- set aCsfMap(CSF_XwLibs) "X11 Xext Xmu Xi"
- set aCsfMap(CSF_MotifLibs) "X11"
-
- # variable is required for support for OCCT version that use fgtl
- #-- FTGL (font renderer for OpenGL)
- set aCsfMap(CSF_FTGL) "ftgl"
-
- #-- FreeType
- set aCsfMap(CSF_FREETYPE) "freetype"
-
- #-- optional 3rd-parties
- #-- TBB
- set aCsfMap(CSF_TBB) "tbb tbbmalloc"
-
- #-- FreeImage
- set aCsfMap(CSF_FreeImagePlus) "freeimage"
-
- #-- GL2PS
- set aCsfMap(CSF_GL2PS) "gl2ps"
-
- #-- VTK
- set aCsfMap(CSF_VTK) [osutils:vtkCsf "unix"]
+ # optional 3rd-parties
+ if { "$::HAVE_TBB" == "true" } {
+ set aLibsMap(CSF_TBB) "tbb tbbmalloc"
+ }
+ if { "$::HAVE_FREEIMAGE" == "true" } {
+ set aLibsMap(CSF_FreeImagePlus) "freeimage"
+ }
+ if { "$::HAVE_GL2PS" == "true" } {
+ set aLibsMap(CSF_GL2PS) "gl2ps"
+ }
+ if { "$::HAVE_VTK" == "true" } {
+ set aCsfMap(CSF_VTK) [osutils:vtkCsf "unix"]
+ }
}
}
return [join $aLibArray " "]
}
-proc osutils:usedOsLibs { theToolKit theOS } {
+# @param theLibsList - dependencies (libraries list)
+# @param theFrameworks - dependencies (frameworks list, OS X specific)
+proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
global path
- set aUsedLibs [list]
+ upvar $theLibsList aLibsList
+ upvar $theFrameworks aFrameworks
+ set aLibsList [list]
+ set aFrameworks [list]
- osutils:csfList $theOS anOsCsfList
+ osutils:csfList $theOS aLibsMap aFrmsMap
- foreach element [osutils:tk:hascsf "$path/src/${theToolKit}/EXTERNLIB"] {
- # test if variable is not setted - continue
- if ![info exists anOsCsfList($element)] {
- continue
+ foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
+ if [info exists aLibsMap($aCsfElem)] {
+ foreach aLib [split "$aLibsMap($aCsfElem)"] {
+ if { [lsearch $aLibsList $aLib] == "-1" } {
+ lappend aLibsList $aLib
+ }
+ }
}
-
- foreach aLib [split "$anOsCsfList($element)"] {
- if { [lsearch $aUsedLibs $aLib] == "-1"} {
- lappend aUsedLibs $aLib
+ if [info exists aFrmsMap($aCsfElem)] {
+ foreach aFrm [split "$aFrmsMap($aCsfElem)"] {
+ if { [lsearch $aFrameworks $aFrm] == "-1" } {
+ lappend aFrameworks $aFrm
+ }
}
}
}
-
- return $aUsedLibs
}
# Returns liste of UD in a toolkit. tkloc is a full path wok.
lappend aCommonUsedTK "${tkx}.lib"
}
- set aUsedToolKits [concat $aCommonUsedTK [osutils:usedOsLibs $theToolKit "wnt"]]
+ osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
+ set aUsedToolKits [concat $aCommonUsedTK $aLibs]
# correct names of referred third-party libraries that are named with suffix
# depending on VC version
lappend aCommonUsedTK "${tkx}.lib"
}
- set aUsedToolKits [concat $aCommonUsedTK [osutils:usedOsLibs $theToolKit "wnt"]]
+ osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
+ set aUsedToolKits [concat $aCommonUsedTK $aLibs]
# correct names of referred third-party libraries that are named with suffix
# depending on VC version
# remove from listloc OpenCascade units indesirables on Unix
proc osutils:justunix { listloc } {
- if { "$::tcl_platform(os)" == "Darwin" && "$::MACOSX_USE_GLX" != "true" } {
+ if { "$::tcl_platform(os)" == "Darwin" } {
set goaway [list Xw WNT]
} else {
set goaway [list WNT]
set lsrc [lsort [osutils:tk:files $tkloc osutils:compilable 1 osutils:justunix]]
set lobj [wokUtils:LIST:sanspoint $lsrc]
- set lcsf [osutils:tk:hascsf $path/src/${tkloc}/EXTERNLIB]
+ set lcsf [osutils:tk:csfInExternlib $path/src/${tkloc}/EXTERNLIB]
set final 0
set externinc ""
set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
puts "pkgs $pkgs"
- #set lcsf [osutils:tk:hascsf [woklocate -p ${tkloc}:source:EXTERNLIB [wokcd]]]
+ #set lcsf [osutils:tk:csfInExternlib [woklocate -p ${tkloc}:source:EXTERNLIB [wokcd]]]
set lcsf {}
foreach tk $pkgs {
- foreach element [osutils:tk:hascsf "$path/src/${tk}/EXTERNLIB"] {
+ foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
if {[lsearch $lcsf $element] == "-1"} {
set lcsf [concat $lcsf $element]
}
}
set pkgs [LibToLinkX $tkloc [lindex $CXXList 0]]
set lpkgs [osutils:justunix [wokUtils:FILES:FileToList $pkgs]]
- set lcsf [osutils:tk:hascsf "$path/src/${tkloc}/EXTERNLIB"]
+ set lcsf [osutils:tk:csfInExternlib "$path/src/${tkloc}/EXTERNLIB"]
set lcsf {}
foreach tk $pkgs {
- foreach element [osutils:tk:hascsf "$path/src/${tk}/EXTERNLIB"] {
+ foreach element [osutils:tk:csfInExternlib "$path/src/${tk}/EXTERNLIB"] {
if {[lsearch $lcsf $element] == "-1"} {
set lcsf [concat $lcsf $element]
}
set aTKSrcFiles [list]
set aProjName [file rootname [file tail $aSrcFile]]
+ osutils:usedOsLibs $theToolKit "$aWokStation" aUsedToolKits aFrameworks
set aDepToolkits [LibToLinkX $theToolKit $aProjName]
foreach tkx $aDepToolkits {
if {[_get_type $tkx] == "t"} {
}
}
- #wokparam -l CSF
-
- foreach tk $aDepToolkits {
- foreach element [osutils:tk:hascsf $path/src/${tk}/EXTERNLIB] {
- if {[_get_options lin csf $element] == ""} {
- continue
- }
- set isFrameworkNext 0
- foreach fl [split [_get_options lin csf $element]] {
- if {[string first "-libpath" $fl] != "-1"} {
- # this is library search path, not the library name
- continue
- } elseif {[string first "-framework" $fl] != "-1"} {
- set isFrameworkNext 1
- continue
- }
-
- set felem [file tail $fl]
- if {$isFrameworkNext == 1} {
- if {[lsearch $aFrameworks $felem] == "-1"} {
- lappend aFrameworks "${felem}"
- }
- set isFrameworkNext 0
- } elseif {[lsearch $aUsedToolKits $felem] == "-1"} {
- if {$felem != "\{\}" & $felem != "lib"} {
- if {[lsearch -nocase [osutils:optinal_libs] $felem] == -1} {
- lappend aUsedToolKits [string trimleft "${felem}" "-l"]
- }
- }
- }
- }
- }
- }
-
set WOKSteps_exec_link [_get_options lin WOKSteps_exec_link $theToolKit]
if { [regexp {WOKStep_DLLink} $WOKSteps_exec_link] || [regexp {WOKStep_Libink} $WOKSteps_exec_link] } {
set isExecutable "false"
# common include paths
lappend anIncPaths "../../../inc"
- # macros for UNIX to use config.h file
+ # extra macros
lappend aTKDefines "CSFDB"
if { "$aWokStation" == "wnt" } {
lappend aTKDefines "WNT"
lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
} else {
- lappend aTKDefines "HAVE_WOK_CONFIG_H"
- lappend aTKDefines "HAVE_CONFIG_H"
if { "$aWokStation" == "lin" } {
lappend aTKDefines "LIN"
}
upvar $theTKDefines aTKDefines
upvar $theTKSrcFiles aTKSrcFiles
+ osutils:usedOsLibs $theToolKit "$aWokStation" aUsedLibs aFrameworks
set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
foreach tkx $aDepToolkits {
lappend aUsedLibs "${tkx}"
}
- # wokparam -l CSF
-
- foreach tk [lappend aDepToolkits $theToolKit] {
- foreach element [osutils:tk:hascsf $path/src/${tk}/EXTERNLIB] {
- if {[_get_options lin csf $element] == ""} {
- continue
- }
- set isFrameworkNext 0
- foreach fl [split [_get_options lin csf $element]] {
- if {[string first "-libpath" $fl] != "-1"} {
- # this is library search path, not the library name
- continue
- } elseif {[string first "-framework" $fl] != "-1"} {
- set isFrameworkNext 1
- continue
- }
-
- set felem [file tail $fl]
- if {$isFrameworkNext == 1} {
- if {[lsearch $aFrameworks $felem] == "-1"} {
- lappend aFrameworks "${felem}"
- }
- set isFrameworkNext 0
- } elseif {[lsearch $aUsedLibs $felem] == "-1"} {
- if {$felem != "\{\}" & $felem != "lib"} {
- if {[lsearch -nocase [osutils:optinal_libs] $felem] == -1} {
- lappend aUsedLibs [string trimleft "${felem}" "-l"]
- }
- }
- }
- }
- }
- }
-
lappend anIncPaths "$theRelativePath/inc"
set listloc [osutils:tk:units $theToolKit]
# lappend anIncPaths "${theRelativePath}/src/${xlo}"
}
- # macros for UNIX to use config.h file
+ # extra macros
lappend aTKDefines "CSFDB"
if { "$aWokStation" == "wnt" } {
lappend aTKDefines "WNT"
lappend aTKDefines "_CRT_SECURE_NO_DEPRECATE"
} else {
- lappend aTKDefines "HAVE_WOK_CONFIG_H"
- lappend aTKDefines "HAVE_CONFIG_H"
if { "$aWokStation" == "lin" } {
lappend aTKDefines "LIN"
}
return $aToolKits
}
+# Function to generate Xcode workspace and project files
+proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} {theLibType "dynamic"} {thePlatform ""} } {
+
+ puts stderr "Generating project files for Xcode"
+
+ # Generate projects for toolkits and separate workspace for each module
+ foreach aModule $theModules {
+ OS:xcworkspace $aModule $aModule $theOutDir
+ OS:xcodeproj $aModule $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
+ }
+
+ # Generate single workspace "OCCT" containing projects from all modules
+ if { "$theAllSolution" != "" } {
+ OS:xcworkspace $theAllSolution $theModules $theOutDir
+ }
+}
+
+# Generates toolkits sections for Xcode workspace file.
+proc OS:xcworkspace:toolkits { theModule } {
+ set aBuff ""
+
+ # Adding toolkits for module in workspace.
+ foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
+ append aBuff " <FileRef\n"
+ append aBuff " location = \"group:${aToolKit}.xcodeproj\">\n"
+ append aBuff " </FileRef>\n"
+ }
+
+ # Adding executables for module, assume one project per cxx file...
+ foreach aUnit [OS:executable ${theModule}] {
+ set aUnitLoc $aUnit
+ set src_files [_get_used_files $aUnit false]
+ set aSrcFiles {}
+ foreach s $src_files {
+ regexp {source ([^\s]+)} $s dummy name
+ lappend aSrcFiles $name
+ }
+ foreach aSrcFile $aSrcFiles {
+ set aFileExtension [file extension $aSrcFile]
+ if { $aFileExtension == ".cxx" } {
+ set aPrjName [file rootname $aSrcFile]
+ append aBuff " <FileRef\n"
+ append aBuff " location = \"group:${aPrjName}.xcodeproj\">\n"
+ append aBuff " </FileRef>\n"
+ }
+ }
+ }
+
+ # Removing unnecessary newline character from the end.
+ set aBuff [string replace $aBuff end end]
+ return $aBuff
+}
+
+# Generates workspace files for Xcode.
+proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
+ # Creating workspace directory for Xcode.
+ set aWorkspaceDir "${theOutDir}/${theWorkspaceName}.xcworkspace"
+ wokUtils:FILES:mkdir $aWorkspaceDir
+ if { ! [file exists $aWorkspaceDir] } {
+ puts stderr "Error: Could not create workspace directory \"$aWorkspaceDir\""
+ return
+ }
+
+ # Creating workspace file.
+ set aWsFilePath "${aWorkspaceDir}/contents.xcworkspacedata"
+ set aFile [open $aWsFilePath "w"]
+
+ # Adding header and section for main Group.
+ puts $aFile "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ puts $aFile "<Workspace"
+ puts $aFile " version = \"1.0\">"
+ puts $aFile " <Group"
+ puts $aFile " location = \"container:\""
+ puts $aFile " name = \"${theWorkspaceName}\">"
+
+ # Adding modules.
+ if { [llength "$theModules"] > 1 } {
+ foreach aModule $theModules {
+ puts $aFile " <Group"
+ puts $aFile " location = \"container:\""
+ puts $aFile " name = \"${aModule}\">"
+ puts $aFile [OS:xcworkspace:toolkits $aModule]
+ puts $aFile " </Group>"
+ }
+ } else {
+ puts $aFile [OS:xcworkspace:toolkits $theModules]
+ }
+
+ # Adding footer.
+ puts $aFile " </Group>"
+ puts $aFile "</Workspace>"
+ close $aFile
+}
+
+# Generates Xcode project files.
+proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
+ upvar $theGuidsMap aGuidsMap
+
+ set isStatic 0
+ if { "$theLibType" == "static" } {
+ set isStatic 1
+ } elseif { "$thePlatform" == "ios" } {
+ set isStatic 1
+ }
+
+ set aProjectFiles {}
+ foreach aModule $theModules {
+ foreach aToolKit [${aModule}:toolkits] {
+ lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit aGuidsMap $isStatic $thePlatform "dylib"]
+ }
+ foreach anExecutable [OS:executable ${aModule}] {
+ lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
+ }
+ }
+ return $aProjectFiles
+}
+
+# Generates dependencies section for Xcode project files.
+proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
+ global path
+ upvar $theGuidsMap aGuidsMap
+ upvar $theFileRefSection aFileRefSection
+ upvar $theDepsGuids aDepsGuids
+ upvar $theDepsRefGuids aDepsRefGuids
+
+ set aBuildFileSection ""
+ set aUsedToolKits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
+ set aDepToolkits [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
+
+ if { "$theTargetType" == "executable" } {
+ set aFile [osutils:tk:files $theToolKit osutils:compilable 0]
+ set aProjName [file rootname [file tail $aFile]]
+ set aDepToolkits [LibToLinkX $theToolKit $aProjName]
+ }
+
+ set aLibExt "dylib"
+ if { $theIsStatic == 1 } {
+ set aLibExt "a"
+ if { "$theTargetType" != "executable" } {
+ return $aBuildFileSection
+ }
+ }
+
+ osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
+ set aUsedToolKits [concat $aUsedToolKits $aLibs]
+ set aUsedToolKits [concat $aUsedToolKits $aFrameworks]
+ foreach tkx $aUsedToolKits {
+ set aDepLib "${tkx}_Dep"
+ set aDepLibRef "${tkx}_DepRef"
+
+ if { ! [info exists aGuidsMap($aDepLib)] } {
+ set aGuidsMap($aDepLib) [OS:genGUID "xcd"]
+ }
+ if { ! [info exists aGuidsMap($aDepLibRef)] } {
+ set aGuidsMap($aDepLibRef) [OS:genGUID "xcd"]
+ }
+
+ append aBuildFileSection "\t\t$aGuidsMap($aDepLib) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aDepLibRef) ; \};\n"
+ if {[lsearch -nocase $aFrameworks $tkx] == -1} {
+ append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = file; name = lib${tkx}.${aLibExt}; path = lib${tkx}.${aLibExt}; sourceTree = \"<group>\"; \};\n"
+ } else {
+ append aFileRefSection "\t\t$aGuidsMap($aDepLibRef) = \{isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ${tkx}.framework; path = /System/Library/Frameworks/${tkx}.framework; sourceTree = \"<absolute>\"; \};\n"
+ }
+ append aDepsGuids "\t\t\t\t$aGuidsMap($aDepLib) ,\n"
+ append aDepsRefGuids "\t\t\t\t$aGuidsMap($aDepLibRef) ,\n"
+ }
+
+ return $aBuildFileSection
+}
+
+# Generates PBXBuildFile and PBXGroup sections for project file.
+proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGroupSection thePackageGuids theSrcFileGuids theGuidsMap theIncPaths} {
+ upvar $theSrcFileRefSection aSrcFileRefSection
+ upvar $theGroupSection aGroupSection
+ upvar $thePackageGuids aPackagesGuids
+ upvar $theSrcFileGuids aSrcFileGuids
+ upvar $theGuidsMap aGuidsMap
+ upvar $theIncPaths anIncPaths
+
+ set listloc [osutils:tk:units $theToolKit]
+ set resultloc [osutils:justunix $listloc]
+ set aBuildFileSection ""
+ set aPackages [lsort -nocase $resultloc]
+ if { "$theTargetType" == "executable" } {
+ set aPackages [list "$theToolKit"]
+ }
+
+ # Generating PBXBuildFile, PBXGroup sections and groups for each package.
+ foreach fxlo $aPackages {
+ set xlo $fxlo
+ set aPackage "${xlo}_Package"
+ set aSrcFileRefGuids ""
+ if { ! [info exists aGuidsMap($aPackage)] } {
+ set aGuidsMap($aPackage) [OS:genGUID "xcd"]
+ }
+
+ set aSrcFiles [osutils:tk:files $xlo osutils:compilable 0]
+ foreach aSrcFile [lsort $aSrcFiles] {
+ set aFileExt "sourcecode.cpp.cpp"
+
+ if { [file extension $aSrcFile] == ".c" } {
+ set aFileExt "sourcecode.c.c"
+ } elseif { [file extension $aSrcFile] == ".mm" } {
+ set aFileExt "sourcecode.cpp.objcpp"
+ }
+
+ if { ! [info exists aGuidsMap($aSrcFile)] } {
+ set aGuidsMap($aSrcFile) [OS:genGUID "xcd"]
+ }
+ set aSrcFileRef "${aSrcFile}_Ref"
+ if { ! [info exists aGuidsMap($aSrcFileRef)] } {
+ set aGuidsMap($aSrcFileRef) [OS:genGUID "xcd"]
+ }
+ if { ! [info exists written([file tail $aSrcFile])] } {
+ set written([file tail $aSrcFile]) 1
+ append aBuildFileSection "\t\t$aGuidsMap($aSrcFile) = \{isa = PBXBuildFile; fileRef = $aGuidsMap($aSrcFileRef) ;\};\n"
+ 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"
+ append aSrcFileGuids "\t\t\t\t$aGuidsMap($aSrcFile) ,\n"
+ append aSrcFileRefGuids "\t\t\t\t$aGuidsMap($aSrcFileRef) ,\n"
+ } else {
+ puts "Warning : more than one occurences for [file tail $aSrcFile]"
+ }
+ }
+
+ append aGroupSection "\t\t$aGuidsMap($aPackage) = \{\n"
+ append aGroupSection "\t\t\tisa = PBXGroup;\n"
+ append aGroupSection "\t\t\tchildren = (\n"
+ append aGroupSection $aSrcFileRefGuids
+ append aGroupSection "\t\t\t);\n"
+ append aGroupSection "\t\t\tname = $xlo;\n"
+ append aGroupSection "\t\t\tsourceTree = \"<group>\";\n"
+ append aGroupSection "\t\t\};\n"
+
+ # Storing packages IDs for adding them later as a child of toolkit
+ append aPackagesGuids "\t\t\t\t$aGuidsMap($aPackage) ,\n"
+ }
+
+ # Removing unnecessary newline character from the end.
+ set aPackagesGuids [string replace $aPackagesGuids end end]
+
+ return $aBuildFileSection
+}
+
+# Creates folders structure and all necessary files for Xcode project.
+proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
+ set aPBXBuildPhase "Headers"
+ set aRunOnlyForDeployment "0"
+ set aProductType "library.dynamic"
+ set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = dylib;"
+ set anExecPrefix "\t\t\t\tEXECUTABLE_PREFIX = lib;"
+ set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = dylib;"
+ set aTKDefines [list "CSFDB" "OCC_CONVERT_SIGNALS"]
+
+ if { "$theTargetType" == "executable" } {
+ set aPBXBuildPhase "CopyFiles"
+ set aRunOnlyForDeployment "1"
+ set aProductType "tool"
+ set anExecExtension ""
+ set anExecPrefix ""
+ set aWrapperExtension ""
+ } elseif { $theIsStatic == 1 } {
+ set aProductType "library.static"
+ set anExecExtension "\t\t\t\tEXECUTABLE_EXTENSION = a;"
+ set aWrapperExtension "\t\t\t\tWRAPPER_EXTENSION = a;"
+ }
+
+ set aUsername [exec whoami]
+
+ # Creation of folders for Xcode projectP.
+ set aToolkitDir "${theOutDir}/${theToolKit}.xcodeproj"
+ wokUtils:FILES:mkdir $aToolkitDir
+ if { ! [file exists $aToolkitDir] } {
+ puts stderr "Error: Could not create project directory \"$aToolkitDir\""
+ return
+ }
+
+ set aUserDataDir "${aToolkitDir}/xcuserdata"
+ wokUtils:FILES:mkdir $aUserDataDir
+ if { ! [file exists $aUserDataDir] } {
+ puts stderr "Error: Could not create xcuserdata directorty in \"$aToolkitDir\""
+ return
+ }
+
+ set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
+ wokUtils:FILES:mkdir $aUserDataDir
+ if { ! [file exists $aUserDataDir] } {
+ puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$aToolkitDir\"/xcuserdata"
+ return
+ }
+
+ set aSchemesDir "${aUserDataDir}/xcschemes"
+ wokUtils:FILES:mkdir $aSchemesDir
+ if { ! [file exists $aSchemesDir] } {
+ puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
+ return
+ }
+ # End of folders creation.
+
+ # Generating GUID for tookit.
+ upvar $theGuidsMap aGuidsMap
+ if { ! [info exists aGuidsMap($theToolKit)] } {
+ set aGuidsMap($theToolKit) [OS:genGUID "xcd"]
+ }
+
+ # Creating xcscheme file for toolkit from template.
+ set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcd"]
+ regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theToolKit aXcschemeTmpl
+ regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theToolKit) aXcschemeTmpl
+ set aXcschemeFile [open "$aSchemesDir/${theToolKit}.xcscheme" "w"]
+ puts $aXcschemeFile $aXcschemeTmpl
+ close $aXcschemeFile
+
+ # Creating xcschememanagement.plist file for toolkit from template.
+ set aPlistTmpl [osutils:readtemplate "plist" "xcd"]
+ regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theToolKit aPlistTmpl
+ regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theToolKit) aPlistTmpl
+ set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
+ puts $aPlistFile $aPlistTmpl
+ close $aPlistFile
+
+ # Creating project.pbxproj file for toolkit.
+ set aPbxprojFile [open "$aToolkitDir/project.pbxproj" "w"]
+ puts $aPbxprojFile "// !\$*UTF8*\$!"
+ puts $aPbxprojFile "\{"
+ puts $aPbxprojFile "\tarchiveVersion = 1;"
+ puts $aPbxprojFile "\tclasses = \{"
+ puts $aPbxprojFile "\t\};"
+ puts $aPbxprojFile "\tobjectVersion = 46;"
+ puts $aPbxprojFile "\tobjects = \{\n"
+
+ # Begin PBXBuildFile section
+ set aPackagesGuids ""
+ set aGroupSection ""
+ set aSrcFileRefSection ""
+ set aSrcFileGuids ""
+ set aDepsFileRefSection ""
+ set aDepsGuids ""
+ set aDepsRefGuids ""
+ set anIncPaths [list "../../../inc"]
+ set anLibPaths ""
+
+ if { [info exists ::env(CSF_OPT_INC)] } {
+ set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
+ foreach anIncCfgPath $anIncCfg {
+ lappend anIncPaths $anIncCfgPath
+ }
+ }
+ if { [info exists ::env(CSF_OPT_LIB64)] } {
+ set anLibCfg [split "$::env(CSF_OPT_LIB64)" ":"]
+ foreach anLibCfgPath $anLibCfg {
+ lappend anLibPaths $anLibCfgPath
+ }
+ }
+
+ puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
+ puts $aPbxprojFile [osutils:xcdtk:deps $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
+ # End PBXBuildFile section
+
+ # Begin PBXFileReference section
+ set aToolkitLib "lib${theToolKit}.dylib"
+ set aPath "$aToolkitLib"
+ if { "$theTargetType" == "executable" } {
+ set aPath "$theToolKit"
+ } elseif { $theIsStatic == 1 } {
+ set aToolkitLib "lib${theToolKit}.a"
+ }
+
+ if { ! [info exists aGuidsMap($aToolkitLib)] } {
+ set aGuidsMap($aToolkitLib) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile "\t\t$aGuidsMap($aToolkitLib) = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.${theTargetType}\"; includeInIndex = 0; path = $aPath; sourceTree = BUILT_PRODUCTS_DIR; };\n"
+ puts $aPbxprojFile $aSrcFileRefSection
+ puts $aPbxprojFile $aDepsFileRefSection
+ # End PBXFileReference section
+
+
+ # Begin PBXFrameworksBuildPhase section
+ set aTkFrameworks "${theToolKit}_Frameworks"
+ if { ! [info exists aGuidsMap($aTkFrameworks)] } {
+ set aGuidsMap($aTkFrameworks) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkFrameworks) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXFrameworksBuildPhase;"
+ puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+ puts $aPbxprojFile "\t\t\tfiles = ("
+ puts $aPbxprojFile $aDepsGuids
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXFrameworksBuildPhase section
+
+ # Begin PBXGroup section
+ set aTkPBXGroup "${theToolKit}_PBXGroup"
+ if { ! [info exists aGuidsMap($aTkPBXGroup)] } {
+ set aGuidsMap($aTkPBXGroup) [OS:genGUID "xcd"]
+ }
+
+ set aTkSrcGroup "${theToolKit}_SrcGroup"
+ if { ! [info exists aGuidsMap($aTkSrcGroup)] } {
+ set aGuidsMap($aTkSrcGroup) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile $aGroupSection
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkPBXGroup) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
+ puts $aPbxprojFile "\t\t\tchildren = ("
+ puts $aPbxprojFile $aDepsRefGuids
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSrcGroup) ,"
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aToolkitLib) ,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
+ puts $aPbxprojFile "\t\t\};"
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkSrcGroup) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXGroup;"
+ puts $aPbxprojFile "\t\t\tchildren = ("
+ puts $aPbxprojFile $aPackagesGuids
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tname = \"Source files\";"
+ puts $aPbxprojFile "\t\t\tsourceTree = \"<group>\";"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXGroup section
+
+ # Begin PBXHeadersBuildPhase section
+ set aTkHeaders "${theToolKit}_Headers"
+ if { ! [info exists aGuidsMap($aTkHeaders)] } {
+ set aGuidsMap($aTkHeaders) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkHeaders) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBX${aPBXBuildPhase}BuildPhase;"
+ puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+ puts $aPbxprojFile "\t\t\tfiles = ("
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = ${aRunOnlyForDeployment};"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXHeadersBuildPhase section
+
+ # Begin PBXNativeTarget section
+ set aTkBuildCfgListNativeTarget "${theToolKit}_BuildCfgListNativeTarget"
+ if { ! [info exists aGuidsMap($aTkBuildCfgListNativeTarget)] } {
+ set aGuidsMap($aTkBuildCfgListNativeTarget) [OS:genGUID "xcd"]
+ }
+
+ set aTkSources "${theToolKit}_Sources"
+ if { ! [info exists aGuidsMap($aTkSources)] } {
+ set aGuidsMap($aTkSources) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile "\t\t$aGuidsMap($theToolKit) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXNativeTarget;"
+ puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListNativeTarget) ;"
+ puts $aPbxprojFile "\t\t\tbuildPhases = ("
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkSources) ,"
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkFrameworks) ,"
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkHeaders) ,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tbuildRules = ("
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tdependencies = ("
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tname = $theToolKit;"
+ puts $aPbxprojFile "\t\t\tproductName = $theToolKit;"
+ puts $aPbxprojFile "\t\t\tproductReference = $aGuidsMap($aToolkitLib) ;"
+ puts $aPbxprojFile "\t\t\tproductType = \"com.apple.product-type.${aProductType}\";"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXNativeTarget section
+
+ # Begin PBXProject section
+ set aTkProjectObj "${theToolKit}_ProjectObj"
+ if { ! [info exists aGuidsMap($aTkProjectObj)] } {
+ set aGuidsMap($aTkProjectObj) [OS:genGUID "xcd"]
+ }
+
+ set aTkBuildCfgListProj "${theToolKit}_BuildCfgListProj"
+ if { ! [info exists aGuidsMap($aTkBuildCfgListProj)] } {
+ set aGuidsMap($aTkBuildCfgListProj) [OS:genGUID "xcd"]
+ }
+
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkProjectObj) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXProject;"
+ puts $aPbxprojFile "\t\t\tattributes = \{"
+ puts $aPbxprojFile "\t\t\t\tLastUpgradeCheck = 0430;"
+ puts $aPbxprojFile "\t\t\t\};"
+ puts $aPbxprojFile "\t\t\tbuildConfigurationList = $aGuidsMap($aTkBuildCfgListProj) ;"
+ puts $aPbxprojFile "\t\t\tcompatibilityVersion = \"Xcode 3.2\";"
+ puts $aPbxprojFile "\t\t\tdevelopmentRegion = English;"
+ puts $aPbxprojFile "\t\t\thasScannedForEncodings = 0;"
+ puts $aPbxprojFile "\t\t\tknownRegions = ("
+ puts $aPbxprojFile "\t\t\t\ten,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tmainGroup = $aGuidsMap($aTkPBXGroup);"
+ puts $aPbxprojFile "\t\t\tproductRefGroup = $aGuidsMap($aTkPBXGroup);"
+ puts $aPbxprojFile "\t\t\tprojectDirPath = \"\";"
+ puts $aPbxprojFile "\t\t\tprojectRoot = \"\";"
+ puts $aPbxprojFile "\t\t\ttargets = ("
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($theToolKit) ,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXProject section
+
+ # Begin PBXSourcesBuildPhase section
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkSources) = \{"
+ puts $aPbxprojFile "\t\t\tisa = PBXSourcesBuildPhase;"
+ puts $aPbxprojFile "\t\t\tbuildActionMask = 2147483647;"
+ puts $aPbxprojFile "\t\t\tfiles = ("
+ puts $aPbxprojFile $aSrcFileGuids
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\trunOnlyForDeploymentPostprocessing = 0;"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End PBXSourcesBuildPhase section
+
+ # Begin XCBuildConfiguration section
+ set aTkDebugProject "${theToolKit}_DebugProject"
+ if { ! [info exists aGuidsMap($aTkDebugProject)] } {
+ set aGuidsMap($aTkDebugProject) [OS:genGUID "xcd"]
+ }
+
+ set aTkReleaseProject "${theToolKit}_ReleaseProject"
+ if { ! [info exists aGuidsMap($aTkReleaseProject)] } {
+ set aGuidsMap($aTkReleaseProject) [OS:genGUID "xcd"]
+ }
+
+ set aTkDebugNativeTarget "${theToolKit}_DebugNativeTarget"
+ if { ! [info exists aGuidsMap($aTkDebugNativeTarget)] } {
+ set aGuidsMap($aTkDebugNativeTarget) [OS:genGUID "xcd"]
+ }
+
+ set aTkReleaseNativeTarget "${theToolKit}_ReleaseNativeTarget"
+ if { ! [info exists aGuidsMap($aTkReleaseNativeTarget)] } {
+ set aGuidsMap($aTkReleaseNativeTarget) [OS:genGUID "xcd"]
+ }
+
+ # Debug target
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+ puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+
+ puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
+ puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+ if { "$thePlatform" == "ios" } {
+ puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
+ puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
+ puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
+ puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
+ puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
+ }
+ puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
+ puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
+ puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
+ puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
+ puts $aPbxprojFile "\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;"
+ puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;"
+ puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+ puts $aPbxprojFile "\t\t\t\t\t\"DEBUG=1\","
+ puts $aPbxprojFile "\t\t\t\t\t\"\$\(inherited\)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = NO;"
+ puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
+ puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64D)\"; "
+ if { "$thePlatform" == "ios" } {
+ puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = NO;"
+ puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
+ } else {
+ puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
+ }
+ puts $aPbxprojFile "\t\t\t\};"
+
+ puts $aPbxprojFile "\t\t\tname = Debug;"
+ puts $aPbxprojFile "\t\t\};"
+
+ # Release target
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+ puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+
+ puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
+ puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+ if { "$thePlatform" == "ios" } {
+ puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphoneos\*\]\" = \"\$(ARCHS_STANDARD)\";";
+ puts $aPbxprojFile "\t\t\t\t\"ARCHS\[sdk=iphonesimulator\*\]\" = \"x86_64\";";
+ puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";"
+ puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_MODULES = YES;"
+ puts $aPbxprojFile "\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;"
+ }
+ puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
+ puts $aPbxprojFile "\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";"
+ puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
+ puts $aPbxprojFile "\t\t\t\tGCC_ENABLE_OBJC_EXCEPTIONS = YES;"
+ puts $aPbxprojFile "\t\t\t\tDEAD_CODE_STRIPPING = NO;"
+ puts $aPbxprojFile "\t\t\t\tGCC_OPTIMIZATION_LEVEL = 2;"
+ puts $aPbxprojFile "\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES;"
+ puts $aPbxprojFile "\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;"
+ puts $aPbxprojFile "\t\t\t\tOTHER_LDFLAGS = \"\$(CSF_OPT_LNK64)\";"
+ if { "$thePlatform" == "ios" } {
+ puts $aPbxprojFile "\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 7.0;"
+ puts $aPbxprojFile "\t\t\t\tSDKROOT = iphoneos;"
+ }
+ puts $aPbxprojFile "\t\t\t\};"
+ puts $aPbxprojFile "\t\t\tname = Release;"
+ puts $aPbxprojFile "\t\t\};"
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugNativeTarget) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+ puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+ puts $aPbxprojFile "${anExecExtension}"
+ puts $aPbxprojFile "${anExecPrefix}"
+ puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+ foreach aMacro $aTKDefines {
+ puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
+ }
+ puts $aPbxprojFile "\t\t\t\t);"
+
+ puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
+ foreach anIncPath $anIncPaths {
+ puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
+ }
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+
+ puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
+ foreach anLibPath $anLibPaths {
+ puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
+ }
+ puts $aPbxprojFile "\t\t\t\t);"
+
+ puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
+ set anUserHeaderSearchPath "\t\t\t\tUSER_HEADER_SEARCH_PATHS = \""
+ foreach anIncPath $anIncPaths {
+ append anUserHeaderSearchPath " ${anIncPath}"
+ }
+ append anUserHeaderSearchPath "\";"
+ puts $aPbxprojFile $anUserHeaderSearchPath
+ puts $aPbxprojFile "${aWrapperExtension}"
+ puts $aPbxprojFile "\t\t\t\};"
+ puts $aPbxprojFile "\t\t\tname = Debug;"
+ puts $aPbxprojFile "\t\t\};"
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseNativeTarget) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
+ puts $aPbxprojFile "\t\t\tbuildSettings = \{"
+ puts $aPbxprojFile "${anExecExtension}"
+ puts $aPbxprojFile "${anExecPrefix}"
+ puts $aPbxprojFile "\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = ("
+ foreach aMacro $aTKDefines {
+ puts $aPbxprojFile "\t\t\t\t\t${aMacro} ,"
+ }
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tHEADER_SEARCH_PATHS = ("
+ foreach anIncPath $anIncPaths {
+ puts $aPbxprojFile "\t\t\t\t\t${anIncPath},"
+ }
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+
+ puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = ("
+ foreach anLibPath $anLibPaths {
+ puts $aPbxprojFile "\t\t\t\t\t${anLibPath},"
+ }
+ puts $aPbxprojFile "\t\t\t\t);"
+
+ puts $aPbxprojFile "\t\t\t\tOTHER_CFLAGS = ("
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_CMPL)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tOTHER_CPLUSPLUSFLAGS = ("
+ puts $aPbxprojFile "\t\t\t\t\t\"\$(OTHER_CFLAGS)\","
+ puts $aPbxprojFile "\t\t\t\t);"
+ puts $aPbxprojFile "\t\t\t\tPRODUCT_NAME = \"\$(TARGET_NAME)\";"
+ puts $aPbxprojFile $anUserHeaderSearchPath
+ puts $aPbxprojFile "${aWrapperExtension}"
+ puts $aPbxprojFile "\t\t\t\};"
+ puts $aPbxprojFile "\t\t\tname = Release;"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End XCBuildConfiguration section
+
+ # Begin XCConfigurationList section
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListProj) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
+ puts $aPbxprojFile "\t\tbuildConfigurations = ("
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugProject) ,"
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseProject) ,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
+ puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
+ puts $aPbxprojFile "\t\t\};"
+ puts $aPbxprojFile "\t\t$aGuidsMap($aTkBuildCfgListNativeTarget) = \{"
+ puts $aPbxprojFile "\t\t\tisa = XCConfigurationList;"
+ puts $aPbxprojFile "\t\t\tbuildConfigurations = ("
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkDebugNativeTarget) ,"
+ puts $aPbxprojFile "\t\t\t\t$aGuidsMap($aTkReleaseNativeTarget) ,"
+ puts $aPbxprojFile "\t\t\t);"
+ puts $aPbxprojFile "\t\t\tdefaultConfigurationIsVisible = 0;"
+ puts $aPbxprojFile "\t\t\tdefaultConfigurationName = Release;"
+ puts $aPbxprojFile "\t\t\};\n"
+ # End XCConfigurationList section
+
+ puts $aPbxprojFile "\t\};"
+ puts $aPbxprojFile "\trootObject = $aGuidsMap($aTkProjectObj) ;"
+ puts $aPbxprojFile "\}"
+
+ close $aPbxprojFile
+}
+
+proc osutils:xcdx { theOutDir theExecutable theGuidsMap } {
+ set aUsername [exec whoami]
+
+ # Creating folders for Xcode project file.
+ set anExecutableDir "${theOutDir}/${theExecutable}.xcodeproj"
+ wokUtils:FILES:mkdir $anExecutableDir
+ if { ! [file exists $anExecutableDir] } {
+ puts stderr "Error: Could not create project directory \"$anExecutableDir\""
+ return
+ }
+
+ set aUserDataDir "${anExecutableDir}/xcuserdata"
+ wokUtils:FILES:mkdir $aUserDataDir
+ if { ! [file exists $aUserDataDir] } {
+ puts stderr "Error: Could not create xcuserdata directorty in \"$anExecutableDir\""
+ return
+ }
+
+ set aUserDataDir "${aUserDataDir}/${aUsername}.xcuserdatad"
+ wokUtils:FILES:mkdir $aUserDataDir
+ if { ! [file exists $aUserDataDir] } {
+ puts stderr "Error: Could not create ${aUsername}.xcuserdatad directorty in \"$anExecutableDir\"/xcuserdata"
+ return
+ }
+
+ set aSchemesDir "${aUserDataDir}/xcschemes"
+ wokUtils:FILES:mkdir $aSchemesDir
+ if { ! [file exists $aSchemesDir] } {
+ puts stderr "Error: Could not create xcschemes directorty in \"$aUserDataDir\""
+ return
+ }
+ # End folders creation.
+
+ # Generating GUID for tookit.
+ upvar $theGuidsMap aGuidsMap
+ if { ! [info exists aGuidsMap($theExecutable)] } {
+ set aGuidsMap($theExecutable) [OS:genGUID "xcd"]
+ }
+
+ # Creating xcscheme file for toolkit from template.
+ set aXcschemeTmpl [osutils:readtemplate "xcscheme" "xcode"]
+ regsub -all -- {__TOOLKIT_NAME__} $aXcschemeTmpl $theExecutable aXcschemeTmpl
+ regsub -all -- {__TOOLKIT_GUID__} $aXcschemeTmpl $aGuidsMap($theExecutable) aXcschemeTmpl
+ set aXcschemeFile [open "$aSchemesDir/${theExecutable}.xcscheme" "w"]
+ puts $aXcschemeFile $aXcschemeTmpl
+ close $aXcschemeFile
+
+ # Creating xcschememanagement.plist file for toolkit from template.
+ set aPlistTmpl [osutils:readtemplate "plist" "xcode"]
+ regsub -all -- {__TOOLKIT_NAME__} $aPlistTmpl $theExecutable aPlistTmpl
+ regsub -all -- {__TOOLKIT_GUID__} $aPlistTmpl $aGuidsMap($theExecutable) aPlistTmpl
+ set aPlistFile [open "$aSchemesDir/xcschememanagement.plist" "w"]
+ puts $aPlistFile $aPlistTmpl
+ close $aPlistFile
+}
+
# launch generation
genproj {*}$::argv