Skip to content

Commit

Permalink
0030967: Configuration, genproj.tcl - generate OCCProducts solution f…
Browse files Browse the repository at this point in the history
…or products

genproj procedure has been extended with new parameters -solution, set to OCCT by default.
Added missing HAVE_RAPIDJSON to env.sh.

Added implicit file path normalization for PRODUCTS_PATH variable,
to avoid genconf.tcl script malfunction on backslashed.
  • Loading branch information
gkv311 authored and bugmaster committed Sep 16, 2019
1 parent 487942b commit f4b0c77
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 28 deletions.
10 changes: 7 additions & 3 deletions adm/genconf.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# load tools
source [file join [file dirname [info script]] genconfdeps.tcl]

# proxy variable for implicit file path normalization
set PRODUCTS_PATH_INPUT "$::PRODUCTS_PATH"

package require Tk

set aRowIter 0
Expand Down Expand Up @@ -225,9 +228,9 @@ proc wokdep:gui:BrowseVcVars {} {
}

proc wokdep:gui:BrowsePartiesRoot {} {
set aResult [tk_chooseDirectory -initialdir $::PRODUCTS_PATH -title "Choose a directory"]
set aResult [tk_chooseDirectory -initialdir $::PRODUCTS_PATH_INPUT -title "Choose a directory"]
if { "$aResult" != "" } {
set ::PRODUCTS_PATH $aResult
set ::PRODUCTS_PATH_INPUT $aResult
wokdep:gui:UpdateList
}
}
Expand Down Expand Up @@ -441,7 +444,7 @@ ttk::label .myFrame.myHxxChecks.myScutsLbl -text "Strategy for filling he

#
ttk::label .myFrame.mySrchLbl -text "3rd-parties search path:" -padding {5 5 80 5}
entry .myFrame.mySrchEntry -textvariable PRODUCTS_PATH -width 80
entry .myFrame.mySrchEntry -textvariable PRODUCTS_PATH_INPUT -width 80
ttk::button .myFrame.mySrchBrowseBtn -text "Browse" -command wokdep:gui:BrowsePartiesRoot
checkbutton .myFrame.myChecks.myFImageCheck -offvalue "false" -onvalue "true" -variable HAVE_FREEIMAGE -command wokdep:gui:UpdateList
ttk::label .myFrame.myChecks.myFImageLbl -text "Use FreeImage"
Expand Down Expand Up @@ -650,6 +653,7 @@ bind .myFrame.myVsFrame.myArchCombo <<ComboboxSelected>> {
}

.myFrame.mySrchEntry configure -validate all -validatecommand {
set ::PRODUCTS_PATH [file normalize "$::PRODUCTS_PATH_INPUT"]
#return [file exists "$::PRODUCTS_PATH"]
wokdep:gui:UpdateList
return 1
Expand Down
5 changes: 4 additions & 1 deletion adm/genconfdeps.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ if { "$tcl_platform(platform)" != "windows" } {
set HAVE_D3D ""
set HAVE_RelWithDebInfo ""
}
foreach anEnvIter {ARCH VCVER VCVARS PRJFMT PRODUCTS_PATH} {
foreach anEnvIter {ARCH VCVER VCVARS PRJFMT } {
if { [info exists ::env(${anEnvIter})] } {
set ${anEnvIter} "$::env(${anEnvIter})"
}
}
if { [info exists ::env(PRODUCTS_PATH)] } {
set PRODUCTS_PATH [file normalize "$::env(PRODUCTS_PATH)"]
}

if { [info exists ::env(CSF_OPT_INC)] } {
set CSF_OPT_INC [split "$::env(CSF_OPT_INC)" $::SYS_PATH_SPLITTER]
Expand Down
53 changes: 35 additions & 18 deletions adm/genproj.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ proc genproj {theFormat args} {

# Check optional arguments
set aLibType "dynamic"
foreach arg $args {
if { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
set aSolution "OCCT"
for {set anArgIter 0} {$anArgIter < [llength args]} {incr anArgIter} {
set arg [lindex $args $anArgIter]
if { $arg == "" } {
continue
} elseif { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
set isHelpRequire true
} elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
set aPlatform $arg
Expand All @@ -295,6 +299,9 @@ proc genproj {theFormat args} {
} elseif { $arg == "-dynamic" } {
set aLibType "dynamic"
puts "Dynamic build has been selected"
} elseif { $arg == "-solution" } {
incr anArgIter
set aSolution [lindex $args $anArgIter]
} else {
puts "Error: genproj: unrecognized option \"$arg\""
set isHelpRequire true
Expand Down Expand Up @@ -340,9 +347,9 @@ proc genproj {theFormat args} {
# base path to where to generate projects, hardcoded from current dir
set anAdmPath [file normalize "${::path}/adm"]

OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl"
OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl" "$aSolution"

genprojbat "$theFormat" "$aPlatform"
genprojbat "$theFormat" "$aPlatform" "$aSolution"
genAllResources
}

Expand All @@ -362,7 +369,8 @@ proc copy_with_warning {from to} {
file copy -force -- "$from" "$to"
}

proc genprojbat {theFormat thePlatform} {
# Generate auxiliary scripts for launching IDE.
proc genprojbat {theFormat thePlatform theSolution} {
set aTargetPlatformExt sh
if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
set aTargetPlatformExt bat
Expand Down Expand Up @@ -390,14 +398,13 @@ proc genprojbat {theFormat thePlatform} {
copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
}

set aSolShList ""
if { [regexp {^vc} $theFormat] } {
copy_with_warning "$::THE_CASROOT/adm/templates/msvc.bat" "$::path/msvc.bat"
set aSolShList "msvc.bat"
} else {
switch -exact -- "$theFormat" {
"cbp" {
file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.sh" "$::path/codeblocks.sh"
file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.bat" "$::path/codeblocks.bat"

"cbp" {
set aSolShList { "codeblocks.sh" "codeblocks.bat" }
# Code::Blocks 16.01 does not create directory for import libs, help him
set aPlatformAndCompiler "${thePlatform}/gcc"
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
Expand All @@ -406,9 +413,21 @@ proc genprojbat {theFormat thePlatform} {
file mkdir "$::path/${aPlatformAndCompiler}/lib"
file mkdir "$::path/${aPlatformAndCompiler}/libd"
}
"xcd" { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh" "$::path/xcode.sh" }
"xcd" { set aSolShList "xcode.sh" }
}
}

foreach aSolSh $aSolShList {
set anShFile [open "$::THE_CASROOT/adm/templates/${aSolSh}" "r"]
set anShTmpl [read $anShFile]
close $anShFile

regsub -all -- {__SOLUTION__} $anShTmpl "$theSolution" anShTmpl

set anShFile [open "$::path/${aSolSh}" "w"]
puts $anShFile $anShTmpl
close $anShFile
}
}

###### MSVC #############################################################33
Expand All @@ -429,7 +448,8 @@ set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
# @param theLibType Library type - dynamic or static
# @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
# @param theCmpl Compiler option (msvc or gcc)
proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
# @param theSolution Solution name
proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution } {
global path
set anOutRoot $theOutDir
if { $anOutRoot == "" } {
Expand Down Expand Up @@ -493,9 +513,6 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
return
}

# generate one solution for all projects if complete OS or VAS is processed
set anAllSolution "OCCT"

wokUtils:FILES:mkdir $anOutDir
if { ![file exists $anOutDir] } {
puts stderr "Error: Could not create output directory \"$anOutDir\""
Expand All @@ -512,11 +529,11 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
"vc12" -
"vc14" -
"vc141" -
"vc142" { OS:MKVC $anOutDir $aModules $anAllSolution $theFormat $isUWP}
"cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution $thePlatform $theCmpl }
"vc142" { OS:MKVC $anOutDir $aModules $theSolution $theFormat $isUWP}
"cbp" { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl }
"xcd" {
set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
OS:MKXCD $anOutDir $aModules $theSolution $theLibType $thePlatform
}
}

Expand Down
5 changes: 3 additions & 2 deletions adm/templates/codeblocks.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/bin/bash
# This file has been generated by genproj.tcl script from CASROOT/adm/templates/codeblocks.sh

export TARGET="cbp"

source ./env.sh "$1" "$TARGET"

if [ -e "/Applications/CodeBlocks.app/Contents/MacOS/CodeBlocks" ]; then
/Applications/CodeBlocks.app/Contents/MacOS/CodeBlocks ./adm/$WOKSTATION/cbp/OCCT.workspace
/Applications/CodeBlocks.app/Contents/MacOS/CodeBlocks ./adm/$WOKSTATION/cbp/__SOLUTION__.workspace
else
codeblocks ./adm/$WOKSTATION/cbp/OCCT.workspace
codeblocks ./adm/$WOKSTATION/cbp/__SOLUTION__.workspace
fi
2 changes: 2 additions & 0 deletions adm/templates/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export HAVE_VTK="false";
export HAVE_GLES2="false";
export HAVE_ZLIB="false";
export HAVE_LIBLZMA="false";
export HAVE_RAPIDJSON="false";
export MACOSX_USE_GLX="false";
export CSF_OPT_INC=""
export CSF_OPT_LIB32=""
Expand Down Expand Up @@ -103,6 +104,7 @@ if [ "$HAVE_GLES2" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -D
if [ "$HAVE_VTK" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_VTK"; fi
if [ "$HAVE_ZLIB" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_ZLIB"; fi
if [ "$HAVE_LIBLZMA" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_LIBLZMA"; fi
if [ "$HAVE_RAPIDJSON" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DHAVE_RAPIDJSON"; fi
# Option to compile OCCT with X11 libs on Mac OS X
if [ "$MACOSX_USE_GLX" == "true" ]; then export CSF_OPT_CMPL="${CSF_OPT_CMPL} -DMACOSX_USE_GLX"; fi

Expand Down
3 changes: 2 additions & 1 deletion adm/templates/msvc.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@echo off
rem This file has been generated by genproj.tcl script from CASROOT/adm/templates/msvc.bat

rem Setup environment
call "%~dp0env.bat" %1 %2 %3

rem Define path to project file
set "PRJFILE=%~dp0\adm\msvc\%VCVER%\OCCT.sln"
set "PRJFILE=%~dp0\adm\msvc\%VCVER%\__SOLUTION__.sln"
if not exist "%PRJFILE%" set "PRJFILE=%~dp0\adm\msvc\%VCVER%\Products.sln"
if not "%4" == "" (
set "PRJFILE=%4"
Expand Down
3 changes: 2 additions & 1 deletion adm/templates/xcode.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
# This file has been generated by genproj.tcl script from CASROOT/adm/templates/xcode.sh

export TARGET="xcd"

source ./env.sh "$1" "$TARGET"

open -a Xcode ./adm/mac/xcd/OCCT.xcworkspace
open -a Xcode ./adm/mac/xcd/__SOLUTION__.xcworkspace
2 changes: 1 addition & 1 deletion genproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if [ "$aTarget" == "" ]; then
fi

cd $aScriptPath
tclsh "./adm/start.tcl" genproj ${aTarget} $anOpt2 $anOpt3 $anOpt4 $anOpt5
tclsh "./adm/start.tcl" genproj ${aTarget} -solution "OCCT" $anOpt2 $anOpt3 $anOpt4 $anOpt5

export PATH="$anOldPath"
export LD_LIBRARY_PATH="$anOldLd"
Expand Down
2 changes: 1 addition & 1 deletion genproj.bat
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ if "%aPrjFmt%" == "" ( set "aPrjFmt=vcxproj" )
if "%aPrjFmt%" == "vcxproj" ( set "aPrjFmt=%VCFMT%" )

cd %~dp0
%TCL_EXEC% %~dp0adm/start.tcl genproj %aPrjFmt% %aPlatform% %3 %4 %5
%TCL_EXEC% %~dp0adm/start.tcl genproj %aPrjFmt% %aPlatform% -solution "OCCT" %3 %4 %5
SET "PATH=%OLD_PATH%"

0 comments on commit f4b0c77

Please sign in to comment.