1+ @ echo on
2+
3+ :: Set the CMAKE_BUILD_TYPE
4+ set " CMAKE_BUILD_TYPE = %BUILD_TYPE% "
5+
6+ :: activate visual studio
7+ call " %DEPENDENCIES_DIR% \VSBuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64 -vcvars_ver=%MSVC_VERSION%
8+ where cl.exe
9+
10+ :: change to source directory
11+ cd %PYTORCH_ROOT%
12+
13+ :: create virtual environment
14+ python -m venv .venv
15+ echo * > .venv\.gitignore
16+ call .\.venv\Scripts\activate
17+ where python
18+
19+ :: python install dependencies
20+ python -m pip install --upgrade pip
21+ pip install -r requirements.txt
22+
23+ :: start sccache server and reset sccache stats
24+ sccache --start-server
25+ sccache --zero-stats
26+ sccache --show-stats
27+
28+ :: Prepare the environment
29+ mkdir libtorch
30+ mkdir libtorch\bin
31+ mkdir libtorch\cmake
32+ mkdir libtorch\include
33+ mkdir libtorch\lib
34+ mkdir libtorch\share
35+ mkdir libtorch\test
36+
37+ :: Call LibTorch build script
38+ python ./tools/build_libtorch.py
39+
40+ :: Check if there is an error
41+ IF ERRORLEVEL 1 exit /b 1
42+ IF NOT ERRORLEVEL 0 exit /b 1
43+
44+ :: Move the files to the correct location
45+ move /Y torch\bin\*.* libtorch\bin\
46+ move /Y torch\cmake\*.* libtorch\cmake\
47+ robocopy /move /e torch\include\ libtorch\include\
48+ move /Y torch\lib\*.* libtorch\lib\
49+ robocopy /move /e torch\share\ libtorch\share\
50+ move /Y torch\test\*.* libtorch\test\
51+ move /Y libtorch\bin\*.dll libtorch\lib\
52+
53+ :: Set version
54+ echo %PYTORCH_BUILD_VERSION% > libtorch\build-version
55+ git rev-parse HEAD > libtorch\build-hash
56+
57+ :: Set LIBTORCH_PREFIX
58+ IF " %DEBUG% " == " " (
59+ set LIBTORCH_PREFIX = libtorch-win-arm64-shared-with-deps
60+ ) ELSE (
61+ set LIBTORCH_PREFIX = libtorch-win-arm64-shared-with-deps-debug
62+ )
63+
64+ :: Create output
65+ C:\Windows\System32\tar.exe -cvaf %LIBTORCH_PREFIX% -%PYTORCH_BUILD_VERSION% .zip -C libtorch *
66+
67+ :: Copy output to target directory
68+ if not exist ..\output mkdir ..\output
69+ copy /Y " %LIBTORCH_PREFIX% -%PYTORCH_BUILD_VERSION% .zip" " %PYTORCH_FINAL_PACKAGE_DIR% \"
70+ copy /Y " %LIBTORCH_PREFIX% -%PYTORCH_BUILD_VERSION% .zip" " %PYTORCH_FINAL_PACKAGE_DIR% \%LIBTORCH_PREFIX% -latest.zip"
71+
72+ :: Cleanup raw data to save space
73+ rmdir /s /q libtorch
0 commit comments