0029063: Configuration - improve paths in environment files
authorapn <apn@opencascade.com>
Mon, 28 Aug 2017 11:17:45 +0000 (14:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 30 Aug 2017 10:52:29 +0000 (13:52 +0300)
Change absolute paths to relative in OCCT environment files.
Move content of vcver.bat to env.bat.

CMakeLists.txt
adm/templates/custom.install.bat.in
adm/templates/custom.install.sh.in
adm/templates/env.bat
adm/templates/env.bat.in
adm/templates/env.sh
adm/templates/env.sh.in
adm/vcver.bat [deleted file]

index 43621df..9954ab4 100644 (file)
@@ -870,6 +870,22 @@ else()
   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}")
 endif()
 
+if (WIN32)
+  set (THIRDPARTY_DIR_REPLACE "%THIRDPARTY_DIR%")
+else()
+  set (THIRDPARTY_DIR_REPLACE "\${THIRDPARTY_DIR}")
+endif()
+get_cmake_property(USED_3RDPARTY_CACHE_VARIABLES VARIABLES)
+string (REGEX MATCHALL "(^|;)USED_3RDPARTY_[^;]+_DIR[^;]*" USED_3RDPARTY_CACHE_VARIABLES "${USED_3RDPARTY_CACHE_VARIABLES}")
+file (TO_CMAKE_PATH "${3RDPARTY_DIR}" 3RDPARTY_DIR)
+foreach (USED_3RDPARTY_CACHE_VARIABLE ${USED_3RDPARTY_CACHE_VARIABLES})
+   file (TO_CMAKE_PATH "${${USED_3RDPARTY_CACHE_VARIABLE}}" ${USED_3RDPARTY_CACHE_VARIABLE})
+   string (REPLACE "${3RDPARTY_DIR}" "${THIRDPARTY_DIR_REPLACE}" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
+   if (NOT WIN32)
+     string (REGEX REPLACE ";" ":" ${USED_3RDPARTY_CACHE_VARIABLE} "${${USED_3RDPARTY_CACHE_VARIABLE}}")
+   endif()
+endforeach()
+
 # write current custom.bat/sh (for install directory)
 set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}")
 OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}")
index 32683e2..1cbdca0 100644 (file)
@@ -24,18 +24,15 @@ if /I "%VCVER%" == "@COMPILER@" (
     set "TCL_VERSION_WITH_DOT=@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     set "TK_VERSION_WITH_DOT=@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
-    set "CSF_OCCTBinPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_BIN@%3"
-    set "CSF_OCCTLibPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_LIB@%3"
-
-    set "CSF_OCCTIncludePath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_INCLUDE@"
-    set "CSF_OCCTResourcePath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_RESOURCE@"
-    set "CSF_OCCTDataPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_DATA@"
-    set "CSF_OCCTSamplesPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_SAMPLES@"
-    set "CSF_OCCTTestsPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_TESTS@"
-    set "CSF_OCCTDocPath=@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_DOC@"
-
-    rem for compatability with external application using CASROOT
-    set "CASROOT=@INSTALL_DIR_ABSOLUTE@"
+    set "CSF_OCCTBinPath=%CASROOT%/@INSTALL_DIR_BIN@%3"
+    set "CSF_OCCTLibPath=%CASROOT%/@INSTALL_DIR_LIB@%3"
+
+    set "CSF_OCCTIncludePath=%CASROOT%/@INSTALL_DIR_INCLUDE@"
+    set "CSF_OCCTResourcePath=%CASROOT%/@INSTALL_DIR_RESOURCE@"
+    set "CSF_OCCTDataPath=%CASROOT%/@INSTALL_DIR_DATA@"
+    set "CSF_OCCTSamplesPath=%CASROOT%/@INSTALL_DIR_SAMPLES@"
+    set "CSF_OCCTTestsPath=%CASROOT%/@INSTALL_DIR_TESTS@"
+    set "CSF_OCCTDocPath=%CASROOT%/@INSTALL_DIR_DOC@"
   )
 )
 
index 8bf6310..206c1c3 100644 (file)
@@ -21,17 +21,14 @@ if [ "$1" == "@BIN_LETTER@" ]; then
     export TCL_VERSION_WITH_DOT="@3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT@"
     export TK_VERSION_WITH_DOT="@3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT@"
 
-    export CSF_OCCTBinPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_BIN@"
-    export CSF_OCCTLibPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_LIB@"
-    export CSF_OCCTIncludePath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_INCLUDE@"
-    export CSF_OCCTResourcePath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_RESOURCE@"
-    export CSF_OCCTDataPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_DATA@"
-    export CSF_OCCTSamplesPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_SAMPLES@"
-    export CSF_OCCTTestsPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_TESTS@"
-    export CSF_OCCTDocPath="@INSTALL_DIR_ABSOLUTE@/@INSTALL_DIR_DOC@"
-    
-    # for compatability with external application using CASROOT
-    export CASROOT="@INSTALL_DIR_ABSOLUTE@"
+    export CSF_OCCTBinPath="${CASROOT}/@INSTALL_DIR_BIN@"
+    export CSF_OCCTLibPath="${CASROOT}/@INSTALL_DIR_LIB@"
+    export CSF_OCCTIncludePath="${CASROOT}/@INSTALL_DIR_INCLUDE@"
+    export CSF_OCCTResourcePath="${CASROOT}/@INSTALL_DIR_RESOURCE@"
+    export CSF_OCCTDataPath="${CASROOT}/@INSTALL_DIR_DATA@"
+    export CSF_OCCTSamplesPath="${CASROOT}/@INSTALL_DIR_SAMPLES@"
+    export CSF_OCCTTestsPath="${CASROOT}/@INSTALL_DIR_TESTS@"
+    export CSF_OCCTDocPath="${CASROOT}/@INSTALL_DIR_DOC@"
   fi
 fi
 
index bbc6a85..0748e48 100644 (file)
@@ -31,14 +31,14 @@ set "CSF_OPT_LIB64="
 set "CSF_OPT_BIN32="
 set "CSF_OPT_BIN64="
 
-rem ----- Load local settings -----
-if exist "%~dp0custom.bat" (
-  call "%~dp0custom.bat" %1 %2 %3 %4 %5
-)
-
 if not ["%CASROOT%"] == [""] if exist "%SCRIPTROOT%\%CASROOT%" set "CASROOT=%SCRIPTROOT%\%CASROOT%"
 if     ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
 
+rem ----- Load local settings -----
+if exist "%CASROOT%\custom.bat" (
+  call "%CASROOT%\custom.bat" %1 %2 %3 %4 %5
+)
+
 rem ----- Read script arguments (override local settings) -----
 if not ["%1"]    == [""]      set "VCVER=%1"
 if not ["%2"]    == [""]      set "ARCH=%2"
@@ -49,8 +49,33 @@ if /I ["%3"]     == ["d"]     set "CASDEB=d"
 if /I ["%3"]     == ["i"]     set "CASDEB=i"
 if /I ["%3"]     == ["relwithdeb"] set "CASDEB=i"
 
-rem Decode VCVER
-call "%~dp0adm\vcver.bat"
+rem Decode VCVER variable and define related ones:
+rem
+rem VCFMT - "vc" followed by full version number of Visual Studio toolset
+rem         (same as VCVER without optional suffix "-uwp")
+rem VCLIB - name of folder contining binaries
+rem         (same as VCVER except without third version in number)
+rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
+rem
+rem Note that for VS before 2015 (vc14) always
+rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
+
+rem Since VS 2017, environment variables like VS100COMNTOOLS are not defined 
+rem any more, we can only use vswhere.exe tool to find Visual Studio.
+rem Add path to vswhere.exe
+set "PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
+
+rem for vc10-12, interpretation is trivial
+set VCFMT=%VCVER%
+set VCLIB=%VCVER:~0,4%
+set VCPROP=NativeDesktop
+rem vc14 and later can have optional suffix "-uwp"
+if "%VCVER:~-4%" == "-uwp" (
+  set VCFMT=%VCVER:~0,-4%
+  set VCLIB=%VCLIB%-uwp
+  set VCPROP=Universal
+)
+rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%
 
 rem ----- Parsing of Visual Studio platform -----
 set "VisualStudioExpressName=VCExpress"
index ac92538..c84a963 100644 (file)
@@ -101,17 +101,20 @@ if /I "%VCFMT%" == "vc10" (
   exit
 )
 
+rem ----- For compatability with external application using CASROOT -----
+if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
+
+rem ----- Define path to 3rdparty products -----
+set "THIRDPARTY_DIR=@3RDPARTY_DIR@"
+
 if ["%ARCH%"] == ["32"] set VCARCH=x86
 if ["%ARCH%"] == ["64"] set VCARCH=amd64
 
 if /I ["%1"] == ["vc141"] set "VCVER=vc14"
-if exist "%~dp0custom.bat" (
-  call "%~dp0custom.bat" %VCVER% %ARCH% %CASDEB%
+if exist "%CASROOT%\custom.bat" (
+  call "%CASROOT%\custom.bat" %VCVER% %ARCH% %CASDEB%
 )
 
-rem for compatability with external application using CASROOT
-if ["%CASROOT%"] == [""] set "CASROOT=%SCRIPTROOT%"
-
 if not ["%TCL_DIR%"] == [""]           set "PATH=%TCL_DIR%;%PATH%"
 if not ["%TK_DIR%"] == [""]            set "PATH=%TK_DIR%;%PATH%"
 if not ["%FREETYPE_DIR%"] == [""]      set "PATH=%FREETYPE_DIR%;%PATH%"
@@ -152,7 +155,7 @@ set "CSF_STEPDefaults=%CSF_OCCTResourcePath%\XSTEPResource"
 set "CSF_XmlOcafResource=%CSF_OCCTResourcePath%\XmlOcafResource"
 set "CSF_MIGRATION_TYPES=%CSF_OCCTResourcePath%\StdResource\MigrationSheet.txt"
 
-rem Draw Harness special stuff
+rem ----- Draw Harness special stuff -----
 if exist "%CSF_OCCTResourcePath%\DrawResources" (
   set "DRAWHOME=%CSF_OCCTResourcePath%\DrawResources"
   set "CSF_DrawPluginDefaults=%CSF_OCCTResourcePath%\DrawResources"
index fc9c360..8ec6e35 100644 (file)
@@ -24,15 +24,13 @@ export CSF_OPT_BIN32=""
 export CSF_OPT_BIN64=""
 
 # ----- Set local settings -----
-if [ "${CASROOT}" != "" ] && [ -e "${CASROOT}/custom.sh" ]; then source "${CASROOT}/custom.sh"; fi
-if [ -e "${aScriptPath}/custom.sh" ]; then source "${aScriptPath}/custom.sh"; fi
-
 if [ "${CASROOT}" != "" ] && [ -d "${aScriptPath}/${CASROOT}" ]; then
   export CASROOT="${aScriptPath}/${CASROOT}"
 fi
 if [ "${CASROOT}" == "" ]; then
   export CASROOT="${aScriptPath}"
 fi
+if [ -e "${CASROOT}/custom.sh" ]; then source "${CASROOT}/custom.sh"; fi
 
 # Read script arguments
 shopt -s nocasematch
index 0c1e822..ff78b1d 100644 (file)
@@ -2,12 +2,15 @@
 
 aScriptPath=${BASH_SOURCE%/*}; if [ -d "${aScriptPath}" ]; then cd "$aScriptPath"; fi; aScriptPath="$PWD";
 
-# ----- for compatability with external application using CASROOT -----
+# ----- For compatability with external application using CASROOT -----
 if [ "${CASROOT}" == "" ]; then
-  export CASROOT="${aScriptPath}"
+  export CASROOT="@INSTALL_DIR@"
 fi
 
-# Read script arguments
+# ----- Define path to 3rdparty products -----
+export THIRDPARTY_DIR="@3RDPARTY_DIR@"
+
+# ----- Read script arguments -----
 shopt -s nocasematch
 export CASDEB="";
 if [[ "$1" == "debug" ]]; then export CASDEB="d"; fi
@@ -33,8 +36,8 @@ else
 fi
 
 # ----- Set local settings -----
-if [ -e "${aScriptPath}/custom.sh" ]; then
-  source "${aScriptPath}/custom.sh" "${CASDEB}" "${ARCH}"
+if [ -e "${CASROOT}/@INSTALL_DIR_SCRIPT@/custom.sh" ]; then
+  source "${CASROOT}/@INSTALL_DIR_SCRIPT@/custom.sh" "${CASDEB}" "${ARCH}"
 fi
 
 THRDPARTY_PATH=""
@@ -127,7 +130,7 @@ export CSF_STEPDefaults="${CSF_OCCTResourcePath}/XSTEPResource"
 export CSF_XmlOcafResource="${CSF_OCCTResourcePath}/XmlOcafResource"
 export CSF_MIGRATION_TYPES="${CSF_OCCTResourcePath}/StdResource/MigrationSheet.txt"
 
-# Draw Harness special stuff
+# ----- Draw Harness special stuff -----
 if [ -e "${CSF_OCCTResourcePath}/DrawResources" ]; then
   export DRAWHOME="${CSF_OCCTResourcePath}/DrawResources"
   export CSF_DrawPluginDefaults="${CSF_OCCTResourcePath}/DrawResources"
diff --git a/adm/vcver.bat b/adm/vcver.bat
deleted file mode 100644 (file)
index 61ca6e6..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-@echo off
-rem Decode VCVER variable and define related ones:
-rem
-rem VCFMT - "vc" followed by full version number of Visual Studio toolset
-rem         (same as VCVER without optional suffix "-uwp")
-rem VCLIB - name of folder contining binaries
-rem         (same as VCVER except without third version in number)
-rem VCPROP - name of required Visual Studion Workload (starting with VS 2017)
-rem
-rem Note that for VS before 2015 (vc14) always
-rem VCFMT=VCLIB=VCVER and VCPROP=NativeDesktop
-
-rem Since VS 2017, environment variables like VS100COMNTOOLS are not defined 
-rem any more, we can only use vswhere.exe tool to find Visual Studio.
-rem Add path to vswhere.exe
-set "PATH=%PATH%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
-
-rem for vc10-12, interpretation is trivial
-set VCFMT=%VCVER%
-set VCLIB=%VCVER:~0,4%
-set VCPROP=NativeDesktop
-
-rem vc14 and later can have optional suffix "-uwp"
-if "%VCVER:~-4%" == "-uwp" (
-  set VCFMT=%VCVER:~0,-4%
-  set VCLIB=%VCLIB%-uwp
-  set VCPROP=Universal
-)
-
-rem echo VCVER=%VCVER% VCFMT=%VCFMT% VCLIB=%VCLIB% VCPROP=%VCPROP%