From e53561f9b3acf915fd5258fc2fe3e3c21cacb202 Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 26 Oct 2012 10:40:09 +0400 Subject: [PATCH] wgenproj: option -IDE= added Choice of compilation IDE has been added to the WOK function wgenproj Possible ide values: "vc7","vc8","vc9","vc10","cbp" --- src/WOKTclLib/OS.tcl | 147 +++++++++++++++++++++--------------- src/WOKTclLib/osutils.tcl | 19 ----- src/WOKsite/wok_tclshrc.tcl | 44 ++++++++--- 3 files changed, 120 insertions(+), 90 deletions(-) diff --git a/src/WOKTclLib/OS.tcl b/src/WOKTclLib/OS.tcl index 36b7481..9dbf135 100644 --- a/src/WOKTclLib/OS.tcl +++ b/src/WOKTclLib/OS.tcl @@ -2775,13 +2775,25 @@ proc OS:wpack { module dir {verbose 0} } { ;# Dans ce cas module est seulement utilise pour le nom de fichier .sln ;# Avec ca je fais un OCC.sln qui concatene plusieurs modules dans le bon ordre. ;# -proc OS:genGUID {} { - set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]" - set p2 "[format %04X [expr { int(rand() * 6536) }]]" - set p3 "[format %04X [expr { int(rand() * 6536) }]]" - set p4 "[format %04X [expr { int(rand() * 6536) }]]" - set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]" - return "{$p1-$p2-$p3-$p4-$p5}" +proc OS:genGUID { {theIDE "vc"} } { + if { "$theIDE" == "vc" } { + set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]" + set p2 "[format %04X [expr { int(rand() * 6536) }]]" + set p3 "[format %04X [expr { int(rand() * 6536) }]]" + set p4 "[format %04X [expr { int(rand() * 6536) }]]" + set p5 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]" + return "{$p1-$p2-$p3-$p4-$p5}" + } else { + set p1 "[format %04X [expr { int(rand() * 6536) }]]" + set p2 "[format %04X [expr { int(rand() * 6536) }]]" + set p3 "[format %04X [expr { int(rand() * 6536) }]]" + set p4 "[format %04X [expr { int(rand() * 6536) }]]" + set p5 "[format %04X [expr { int(rand() * 6536) }]]" + set p6 "[format %04X [expr { int(rand() * 6536) }]]" + #set p1 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]" + #set p2 "[format %06X [expr { int(rand() * 16777216) }]][format %06X [expr { int(rand() * 16777216) }]]" + return "$p1$p2$p3$p4$p5$p6" + } } # generate Visual Studio solution file @@ -2941,20 +2953,24 @@ proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } { return $aProjectFiles } -# Generate Code::Blocks projects -proc OS:cbp { theModules theOutDir } { - set aProjectFiles {} +# Function to generate Visual Studio solution and project files +proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } { + + puts stderr "Generating VS project files for $theVcVer" + + # generate projects for toolkits and separate solution for each module foreach aModule $theModules { - foreach aToolKit [${aModule}:toolkits] { - lappend aProjectFiles [osutils:cbptk $theOutDir $aToolKit ] - } - foreach anExecutable [OS:executable ${aModule}] { - lappend aProjectFiles [osutils:cbpx $theOutDir $anExecutable] - } + OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST + OS:vcproj $theVcVer $aModule $theOutDir ::THE_GUIDS_LIST + } + + # generate single solution "OCCT" containing projects from all modules + if { "$theAllSolution" != "" } { + OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST } - return $aProjectFiles } +# Generates Code Blocks workspace. proc OS:cworkspace { theSolName theModules theOutDir } { set aWsFilePath "${theOutDir}/${theSolName}.workspace" set aFile [open $aWsFilePath "w"] @@ -3011,22 +3027,57 @@ proc OS:cworkspace { theSolName theModules theOutDir } { return $aWsFilePath } +# Generate Code Blocks projects +proc OS:cbp { theModules theOutDir } { + set aProjectFiles {} + foreach aModule $theModules { + foreach aToolKit [${aModule}:toolkits] { + lappend aProjectFiles [osutils:cbptk $theOutDir $aToolKit ] + } + foreach anExecutable [OS:executable ${aModule}] { + lappend aProjectFiles [osutils:cbpx $theOutDir $anExecutable] + } + } + return $aProjectFiles +} + +# Function to generate Code Blocks workspace and project files +proc OS:MKCBP { theOutDir {theModules {}} {theAllSolution ""} } { + + puts stderr "Generating project files for Code Blocks" + + # Generate projects for toolkits and separate workspace for each module + foreach aModule $theModules { + OS:cworkspace $aModule $aModule $theOutDir + OS:cbp $aModule $theOutDir + } + + # Generate single workspace "OCCT" containing projects from all modules + if { "$theAllSolution" != "" } { + OS:cworkspace $theAllSolution $theModules $theOutDir + } +} + # Store global GUIDs map to reproduce same values on sequential calls set aTKNullKey "TKNull" set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}" -# Entry function to generate VS project files and solutions -proc OS:MKPRC { {theOutDir {}} {theModules {}} {theVcVersions {vc8 vc9 vc10}} } { +# Entry function to generate project files and solutions for IDE +proc OS:MKPRC { {theOutDir {}} {theModules {}} {theIDE ""} } { + set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "cbp"} + + if { [lsearch $aSupportedIDE $theIDE] < 0 } { + puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE" + return + } + set anOutRoot $theOutDir if { $anOutRoot == "" } { set anOutRoot [OS -box] } - # versions of VC supported for each platform - set aVcVersions {vc7 vc8 vc9 vc10} - # read map of already generated GUIDs - set aGuidsFilePath [file join $::env(WOK_SESSIONID) "wok_vs_guids.txt"] + set aGuidsFilePath [file join $::env(WOK_SESSIONID) "wok_${theIDE}_guids.txt"] if [file exists "$aGuidsFilePath"] { set aFileIn [open "$aGuidsFilePath" r] set aFileDataRaw [read $aFileIn] @@ -3051,48 +3102,22 @@ proc OS:MKPRC { {theOutDir {}} {theModules {}} {theVcVersions {vc8 vc9 vc10}} } set anAllSolution "Products" } - # generate projects for each of supported versions of VC - foreach aVcVer $aVcVersions { - if { [llength $theVcVersions] > 0 && [lsearch $theVcVersions $aVcVer] < 0 } { - #puts stderr "Error: No supported versions of Visual Studio" - continue; - } - puts stderr "Generating VS project files for $aVcVer" - - # create output directory - set anOutDir $anOutRoot/msvc/$aVcVer - OS:mkdir $anOutDir - if { ! [file exists $anOutDir] } { - puts stderr "Error: Could not create output directory \"$anOutDir\"" - continue - } - - # generate projects for toolkits and separate solution for each module - foreach aModule $aModules { - OS:vcsolution $aVcVer $aModule $aModule $anOutDir ::THE_GUIDS_LIST - OS:vcproj $aVcVer $aModule $anOutDir ::THE_GUIDS_LIST - } - - # generate single solution "OCCT" containing projects from all modules - if { "$anAllSolution" != "" } { - OS:vcsolution $aVcVer $anAllSolution $aModules $anOutDir ::THE_GUIDS_LIST - } - } - - # create output directory for Code::Blocks project files + # Create output directory set aWokStation "$::env(WOKSTATION)" - set anOutDir "${anOutRoot}/${aWokStation}/cbp" + set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}" OS:mkdir $anOutDir if { ! [file exists $anOutDir] } { puts stderr "Error: Could not create output directory \"$anOutDir\"" - } else { - foreach aModule $aModules { - OS:cworkspace $aModule $aModule $anOutDir - OS:cbp $aModule $anOutDir - } - if { "$anAllSolution" != "" } { - OS:cworkspace $anAllSolution $aModules $anOutDir - } + return + } + + # Generating project files for the selected IDE + switch -exact -- "$theIDE" { + "vc7" - + "vc8" - + "vc9" - + "vc10" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE } + "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution } } # Store generated GUIDs map diff --git a/src/WOKTclLib/osutils.tcl b/src/WOKTclLib/osutils.tcl index b5ce2cf..a8354f2 100755 --- a/src/WOKTclLib/osutils.tcl +++ b/src/WOKTclLib/osutils.tcl @@ -2101,25 +2101,6 @@ proc osutils:cbp { theOutDir theProjName theSrcFiles theLibsList theIncPaths the } } - if { "$theIsExe" == "true" } { - puts $aFile "\t\t" - puts $aFile "\t\t\t" - puts $aFile "\t\t\t" - puts $aFile "\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t\t\t" - puts $aFile "\t\t\t\t" - puts $aFile "\t\t\t" - puts $aFile "\t\t\t" - puts $aFile "\t\t" - } - puts $aFile "\t" puts $aFile "" close $aFile diff --git a/src/WOKsite/wok_tclshrc.tcl b/src/WOKsite/wok_tclshrc.tcl index c3d22c7..67a465a 100644 --- a/src/WOKsite/wok_tclshrc.tcl +++ b/src/WOKsite/wok_tclshrc.tcl @@ -234,7 +234,7 @@ set env(PATH) "${aBinPaths}${::SYS_PATH_SPLITTER}$env(PATH)" if { [file exists "$::env(WOKHOME)/lib/OS.tcl"] } { source "$::env(WOKHOME)/lib/OS.tcl" } -proc wgenprojbat {thePath} { +proc wgenprojbat {thePath theIDE} { source "$::env(WOKHOME)/lib/osutils.tcl" source "$::env(WOKHOME)/lib/OS.tcl" @@ -245,7 +245,6 @@ proc wgenprojbat {thePath} { wokcd -P Home set anOsRootPath [pwd] wokcd $aWokCD - set aVcVer "$::VCVER" set aBox [file normalize "$thePath/.."] @@ -290,18 +289,43 @@ proc wgenprojbat {thePath} { if { "$::tcl_platform(platform)" == "windows" } { catch {file copy -- "$::env(WOKHOME)/site/custom.bat" "$aBox/custom.bat"} file copy -force -- "$::env(WOKHOME)/lib/templates/draw.bat" "$aBox/draw.bat" - file copy -force -- "$::env(WOKHOME)/lib/templates/msvc.bat" "$aBox/msvc.bat" } else { catch {file copy -- "$::env(WOKHOME)/site/custom.sh" "$aBox/custom.sh"} file copy -force -- "$::env(WOKHOME)/lib/templates/draw.sh" "$aBox/draw.sh" - file copy -force -- "$::env(WOKHOME)/lib/templates/codeblocks.sh" "$aBox/codeblocks.sh" + } + + switch -exact -- "$theIDE" { + "vc7" - + "vc8" - + "vc9" - + "vc10" { file copy -force -- "$::env(WOKHOME)/lib/templates/msvc.bat" "$aBox/msvc.bat" } + "cbp" { file copy -force -- "$::env(WOKHOME)/lib/templates/codeblocks.sh" "$aBox/codeblocks.sh" } } } # Wrapper-function to generate VS project files -proc wgenproj {{theProcArgs ""}} { - if { "$theProcArgs" != "" } { - wprocess $theProcArgs -DGroups=Src,Xcpp +proc wgenproj { args } { + + set aProcArgs $args + + # Setting default IDE. + # For Windows - Visual Studio (vc), Linux - Code Blocks (cbp), Mac OS X - Xcode (). + set anIDE "" + switch -exact -- "$::env(WOKSTATION)" { + "wnt" {set anIDE "$::VCVER"} + "lin" {set anIDE "cbp"} + } + + # Getting from arguments the name of IDE, for which we should generate project files. + set anIndex [lsearch $aProcArgs -IDE=*] + if {$anIndex >= 0} { + set anIDE [lindex $aProcArgs $anIndex] + set anIDE [string map {-IDE= ""} $anIDE] + set aProcArgs [lreplace $aProcArgs $anIndex $anIndex] + } + + if { "$aProcArgs" != "" } { + wprocess $aProcArgs -DGroups=Src,Xcpp } else { wprocess -DGroups=Src,Xcpp } @@ -313,12 +337,12 @@ proc wgenproj {{theProcArgs ""}} { wokcd $aWokCD if { [wokinfo -x OS] } { - OS:MKPRC "$anAdmPath" "OS" "$::VCVER" + OS:MKPRC "$anAdmPath" "OS" "$anIDE" } if { [wokinfo -x VAS] } { - OS:MKPRC "$anAdmPath" "VAS" "$::VCVER" + OS:MKPRC "$anAdmPath" "VAS" "$anIDE" } - wgenprojbat "$anAdmPath" + wgenprojbat "$anAdmPath" "$anIDE" } # Function to prepare environment -- 2.39.5