1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0030339: Configuration - add project files for qmake

Added adm/qmake/Occt.pro for building OCCT using Qt Creator.
genproj/genconf scripts have been extended with an option defining project format.

Draw_Appli now tries resolving CASROOT/DRAWDEFAULT/CSF_OCCTResourcePath/CSF_OCCTSamplesPath
locations within usual OCCT development/installation environment.
Added missing TKShHealing dependency to TKDraw/DRAWEXE (inherited from TKMesh).
OSD_Process::ExecutableFolder() - added method returning executable folder.
This commit is contained in:
kgv 2019-04-01 23:44:20 +03:00 committed by apn
parent 84b904bc36
commit aafe169f89
24 changed files with 892 additions and 119 deletions

1
adm/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build-*

View File

@ -30,10 +30,30 @@ set aRowIter 0
set aCheckRowIter 0
frame .myFrame -padx 5 -pady 5
pack .myFrame -fill both -expand 1
frame .myFrame.myPrjFrame
frame .myFrame.myVsFrame
frame .myFrame.myHxxChecks
frame .myFrame.myChecks
# project file format
set SYS_PRJFMT_LIST {}
set SYS_PRJNAME_LIST {}
if { "$::tcl_platform(platform)" == "windows" } {
lappend ::SYS_PRJFMT_LIST "vcxproj"
lappend ::SYS_PRJNAME_LIST "Visual Studio (.vcxproj)"
}
if { "$tcl_platform(os)" == "Darwin" } {
lappend ::SYS_PRJFMT_LIST "xcd"
lappend ::SYS_PRJNAME_LIST "XCode (.xcd)"
}
lappend ::SYS_PRJFMT_LIST "cbp"
lappend ::SYS_PRJNAME_LIST "Code Blocks (.cbp)"
lappend ::SYS_PRJFMT_LIST "pro"
lappend ::SYS_PRJNAME_LIST "Qt Creator (.pro)"
set aPrjIndex [lsearch $::SYS_PRJFMT_LIST $::PRJFMT]
set ::PRJNAME [lindex $::SYS_PRJNAME_LIST $aPrjIndex]
set SYS_VS_LIST {}
set SYS_VC_LIST {}
set SYS_VCVARS_LIST {}
@ -101,6 +121,7 @@ proc wokdep:gui:Close {} {
}
proc wokdep:gui:SwitchConfig {} {
set ::PRJFMT [lindex $::SYS_PRJFMT_LIST [.myFrame.myPrjFrame.myPrjCombo current]]
set ::VCVER [lindex $::SYS_VC_LIST [.myFrame.myVsFrame.myVsCombo current]]
set ::VCVARS [lindex $::SYS_VCVARS_LIST [.myFrame.myVsFrame.myVsCombo current]]
@ -390,6 +411,8 @@ proc wokdep:gui:Show64Bitness { theRowIter } {
}
# Header
ttk::label .myFrame.myPrjFrame.myPrjLbl -text "Project format:" -padding {5 5 20 5}
ttk::combobox .myFrame.myPrjFrame.myPrjCombo -values $SYS_PRJNAME_LIST -state readonly -textvariable PRJNAME -width 40
ttk::label .myFrame.myVsFrame.myVsLbl -text "Visual Studio configuration:" -padding {5 5 20 5}
ttk::combobox .myFrame.myVsFrame.myVsCombo -values $SYS_VS_LIST -state readonly -textvariable VSVER -width 40
ttk::combobox .myFrame.myVsFrame.myArchCombo -values { {32} {64} } -textvariable ARCH -state readonly -width 6
@ -494,6 +517,10 @@ ttk::button .myFrame.myClose -text "Close" -command wokdep:gui:Close
# Create grid
# Header
grid .myFrame.myPrjFrame -row $aRowIter -column 0 -columnspan 10 -sticky w
grid .myFrame.myPrjFrame.myPrjLbl -row 0 -column 0
grid .myFrame.myPrjFrame.myPrjCombo -row 0 -column 1
incr aRowIter
if { "$tcl_platform(platform)" == "windows" } {
grid .myFrame.myVsFrame -row $aRowIter -column 0 -columnspan 10 -sticky w
grid .myFrame.myVsFrame.myVsLbl -row 0 -column 0
@ -592,6 +619,9 @@ grid .myFrame.mySave -row $aRowIter -column 4 -columnspan 2
grid .myFrame.myClose -row $aRowIter -column 6 -columnspan 2
# Bind events
bind .myFrame.myPrjFrame.myPrjCombo <<ComboboxSelected>> {
wokdep:gui:SwitchConfig
}
bind .myFrame.myVsFrame.myVsCombo <<ComboboxSelected>> {
wokdep:gui:SwitchConfig
}

View File

@ -27,8 +27,10 @@ if { "$tcl_platform(platform)" == "unix" } {
set SYS_EXE_SUFFIX ""
if { "$tcl_platform(os)" == "Darwin" } {
set SYS_LIB_SUFFIX "dylib"
set PRJFMT "xcd"
} else {
set SYS_LIB_SUFFIX "so"
set PRJFMT "cbp"
}
set VCVER "gcc"
set VCVARS ""
@ -39,6 +41,7 @@ if { "$tcl_platform(platform)" == "unix" } {
set SYS_EXE_SUFFIX ".exe"
set VCVER "vc10"
set VCVARS ""
set PRJFMT "vcxproj"
}
set SHORTCUT_HEADERS "ShortCut"
@ -82,7 +85,7 @@ if { "$tcl_platform(platform)" != "windows" } {
set HAVE_D3D ""
set HAVE_RelWithDebInfo ""
}
foreach anEnvIter {ARCH VCVER VCVARS PRODUCTS_PATH} {
foreach anEnvIter {ARCH VCVER VCVARS PRJFMT PRODUCTS_PATH} {
if { [info exists ::env(${anEnvIter})] } {
set ${anEnvIter} "$::env(${anEnvIter})"
}
@ -1118,15 +1121,33 @@ proc wokdep:SearchX11 {theErrInc theErrLib32 theErrLib64 theErrBin32 theErrBin64
return "$isFound"
}
# Returns OCCT version string from file Standard_Version.hxx (if available)
proc wokdep:DetectCasVersion {} {
set occt_ver 7.0.0
set aCasRoot [file normalize [file dirname [info script]]]
set filename "${aCasRoot}/src/Standard/Standard_Version.hxx"
if { [file exists $filename] } {
set fh [open $filename "r"]
set fh_loaded [read $fh]
close $fh
regexp {[^/]\s*#\s*define\s+OCC_VERSION_COMPLETE\s+\"([^\s]*)\"} $fh_loaded dummy occt_ver
} else {
puts "Error: file '$filename' not found"
}
return $occt_ver
}
# Generate (override) custom environment file
proc wokdep:SaveCustom {} {
set aGenInfo "This environment file was generated by genconf.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
if { "$::tcl_platform(platform)" == "windows" } {
set aCustomFilePath "./custom.bat"
set aFile [open $aCustomFilePath "w"]
puts $aFile "@echo off"
puts $aFile "rem This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
puts $aFile "rem $aGenInfo"
puts $aFile ""
puts $aFile "set PRJFMT=$::PRJFMT"
puts $aFile "set VCVER=$::VCVER"
puts $aFile "set ARCH=$::ARCH"
puts $aFile "set VCVARS=$::VCVARS"
@ -1175,9 +1196,10 @@ proc wokdep:SaveCustom {} {
set aCustomFilePath "./custom.sh"
set aFile [open $aCustomFilePath "w"]
puts $aFile "#!/bin/bash"
puts $aFile "# This environment file was generated by wok_depsgui.tcl script at [clock format [clock seconds] -format "%Y.%m.%d %H:%M"]"
puts $aFile "# $aGenInfo"
puts $aFile ""
puts $aFile "export PRJFMT=$::PRJFMT"
puts $aFile "export ARCH=$::ARCH"
puts $aFile "export SHORTCUT_HEADERS=$::SHORTCUT_HEADERS"
@ -1211,6 +1233,52 @@ proc wokdep:SaveCustom {} {
close $aFile
}
puts "Configuration saved to file '$aCustomFilePath'"
if { "$::PRJFMT" == "pro" } {
set aCasVer [wokdep:DetectCasVersion]
set aCustomFilePath "./adm/qmake/custom.auto.pri"
set aFile [open $aCustomFilePath "w"]
puts $aFile "# $aGenInfo"
puts $aFile ""
puts $aFile "VERSION=$aCasVer"
puts $aFile "PRODUCTS_PATH=\"$::PRODUCTS_PATH\""
puts $aFile ""
puts $aFile "# Optional 3rd-parties switches"
foreach anEnvIter $::THE_ENV_VARIABLES {
set aName ${anEnvIter}
set aValue [set ::${anEnvIter}]
if { "$aValue" == "true" } {
puts $aFile "CONFIG += ${aName}"
} else {
#puts $aFile "CONFIG -= ${aName}"
}
}
puts $aFile ""
puts $aFile "# Additional headers search paths"
foreach anIncPath $::CSF_OPT_INC {
puts $aFile "INCLUDEPATH += \"${anIncPath}\""
}
puts $aFile ""
puts $aFile "# Additional libraries search paths"
foreach aLibPath [set ::CSF_OPT_LIB$::ARCH] {
puts $aFile "LIBS += -L\"${aLibPath}\""
}
if { "$::tcl_platform(platform)" == "windows" } {
puts $aFile ""
puts $aFile "# Additional DLLs search paths"
foreach aDllPath [set ::CSF_OPT_BIN$::ARCH] {
puts $aFile "LIBS += -L\"${aDllPath}\""
}
}
puts $aFile ""
close $aFile
puts "Configuration saved to file '$aCustomFilePath'"
}
}

View File

@ -256,7 +256,7 @@ proc genAllResources {} {
# Wrapper-function to generate VS project files
proc genproj {theFormat args} {
set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "cbp" "xcd"}
set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "cbp" "xcd" "pro"}
set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" }
set isHelpRequire false
@ -314,6 +314,7 @@ proc genproj {theFormat args} {
vc141 - Visual Studio 2017
cbp - CodeBlocks
xcd - XCode
pro - Qt Creator
Platform (optional):
wnt - Windows Desktop
@ -395,9 +396,14 @@ proc genprojbat {theFormat thePlatform} {
"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"
# Code::Blocks 16.01 does not create directory for import libs, help him
file mkdir "$::path/$thePlatform/cbp/lib"
file mkdir "$::path/$thePlatform/cbp/libd"
set aPlatformAndCompiler "${thePlatform}/gcc"
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
set aPlatformAndCompiler "${thePlatform}/clang"
}
file mkdir "$::path/${aPlatformAndCompiler}/lib"
file mkdir "$::path/${aPlatformAndCompiler}/libd"
}
"xcd" { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh" "$::path/xcode.sh" }
}
@ -472,15 +478,6 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
}
}
# 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\""
return
}
# create the out dir if it does not exist
if (![file isdirectory $path/inc]) {
puts "$path/inc folder does not exists and will be created"
@ -491,6 +488,19 @@ proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl } {
puts "Collecting required header files into $path/inc ..."
osutils:collectinc $aModules $path/inc
if { "$theFormat" == "pro" } {
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\""
return
}
# Generating project files for the selected format
switch -exact -- "$theFormat" {
"vc7" -
@ -2295,6 +2305,10 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
set aCmplFlagsDebug [list]
set toPassArgsByFile 0
set aLibPrefix "lib"
set aPlatformAndCompiler "${thePlatform}/gcc"
if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
set aPlatformAndCompiler "${thePlatform}/clang"
}
if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" || "$thePlatform" == "qnx" } {
set toPassArgsByFile 1
}
@ -2351,17 +2365,17 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
# Release target configuration
puts $aFile "\t\t\t<Target title=\"Release\">"
if { "$theIsExe" == "true" } {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option type=\"1\" />"
} else {
if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${thePlatform}/cbp/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
} else {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
}
puts $aFile "\t\t\t\t<Option type=\"3\" />"
}
puts $aFile "\t\t\t\t<Option object_output=\"../../../${thePlatform}/cbp/obj\" />"
puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/obj\" />"
puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
@ -2384,7 +2398,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
if { $toPassArgsByFile == 1 } {
puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
}
puts $aFile "\t\t\t\t\t<Add directory=\"../../../${thePlatform}/cbp/lib\" />"
puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/lib\" />"
if { "$thePlatform" == "mac" } {
if { [ lsearch $theLibsList X11 ] >= 0} {
puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
@ -2392,7 +2406,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
}
puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
if { "$thePlatform" == "lin" } {
puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${thePlatform}/cbp/lib\" />"
puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/lib\" />"
}
puts $aFile "\t\t\t\t</Linker>"
@ -2401,17 +2415,17 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
# Debug target configuration
puts $aFile "\t\t\t<Target title=\"Debug\">"
if { "$theIsExe" == "true" } {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option type=\"1\" />"
} else {
if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${thePlatform}/cbp/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
} else {
puts $aFile "\t\t\t\t<Option output=\"../../../${thePlatform}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
}
puts $aFile "\t\t\t\t<Option type=\"3\" />"
}
puts $aFile "\t\t\t\t<Option object_output=\"../../../${thePlatform}/cbp/objd\" />"
puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/objd\" />"
puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
@ -2434,7 +2448,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
if { $toPassArgsByFile == 1 } {
puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
}
puts $aFile "\t\t\t\t\t<Add directory=\"../../../${thePlatform}/cbp/libd\" />"
puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/libd\" />"
if { "$thePlatform" == "mac" } {
if { [ lsearch $theLibsList X11 ] >= 0} {
puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
@ -2442,7 +2456,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
}
puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
if { "$thePlatform" == "lin" } {
puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${thePlatform}/cbp/libd\" />"
puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/libd\" />"
}
puts $aFile "\t\t\t\t</Linker>"
@ -2509,8 +2523,8 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
puts $aFile "\t\t\t<Option link=\"0\" />"
puts $aFile "\t\t</Unit>"
set aFileObj [string map {.cxx .o} [string map [list "/src/" "/$thePlatform/cbp/obj/src/"] $aSrcFile]]
set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$thePlatform/cbp/objd/src/"] $aSrcFile]]
set aFileObj [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/obj/src/"] $aSrcFile]]
set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/objd/src/"] $aSrcFile]]
puts -nonewline $aFileLnkObj "$aFileObj "
puts -nonewline $aFileLnkObjd "$aFileObjd "
} else {

5
adm/qmake/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/*/*.pro
/*/*/*.pro
*.pro.user
custom.pri
custom.auto.pri

134
adm/qmake/OccCppConfig.pri Normal file
View File

@ -0,0 +1,134 @@
# This is project defines C++ compilation rules for building an OCCT Toolkit.
exists(custom.auto.pri) { include(custom.auto.pri) }
exists(custom.pri) { include(custom.pri) }
# Disable some dummy Qt defaults
QT -= core gui
CONFIG -= qt app_bundle
CONFIG -= qml_debug
CONFIG -= debug_and_release
OccGitRoot = $$_PRO_FILE_PWD_/../../../..
# Define compilation flags
!win32 { DEFINES += OCC_CONVERT_SIGNALS }
android {
CONFIG += warn_off
QMAKE_CFLAGS += -fexceptions -Wno-ignored-qualifiers -Wall
QMAKE_CXXFLAGS += -fexceptions -Wno-ignored-qualifiers -Wall
#android-g++ { QMAKE_CXXFLAGS += -Wno-strict-overflow }
} else:win32 {
QMAKE_CXXFLAGS_WARN_ON = -W4
QMAKE_CXXFLAGS_EXCEPTIONS_ON = /EHa
QMAKE_CXXFLAGS_STL_ON = /EHa
QMAKE_CXXFLAGS += -fp:precise
#QMAKE_CXXFLAGS -= -Zc:throwingNew
#QMAKE_CXXFLAGS -= -Zc:rvalueCast
QMAKE_LFLAGS += -INCREMENTAL:NO
CONFIG(debug, debug|release) {
QMAKE_CXXFLAGS += -Od
QMAKE_CXXFLAGS += -Ob1
}
DEFINES -= WIN32
DEFINES -= WIN64
DEFINES += _CRT_SECURE_NO_WARNINGS
DEFINES += _CRT_NONSTDC_NO_DEPRECATE
DEFINES += _SCL_SECURE_NO_WARNINGS
} else:mac {
CONFIG += c++11
CONFIG += warn_off
QMAKE_CXXFLAGS += -Wall
QMAKE_CXXFLAGS += -fvisibility=default
iphoneos {
QMAKE_IOS_DEPLOYMENT_TARGET = 8.0
} else {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
}
}
# Define output folder depending on compiler name
MY_BITNESS = 32
equals(QMAKE_TARGET.arch, x86_64) | equals(QMAKE_HOST.arch, x86_64) { MY_BITNESS = 64 }
equals(ANDROID_TARGET_ARCH, arm64-v8a) { MY_BITNESS = 64 }
MY_PLATFORM = platform
CONFIG(iphonesimulator, iphoneos|iphonesimulator) { MY_PLATFORM = iphonesimulator
} else:CONFIG(iphoneos, iphoneos|iphonesimulator) { MY_PLATFORM = iphoneos
} else:android { MY_PLATFORM = android-$$ANDROID_TARGET_ARCH
} else:win32 { MY_PLATFORM = win$$MY_BITNESS
} else:mac { MY_PLATFORM = mac
} else:linux { MY_PLATFORM = lin
} else:unix { MY_PLATFORM = unix
} else { warning (Unknown platform. "$$MY_PLATFORM" is used) }
MY_COMPILER = compiler
MY_VC_VER = 0
android-g++ {
MY_COMPILER = gcc
} else:clang {
MY_COMPILER = clang
} else:gcc {
MY_COMPILER = gcc
} else:win32-msvc2010 {
MY_COMPILER = vc10
MY_VC_VER = 10
} else:win32-msvc2012 {
MY_COMPILER = vc11
MY_VC_VER = 11
} else:win32-msvc2013 {
MY_COMPILER = vc12
MY_VC_VER = 12
} else:win32-msvc2015 {
MY_COMPILER = vc14
MY_VC_VER = 14
} else:win32-msvc2017 {
MY_COMPILER = vc14
MY_VC_VER = 14
} else {
warning (Unknown compiler. "$$MY_COMPILER" is used)
}
MY_PLATFORM_AND_COMPILER = $$MY_PLATFORM/$$MY_COMPILER
#message (The platform is "$$MY_PLATFORM"; bitness is "$$MY_BITNESS"; compiler is "$$MY_COMPILER")
CONFIG(debug, debug|release) { MY_BUILDTYPE = d }
DESTDIR = $$OccGitRoot/$${MY_PLATFORM_AND_COMPILER}/lib$${MY_BUILDTYPE}
win32 {
DESTDIR = $$OccGitRoot/win$${MY_BITNESS}/vc$${MY_VC_VER}/bin$${MY_BUILDTYPE}
aLibDest = $$DESTDIR/../lib$${MY_BUILDTYPE}
#DLLDESTDIR = $$DESTDIR/../bin$${MY_BUILDTYPE}
# dummy target creating lib/libd folder
occtkgen_libfolder.input = $$_PRO_FILE_PWD_/../../OcctDummy.in
occtkgen_libfolder.output = $$aLibDest/dummy.tmp
occtkgen_libfolder.config = verbatim
QMAKE_SUBSTITUTES += occtkgen_libfolder
LIBS += -L$$aLibDest
HAVE_RelWithDebInfo {
!CONFIG(debug, debug|release) { CONFIG += force_debug_info }
}
equals(TEMPLATE, lib) {
QMAKE_CLEAN += $$DESTDIR/$${TARGET}.dll
QMAKE_CLEAN += $$aLibDest/$${TARGET}.lib
QMAKE_CLEAN += $$aLibDest/$${TARGET}.exp
} else {
QMAKE_CLEAN += $$DESTDIR/$${TARGET}.exe
}
QMAKE_CLEAN += $$DESTDIR/$${TARGET}.pdb
QMAKE_LFLAGS += -PDB:"$$DESTDIR/$${TARGET}.pdb"
QMAKE_LFLAGS += -IMPLIB:"$$aLibDest/$${TARGET}.lib"
} else {
LIBS += -L$$DESTDIR
equals(TEMPLATE, app) {
DESTDIR = $$OccGitRoot/$${MY_PLATFORM_AND_COMPILER}/bin$${MY_BUILDTYPE}
}
}
#OBJECTS_DIR = $$DESTDIR/../obj$${MY_BUILDTYPE}/$${TARGET}
OBJECTS_DIR = $$DESTDIR/../obj$${MY_BUILDTYPE}

36
adm/qmake/OccModule.pri Normal file
View File

@ -0,0 +1,36 @@
# This is a project template file defining an OCCT Module.
# This project should be included with predefined OCC_MODULE_NAME variable.
TEMPLATE = subdirs
exists(custom.auto.pri) { include(custom.auto.pri) }
exists(custom.pri) { include(custom.pri) }
# Iterate over Toolkits within current Module and generate sub-project per Toolkit
aModuleList = $$cat(../MODULES, lines)
for (aModuleIter, aModuleList) {
#aTkList = $$list($$aModuleIter) - this doesn't work, qmake bug?
aModule = $$first($$list($$aModuleIter))
equals (aModule, $$OCC_MODULE_NAME) {
for (aToolKit, $$list($$aModuleIter)) {
toSkipToolkit = 0
equals (aToolKit, $$OCC_MODULE_NAME) { toSkipToolkit = 1 }
!HAVE_VTK:equals (aToolKit, "TKIVtk") { toSkipToolkit = 1 }
!HAVE_VTK:equals (aToolKit, "TKIVtkDraw") { toSkipToolkit = 1 }
!win32: equals (aToolKit, "TKD3DHost") { toSkipToolkit = 1 }
equals (toSkipToolkit, 0) {
#warning(aToolKit($$OCC_MODULE_NAME)=$$aToolKit)
eval(occtkgen_$${aToolKit}.input = $$_PRO_FILE_PWD_/../OccToolkit.pro.in)
eval(occtkgen_$${aToolKit}.output = $$_PRO_FILE_PWD_/$${aToolKit}/$${aToolKit}.pro)
eval(occtkgen_$${aToolKit}.config = verbatim)
eval(QMAKE_SUBSTITUTES += occtkgen_$${aToolKit})
SUBDIRS += $${aToolKit}
aModExtList = $$cat(../../src/$${aToolKit}/EXTERNLIB, lines)
aTkDepends = $${aToolKit}.depends
for (aModExtIter, aModExtList) {
contains ($$list($$aModuleIter), $$aModExtIter) { eval ($${aTkDepends} += $$aModExtIter) }
}
#warning($$aToolKit depends on: $$reverse($${aTkDepends}))
}
}
}
}

View File

@ -0,0 +1,2 @@
OCC_MODULE_NAME = \$\$TARGET
include(../OccModule.pri)

137
adm/qmake/OccToolkit.pri Normal file
View File

@ -0,0 +1,137 @@
# This is a project template file defining an OCCT Toolkit.
# This project should be included with predefined OCC_TOOLKIT_NAME variable.
TEMPLATE = lib
!exists(../../src/$$OCC_TOOLKIT_NAME/PACKAGES) {
TEMPLATE = app
CONFIG += console
}
win32 {
# do not append version to DLL name
CONFIG += skip_target_version_ext
}
include(OccCppConfig.pri)
aSrcRoot = $$OccGitRoot/src
aHxxRoot = $$OccGitRoot/inc
INCLUDEPATH += $$aHxxRoot
# CSF variables
CSF_FREETYPE = -lfreetype
CSF_TclLibs = -ltcl8.6
CSF_TclTkLibs = -ltk8.6
HAVE_FREEIMAGE { CSF_FreeImagePlus = -lfreeimage } else:win32 { CSF_FreeImagePlus = -lwindowscodecs -lole32 }
HAVE_FFMPEG { CSF_FFmpeg = -lavcodec -lavformat -lswscale -lavutil }
HAVE_TBB { CSF_TBB = -ltbb -ltbbmalloc }
HAVE_ZLIB { CSF_ZLIB = -lzlib }
HAVE_LIBLZMA { CSF_LIBLZMA = -lliblzma }
win32 {
CSF_kernel32 = -lkernel32
CSF_advapi32 = -ladvapi32
CSF_gdi32 = -lgdi32
CSF_user32 = -luser32 -lcomdlg32
CSF_shell32 = -lShell32
CSF_opengl32 = -lopengl32
CSF_wsock32 = -lwsock32
CSF_netapi32 = -lnetapi32
CSF_OpenGlLibs = -lopengl32
HAVE_GLES2 { CSF_OpenGlLibs = -llibEGL -llibGLESv2 }
CSF_psapi = -lPsapi
CSF_d3d9 = -ld3d9
CSF_TclLibs = -ltcl86
CSF_TclTkLibs = -ltk86
CSF_TBB =
} else:mac {
CSF_dl = -ldl
CSF_objc = -lobjc
CSF_Appkit = -framework AppKit
CSF_IOKit = -framework IOKit
CSF_OpenGlLibs = -framework OpenGL
CSF_TclLibs = -framework Tcl
CSF_TclTkLibs = -framework Tk
} else {
CSF_dl = -ldl
CSF_ThreadLibs = -lpthread -lrt
CSF_OpenGlLibs = -lGL
CSF_TclTkLibs = -lX11 -ltk8.6
CSF_XwLibs = -lX11 -lXext -lXmu -lXi
CSF_MotifLibs = -lX11
HAVE_GLES2 { CSF_OpenGlLibs = -lEGL -lGLESv2 }
}
for (aCfgIter, CONFIG) {
aRes = $$find(aCfgIter, "^HAVE_")
count(aRes, 1) {
DEFINES += $$aCfgIter
}
}
# Define the list of standard OCCT file extensions
aHxxRegex = ^.*\.(hxx|h|lxx|gxx)$
aPxxRegex = ^.*\.(pxx)$
aCxxRegex = ^.*\.(cxx|c)$
mac { aCxxRegex = ^.*\.(cxx|c|m|mm)$ }
# Auxiliary function for probing file extension
defineTest (occCheckExtension) {
aProbe = $$find(1, "$$2")
count(aProbe, 1) { return(true) } else { return(false) }
}
# Auxiliary function for probing compilable files
defineTest (occIsCxxFile) { occCheckExtension ($$1, $$aCxxRegex) { return(true) } else { return(false) } }
# Auxiliary function for probing header files
defineTest (occIsHxxFile) { occCheckExtension ($$1, $$aHxxRegex) { return(true) } else { return(false) } }
aTkFiles = $$cat($$aSrcRoot/$$OCC_TOOLKIT_NAME/FILES, lines)
aTkFiles += CMakeLists.txt
aPackages = $$cat($$aSrcRoot/$$OCC_TOOLKIT_NAME/PACKAGES, lines)
anExternLibs = $$cat($$aSrcRoot/$$OCC_TOOLKIT_NAME/EXTERNLIB, lines)
for (aTkFileIter, aTkFiles) { OTHER_FILES += $$aSrcRoot/$$OCC_TOOLKIT_NAME/$$aTkFileIter }
for (anExternLib, anExternLibs) {
hasCsf = $$find(anExternLib, CSF_)
count(hasCsf, 1) {
aList = $$split($$anExternLib, "\n")
LIBS += $$aList
} else {
LIBS += -l$$anExternLib
}
}
# Iterate over Packages and add compilable files into this project
isEmpty (aPackages) { aPackages = $$OCC_TOOLKIT_NAME }
for (aPackage, aPackages) {
aPackageFolder = $$aSrcRoot/$$OCC_TOOLKIT_NAME/$$aPackage
aPackageFiles = $$cat($$aSrcRoot/$$aPackage/FILES, lines)
for (aFileIter, aPackageFiles) {
occIsCxxFile($$aFileIter) {
SOURCES += $$aSrcRoot/$$aPackage/$$aFileIter
}
}
}
# extend clean with versioned .so files
!win32 {
aVerList = $$split(VERSION, ".")
aVerMaj = $$member(aVerList, 0)
aVerMin = $$member(aVerList, 1)
aVerMic = $$member(aVerList, 2)
equals(TEMPLATE, app) {
QMAKE_CLEAN += $$DESTDIR/$${TARGET}
} else {
mac {
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.dylib
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.dylib
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.$${aVerMin}.dylib
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.$${aVerMaj}.$${aVerMin}.$${aVerMic}.dylib
} else {
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so.$${aVerMaj}
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so.$${aVerMaj}.$${aVerMin}
QMAKE_CLEAN += $$DESTDIR/lib$${TARGET}.so.$${aVerMaj}.$${aVerMin}.$${aVerMic}
}
}
}

View File

@ -0,0 +1,2 @@
OCC_TOOLKIT_NAME = \$\$TARGET
include(../../OccToolkit.pri)

41
adm/qmake/Occt.pro Normal file
View File

@ -0,0 +1,41 @@
# This is an experimental Solution project for building entire OCCT framework using qmake.
# It can be also used for just source code navigation in Qt Creator without actually building OCCT.
# Note, as this is an experimental project, compiler flags might differ from official builds - use it on your own risk!
# Building OCCT using CMake is a preferred solution.
#
# This project GENERATES sub-projects (OCCT modules) dynamically, so to start using it:
# - Launch genconf, select Project Format "Qt Project" and configure dependencies; this will also generate "custom.auto.pri".
# - Launch genproj to fill in "inc" folder with links to header files.
# - Open project in Qt Creator, and call "Run qmake".
# - Close the project in Qt Creator, open it again so that you should see the sub-modules in Project tree; call "Run qmake" again.
# - "Run qmake" and perform Build.
TEMPLATE = subdirs
exists(custom.auto.pri) { include(custom.auto.pri) }
exists(custom.pri) { include(custom.pri) }
OTHER_FILES += OccModule.pro.in \
OcctHeaderLink.hxx.in \
OccToolkit.pro.in \
OccCppConfig.pri \
OccModule.pri \
OccToolkit.pri \
custom.pri.template
# Iterate over Modules and generate sub-projects
aSolModuleList = $$cat(../MODULES, lines)
for (aSolModuleIter, aSolModuleList) {
aSolModule = $$first($$list($$aSolModuleIter))
eval(occtkgen_$${aSolModule}.input = $$_PRO_FILE_PWD_/OccModule.pro.in)
eval(occtkgen_$${aSolModule}.output = $$_PRO_FILE_PWD_/$${aSolModule}/$${aSolModule}.pro)
eval(occtkgen_$${aSolModule}.config = verbatim)
eval(QMAKE_SUBSTITUTES += occtkgen_$${aSolModule})
SUBDIRS += $${aSolModule}
}
# These dependencies are manually defined
ModelingData.depends = FoundationClasses
ModelingAlgorithms.depends = FoundationClasses ModelingData
Visualization.depends = FoundationClasses ModelingData ModelingAlgorithms
ApplicationFramework.depends = FoundationClasses ModelingData ModelingAlgorithms Visualization
DataExchange.depends = FoundationClasses ModelingData ModelingAlgorithms ApplicationFramework
Draw.depends = FoundationClasses ModelingData ModelingAlgorithms ApplicationFramework DataExchange Visualization

0
adm/qmake/OcctDummy.in Normal file
View File

View File

@ -0,0 +1 @@
#include \"../src/$${OCCT_PACKAGE}/$${OCCT_HEADER}\"

View File

@ -0,0 +1,17 @@
PRODUCTS_PATH = c:/3rdparty/vc14
#CONFIG += HAVE_FREEIMAGE
#CONFIG += HAVE_FFMPEG
#CONFIG += HAVE_TBB
#CONFIG += HAVE_GLES2
#CONFIG += HAVE_D3D
#CONFIG += HAVE_VTK
aFreeType = $$PRODUCTS_PATH/freetype-2.5.5-vc14-64
aTclTk = $$PRODUCTS_PATH/tcltk-86-64
INCLUDEPATH += $$aFreeType/include
LIBS += -L$$aFreeType/lib
INCLUDEPATH += $$aTclTk/include
LIBS += -L$$aTclTk/lib

View File

@ -6,7 +6,7 @@ aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath
# Reset values
export CASROOT="__CASROOT__"
export CASDEB=""
export TARGET="";
export PRJFMT="";
export HAVE_TBB="false";
export HAVE_OPENCL="false";
export HAVE_FREEIMAGE="false";
@ -40,9 +40,9 @@ do
elif [ "$i" == "i" ] || [ "$i" == "relwithdeb" ]; then
export CASDEB="i"
elif [ "$i" == "cbp" ]; then
export TARGET="cbp";
export PRJFMT="cbp";
elif [ "$i" == "xcd" ] || [ "$i" == "xcode" ]; then
export TARGET="xcd";
export PRJFMT="xcd";
fi
done
shopt -u nocasematch
@ -64,28 +64,32 @@ else
fi
export CASBIN=""
if [ "${TARGET}" == "cbp" ]; then
export CASBIN="${WOKSTATION}/cbp"
elif [ "${TARGET}" == "xcd" ]; then
if [ "${PRJFMT}" == "xcd" ]; then
export CASBIN="adm/mac/xcd/build"
else
if [ "$aSystem" == "Darwin" ]; then
export CASBIN="${WOKSTATION}/clang"
else
export CASBIN="${WOKSTATION}/gcc"
fi
fi
export CSF_OPT_INC="${CSF_OPT_INC}:${CASROOT}/inc"
if [ "${TARGET}" == "cbp" ]; then
export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libd"
export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libd"
export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/lib"
export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/lib"
export CSF_OPT_LIB32I="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libi"
export CSF_OPT_LIB64I="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libi"
elif [ "${TARGET}" == "xcd" ]; then
if [ "${PRJFMT}" == "xcd" ]; then
export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/Debug"
export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/Debug"
export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/Release"
export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/Release"
export CSF_OPT_LIB32I="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/RelWithDebInfo"
export CSF_OPT_LIB64I="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/RelWithDebInfo"
else
export CSF_OPT_LIB32D="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libd"
export CSF_OPT_LIB64D="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libd"
export CSF_OPT_LIB32="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/lib"
export CSF_OPT_LIB64="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/lib"
export CSF_OPT_LIB32I="${CSF_OPT_LIB32}:${CASROOT}/${CASBIN}/libi"
export CSF_OPT_LIB64I="${CSF_OPT_LIB64}:${CASROOT}/${CASBIN}/libi"
fi
export CSF_OPT_CMPL=""
@ -174,7 +178,7 @@ export CSF_OCCTSamplesPath="${CSF_OCCTSamplesPath:-$CASROOT/samples}"
export CSF_OCCTDataPath="${CSF_OCCTDataPath:-$CASROOT/data}"
export CSF_OCCTTestsPath="${CSF_OCCTTestsPath:-$CASROOT/tests}"
if [ "${TARGET}" == "xcd" ]; then
if [ "${PRJFMT}" == "xcd" ]; then
if [ "${CASDEB}" == "d" ]; then
export CSF_OCCTBinPath="${CSF_OCCTBinPath:-$CASROOT/$CASBIN/Debug}"
else

10
genproj
View File

@ -19,10 +19,6 @@ anOpt2=$2
anOpt3=$3
anOpt4=$4
anOpt5=$5
if [ "$aTarget" == "" ]; then
aTarget="cbp"
if [ "$aSystem" == "Darwin" ]; then aTarget="xcd"; fi;
fi
if [ ! -e "${aScriptPath}/custom.sh" ]; then
tclsh "${aScriptPath}/adm/genconf.tcl"
@ -37,6 +33,12 @@ source "${aScriptPath}/custom.sh"
if [ -e "${aScriptPath}/env.sh" ]; then source "${aScriptPath}/env.sh"; fi
if [ "$aTarget" == "" ]; then aTarget=$PRJFMT; fi;
if [ "$aTarget" == "" ]; then
aTarget="cbp"
if [ "$aSystem" == "Darwin" ]; then aTarget="xcd"; fi;
fi
cd $aScriptPath
tclsh "./adm/start.tcl" genproj ${aTarget} $anOpt2 $anOpt3 $anOpt4 $anOpt5

View File

@ -49,6 +49,10 @@ if "%aPlatform%" == "" (
)
)
set aPrjFmt=%PRJFMT%
if "%aPrjFmt%" == "" ( set "aPrjFmt=vcxproj" )
if "%aPrjFmt%" == "vcxproj" ( set "aPrjFmt=%VCFMT%" )
cd %~dp0
%TCL_EXEC% %~dp0adm/start.tcl genproj %VCFMT% %aPlatform% %3 %4 %5
%TCL_EXEC% %~dp0adm/start.tcl genproj %aPrjFmt% %aPlatform% %3 %4 %5
SET "PATH=%OLD_PATH%"

View File

@ -1,5 +1,6 @@
TKDraw
TKMesh
TKShHealing
TKTopAlgo
TKHLR
TKGeomAlgo

View File

@ -25,6 +25,8 @@
#include <gp_Pnt2d.hxx>
#include <OSD.hxx>
#include <OSD_Environment.hxx>
#include <OSD_File.hxx>
#include <OSD_Process.hxx>
#include <OSD_SharedLibrary.hxx>
#include <OSD_Timer.hxx>
#include <Plugin_MapOfFunctions.hxx>
@ -75,18 +77,19 @@ Standard_EXPORT Standard_Boolean Draw_Interprete(const char* command);
// read an init file
// *******************************************************************
static void ReadInitFile (const TCollection_AsciiString& theFileName)
static void interpreteTclCommand (const TCollection_AsciiString& theCmd)
{
TCollection_AsciiString aPath = theFileName;
#ifdef _WIN32
aPath.ChangeAll('\\', '/');
if (!Draw_Batch)
{
try
{
while (console_semaphore == HAS_CONSOLE_COMMAND)
{
TCollection_ExtendedString aCmdWide ("source -encoding utf-8 \"");
aCmdWide += TCollection_ExtendedString (aPath) + "\"";
Sleep(10);
}
{
TCollection_ExtendedString aCmdWide (theCmd);
wcscpy_s (console_command, aCmdWide.ToWideString());
}
console_semaphore = HAS_CONSOLE_COMMAND;
@ -95,19 +98,127 @@ static void ReadInitFile (const TCollection_AsciiString& theFileName)
Sleep(10);
}
}
catch(...) {
cout << "Error while reading a script file." << endl;
catch (...)
{
std::cout << "Error while reading a script file.\n";
ExitProcess(0);
}
} else {
#endif
char* com = new char [aPath.Length() + strlen ("source -encoding utf-8 ") + 2];
Sprintf (com, "source -encoding utf-8 %s", aPath.ToCString());
Draw_Interprete (com);
delete [] com;
#ifdef _WIN32
}
else
#endif
{
Draw_Interprete (theCmd.ToCString());
}
}
static void ReadInitFile (const TCollection_AsciiString& theFileName)
{
TCollection_AsciiString aCmd = theFileName;
#ifdef _WIN32
aCmd.ChangeAll ('\\', '/');
#endif
aCmd = TCollection_AsciiString ("source -encoding utf-8 \"") + aCmd + "\"";
interpreteTclCommand (aCmd);
}
//! Define environment variable available from Tcl and OCCT.
static void setOcctTclEnv (const TCollection_AsciiString& theName,
TCollection_AsciiString& thePath)
{
if (thePath.IsEmpty())
{
return;
}
thePath.ChangeAll ('\\', '/');
OSD_Environment aRedPathEnv (theName);
aRedPathEnv.SetValue (thePath);
aRedPathEnv.Build();
const TCollection_AsciiString aPutEnv = theName + "=" + thePath;
Tcl_PutEnv (aPutEnv.ToCString());
}
//! Look for resource within standard installation layouts relative to executable location.
//!
//! Bin (INSTALL_DIR_BIN):
//! - Windows: <prefix>/win64/vc10/bin(d)
//! - Unix: <prefix>/bin
//! Resources (INSTALL_DIR_RESOURCE):
//! - Windows: <prefix>/src
//! - Unix: <prefix>/share/opencascade-7.0.0/resources
//! Samples (INSTALL_DIR_SAMPLES):
//! - Windows: <prefix>/samples
//! - Unix: <prefix>/share/opencascade-7.0.0/samples
//! Tests (INSTALL_DIR_TESTS):
//! - Windows: <prefix>/tests
//! - Unix: <prefix>/share/opencascade-7.0.0/tests
//!
//! @param theCasRoot [out] found CASROOT location (e.g. installation folder)
//! @param theResRoot [out] found resources root location
//! @param theResName [in] resource to find ("resources", "samples", etc.)
//! @param theProbeFile [in] file to probe within resources location (e.g. "DrawResources/DrawDefault" within "resources")
static bool searchResources (TCollection_AsciiString& theCasRoot,
TCollection_AsciiString& theResRoot,
const TCollection_AsciiString& theResName,
const TCollection_AsciiString& theProbeFile)
{
const TCollection_AsciiString aResLayouts[] =
{
TCollection_AsciiString("/share/opencascade-" OCC_VERSION_STRING_EXT "/") + theResName,
TCollection_AsciiString("/share/opencascade-" OCC_VERSION_COMPLETE "/") + theResName,
TCollection_AsciiString("/share/opencascade-" OCC_VERSION_STRING "/") + theResName,
TCollection_AsciiString("/share/opencascade/") + theResName,
TCollection_AsciiString("/share/occt-" OCC_VERSION_STRING_EXT "/") + theResName,
TCollection_AsciiString("/share/occt-" OCC_VERSION_COMPLETE "/") + theResName,
TCollection_AsciiString("/share/occt-" OCC_VERSION_STRING "/") + theResName,
TCollection_AsciiString("/share/occt/") + theResName,
TCollection_AsciiString("/") + theResName,
TCollection_AsciiString("/share/opencascade"),
TCollection_AsciiString("/share/occt"),
TCollection_AsciiString("/share"),
TCollection_AsciiString("/src"),
TCollection_AsciiString("")
};
const TCollection_AsciiString anExeDir (OSD_Process::ExecutableFolder());
for (Standard_Integer aLayIter = 0;; ++aLayIter)
{
const TCollection_AsciiString& aResLayout = aResLayouts[aLayIter];
const TCollection_AsciiString aProbeFile = aResLayout + "/" + theProbeFile;
if (OSD_File (anExeDir + aProbeFile).Exists())
{
theCasRoot = anExeDir;
theResRoot = theCasRoot + aResLayout;
return true;
}
// <prefix>/bin(d)
else if (OSD_File (anExeDir + "../" + aProbeFile).Exists())
{
theCasRoot = anExeDir + "..";
theResRoot = theCasRoot + aResLayout;
return true;
}
// <prefix>/gcc/bin(d)
else if (OSD_File (anExeDir + "../../" + aProbeFile).Exists())
{
theCasRoot = anExeDir + "../..";
theResRoot = theCasRoot + aResLayout;
return true;
}
// <prefix>/win64/vc10/bin(d)
else if (OSD_File (anExeDir + "../../../" + aProbeFile).Exists())
{
theCasRoot = anExeDir + "../../..";
theResRoot = theCasRoot + aResLayout;
return true;
}
if (aResLayout.IsEmpty())
{
return false;
}
}
}
//=======================================================================
@ -325,10 +436,52 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
// read init files
// *****************************************************************
// default
if (getenv ("DRAWDEFAULT") == NULL)
const TCollection_AsciiString aDrawDef (OSD_Environment ("DRAWDEFAULT").Value());
if (!aDrawDef.IsEmpty())
{
if (getenv ("CASROOT") == NULL)
ReadInitFile (aDrawDef);
}
else
{
TCollection_AsciiString aDrawHome;
TCollection_AsciiString aCasRoot (OSD_Environment ("CASROOT").Value());
if (!aCasRoot.IsEmpty())
{
aDrawHome = aCasRoot + "/src/DrawResources";
}
else
{
// search for relative locations within standard development environment
TCollection_AsciiString aResPath;
if (searchResources (aCasRoot, aResPath, "resources", "DrawResources/DrawDefault"))
{
aDrawHome = aResPath + "/DrawResources";
setOcctTclEnv ("CASROOT", aCasRoot);
setOcctTclEnv ("DRAWHOME", aDrawHome);
setOcctTclEnv ("CSF_OCCTResourcePath", aResPath);
}
TCollection_AsciiString aSamplesPath;
if (OSD_Environment ("CSF_OCCTSamplesPath").Value().IsEmpty()
&& searchResources (aCasRoot, aSamplesPath, "samples", "tcl/Readme.txt"))
{
setOcctTclEnv ("CSF_OCCTSamplesPath", aSamplesPath);
}
TCollection_AsciiString aTestsPath;
if (OSD_Environment ("CSF_TestScriptsPath").Value().IsEmpty()
&& searchResources (aCasRoot, aTestsPath, "tests", "parse.rules"))
{
setOcctTclEnv ("CSF_TestScriptsPath", aTestsPath);
}
}
if (!aDrawHome.IsEmpty())
{
const TCollection_AsciiString aDefStr = aDrawHome + "/DrawDefault";
ReadInitFile (aDefStr);
}
else
{
#ifdef _WIN32
ReadInitFile ("ddefault");
@ -337,16 +490,6 @@ void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
cout << "No default file" << endl;
#endif
}
else
{
TCollection_AsciiString aDefStr (getenv ("CASROOT"));
aDefStr += "/src/DrawResources/DrawDefault";
ReadInitFile (aDefStr);
}
}
else
{
ReadInitFile (getenv ("DRAWDEFAULT"));
}
// read commands from file

View File

@ -59,18 +59,28 @@ static Standard_Boolean FindPluginFile (TCollection_AsciiString& thePluginName,
// the order of search : by CSF_<PluginFileName>Defaults and then by CASROOT
TCollection_AsciiString aCSFVariable = TCollection_AsciiString ("CSF_") + thePluginName + "Defaults";
aPluginDir = getenv (aCSFVariable.ToCString());
if (aPluginDir.IsEmpty()) {
// now try by CASROOT
aPluginDir = getenv("CASROOT");
if ( !aPluginDir.IsEmpty() ) {
aPluginDir +="/src/DrawResources" ;
aPluginDir = OSD_Environment (aCSFVariable).Value();
if (aPluginDir.IsEmpty())
{
aPluginDir = OSD_Environment ("DRAWHOME").Value();
if (!aPluginDir.IsEmpty())
{
aToSetCSFVariable = Standard_True; //CSF variable to be set later
} else {
aResult = aDirFound = Standard_False;
cout << FAILSTR "Neither " << aCSFVariable.ToCString() << ", nor CASROOT variables have been set" << endl;
}
else
{
// now try by CASROOT
aPluginDir = OSD_Environment ("CASROOT").Value();
if (!aPluginDir.IsEmpty())
{
aPluginDir += "/src/DrawResources";
aToSetCSFVariable = Standard_True; //CSF variable to be set later
}
else
{
aResult = aDirFound = Standard_False;
std::cout << FAILSTR "Neither " << aCSFVariable << ", nor CASROOT variables have been set\n";
}
}
}

View File

@ -12,24 +12,44 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _WIN32
#ifdef _WIN32
//it is important to undefine NOUSER and enforce including <windows.h> before
//Standard_Macro.hxx defines it and includes <windows.h> causing compilation errors
#ifdef NOUSER
#undef NOUSER // we need SW_HIDE from windows.h
#endif
#include <windows.h>
#endif
#include <OSD_Process.hxx>
#include <NCollection_Array1.hxx>
#include <OSD_Environment.hxx>
#include <OSD_OSDError.hxx>
#include <OSD_Path.hxx>
#include <OSD_Process.hxx>
#include <OSD_WhoAmI.hxx>
#include <Standard_PExtCharacter.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Quantity_Date.hxx>
#include <TCollection_AsciiString.hxx>
const OSD_WhoAmI Iam = OSD_WProcess;
#ifdef _WIN32
#include <OSD_WNT.hxx>
#include <lmcons.h> // for UNLEN - maximum user name length GetUserName()
#else
const OSD_WhoAmI Iam = OSD_WProcess;
#include <errno.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/time.h>
#include <pwd.h> // For command getpwuid
#include <unistd.h>
#endif
#include <errno.h>
#include <stdlib.h>
#include <sys/param.h>
#include <sys/time.h>
#include <pwd.h> // For command getpwuid
#include <unistd.h>
#if defined(__APPLE__)
#include <mach-o/dyld.h>
#endif
#ifndef _WIN32
OSD_Process::OSD_Process(){
}
@ -167,23 +187,6 @@ Standard_Integer OSD_Process::Error()const{
//------------------- WNT Sources of OSD_Path ---------------------------
//------------------------------------------------------------------------
//it is important to undefine NOUSER and enforce including <windows.h> before
//Standard_Macro.hxx defines it and includes <windows.h> causing compilation errors
#ifdef NOUSER
#undef NOUSER /* we need SW_HIDE from windows.h */
#endif
#include <windows.h>
#include <OSD_Process.hxx>
#include <OSD_Path.hxx>
#include <Quantity_Date.hxx>
#include <Standard_PExtCharacter.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_WNT.hxx>
#include <lmcons.h> // for UNLEN - maximum user name length GetUserName()
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
// =======================================================================
@ -354,3 +357,112 @@ Standard_Integer OSD_Process :: Error () const {
} // end OSD_Process :: Error
#endif
// =======================================================================
// function : ExecutablePath
// purpose :
// =======================================================================
TCollection_AsciiString OSD_Process::ExecutablePath()
{
#ifdef _WIN32
wchar_t aBuff[MAX_PATH + 2];
DWORD aLenFilled = GetModuleFileNameW (0, aBuff, MAX_PATH + 1);
aBuff[MAX_PATH + 1] = 0;
if (aLenFilled == 0)
{
return TCollection_AsciiString();
}
else if (aLenFilled <= MAX_PATH)
{
return TCollection_AsciiString (aBuff);
}
// buffer is not large enough (e.g. path uses \\?\ prefix)
wchar_t* aBuffDyn = NULL;
for (int anIter = 2;; ++anIter)
{
size_t aBuffLen = MAX_PATH * anIter;
aBuffDyn = reinterpret_cast<wchar_t*> (realloc (aBuffDyn, sizeof(wchar_t) * (aBuffLen + 1)));
if (aBuffDyn == NULL)
{
return TCollection_AsciiString();
}
aLenFilled = GetModuleFileNameW (NULL, aBuffDyn, DWORD(aBuffLen));
if (aLenFilled != aBuffLen)
{
aBuffDyn[aBuffLen] = L'\0';
TCollection_AsciiString aRes (aBuffDyn);
free (aBuffDyn);
return aRes;
}
}
#elif defined(__APPLE__)
// determine buffer size
uint32_t aNbBytes = 0;
_NSGetExecutablePath (NULL, &aNbBytes);
if (aNbBytes == 0)
{
return TCollection_AsciiString();
}
// retrieve path to executable (probably link)
NCollection_Array1<char> aBuff (0, aNbBytes);
_NSGetExecutablePath (&aBuff.ChangeFirst(), &aNbBytes);
aBuff[aNbBytes] = '\0';
// retrieve real path to executable (resolve links and normalize)
char* aResultBuf = realpath (&aBuff.First(), NULL);
if (aResultBuf == NULL)
{
return TCollection_AsciiString();
}
TCollection_AsciiString aProcessPath (aResultBuf);
free (aResultBuf); // according to man for realpath()
return aProcessPath;
#elif defined(__linux__)
// get info from /proc/PID/exe
TCollection_AsciiString aSimLink = TCollection_AsciiString("/proc/") + TCollection_AsciiString(getpid()) + "/exe";
char aBuff[4096];
ssize_t aBytes = readlink (aSimLink.ToCString(), aBuff, 4096);
if (aBytes > 0)
{
aBuff[aBytes] = '\0';
return TCollection_AsciiString(aBuff);
}
return TCollection_AsciiString();
#else
// not implemented
return TCollection_AsciiString();
#endif
}
// =======================================================================
// function : ExecutableFolder
// purpose :
// =======================================================================
TCollection_AsciiString OSD_Process::ExecutableFolder()
{
TCollection_AsciiString aFullPath = ExecutablePath();
Standard_Integer aLastSplit = -1;
#ifdef _WIN32
const char THE_FILE_SEPARATOR = '\\';
#else
const char THE_FILE_SEPARATOR = '/';
#endif
for (Standard_Integer anIter = 1; anIter <= aFullPath.Length(); ++anIter)
{
if (aFullPath.Value (anIter) == THE_FILE_SEPARATOR)
{
aLastSplit = anIter;
}
}
if (aLastSplit != -1)
{
return aFullPath.SubString (1, aLastSplit);
}
return TCollection_AsciiString();
}

View File

@ -22,10 +22,9 @@
#include <Standard_Handle.hxx>
#include <OSD_Error.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
class OSD_OSDError;
class TCollection_AsciiString;
class Quantity_Date;
class OSD_Path;
@ -39,8 +38,15 @@ class OSD_Process
{
public:
DEFINE_STANDARD_ALLOC
//! Return full path to the current process executable.
Standard_EXPORT static TCollection_AsciiString ExecutablePath();
//! Return full path to the folder containing current process executable with trailing separator.
Standard_EXPORT static TCollection_AsciiString ExecutableFolder();
public:
DEFINE_STANDARD_ALLOC
//! Initializes the object and prepare for a possible dump
Standard_EXPORT OSD_Process();

View File

@ -6,6 +6,7 @@ TKMath
TKBRep
TKGeomAlgo
TKTopAlgo
TKShHealing
TKMesh
TKService
TKHLR

View File

@ -6,6 +6,8 @@ TKGeomAlgo
TKG2d
TKG3d
TKTopAlgo
CSF_user32
CSF_advapi32
CSF_OpenGlLibs
CSF_advapi32
CSF_user32