]> OCCT Git - occt-wok.git/commitdiff
0025744: XCode projects generator - add extraction options CR25744 master
authorkgv <kgv@opencascade.com>
Thu, 22 Jan 2015 11:51:30 +0000 (14:51 +0300)
committeribs <ibs@opencascade.com>
Mon, 6 Apr 2015 10:54:11 +0000 (13:54 +0300)
wgenproj - generate XCode projets for iOS target with option -ios
wgenproj - generate XCode projects for static libraries with option -static

Export to XCode - hadrcode actual values of $CSF_OPT_INC and $CSF_OPT_LIB64 into project file
New XCode does not want to read environment variables.

src/WOKTclLib/OS.tcl
src/WOKTclLib/osutils.tcl [changed mode: 0755->0644]
src/WOKsite/wok_tclshrc.tcl

index 44d1b3c03fb8b71267da8973c8fe7fae8e7509bf..5a6f9a878a301d4de3d2b022893c86067f5e8a3d 100755 (executable)
@@ -3315,30 +3315,37 @@ proc OS:xcworkspace { theWorkspaceName theModules theOutDir } {
 }
 
 # Generates Xcode project files.
-proc OS:xcodeproj { theModules theOutDir theGuidsMap} {
+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 "dylib"]
+      lappend aProjectFiles [osutils:xcdtk $theOutDir $aToolKit     aGuidsMap $isStatic $thePlatform "dylib"]
     }
     foreach anExecutable [OS:executable ${aModule}] {
-      lappend aProjectFiles [osutils:xcdtk  $theOutDir $anExecutable aGuidsMap "executable"]
+      lappend aProjectFiles [osutils:xcdtk $theOutDir $anExecutable aGuidsMap $isStatic $thePlatform "executable"]
     }
   }
   return $aProjectFiles
 }
 
 # Function to generate Xcode workspace and project files
-proc OS:MKXCD { theOutDir {theModules {}} {theAllSolution ""} } {
+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
+    OS:xcodeproj   $aModule          $theOutDir ::THE_GUIDS_LIST $theLibType $thePlatform
   }
 
   # Generate single workspace "OCCT" containing projects from all modules
@@ -3352,7 +3359,7 @@ 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 {}} {theProjectType {}} {theIDE ""} } {
+proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} {theLibType "dynamic"} {thePlatform ""} } {
   set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd"}
 
   if { [lsearch $aSupportedIDE $theIDE] < 0 } {
@@ -3423,7 +3430,7 @@ proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} } {
     "amk"   { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"}
     "xcd"   {
       set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000" 
-      OS:MKXCD $anOutDir $aModules $anAllSolution
+      OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
     }
   }
 
old mode 100755 (executable)
new mode 100644 (file)
index a54f999..45dde4a
@@ -2744,7 +2744,7 @@ proc relativePath {thePathFrom thePathTo} {
 }
 
 # Generates dependencies section for Xcode project files.
-proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids} {
+proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
   upvar $theGuidsMap         aGuidsMap
   upvar $theFileRefSection   aFileRefSection
   upvar $theDepsGuids        aDepsGuids
@@ -2796,6 +2796,14 @@ proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection
     }
   }
 
+  set aLibExt "dylib"
+  if { $theIsStatic == 1 } {
+    set aLibExt "a"
+    if { "$theTargetType" != "executable" } {
+      return $aBuildFileSection
+    }
+  }
+
   foreach tkx $aUsedToolKits {
     set aDepLib    "${tkx}_Dep"
     set aDepLibRef "${tkx}_DepRef"
@@ -2809,7 +2817,7 @@ proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection
 
     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}.dylib; path = lib${tkx}.dylib; sourceTree = \"<group>\"; \};\n"
+      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"
     }
@@ -2896,7 +2904,7 @@ proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGro
 }
 
 # Creates folders structure and all necessary files for Xcode project.
-proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} } {
+proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {theTargetType "dylib"} } {
   set aPBXBuildPhase "Headers"
   set aRunOnlyForDeployment "0"
   set aProductType "library.dynamic"
@@ -2912,6 +2920,10 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
     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]
@@ -2987,8 +2999,26 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   set aDepsGuids ""
   set aDepsRefGuids ""
   set anIncPaths [list "../../../inc" $::env(WOK_LIBRARY)]
+  set anLibPaths ""
+
+  if { [info exists ::env(CSF_OPT_INC)] } {
+    set anIncCfg [split "$::env(CSF_OPT_INC)" ":"]
+    foreach anIncCfgPath $anIncCfg {
+      lappend anIncPaths $anIncCfgPath
+    }
+  }
+  if { "$::MACOSX_USE_GLX" == "true" } {
+    lappend anLibPaths "/usr/X11/lib"
+  }
+  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]
+  puts $aPbxprojFile [osutils:xcdtk:deps    $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
   # End PBXBuildFile section
 
   # Begin PBXFileReference section
@@ -2996,6 +3026,8 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   set aPath "$aToolkitLib"
   if { "$theTargetType" == "executable" } {
     set aPath "$theToolKit"
+  } elseif { $theIsStatic == 1 } {
+    set aToolkitLib "lib${theToolKit}.a"
   }
 
   if { ! [info exists aGuidsMap($aToolkitLib)] } {
@@ -3168,7 +3200,19 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   puts $aPbxprojFile "\t\t$aGuidsMap($aTkDebugProject) = \{"
   puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
   puts $aPbxprojFile "\t\t\tbuildSettings = \{"
-  puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
+    puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+    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_LANGUAGE_STANDARD = \"gnu++0x\";"
+    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;"
+  } else {
+    puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+  }
   puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
   puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = NO;"
   puts $aPbxprojFile "\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;"
@@ -3186,17 +3230,35 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   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)\"; "
-  puts $aPbxprojFile "\t\t\t\tONLY_ACTIVE_ARCH = YES;"
+  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\};"
   puts $aPbxprojFile "\t\t$aGuidsMap($aTkReleaseProject) = \{"
   puts $aPbxprojFile "\t\t\tisa = XCBuildConfiguration;"
   puts $aPbxprojFile "\t\t\tbuildSettings = \{"
-  puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+
+  if { "$thePlatform" == "ios" } {
+    puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;"
+    puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+    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_LANGUAGE_STANDARD = \"gnu++0x\";"
+    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;"
+  } else {
+    puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
+    puts $aPbxprojFile "\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;"
+  }
   puts $aPbxprojFile "\t\t\t\tARCHS = \"\$(ARCHS_STANDARD_64_BIT)\";"
   puts $aPbxprojFile "\t\t\t\tCOPY_PHASE_STRIP = YES;"
-  puts $aPbxprojFile "\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";"
   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\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;"
@@ -3205,6 +3267,11 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   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\tGCC_OPTIMIZATION_LEVEL = fast;"
+    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\};"
@@ -3218,15 +3285,20 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
     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);"
-  if { "$::MACOSX_USE_GLX" == "true" } {
-    puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = /usr/X11/lib;"
+
+  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);"
@@ -3260,9 +3332,13 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap {theTargetType "dylib"} }
   }
   puts $aPbxprojFile "\t\t\t\t\t\"\$(CSF_OPT_INC)\","
   puts $aPbxprojFile "\t\t\t\t);"
-  if { "$::MACOSX_USE_GLX" == "true" } {
-    puts $aPbxprojFile "\t\t\t\tLIBRARY_SEARCH_PATHS = /usr/X11/lib;"
+
+  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);"
index 4ef676af96b0705337f37f7b2bb10605984bc1f2..587f7946a725230091522f1ef92d8375cdc0b16f 100644 (file)
@@ -319,11 +319,11 @@ proc wgenproj { args } {
 
   # Setting default IDE.
   # For Windows - Visual Studio (vc), Linux - Code Blocks (cbp), Mac OS X - Xcode (cmake).
-  set anTarget ""
+  set anIde ""
   switch -exact -- "$::env(WOKSTATION)" {
-    "wnt"   {set anTarget "$::VCVER"}
-    "lin"   {set anTarget "cmake"}
-    "mac"   {set anTarget "cmake"}
+    "wnt"   {set anIde "$::VCVER"}
+    "lin"   {set anIde "cmake"}
+    "mac"   {set anIde "cmake"}
   }
 
   set isTargetDefault true
@@ -334,19 +334,19 @@ proc wgenproj { args } {
   }
 
   if { [set anIndex [lsearch -nocase $anArgs -ide=*]] != -1 } {
-    regsub -nocase "\\-ide=" [lindex $anArgs $anIndex] "" anTarget
+    regsub -nocase "\\-ide=" [lindex $anArgs $anIndex] "" anIde
     set anArgs [removeAllOccurrencesOf -ide=* $anArgs]
     set isTargetDefault false
   }
 
   if { [set anIndex [lsearch -nocase $anArgs -target=*]] != -1 } {
-    regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anTarget
+    regsub -nocase "\\-target=" [lindex $anArgs $anIndex] "" anIde
     set anArgs [removeAllOccurrencesOf -target=* $anArgs]
     set isTargetDefault false
   }
 
   if { [llength $anArgs] == 0 && $isTargetDefault == true } {
-    puts "the default \'$anTarget\' target has been applied"
+    puts "the default \'$anIde\' target has been applied"
   }
 
   set isHelpRequire false
@@ -355,8 +355,25 @@ proc wgenproj { args } {
     set isHelpRequire true
   }
 
-  if { [lsearch -nocase $aSupportedTargets $anTarget] == -1} {
-    puts "the \'$anTarget\' is wrong TARGET"
+  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 $anIde] == -1} {
+    puts "the \'$anIde\' is wrong TARGET"
     set isHelpRequire true
   }
 
@@ -384,16 +401,16 @@ proc wgenproj { args } {
       return
   }
 
-  puts "the \'$anTarget\' target has been applied"
+  puts "the \'$anIde\' target has been applied"
 
   source "$::env(WOKHOME)/lib/osutils.tcl"
   source "$::env(WOKHOME)/lib/OS.tcl"
 
   # change station if it is necessary
   set anOldStation "$::env(WOKSTATION)"
-  if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12} $anTarget] != -1 && "$anOldStation" != "wnt"} {
+  if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12} $anIde] != -1 && "$anOldStation" != "wnt"} {
     changeStationAndDependentEnvironment wnt
-  } elseif { "$anTarget" == "amk" && "$anOldStation" != "lin"} {
+  } elseif { "$anIde" == "amk" && "$anOldStation" != "lin"} {
     changeStationAndDependentEnvironment lin
   }
 
@@ -415,13 +432,13 @@ proc wgenproj { args } {
   wokcd $aWokCD
 
   if { [wokinfo -x OS] } {
-    OS:MKPRC "$anAdmPath" "OS"  "$anTarget"
+    OS:MKPRC "$anAdmPath" "OS"  "$anIde" "$aLibType" "$aPlatform"
   }
   if { [wokinfo -x VAS] } {
-    OS:MKPRC "$anAdmPath" "VAS" "$anTarget"
+    OS:MKPRC "$anAdmPath" "VAS" "$anIde" "$aLibType" "$aPlatform"
   }
 
-  wgenprojbat "$anAdmPath" "$anTarget"
+  wgenprojbat "$anAdmPath" "$anIde"
   
   # change back station if it is require
   changeStationAndDependentEnvironment "$anOldStation"