@echo off rem Version: 2.15.0 rem rem See the following gist for details rem https://gist.github.com/SteveALee/da24c2be633340b8791066dd98eb5d0b rem rem Options (only one may be specified) rem rem --install or none - install tools and build rem --build - build, no install rem --noget - build only but don't fetch again from git rem --getonly - only get the files rem --rebuild - cleanall and build rem --clean - remove built files rem --cleanall - remove fetched, built files and conan modules rem --cleaninstall - remove downloaded installation files rem -vj.m.p version - default is 3.7.5 (using conan 2.3.2) - limited due to dependencies rem rem MIT licence rem steve@fullmeasure.co.uk TITLE Build Audacity with ASIO setlocal rem Clean up arguments set TARGET=%1 set VERSION=%2 rem substring on empty var fails within parenthesis if not [%TARGET%] == [] set TARGET_PREFIX=%TARGET:~0,2% if [%TARGET_PREFIX%] == [-v] ( set TARGET=%2 set VERSION=%1 ) if [%TARGET%] == [] set TARGET=--install if [%VERSION%] == [] ( set AUDACITY_REL=3.7.5 ) else ( set AUDACITY_REL=%VERSION:~2% ) set VISUALSTUDIOVER=2022\Community set VISUALSTUDIOCMAKE=Visual Studio 17 2022 set VSDIR=%ProgramFiles%\Microsoft Visual Studio\%VISUALSTUDIOVER% set PROJROOT=C:\projects set AUDACITY=%PROJROOT%\audacity set AUDACITY_BUILD=%PROJROOT%\audacity-asio set MAKE_CONFIG=RelWithDebInfo set EXEDIR=%AUDACITY_BUILD%\%MAKE_CONFIG% set INSTALLFILEDIR=bin rem More vaiables set for --install if [%AUDACITY_REL:~0,3%] == [3.3] (set CONAN_VER=1.59.0) else (set CONAN_VER=2.11.0) set CMAKE_OPTS=-DAUDACITY_BUILD_LEVEL=2 -Daudacity_has_asio_support=On if [%AUDACITY_REL:~0,3%] GEQ [3.5] set CMAKE_OPTS=%CMAKE_OPTS% -Daudacity_has_audiocom_upload=On -Daudacity_has_networking=On -Daudacity_has_url_schemes_support=On rem check projroot exists if /I not [%~dp0] == [%PROJROOT%\] ( echo. echo Error: This script must be run in %PROJROOT% - see %%PROJROOT%% in file echo. if not exist %PROJROOT% ( echo Create %PROJROOT goto exit ) else ( echo cd to %PROJROOT% goto exit ) ) echo. echo Building Audacity %AUDACITY_REL% 64 bit RelWithDebInfo with ASIO support... echo. rem Get tools rem ANSI escape sequences do not work in if () block so we use goto set git-url=https://github.com/git-for-windows/git/releases/download/v2.51.0.windows.1/Git-2.51.0-64-bit.exe set GITPATH=%ProgramFiles%\Git\cmd\ set vs2022-url=https://aka.ms/vs/17/release/vs_community.exe rem Conan is installed later if [%CONAN_VER:~0,1%] == [1] ( rem Note Conan 1.59 has dependency issues with python 3.12 set python-url=https://www.python.org/ftp/python/3.11.0/python-3.11.0-amd64.exe set PYTHONPATH=%LOCALAPPDATA%\Programs\Python\Python311\ ) else ( set python-url=https://www.python.org/ftp/python/3.13.7/python-3.13.7-amd64.exe set PYTHONPATH=%LOCALAPPDATA%\Programs\Python\Python313\ ) set PIPPATH=%PYTHONPATH%Scripts\ if not [%TARGET%] == [--install] if not [%TARGET%] == [--cleaninstall] goto clean if [%TARGET%] == [--cleaninstall] echo Cleaning installation files... & rmdir /s/q %INSTALLFILEDIR% 2> :null & goto exit echo    echo. echo Fetching tools.. echo  mkdir %INSTALLFILEDIR% 2> :null curl -L %git-url% -o %INSTALLFILEDIR%\g4w.exe curl -L %vs2022-url% -o %INSTALLFILEDIR%\vs.exe curl -L %python-url% -o %INSTALLFILEDIR%\python.exe echo    echo. echo Installing tools... echo. echo IMPORTANT!! Follow the instructions below for each installer echo Close each installer when it is done before starting next echo. echo Git for Windows echo Choose the option "Git from the command line..." pause %INSTALLFILEDIR%\g4w.exe echo. echo Visual Studio: make sure you select the Workload "Desktop development with C++" echo You can uncheck "Start After installation" pause %INSTALLFILEDIR%\vs.exe echo. echo Python: make sure you select "Add python.exe to PATH" for future access pause %INSTALLFILEDIR%\python.exe echo. echo. echo  set installing=true call :clean --rebuild goto exit :clean rem Python is on path, unless in windows sandbox rem where /q python & if ERRORLEVEL 1 path %PATH%;%PYTHONPATH% rem where /q pip & if ERRORLEVEL 1 path %PATH%;%PIPPATH% rem where /q git & if ERRORLEVEL 1 path %PATH%;%GITPATH% path %PYTHONPATH%;%PIPPATH%;%GITPATH%;%PATH% if not [%TARGET%] == [--getonly] ( if /I [%TARGET%] == [--clean] echo Cleaning built files... & rmdir /s/q %AUDACITY_BUILD% 2> :null & goto exit if /I [%TARGET%] == [--cleanall] call :cleanall & goto exit if /I [%TARGET%] == [--rebuild] call :cleanall ) goto skip rem subroutine :cleanall echo Cleaning source and built files... & rmdir /s/q %AUDACITY% %AUDACITY_BUILD% 2> :null where /q conan & if ERRORLEVEL 0 echo Cleaning conan cache... & conan remove -c "*" 2>&1 > :null exit /B :skip rem Launch cmake-gui rem VS doesn't include this with it's cmake rem if [%TARGET%]==[--gui] cmake-gui -Daudacity_has_asio_support=On %CMAKE_OPTS% -S %AUDACITY% -B %AUDACITY_BUILD% & goto build :checktools rem ensure tools are installed if not [%TARGET%] == [--noget] ( where /q git & if ERRORLEVEL 1 echo Git for Windows does not appear to be installed. Rerun with "--install" & goto exit /b ) if not [%TARGET%] == [--getonly] ( if not exist "%VSDIR%\VC\Auxiliary\Build\vcvars64.bat" echo Visual Studio does not appear to be installed. Re run with "--install" & goto exit /b if not defined VisualStudioVersion call "%VSDIR%\VC\Auxiliary\Build\vcvars64.bat" where /q python & if ERRORLEVEL 1 echo Python does not appear to be installed. Open a new cmd window or re-run with "--install" & goto exit /b where /q conan & if ERRORLEVEL 0 pip show --version conan | findstr /R /C:"Version: %CONAN_VER%" & if ERRORLEVEL 1 echo conan %CONAN_VER% not found & pip uninstall -y -q conan where /q conan & if ERRORLEVEL 1 echo installing conan %CONAN_VER% & pip install conan==%CONAN_VER% ) rem Get source code :getcode if /I not [%TARGET%] == [--clean] ( if /I not [%TARGET%] == [--cleanall] ( if /I not [%TARGET%] == [--noget] ( echo Fetching code for Audacity %AUDACITY_REL%... echo. git clone -b Audacity-%AUDACITY_REL% --depth 1 https://github.com/audacity/audacity/ %AUDACITY% if ERRORLEVEL 1 echo Error: cannot fetch the Audacity code. Try the --cleanall or --noget options & goto exit ) ) ) if /I [%TARGET%] == [--getonly] goto exit if not exist %AUDACITY%\CMakeLists.txt echo The code files appear to be missing from %AUDACITY%. & goto exit :cmake cd %AUDACITY% cmake.exe -G "%VISUALSTUDIOCMAKE%" -DCMAKE_CONFIGURATION_TYPES=%MAKE_CONFIG% %CMAKE_OPTS% -S %AUDACITY% -B %AUDACITY_BUILD% & if ERRORLEVEL 1 echo Error: Cannot create Audacity buildfiles & goto exit :build cd %AUDACITY_BUILD% set msbuild="%VSDIR%\MSBuild\Current\Bin\MsBuild.exe" %msbuild% ALL_BUILD.vcxproj -p:configuration=%MAKE_CONFIG% if ERRORLEVEL 1 echo Error: cannot build Audacity & goto exit rem Settings stored with files rather than home directory rem See https://manual.audacityteam.org/man/portable_audacity.html mkdir %EXEDIR%\"Portable Settings" cd %PROJROOT% rem All done echo  echo. echo Congratulations! echo Your new Audacity %AUDACITY_REL% with ASIO support will now launch. echo The ASIO options will appear if you have ASIO drivers and connected hardware echo In future just run the audacity.exe. No need to install. echo. echo %EXEDIR%\audacity.exe echo. echo Or copy the folder echo. echo %EXEDIR%\ echo. echo and run the included audacity.exe echo. echo Note settings and preferences are stored in "%EXEDIR%\Portable Settings" echo If you want to use settings in the user's home directory then delete this folder. echo. echo  start %EXEDIR%\audacity.exe if defined installing exit /B :exit cd %PROJROOT% endlocal