gitattributes: ensure platform dependent files are stored using correct line endings

This commit is contained in:
Andrej730
2026-08-06 19:42:56 +05:00
parent 027203008d
commit 3d05ccbd59
4 changed files with 1483 additions and 1481 deletions
+3 -1
View File
@@ -19,6 +19,8 @@
# normalize the line endings of the following files
*.bat text eol=crlf
*.cmd text eol=crlf
*.cpp text
*.css text
*.csv text
@@ -34,11 +36,11 @@
*.po text
*.pot text
*.py text
*.sh text eol=lf
*.txt text
# files not normalized ATM
# bat
# bnf
# blend
# i
+1027 -1027
View File
File diff suppressed because it is too large Load Diff
+188 -188
View File
@@ -1,163 +1,163 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: This file is part of IfcOpenShell. ::
:: ::
:: IfcOpenShell is free software: you can redistribute it and/or modify ::
:: it under the terms of the Lesser GNU General Public License as published by ::
:: the Free Software Foundation, either version 3.0 of the License, or ::
:: (at your option) any later version. ::
:: ::
:: IfcOpenShell is distributed in the hope that it will be useful, ::
:: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
:: Lesser GNU General Public License for more details. ::
:: ::
:: You should have received a copy of the Lesser GNU General Public License ::
:: along with this program. If not, see <http://www.gnu.org/licenses/>. ::
:: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: This file is part of IfcOpenShell. ::
:: ::
:: IfcOpenShell is free software: you can redistribute it and/or modify ::
:: it under the terms of the Lesser GNU General Public License as published by ::
:: the Free Software Foundation, either version 3.0 of the License, or ::
:: (at your option) any later version. ::
:: ::
:: IfcOpenShell is distributed in the hope that it will be useful, ::
:: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
:: Lesser GNU General Public License for more details. ::
:: ::
:: You should have received a copy of the Lesser GNU General Public License ::
:: along with this program. If not, see <http://www.gnu.org/licenses/>. ::
:: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Example usage:
:: run-cmake.bat vs2022-x64
:: run-cmake.bat vs2022-x64 -DGLTF_SUPPORT=ON
::
:: Used environment variables:
:: - `ADD_COMMIT_SHA` - if defined then `ADD_COMMIT_SHA` and `VERSION_OVERRIDE` cmake args will be set to `ON`.
:: - `USE_NINJA` - if defined then the Ninja generator will be used instead of the Visual Studio.
@if not defined ECHO_ON ( echo off )
echo.
set PROJECT_NAME=IfcOpenShell
setlocal EnableDelayedExpansion
set IFCOS_PAUSE_ON_ERROR=
set GENERATOR=%1
:: If no GENERATOR was provided, read cached variables from any BuildDepsCache-XXX.txt
:: found in this directory; note that if more than one is present, the result could be wrong!
if (%1)==() (
for /f "tokens=*" %%f in ('dir BuildDepsCache-*.txt /o:-n /t:a /b') do (
for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
)
if not defined GEN_SHORTHAND (
echo BuildDepsCache file does not exist and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it.
set IFCOS_PAUSE_ON_ERROR=pause
goto :Error
)
set GENERATOR=!GEN_SHORTHAND!
echo Generator not passed, but GEN_SHORTHAND=!GENERATOR! read from BuildDepsCache
echo.
)
call vs-cfg.cmd %GENERATOR%
IF NOT %ERRORLEVEL%==0 GOTO :Error
:: If cached variables are still undefined,
:: read them from the specific BuildDepsCache-XXX.txt.
set "_test=0"
if not defined OCC_INCLUDE_DIR set _test=1
if not defined OCC_LIBRARY_DIR set _test=1
if %_test% EQU 1 (
IF DEFINED VS_TOOLSET (
set "BUILD_DEPS_CACHE_PATH=BuildDepsCache-%VS_PLATFORM%-%VS_TOOLSET%.txt"
) ELSE (
set "BUILD_DEPS_CACHE_PATH=BuildDepsCache-%VS_PLATFORM%.txt"
)
for /f "tokens=*" %%f in ('dir !BUILD_DEPS_CACHE_PATH! /o:-n /t:a /b') do (
for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
)
)
:: As CMake options are typically of format -DSOMETHING:BOOL=ON or -DSOMETHING=1, i.e. they contain an equal sign,
:: they will mess up the batch file argument parsing if the arguments are passed on by splitting them %2 %3 %4 %5
:: %6 %7 %8 %9. Work around that, http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute
if not (%1)==() (
set ARGUMENTS=%*
call set ARGUMENTS=%%ARGUMENTS:%1=%%
)
pushd ..
set CMAKE_INSTALL_PREFIX=%CD%\_installed-%GEN_SHORTHAND%
popd
IF NOT EXIST ..\%BUILD_DIR%. mkdir ..\%BUILD_DIR%
pushd ..\%BUILD_DIR%
:: Legacy setup.
if not defined BOOST_INSTALL_DIR (
set BOOST_INSTALL_DIR=%DEPS_DIR%\boost_1_86_0\stage\%GEN_SHORTHAND%
)
::
:: Used environment variables:
:: - `ADD_COMMIT_SHA` - if defined then `ADD_COMMIT_SHA` and `VERSION_OVERRIDE` cmake args will be set to `ON`.
:: - `USE_NINJA` - if defined then the Ninja generator will be used instead of the Visual Studio.
@if not defined ECHO_ON ( echo off )
echo.
set PROJECT_NAME=IfcOpenShell
setlocal EnableDelayedExpansion
set IFCOS_PAUSE_ON_ERROR=
set GENERATOR=%1
:: If no GENERATOR was provided, read cached variables from any BuildDepsCache-XXX.txt
:: found in this directory; note that if more than one is present, the result could be wrong!
if (%1)==() (
for /f "tokens=*" %%f in ('dir BuildDepsCache-*.txt /o:-n /t:a /b') do (
for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
)
if not defined GEN_SHORTHAND (
echo BuildDepsCache file does not exist and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it.
set IFCOS_PAUSE_ON_ERROR=pause
goto :Error
)
set GENERATOR=!GEN_SHORTHAND!
echo Generator not passed, but GEN_SHORTHAND=!GENERATOR! read from BuildDepsCache
echo.
)
call vs-cfg.cmd %GENERATOR%
IF NOT %ERRORLEVEL%==0 GOTO :Error
:: If cached variables are still undefined,
:: read them from the specific BuildDepsCache-XXX.txt.
set "_test=0"
if not defined OCC_INCLUDE_DIR set _test=1
if not defined OCC_LIBRARY_DIR set _test=1
if %_test% EQU 1 (
IF DEFINED VS_TOOLSET (
set "BUILD_DEPS_CACHE_PATH=BuildDepsCache-%VS_PLATFORM%-%VS_TOOLSET%.txt"
) ELSE (
set "BUILD_DEPS_CACHE_PATH=BuildDepsCache-%VS_PLATFORM%.txt"
)
for /f "tokens=*" %%f in ('dir !BUILD_DEPS_CACHE_PATH! /o:-n /t:a /b') do (
for /f "delims== tokens=1,2" %%G in (%%f) do set %%G=%%H
)
)
:: As CMake options are typically of format -DSOMETHING:BOOL=ON or -DSOMETHING=1, i.e. they contain an equal sign,
:: they will mess up the batch file argument parsing if the arguments are passed on by splitting them %2 %3 %4 %5
:: %6 %7 %8 %9. Work around that, http://scripts.dragon-it.co.uk/scripts.nsf/docs/batch-search-replace-substitute
if not (%1)==() (
set ARGUMENTS=%*
call set ARGUMENTS=%%ARGUMENTS:%1=%%
)
pushd ..
set CMAKE_INSTALL_PREFIX=%CD%\_installed-%GEN_SHORTHAND%
popd
IF NOT EXIST ..\%BUILD_DIR%. mkdir ..\%BUILD_DIR%
pushd ..\%BUILD_DIR%
:: Legacy setup.
if not defined BOOST_INSTALL_DIR (
set BOOST_INSTALL_DIR=%DEPS_DIR%\boost_1_86_0\stage\%GEN_SHORTHAND%
)
set OPENCOLLADA_INSTALL_DIR=%INSTALL_DIR%\OpenCOLLADA
set LIBXML2_INCLUDE_DIR=%DEPS_DIR%\OpenCOLLADA\Externals\LibXML\include
set LIBXML2_LIBRARIES=%INSTALL_DIR%\OpenCOLLADA\lib\opencollada\xml.lib
set PYTHON_EXECUTABLE=%PYTHONHOME%\python.exe
for /f "usebackq delims=" %%v in (`
call "%PYTHON_EXECUTABLE%" -c "import sys; print(f'{sys.version_info[0]}{sys.version_info[1]}')"
`) do set "PY_VER_MAJOR_MINOR=%%v"
set PYTHON_INCLUDE_DIR=%PYTHONHOME%\include
set PYTHON_LIBRARY=%PYTHONHOME%\libs\python%PY_VER_MAJOR_MINOR%.lib
:: `swigwin` is a legacy installation folder name, before we started using versioned folders.
:: we can remove it later.
if not defined SWIG_INSTALL_DIR set SWIG_INSTALL_DIR=%INSTALL_DIR%\swigwin
set JSON_INCLUDE_DIR=%INSTALL_DIR%\json
if defined ADD_COMMIT_SHA (
set ADD_COMMIT_SHA=ON
set VERSION_OVERRIDE=ON
) else (
set ADD_COMMIT_SHA=OFF
set VERSION_OVERRIDE=OFF
)
set CGAL_INSTALL_DIR=%INSTALL_DIR%\cgal
set GMP_INSTALL_DIR=%INSTALL_DIR%\mpir
set MPFR_INSTALL_DIR=%INSTALL_DIR%\mpfr
:: We don't install Eigen currently,
:: so there's no Eigen3config.cmake and therefore we provide path explicitly.
set EIGEN_DIR=%INSTALL_DIR%\Eigen
set PYTHON_EXECUTABLE=%PYTHONHOME%\python.exe
for /f "usebackq delims=" %%v in (`
call "%PYTHON_EXECUTABLE%" -c "import sys; print(f'{sys.version_info[0]}{sys.version_info[1]}')"
`) do set "PY_VER_MAJOR_MINOR=%%v"
set PYTHON_INCLUDE_DIR=%PYTHONHOME%\include
set PYTHON_LIBRARY=%PYTHONHOME%\libs\python%PY_VER_MAJOR_MINOR%.lib
:: `swigwin` is a legacy installation folder name, before we started using versioned folders.
:: we can remove it later.
if not defined SWIG_INSTALL_DIR set SWIG_INSTALL_DIR=%INSTALL_DIR%\swigwin
set JSON_INCLUDE_DIR=%INSTALL_DIR%\json
if defined ADD_COMMIT_SHA (
set ADD_COMMIT_SHA=ON
set VERSION_OVERRIDE=ON
) else (
set ADD_COMMIT_SHA=OFF
set VERSION_OVERRIDE=OFF
)
set CGAL_INSTALL_DIR=%INSTALL_DIR%\cgal
set GMP_INSTALL_DIR=%INSTALL_DIR%\mpir
set MPFR_INSTALL_DIR=%INSTALL_DIR%\mpfr
:: We don't install Eigen currently,
:: so there's no Eigen3config.cmake and therefore we provide path explicitly.
set EIGEN_DIR=%INSTALL_DIR%\Eigen
set TBB_INSTALL_DIR=%INSTALL_DIR%\tbb
set USD_INSTALL_DIR=%INSTALL_DIR%\usd
set ROCKSDB_INSTALL_DIR=%INSTALL_DIR%\rocksdb
set ZSTD_INSTALL_DIR=%INSTALL_DIR%\zstd
if not defined QT_DIR if defined QT6_INSTALL_DIR set QT_DIR=%QT6_INSTALL_DIR%
if not defined QT_HOST_PATH if defined QT6_HOST_INSTALL_DIR set QT_HOST_PATH=%QT6_HOST_INSTALL_DIR%
echo.
call cecho.cmd 0 10 "Script configuration:"
echo Generator = %GENERATOR%
echo Architecture = %VS_PLATFORM%
echo Toolset = %VS_TOOLSET%
echo Arguments = %ARGUMENTS%
echo.
call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:"
echo BOOST_INSTALL_DIR = %BOOST_INSTALL_DIR%
:: OCC_INCLUDE_DIR / OCC_LIBRARY_DIR are legacy vars, they're not defined by build-deps.cmd anymore.
echo OCC_INCLUDE_DIR = %OCC_INCLUDE_DIR%
echo OCC_LIBRARY_DIR = %OCC_LIBRARY_DIR%
echo OCC_INSTALL_DIR = %OCC_INSTALL_DIR%
echo.
call cecho.cmd 0 10 "Script configuration:"
echo Generator = %GENERATOR%
echo Architecture = %VS_PLATFORM%
echo Toolset = %VS_TOOLSET%
echo Arguments = %ARGUMENTS%
echo.
call cecho.cmd 0 10 "Dependency Environment Variables for %PROJECT_NAME%:"
echo BOOST_INSTALL_DIR = %BOOST_INSTALL_DIR%
:: OCC_INCLUDE_DIR / OCC_LIBRARY_DIR are legacy vars, they're not defined by build-deps.cmd anymore.
echo OCC_INCLUDE_DIR = %OCC_INCLUDE_DIR%
echo OCC_LIBRARY_DIR = %OCC_LIBRARY_DIR%
echo OCC_INSTALL_DIR = %OCC_INSTALL_DIR%
echo OPENCOLLADA_INSTALL_DIR = %OPENCOLLADA_INSTALL_DIR%
echo LIBXML2_INCLUDE_DIR = %LIBXML2_INCLUDE_DIR%
echo LIBXML2_LIBRARIES = %LIBXML2_LIBRARIES%
echo PYTHONHOME = %PYTHONHOME%
echo PYTHON_INCLUDE_DIR = %PYTHON_INCLUDE_DIR%
echo PYTHON_LIBRARY = %PYTHON_LIBRARY%
echo PYTHON_EXECUTABLE = %PYTHON_EXECUTABLE%
echo SWIG_INSTALL_DIR = %SWIG_INSTALL_DIR%
echo JSON_INCLUDE_DIR = %JSON_INCLUDE_DIR%
echo.
echo CGAL_INSTALL_DIR = %CGAL_INSTALL_DIR%
:: echo CGAL_LIBRARY_DIR = %CGAL_LIBRARY_DIR%
echo GMP_INSTALL_DIR = %GMP_INSTALL_DIR%
echo MPFR_INSTALL_DIR = %MPFR_INSTALL_DIR%
echo EIGEN_DIR = %EIGEN_DIR%
echo TBB_INSTALL_DIR = %TBB_INSTALL_DIR%
echo PYTHON_INCLUDE_DIR = %PYTHON_INCLUDE_DIR%
echo PYTHON_LIBRARY = %PYTHON_LIBRARY%
echo PYTHON_EXECUTABLE = %PYTHON_EXECUTABLE%
echo SWIG_INSTALL_DIR = %SWIG_INSTALL_DIR%
echo JSON_INCLUDE_DIR = %JSON_INCLUDE_DIR%
echo.
echo CGAL_INSTALL_DIR = %CGAL_INSTALL_DIR%
:: echo CGAL_LIBRARY_DIR = %CGAL_LIBRARY_DIR%
echo GMP_INSTALL_DIR = %GMP_INSTALL_DIR%
echo MPFR_INSTALL_DIR = %MPFR_INSTALL_DIR%
echo EIGEN_DIR = %EIGEN_DIR%
echo TBB_INSTALL_DIR = %TBB_INSTALL_DIR%
echo USD_INSTALL_DIR = %USD_INSTALL_DIR%
echo ROCKSDB_INSTALL_DIR = %ROCKSDB_INSTALL_DIR%
echo ZSTD_INSTALL_DIR = %ZSTD_INSTALL_DIR%
@@ -166,15 +166,15 @@ echo QT_HOST_PATH = %QT_HOST_PATH%
echo CCACHE_INSTALL_DIR = %CCACHE_INSTALL_DIR%
echo.
echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX%
echo.
set CMAKELISTS_DIR=..\cmake
:: Delete CMakeCache.txt if command-line options were provided for this batch script.
if not (%1)==() if exist CMakeCache.txt. del /Q CMakeCache.txt
echo "Running CMake for %PROJECT_NAME%."
echo.
set CMAKELISTS_DIR=..\cmake
:: Delete CMakeCache.txt if command-line options were provided for this batch script.
if not (%1)==() if exist CMakeCache.txt. del /Q CMakeCache.txt
echo "Running CMake for %PROJECT_NAME%."
set CMAKE_PREFIX_PATH=%OPENCOLLADA_INSTALL_DIR%;%SWIG_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROCKSDB_INSTALL_DIR%;%ZSTD_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%ROCKSDB_INSTALL_DIR%;%ZSTD_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%BOOST_INSTALL_DIR%;%CCACHE_INSTALL_DIR%
set CMake_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%USD_INSTALL_DIR%;%TBB_INSTALL_DIR%
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;%OCC_INSTALL_DIR%;%CGAL_INSTALL_DIR%
@@ -185,45 +185,45 @@ set QT_DIR_OPTION=
if defined QT_DIR set QT_DIR_OPTION=-DQT_DIR="%QT_DIR%"
set QT_HOST_PATH_OPTION=
if defined QT_HOST_PATH set QT_HOST_PATH_OPTION=-DQT_HOST_PATH="%QT_HOST_PATH%"
:: Not fully supported - not available from install-ifcopenshell
:: and some logs are still showing Visual Studio generators.
:: Needed just for debugging.
if defined USE_NINJA (
set GENERATOR=Ninja
set ARCH_OPTION=
) else (
set GENERATOR=%GENERATOR%
set ARCH_OPTION=-A %VS_PLATFORM%
)
IF NOT "%VS_TOOLSET_HOST%"=="" (
set VS_TOOLSET_OPTION=-T %VS_TOOLSET_HOST%
)
cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% %ARCH_OPTION% %VS_TOOLSET_OPTION% ^
-DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ^
:: Not fully supported - not available from install-ifcopenshell
:: and some logs are still showing Visual Studio generators.
:: Needed just for debugging.
if defined USE_NINJA (
set GENERATOR=Ninja
set ARCH_OPTION=
) else (
set GENERATOR=%GENERATOR%
set ARCH_OPTION=-A %VS_PLATFORM%
)
IF NOT "%VS_TOOLSET_HOST%"=="" (
set VS_TOOLSET_OPTION=-T %VS_TOOLSET_HOST%
)
cmake.exe %CMAKELISTS_DIR% -G %GENERATOR% %ARCH_OPTION% %VS_TOOLSET_OPTION% ^
-DCMAKE_INSTALL_PREFIX="%CMAKE_INSTALL_PREFIX%" ^
-DWITH_ROCKSDB=On -DWITH_ZSTD=On ^
-DCMAKE_PREFIX_PATH="%CMAKE_PREFIX_PATH%" ^
%QT_DIR_OPTION% ^
%QT_HOST_PATH_OPTION% ^
-DADD_COMMIT_SHA=%ADD_COMMIT_SHA% -DVERSION_OVERRIDE=%VERSION_OVERRIDE% ^
%ARGUMENTS%
IF NOT %ERRORLEVEL%==0 GOTO :Error
echo.
set IFCOS_SCRIPT_RET=0
goto :Finish
:Error
echo.
call "%~dp0\utils\cecho.cmd" 0 12 "An error occurred! Aborting!"
%IFCOS_PAUSE_ON_ERROR%
set IFCOS_SCRIPT_RET=1
goto :Finish
:Finish
popd
exit /b %IFCOS_SCRIPT_RET%
IF NOT %ERRORLEVEL%==0 GOTO :Error
echo.
set IFCOS_SCRIPT_RET=0
goto :Finish
:Error
echo.
call "%~dp0\utils\cecho.cmd" 0 12 "An error occurred! Aborting!"
%IFCOS_PAUSE_ON_ERROR%
set IFCOS_SCRIPT_RET=1
goto :Finish
:Finish
popd
exit /b %IFCOS_SCRIPT_RET%
+265 -265
View File
@@ -1,275 +1,275 @@
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: This file is part of IfcOpenShell. ::
:: ::
:: IfcOpenShell is free software: you can redistribute it and/or modify ::
:: it under the terms of the Lesser GNU General Public License as published by ::
:: the Free Software Foundation, either version 3.0 of the License, or ::
:: (at your option) any later version. ::
:: ::
:: IfcOpenShell is distributed in the hope that it will be useful, ::
:: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
:: Lesser GNU General Public License for more details. ::
:: ::
:: You should have received a copy of the Lesser GNU General Public License ::
:: along with this program. If not, see <http://www.gnu.org/licenses/>. ::
:: ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::
:: This script initializes various Visual Studio related environment variables.
::
:: It expects a CMake generator as %1. If %1 is not provided, it is deduced from
:: the VisualStudioVersion environment variable and from the location of cl.exe.
::
:: The generator string must be in the CMake 3.0 and newer format, i.e.
:: "Visual Studio 12 2013" instead of "Visual Studio 12"
::
:: User-friendly VS generators are preferred, since they permit a more accurate
:: platform and toolset configuration. Some examples:
::
:: "vs2013" => cmake -G "Visual Studio 12 2013" -A Win32
:: "vs2013-x86" => cmake -G "Visual Studio 12 2013" -A Win32
:: "vs2015-x64" => cmake -G "Visual Studio 14 2015" -A x64
:: "vs2017-ARM64" => cmake -G "Visual Studio 15 2017" -A ARM64
:: "vs2019-x86-v141_xp" => cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp
::
:: NOTE: The delayed environment variable expansion needs to be enabled before calling this.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: ::
:: This file is part of IfcOpenShell. ::
:: ::
:: IfcOpenShell is free software: you can redistribute it and/or modify ::
:: it under the terms of the Lesser GNU General Public License as published by ::
:: the Free Software Foundation, either version 3.0 of the License, or ::
:: (at your option) any later version. ::
:: ::
:: IfcOpenShell is distributed in the hope that it will be useful, ::
:: but WITHOUT ANY WARRANTY; without even the implied warranty of ::
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ::
:: Lesser GNU General Public License for more details. ::
:: ::
:: You should have received a copy of the Lesser GNU General Public License ::
:: along with this program. If not, see <http://www.gnu.org/licenses/>. ::
:: ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::
:: This script initializes various Visual Studio related environment variables.
::
:: It expects a CMake generator as %1. If %1 is not provided, it is deduced from
:: the VisualStudioVersion environment variable and from the location of cl.exe.
::
:: The generator string must be in the CMake 3.0 and newer format, i.e.
:: "Visual Studio 12 2013" instead of "Visual Studio 12"
::
:: User-friendly VS generators are preferred, since they permit a more accurate
:: platform and toolset configuration. Some examples:
::
:: "vs2013" => cmake -G "Visual Studio 12 2013" -A Win32
:: "vs2013-x86" => cmake -G "Visual Studio 12 2013" -A Win32
:: "vs2015-x64" => cmake -G "Visual Studio 14 2015" -A x64
:: "vs2017-ARM64" => cmake -G "Visual Studio 15 2017" -A ARM64
:: "vs2019-x86-v141_xp" => cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp
::
:: NOTE: The delayed environment variable expansion needs to be enabled before calling this.
::
:: Output variables:
:: - VC_VER - e.g. "14.5"
:: - VS_VER - e.g. "2026"
:: - VS_VER - e.g. "2026"
:: - BOOST_BOOTSTRAP_VER - e.g. "vc145"
@if not defined ECHO_ON ( echo off )
set GENERATOR=%1
:: Supported Visual Studio versions:
set GENERATORS[1]="Visual Studio 12 2013"
set GENERATORS[2]="Visual Studio 14 2015"
set GENERATORS[3]="Visual Studio 15 2017"
set GENERATORS[4]="Visual Studio 16 2019"
set GENERATORS[5]="Visual Studio 17 2022"
@if not defined ECHO_ON ( echo off )
set GENERATOR=%1
:: Supported Visual Studio versions:
set GENERATORS[1]="Visual Studio 12 2013"
set GENERATORS[2]="Visual Studio 14 2015"
set GENERATORS[3]="Visual Studio 15 2017"
set GENERATORS[4]="Visual Studio 16 2019"
set GENERATORS[5]="Visual Studio 17 2022"
set GENERATORS[6]="Visual Studio 18 2026"
set LAST_GENERATOR_IDX=6
:: Is generator shorthand used?
set GEN_SHORTHAND=!GENERATOR:vs=!
if not "!GEN_SHORTHAND!"=="" if !GEN_SHORTHAND!==!GENERATOR! goto :GeneratorShorthandCheckDone
set "VS_PLATFORM=Win32"
:: use the command prompt target platform, at least initially
if "%VSCMD_ARG_TGT_ARCH%"=="x86" set "VS_PLATFORM=Win32"
if "%VSCMD_ARG_TGT_ARCH%"=="x64" set "VS_PLATFORM=x64"
if "%VSCMD_ARG_TGT_ARCH%"=="arm" set "VS_PLATFORM=ARM"
if "%VSCMD_ARG_TGT_ARCH%"=="arm64" set "VS_PLATFORM=ARM64"
:: "echo if" trick from http://stackoverflow.com/a/8758579
echo(!GEN_SHORTHAND! | findstr /c:"-x86" >nul && ( set "VS_PLATFORM=Win32" )
echo(!GEN_SHORTHAND! | findstr /c:"-x64" >nul && ( set "VS_PLATFORM=x64" )
echo(!GEN_SHORTHAND! | findstr /c:"-ARM" >nul && ( set "VS_PLATFORM=ARM" )
echo(!GEN_SHORTHAND! | findstr /c:"-ARM64" >nul && ( set "VS_PLATFORM=ARM64" )
echo(!GEN_SHORTHAND! | findstr /c:"-v120" >nul && ( set "VS_TOOLSET=v120" ) && ( set "BOOST_TOOLSET=12.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v120_xp" >nul && ( set "VS_TOOLSET=v120_xp" ) && ( set "BOOST_TOOLSET=12.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v140" >nul && ( set "VS_TOOLSET=v140" ) && ( set "BOOST_TOOLSET=14.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v140_xp" >nul && ( set "VS_TOOLSET=v140_xp" ) && ( set "BOOST_TOOLSET=14.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v141" >nul && ( set "VS_TOOLSET=v141" ) && ( set "BOOST_TOOLSET=14.1" )
echo(!GEN_SHORTHAND! | findstr /c:"-v141_xp" >nul && ( set "VS_TOOLSET=v141_xp" ) && ( set "BOOST_TOOLSET=14.1" )
echo(!GEN_SHORTHAND! | findstr /c:"-v142" >nul && ( set "VS_TOOLSET=v142" ) && ( set "BOOST_TOOLSET=14.2" )
SET VS_VER=%GEN_SHORTHAND:~0,4%
echo(!GENERATOR! | findstr /c:"vs20" >nul && (
for /L %%i in (0,1,%LAST_GENERATOR_IDX%) do (
echo(!GENERATORS[%%i]! | findstr /c:"!VS_VER!" >nul && (
set GENERATOR=!GENERATORS[%%i]!
goto :GeneratorShorthandCheckDone
)
)
)
:GeneratorShorthandCheckDone
:: Deduce desired architecture from the location of cl.exe
:: TODO harmless "INFO: Could not find files for the given pattern(s)." spam if cl.exe not in path
:: Look for path with either "amd64" or "x64" (VS 2017 and newer)
where cl.exe | findstr "amd64 x64" >nul
set START=%ERRORLEVEL%
:: NOTE add space before VC_VER so that e.g. "12" doesn't match with "2012"
IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" (
set VC_VER=%VisualStudioVersion:.0=%
FOR /L %%i in (%START%,1,%LAST_GENERATOR_IDX%) DO (
echo(!GENERATORS[%%i]! | findstr /c:" !VC_VER!" >nul && (
set GENERATOR=!GENERATORS[%%i]!
call utils\cecho.cmd black cyan "Generator not passed, but VisualStudioVersion=%VisualStudioVersion% environment variable detected:"
call utils\cecho.cmd black cyan "using '`"!GENERATOR!`'" as the generator."
SET VS_VER=!GENERATOR:~-5,4!
GOTO :GeneratorValid
)
)
:: Is generator shorthand used?
set GEN_SHORTHAND=!GENERATOR:vs=!
if not "!GEN_SHORTHAND!"=="" if !GEN_SHORTHAND!==!GENERATOR! goto :GeneratorShorthandCheckDone
set "VS_PLATFORM=Win32"
:: use the command prompt target platform, at least initially
if "%VSCMD_ARG_TGT_ARCH%"=="x86" set "VS_PLATFORM=Win32"
if "%VSCMD_ARG_TGT_ARCH%"=="x64" set "VS_PLATFORM=x64"
if "%VSCMD_ARG_TGT_ARCH%"=="arm" set "VS_PLATFORM=ARM"
if "%VSCMD_ARG_TGT_ARCH%"=="arm64" set "VS_PLATFORM=ARM64"
:: "echo if" trick from http://stackoverflow.com/a/8758579
echo(!GEN_SHORTHAND! | findstr /c:"-x86" >nul && ( set "VS_PLATFORM=Win32" )
echo(!GEN_SHORTHAND! | findstr /c:"-x64" >nul && ( set "VS_PLATFORM=x64" )
echo(!GEN_SHORTHAND! | findstr /c:"-ARM" >nul && ( set "VS_PLATFORM=ARM" )
echo(!GEN_SHORTHAND! | findstr /c:"-ARM64" >nul && ( set "VS_PLATFORM=ARM64" )
echo(!GEN_SHORTHAND! | findstr /c:"-v120" >nul && ( set "VS_TOOLSET=v120" ) && ( set "BOOST_TOOLSET=12.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v120_xp" >nul && ( set "VS_TOOLSET=v120_xp" ) && ( set "BOOST_TOOLSET=12.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v140" >nul && ( set "VS_TOOLSET=v140" ) && ( set "BOOST_TOOLSET=14.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v140_xp" >nul && ( set "VS_TOOLSET=v140_xp" ) && ( set "BOOST_TOOLSET=14.0" )
echo(!GEN_SHORTHAND! | findstr /c:"-v141" >nul && ( set "VS_TOOLSET=v141" ) && ( set "BOOST_TOOLSET=14.1" )
echo(!GEN_SHORTHAND! | findstr /c:"-v141_xp" >nul && ( set "VS_TOOLSET=v141_xp" ) && ( set "BOOST_TOOLSET=14.1" )
echo(!GEN_SHORTHAND! | findstr /c:"-v142" >nul && ( set "VS_TOOLSET=v142" ) && ( set "BOOST_TOOLSET=14.2" )
SET VS_VER=%GEN_SHORTHAND:~0,4%
echo(!GENERATOR! | findstr /c:"vs20" >nul && (
for /L %%i in (0,1,%LAST_GENERATOR_IDX%) do (
echo(!GENERATORS[%%i]! | findstr /c:"!VS_VER!" >nul && (
set GENERATOR=!GENERATORS[%%i]!
goto :GeneratorShorthandCheckDone
)
)
)
:GeneratorShorthandCheckDone
:: Deduce desired architecture from the location of cl.exe
:: TODO harmless "INFO: Could not find files for the given pattern(s)." spam if cl.exe not in path
:: Look for path with either "amd64" or "x64" (VS 2017 and newer)
where cl.exe | findstr "amd64 x64" >nul
set START=%ERRORLEVEL%
:: NOTE add space before VC_VER so that e.g. "12" doesn't match with "2012"
IF "!GENERATOR!"=="" IF NOT "%VisualStudioVersion%"=="" (
set VC_VER=%VisualStudioVersion:.0=%
FOR /L %%i in (%START%,1,%LAST_GENERATOR_IDX%) DO (
echo(!GENERATORS[%%i]! | findstr /c:" !VC_VER!" >nul && (
set GENERATOR=!GENERATORS[%%i]!
call utils\cecho.cmd black cyan "Generator not passed, but VisualStudioVersion=%VisualStudioVersion% environment variable detected:"
call utils\cecho.cmd black cyan "using '`"!GENERATOR!`'" as the generator."
SET VS_VER=!GENERATOR:~-5,4!
GOTO :GeneratorValid
)
)
call utils\cecho.cmd 0 12 ^
"Generator is not provided and VisualStudioVersion='%VisualStudioVersion%' is not supported - cannot proceed."
exit /b 1
)
:: Check that the used CMake version supports the chosen generator
set GENERATOR_CHECK=%GENERATOR: Win64=%
cmake --help | findstr /c:%GENERATOR_CHECK% >nul
if not %ERRORLEVEL%==0 (
call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support generator '`"!GENERATOR!`'"- cannot proceed."
exit /b 1
)
FOR /L %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
IF !GENERATOR!==!GENERATORS[%%i]! GOTO :GeneratorValid
)
call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'"- cannot proceed."
echo Supported CMake generator strings:
FOR /L %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
echo !GENERATORS[%%i]!
)
exit /b 1
:GeneratorValid
IF DEFINED VS_PLATFORM goto :PlatformDefined
:: If we do not have defined a platform yet,
:: figure out the build configuration from the CMake generator string.
:: Are we building 32-bit or 64-bit version.
:: Visual Studio platform name, Win32 (i.e. x86) or x64.
set VS_PLATFORM=Win32
:: Find out VS (e.g. 2015) and VC (e.g. 14) versions and are we targeting x64 or not (x86).
:: VS_VER and VC_VER are convenience variables used f.ex. for filenames.
set GENERATOR_NO_DOUBLEQUOTES=%GENERATOR:"=%
set GENERATOR_SPLIT=%GENERATOR_NO_DOUBLEQUOTES: =,%
FOR %%i IN (%GENERATOR_SPLIT%) DO (
call :StrLength LEN %%i
IF !LEN!==1 set VC_VER=%%i
IF !LEN!==2 set VC_VER=%%i
IF !LEN!==4 set VS_VER=%%i
:: Are going to perform a 64-bit build?
IF %%i==Win64 (
set VS_PLATFORM=x64
)
)
:PlatformDefined
:: determine the Visual C++ default version
IF %VS_VER%==2013 ( set "VC_VER=12.0" )
IF %VS_VER%==2015 ( set "VC_VER=14.0" )
IF %VS_VER%==2017 ( set "VC_VER=14.1" )
IF %VS_VER%==2019 ( set "VC_VER=14.2" )
IF %VS_VER%==2022 ( set "VC_VER=14.3" )
)
:: Check that the used CMake version supports the chosen generator
set GENERATOR_CHECK=%GENERATOR: Win64=%
cmake --help | findstr /c:%GENERATOR_CHECK% >nul
if not %ERRORLEVEL%==0 (
call utils\cecho.cmd 0 12 "%~nx0: The used CMake version does not support generator '`"!GENERATOR!`'"- cannot proceed."
exit /b 1
)
FOR /L %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
IF !GENERATOR!==!GENERATORS[%%i]! GOTO :GeneratorValid
)
call utils\cecho.cmd 0 12 "%~nx0: Invalid or unsupported CMake generator string passed: '`"!GENERATOR!`'"- cannot proceed."
echo Supported CMake generator strings:
FOR /L %%i in (0,1,%LAST_GENERATOR_IDX%) DO (
echo !GENERATORS[%%i]!
)
exit /b 1
:GeneratorValid
IF DEFINED VS_PLATFORM goto :PlatformDefined
:: If we do not have defined a platform yet,
:: figure out the build configuration from the CMake generator string.
:: Are we building 32-bit or 64-bit version.
:: Visual Studio platform name, Win32 (i.e. x86) or x64.
set VS_PLATFORM=Win32
:: Find out VS (e.g. 2015) and VC (e.g. 14) versions and are we targeting x64 or not (x86).
:: VS_VER and VC_VER are convenience variables used f.ex. for filenames.
set GENERATOR_NO_DOUBLEQUOTES=%GENERATOR:"=%
set GENERATOR_SPLIT=%GENERATOR_NO_DOUBLEQUOTES: =,%
FOR %%i IN (%GENERATOR_SPLIT%) DO (
call :StrLength LEN %%i
IF !LEN!==1 set VC_VER=%%i
IF !LEN!==2 set VC_VER=%%i
IF !LEN!==4 set VS_VER=%%i
:: Are going to perform a 64-bit build?
IF %%i==Win64 (
set VS_PLATFORM=x64
)
)
:PlatformDefined
:: determine the Visual C++ default version
IF %VS_VER%==2013 ( set "VC_VER=12.0" )
IF %VS_VER%==2015 ( set "VC_VER=14.0" )
IF %VS_VER%==2017 ( set "VC_VER=14.1" )
IF %VS_VER%==2019 ( set "VC_VER=14.2" )
IF %VS_VER%==2022 ( set "VC_VER=14.3" )
IF %VS_VER%==2026 ( set "VC_VER=14.5" )
:: determine the argument for Boost bootstrap
set BOOST_BOOTSTRAP_VER=vc%VC_VER%
set BOOST_BOOTSTRAP_VER=%BOOST_BOOTSTRAP_VER:.=%
set VS_TOOLSET_HOST=
:: determine the toolset and winapi for Boost b2
:: optionally use 64bit toolset to work around memory errors when linking
IF DEFINED VS_TOOLSET (
set BOOST_TOOLSET=msvc-%BOOST_TOOLSET%
if "!VS_TOOLSET:~-3!"=="_xp" (
set BOOST_WIN_API=define=BOOST_USE_WINAPI_VERSION=0x0501
)
IF NOT "%VS_HOST%"=="" (
set VS_TOOLSET_HOST=%VS_TOOLSET%,host=%VS_HOST%
)
) ELSE (
set BOOST_TOOLSET=msvc-%VC_VER%
set BOOST_WIN_API=
IF NOT "%VS_HOST%"=="" (
set VS_TOOLSET_HOST=host=%VS_HOST%
)
)
IF %VS_PLATFORM%==Win32 (
set ARCH_BITS=32
set TARGET_ARCH=x86
)
IF %VS_PLATFORM%==x64 (
set ARCH_BITS=64
set TARGET_ARCH=x64
)
IF %VS_PLATFORM%==ARM (
set ARCH_BITS=32
set TARGET_ARCH=ARM
)
IF %VS_PLATFORM%==ARM64 (
set ARCH_BITS=64
set TARGET_ARCH=ARM64
)
:: Check CMake version and convert possible new format (>= 3.0) generator names to the old versions if using older CMake for VS <= 2013,
:: see http://www.cmake.org/cmake/help/v3.0/release/3.0.0.html#other-changes
FOR /f "delims=" %%i in ('where cmake') DO set CMAKE_PATH=%%i
IF NOT "%CMAKE_PATH%"=="" (
FOR /f "delims=" %%i in ('cmake --version ^| findstr /C:"cmake version 3"') DO GOTO :CMake3AndNewer
FOR /f "delims=" %%i in ('cmake --version ^| findstr /C:"cmake version 4"') DO GOTO :CMake3AndNewer
)
:: reject older CMake, see also build-deps.cmd
echo "CMake v3.11.4 or higher is required"
exit /b 1
:CMake3AndNewer
:: check variables for debugging
echo GENERATOR: [!GENERATOR!]
echo VS_VER: [!VS_VER!]
echo VS_PLATFORM: [!VS_PLATFORM!]
echo VS_TOOLSET: [!VS_TOOLSET!]
echo VC_VER: [!VC_VER!]
echo ARCH_BITS: [!ARCH_BITS!]
echo TARGET_ARCH: [!TARGET_ARCH!]
echo BOOST_BOOTSTRAP_VER: [!BOOST_BOOTSTRAP_VER!]
echo BOOST_TOOLSET: [!BOOST_TOOLSET!]
echo BOOST_WIN_API: [!BOOST_WIN_API!]
IF DEFINED VS_TOOLSET (
set GEN_SHORTHAND=vs%VS_VER%-%VS_PLATFORM%-%VS_TOOLSET%
) ELSE (
set GEN_SHORTHAND=vs%VS_VER%-%VS_PLATFORM%
)
:: VS project file extension is different on older VS versions
set VCPROJ_FILE_EXT=vcxproj
:: Add utils to PATH
set ORIGINAL_PATH=%PATH%
set PATH=%~dp0utils;%PATH%
:: Fetch and build the dependencies to a dedicated directory depending on the used VS version and target architecture.
:: NOTE For IfcOpenShell we can build all of our deps both x86 and x64 using different VS versions in the same directories
:: so no need for -%VS_VER%-%TARGET_ARCH% postfix.
:: set DEPS_DIR=%CD%\deps-%VS_VER%-%TARGET_ARCH%
pushd ..
set DEPS_DIR=%CD%\_deps
set INSTALL_DIR=%CD%\_deps-%GEN_SHORTHAND%-installed
:: set INSTALL_DIR=%CD%\deps-vs%VS_VER%-%TARGET_ARCH%-%DEBUG_OR_RELEASE_LOWERCASE%-installed
:: BUILD_DIR is a relative build directory used for CMake-based projects
set BUILD_DIR=_build-%GEN_SHORTHAND%
popd
GOTO :EOF
:: http://geekswithblogs.net/SoftwareDoneRight/archive/2010/01/30/useful-dos-batch-functions-substring-and-length.aspx
:StrLength
set #=%2%
set length=0
:stringLengthLoop
if defined # (set #=%#:~1%&set /A length += 1&goto stringLengthLoop)
::echo the string is %length% characters long!
set "%~1=%length%"
GOTO :EOF
:: determine the argument for Boost bootstrap
set BOOST_BOOTSTRAP_VER=vc%VC_VER%
set BOOST_BOOTSTRAP_VER=%BOOST_BOOTSTRAP_VER:.=%
set VS_TOOLSET_HOST=
:: determine the toolset and winapi for Boost b2
:: optionally use 64bit toolset to work around memory errors when linking
IF DEFINED VS_TOOLSET (
set BOOST_TOOLSET=msvc-%BOOST_TOOLSET%
if "!VS_TOOLSET:~-3!"=="_xp" (
set BOOST_WIN_API=define=BOOST_USE_WINAPI_VERSION=0x0501
)
IF NOT "%VS_HOST%"=="" (
set VS_TOOLSET_HOST=%VS_TOOLSET%,host=%VS_HOST%
)
) ELSE (
set BOOST_TOOLSET=msvc-%VC_VER%
set BOOST_WIN_API=
IF NOT "%VS_HOST%"=="" (
set VS_TOOLSET_HOST=host=%VS_HOST%
)
)
IF %VS_PLATFORM%==Win32 (
set ARCH_BITS=32
set TARGET_ARCH=x86
)
IF %VS_PLATFORM%==x64 (
set ARCH_BITS=64
set TARGET_ARCH=x64
)
IF %VS_PLATFORM%==ARM (
set ARCH_BITS=32
set TARGET_ARCH=ARM
)
IF %VS_PLATFORM%==ARM64 (
set ARCH_BITS=64
set TARGET_ARCH=ARM64
)
:: Check CMake version and convert possible new format (>= 3.0) generator names to the old versions if using older CMake for VS <= 2013,
:: see http://www.cmake.org/cmake/help/v3.0/release/3.0.0.html#other-changes
FOR /f "delims=" %%i in ('where cmake') DO set CMAKE_PATH=%%i
IF NOT "%CMAKE_PATH%"=="" (
FOR /f "delims=" %%i in ('cmake --version ^| findstr /C:"cmake version 3"') DO GOTO :CMake3AndNewer
FOR /f "delims=" %%i in ('cmake --version ^| findstr /C:"cmake version 4"') DO GOTO :CMake3AndNewer
)
:: reject older CMake, see also build-deps.cmd
echo "CMake v3.11.4 or higher is required"
exit /b 1
:CMake3AndNewer
:: check variables for debugging
echo GENERATOR: [!GENERATOR!]
echo VS_VER: [!VS_VER!]
echo VS_PLATFORM: [!VS_PLATFORM!]
echo VS_TOOLSET: [!VS_TOOLSET!]
echo VC_VER: [!VC_VER!]
echo ARCH_BITS: [!ARCH_BITS!]
echo TARGET_ARCH: [!TARGET_ARCH!]
echo BOOST_BOOTSTRAP_VER: [!BOOST_BOOTSTRAP_VER!]
echo BOOST_TOOLSET: [!BOOST_TOOLSET!]
echo BOOST_WIN_API: [!BOOST_WIN_API!]
IF DEFINED VS_TOOLSET (
set GEN_SHORTHAND=vs%VS_VER%-%VS_PLATFORM%-%VS_TOOLSET%
) ELSE (
set GEN_SHORTHAND=vs%VS_VER%-%VS_PLATFORM%
)
:: VS project file extension is different on older VS versions
set VCPROJ_FILE_EXT=vcxproj
:: Add utils to PATH
set ORIGINAL_PATH=%PATH%
set PATH=%~dp0utils;%PATH%
:: Fetch and build the dependencies to a dedicated directory depending on the used VS version and target architecture.
:: NOTE For IfcOpenShell we can build all of our deps both x86 and x64 using different VS versions in the same directories
:: so no need for -%VS_VER%-%TARGET_ARCH% postfix.
:: set DEPS_DIR=%CD%\deps-%VS_VER%-%TARGET_ARCH%
pushd ..
set DEPS_DIR=%CD%\_deps
set INSTALL_DIR=%CD%\_deps-%GEN_SHORTHAND%-installed
:: set INSTALL_DIR=%CD%\deps-vs%VS_VER%-%TARGET_ARCH%-%DEBUG_OR_RELEASE_LOWERCASE%-installed
:: BUILD_DIR is a relative build directory used for CMake-based projects
set BUILD_DIR=_build-%GEN_SHORTHAND%
popd
GOTO :EOF
:: http://geekswithblogs.net/SoftwareDoneRight/archive/2010/01/30/useful-dos-batch-functions-substring-and-length.aspx
:StrLength
set #=%2%
set length=0
:stringLengthLoop
if defined # (set #=%#:~1%&set /A length += 1&goto stringLengthLoop)
::echo the string is %length% characters long!
set "%~1=%length%"
GOTO :EOF