diff --git a/.github/workflows/ton-x86-64-windows-python.yml b/.github/workflows/ton-x86-64-windows-python.yml new file mode 100644 index 000000000..da27b135d --- /dev/null +++ b/.github/workflows/ton-x86-64-windows-python.yml @@ -0,0 +1,69 @@ +name: Windows TON build (portable, x86-64) + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + workflow_call: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + python: [ 39, 310, 311 ] + runs-on: windows-2022 + env: + RELEASE_NAME: ton-cpython-${{ matrix.python }}-x86_64-windows + + steps: + - name: Get Current OS version + run: Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion + + - name: Check out current repository + uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Setup msbuild.exe + uses: microsoft/setup-msbuild@v1.1 + + - name: Install Pkg-config Lite + run: choco install pkgconfiglite + + - name: Build TON + run: | + copy assembly\native\build-windows-python.bat . + & .\build-windows-python.bat + + - name: Find & copy binaries + run: | + mkdir artifacts + xcopy /i "build\tvm-python\Release\*.pyd" "artifacts\" + + - name: Simple binary test + run: | + cd artifacts + python -c 'import python_ton' + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + name: ${{ env.RELEASE_NAME }} + path: artifacts + + - name: Upload artifacts + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} || + ${{ github.event_name == 'workflow_dispatch' }} + run: | + try { + gh release delete -y ${{ env.RELEASE_NAME }} + } catch {} + gh release create ${{ env.RELEASE_NAME }} --notes " " (Get-ChildItem -Path artifacts).FullName + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/ton-x86-64-windows.yml b/.github/workflows/ton-x86-64-windows.yml deleted file mode 100644 index 670261839..000000000 --- a/.github/workflows/ton-x86-64-windows.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Windows TON build (portable, x86-64) - -on: [push,workflow_dispatch,workflow_call] - -defaults: - run: - shell: cmd - -jobs: - build: - - runs-on: windows-2022 - - steps: - - name: Get Current OS version - run: | - systeminfo | findstr /B /C:"OS Name" /C:"OS Version" - - - name: Check out current repository - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - - name: Build TON - run: | - copy assembly\native\build-windows-github.bat . - copy assembly\native\build-windows.bat . - build-windows-github.bat Enterprise - - - name: Upload artifacts - uses: actions/upload-artifact@master - with: - name: ton-win-binaries - path: artifacts diff --git a/assembly/native/build-windows-python.bat b/assembly/native/build-windows-python.bat new file mode 100644 index 000000000..41e9e718f --- /dev/null +++ b/assembly/native/build-windows-python.bat @@ -0,0 +1,120 @@ +REM execute this script inside elevated (Run as Administrator) console "x64 Native Tools Command Prompt for VS 2022" + +echo off + +call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + +echo Installing ninja... +choco install -y ninja +IF errorlevel 1 ( + echo Can't install ninja + exit /b %errorlevel% +) + +if not exist "zlib" ( +git clone https://github.com/madler/zlib.git +cd zlib\contrib\vstudio\vc14 +msbuild zlibstat.vcxproj /p:Configuration=ReleaseWithoutAsm /p:platform=x64 -p:PlatformToolset=v143 + +IF errorlevel 1 ( + echo Can't install zlib + exit /b %errorlevel% +) +cd ..\..\..\.. +) else ( +echo Using zlib... +) + +if not exist "secp256k1" ( +git clone https://github.com/libbitcoin/secp256k1.git +cd secp256k1\builds\msvc\vs2017 +msbuild /p:Configuration=StaticRelease -p:PlatformToolset=v143 -p:Platform=x64 +IF errorlevel 1 ( + echo Can't install secp256k1 + exit /b %errorlevel% +) +cd ..\..\..\.. +) else ( +echo Using secp256k1... +) + + +if not exist "libsodium" ( +curl -Lo libsodium-1.0.18-stable-msvc.zip https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip +IF errorlevel 1 ( + echo Can't download libsodium + exit /b %errorlevel% +) +unzip libsodium-1.0.18-stable-msvc.zip +) else ( +echo Using libsodium... +) + +if not exist "openssl-3.1.4" ( +curl -Lo openssl-3.1.4.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/openssl-3.1.4.zip +IF errorlevel 1 ( + echo Can't download OpenSSL + exit /b %errorlevel% +) +unzip -q openssl-3.1.4.zip +) else ( +echo Using openssl... +) + +if not exist "libmicrohttpd-0.9.77-w32-bin" ( +curl -Lo libmicrohttpd-0.9.77-w32-bin.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/libmicrohttpd-0.9.77-w32-bin.zip +IF errorlevel 1 ( + echo Can't download libmicrohttpd + exit /b %errorlevel% +) +unzip -q libmicrohttpd-0.9.77-w32-bin.zip +) else ( +echo Using libmicrohttpd... +) + +if not exist "readline-5.0-1-lib" ( +curl -Lo readline-5.0-1-lib.zip https://github.com/neodiX42/precompiled-openssl-win64/raw/main/readline-5.0-1-lib.zip +IF errorlevel 1 ( + echo Can't download readline + exit /b %errorlevel% +) +unzip -q -d readline-5.0-1-lib readline-5.0-1-lib.zip +) else ( +echo Using readline... +) + + +set root=%cd% +echo %root% +set SODIUM_DIR=%root%\libsodium + +mkdir build +cd build +cmake -GNinja -DCMAKE_BUILD_TYPE=Release ^ +-DTON_USE_PYTHON=1 ^ +-DTON_USE_ABSEIL=0 ^ +-DPORTABLE=1 ^ +-DSODIUM_USE_STATIC_LIBS=1 ^ +-DSECP256K1_FOUND=1 ^ +-DSECP256K1_INCLUDE_DIR=%root%\secp256k1\include ^ +-DSECP256K1_LIBRARY=%root%\secp256k1\bin\x64\Release\v143\static\secp256k1.lib ^ +-DMHD_FOUND=1 ^ +-DMHD_LIBRARY=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static\libmicrohttpd.lib ^ +-DMHD_INCLUDE_DIR=%root%\libmicrohttpd-0.9.77-w32-bin\x86_64\VS2019\Release-static ^ +-DZLIB_FOUND=1 ^ +-DZLIB_INCLUDE_DIR=%root%\zlib ^ +-DZLIB_LIBRARIES=%root%\zlib\contrib\vstudio\vc14\x64\ZlibStatReleaseWithoutAsm\zlibstat.lib ^ +-DOPENSSL_FOUND=1 ^ +-DOPENSSL_INCLUDE_DIR=%root%/openssl-3.1.4/x64/include ^ +-DOPENSSL_CRYPTO_LIBRARY=%root%/openssl-3.1.4/x64/lib/libcrypto_static.lib ^ +-DCMAKE_CXX_FLAGS="/DTD_WINDOWS=1 /EHsc /bigobj" .. +IF errorlevel 1 ( + echo Can't configure TON + exit /b %errorlevel% +) + +cmake --build . --config Release -j %NUMBER_OF_PROCESSORS% --target python_ton +IF errorlevel 1 ( + echo Can't compile TON + exit /b %errorlevel% +) \ No newline at end of file