From 824b3a532132fe02d18ec00b463900a7c9807455 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 14 Jan 2020 11:06:17 +0100 Subject: [PATCH] CI: simplified Win --- .github/scripts/Windows/find_msvc.ps1 | 22 +++++++ .github/scripts/Windows/prepare.ps1 | 33 +++++++++++ .github/scripts/Windows/prepare_msys.sh | 31 ++++++++++ .github/workflows/ccpp.yml | 76 +++---------------------- 4 files changed, 94 insertions(+), 68 deletions(-) create mode 100644 .github/scripts/Windows/find_msvc.ps1 create mode 100644 .github/scripts/Windows/prepare.ps1 create mode 100644 .github/scripts/Windows/prepare_msys.sh diff --git a/.github/scripts/Windows/find_msvc.ps1 b/.github/scripts/Windows/find_msvc.ps1 new file mode 100644 index 000000000..cdac9fdd3 --- /dev/null +++ b/.github/scripts/Windows/find_msvc.ps1 @@ -0,0 +1,22 @@ +Set-PSDebug -Trace 1 + +# Find VS +$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" +$installDir = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath +if (-Not $installDir) { + throw "Vswhere failed" +} +$path = join-path $installDir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt' +$pathPresent = test-path $path +if (-Not $pathPresent) { + throw "MSVS not found" +} +$version = gc -raw $path +if (-Not $version) { + throw "Cannot get MSVS version" +} +$version = $version.Trim() +echo "::add-path::$installDir\VC\Tools\MSVC\$version\bin\HostX64\x64" # cl +echo "::add-path::$installDir\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" +echo "::add-path::$installDir\MSBuild\Current\Bin" + diff --git a/.github/scripts/Windows/prepare.ps1 b/.github/scripts/Windows/prepare.ps1 new file mode 100644 index 000000000..c4ca0f484 --- /dev/null +++ b/.github/scripts/Windows/prepare.ps1 @@ -0,0 +1,33 @@ +Set-PSDebug -Trace 1 + +# Install MSYS2 +choco install --no-progress msys2 --params "/NoUpdate /InstallDir:C:\msys64" +echo "::set-env name=MSYS2_PATH_TYPE::inherit" # MSYS2 inherits PATH from Windows + +# Install CUDA +Invoke-WebRequest https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_win10.exe -OutFile cuda_inst.exe +Start-Process -FilePath "cuda_inst.exe" -ArgumentList "-s nvcc_10.2" -Wait -NoNewWindow +echo "::add-path::C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin" + +# Build AJA +if (${env:sdk_pass}) { + $pair = "sdk:${env:sdk_pass}" + $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) + $basicAuthValue = "Basic $encodedCreds" + $Headers = @{Authorization = $basicAuthValue} + Invoke-WebRequest -Headers $Headers https://frakira.fi.muni.cz/~xpulec/sdks/ntv2sdkwin.zip -OutFile aja.zip + Expand-Archive -LiteralPath 'aja.zip' -DestinationPath 'C:' + mv c:\ntv2sdk* c:\AJA + cd c:\AJA + MSBuild.exe ntv2_vs12.sln -p:PlatformToolset=v142 -p:Configuration=Release -p:Platform=x64 -t:libajantv2 +} + +# Install XIMEA +if (${env:sdk_pass}) { + $pair = "sdk:${env:sdk_pass}" + $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) + $basicAuthValue = "Basic $encodedCreds" + $Headers = @{Authorization = $basicAuthValue} + Invoke-WebRequest -Headers $Headers https://frakira.fi.muni.cz/~xpulec/sdks/ximea.zip -OutFile ximea.zip + Expand-Archive -LiteralPath 'ximea.zip' -DestinationPath 'C:' +} diff --git a/.github/scripts/Windows/prepare_msys.sh b/.github/scripts/Windows/prepare_msys.sh new file mode 100644 index 000000000..bdb4f4da8 --- /dev/null +++ b/.github/scripts/Windows/prepare_msys.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -ex + +mkdir -p /usr/local/lib /usr/local/bin /usr/local/include +cat >> ~/.bash_profile <<'EOF' +export PATH=/mingw64/bin:/usr/local/bin:$PATH +export CPATH=/usr/local/include +export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/mingw64/lib/pkgconfig +export LIBRARY_PATH=/usr/local/lib +export CPATH=$CPATH:/c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v10.2/include +EOF +echo cd `cygpath $GITHUB_WORKSPACE` >> ~/.bash_profile + +. ~/.bash_profile + +# Install MSYS2 packages +pacman -Sy --noconfirm automake autoconf git make pkg-config mingw-w64-x86_64-toolchain mingw-w64-x86_64-cppunit unzip zip + +# Build AJA wrapper +data/scripts/build_aja_lib_win64.sh + +# Install FFMPEG +wget --no-verbose https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-latest-win64-dev.zip && wget --no-verbose https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-latest-win64-shared.zip && unzip ffmpeg-latest-win64-dev.zip && unzip ffmpeg-latest-win64-shared.zip && cp -r ffmpeg-latest-win64-dev/include/* /usr/local/include && cp -r ffmpeg-latest-win64-dev/lib/* /usr/local/lib && cp -r ffmpeg-latest-win64-shared/bin/* /usr/local/bin && rm -rf ffmpeg-latest-* + +# Build GPUJPEG +( cd gpujpeg && nvcc -I. -DGPUJPEG_EXPORTS -o gpujpeg.dll --shared src/gpujpeg_*c src/gpujpeg*cu && cp gpujpeg.lib /usr/local/lib && cp gpujpeg.dll /usr/local/bin && cp -r libgpujpeg /usr/local/include ) + +# Build CineForm +( cd cineform-sdk && cmake -DBUILD_STATIC=false -G Visual\ Studio\ 16\ 2019 -A x64 && MSBuild.exe CineFormSDK.sln -property:Configuration=Release && cp Release/CFHDCodec.dll /usr/local/bin && cp Release/CFHDCodec.lib /usr/local/lib && cp Common/* /usr/local/include && cp libcineformsdk.pc /usr/local/lib/pkgconfig ) + diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a74673f3d..25a8c07d3 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -6,6 +6,7 @@ on: - master - ci paths: + - '.github/scripts/**' - '.github/workflows/ccpp.yml' - '**.c' - '**.cpp' @@ -64,7 +65,7 @@ jobs: runs-on: macos-latest env: sdk_pass: ${{ secrets.sdk_pass }} - + steps: - uses: actions/checkout@v1 with: @@ -99,79 +100,18 @@ jobs: name: run Windows runs-on: windows-latest env: - MSYS2_PATH_TYPE: inherit # MSYS2 inherits PATH from Windows sdk_pass: ${{ secrets.sdk_pass }} steps: - - name: set env - run: | - $vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - $installDir = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath - if (-Not $installDir) { - throw "Vswhere failed" - } - $path = join-path $installDir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt' - $pathPresent = test-path $path - if (-Not $pathPresent) { - throw "MSVS not found" - } - $version = gc -raw $path - if (-Not $version) { - throw "Cannot get MSVS version" - } - $version = $version.Trim() - echo "::add-path::$installDir\VC\Tools\MSVC\$version\bin\HostX64\x64" # cl - echo "::add-path::$installDir\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" - echo "::add-path::$installDir\MSBuild\Current\Bin" - uses: actions/checkout@v1 with: submodules: true - - name: Install MSYS2 - run: choco install --no-progress msys2 --params "/NoUpdate /InstallDir:C:\msys64" - - name: Install CUDA - run: | - Invoke-WebRequest https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_win10.exe -OutFile cuda_inst.exe - Start-Process -FilePath "cuda_inst.exe" -ArgumentList "-s nvcc_10.2" -Wait -NoNewWindow - echo "::add-path::C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin" - - name: MSYS2 setup environment - run: | - C:\msys64\usr\bin\bash -lc 'mkdir -p /usr/local/lib /usr/local/bin /usr/local/include' - C:\msys64\usr\bin\bash -lc 'echo export PATH=/mingw64/bin:/usr/local/bin:\$PATH >> ~/.bash_profile' - C:\msys64\usr\bin\bash -lc 'echo export CPATH=/usr/local/include >> ~/.bash_profile' - C:\msys64\usr\bin\bash -lc 'echo export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/mingw64/lib/pkgconfig >> ~/.bash_profile' - C:\msys64\usr\bin\bash -lc 'echo export LIBRARY_PATH=/usr/local/lib >> ~/.bash_profile' - C:\msys64\usr\bin\bash -lc 'echo cd \`cygpath \$GITHUB_WORKSPACE\` >> ~/.bash_profile' - C:\msys64\usr\bin\bash -lc 'echo export CPATH=\$CPATH:/c/Program\\\ Files/NVIDIA\\\ GPU\\\ Computing\\\ Toolkit/CUDA/v10.2/include >> ~/.bash_profile' - - name: Install MSYS2 packages - run: C:\msys64\usr\bin\bash -lc 'pacman -Sy --noconfirm automake autoconf git make pkg-config mingw-w64-x86_64-toolchain mingw-w64-x86_64-cppunit unzip zip' - - name: Build AJA - run: | - if (!${env:sdk_pass}) { exit 0 } - $pair = "sdk:${env:sdk_pass}" - $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) - $basicAuthValue = "Basic $encodedCreds" - $Headers = @{Authorization = $basicAuthValue} - Invoke-WebRequest -Headers $Headers https://frakira.fi.muni.cz/~xpulec/sdks/ntv2sdkwin.zip -OutFile aja.zip - Expand-Archive -LiteralPath 'aja.zip' -DestinationPath 'C:' - mv c:\ntv2sdk* c:\AJA - cd c:\AJA - MSBuild.exe ntv2_vs12.sln -p:PlatformToolset=v142 -p:Configuration=Release -p:Platform=x64 -t:libajantv2 - C:\msys64\usr\bin\bash -lc "data/scripts/build_aja_lib_win64.sh" - - name: Install FFMPEG - run: C:\msys64\usr\bin\bash -lc 'wget --no-verbose https://ffmpeg.zeranoe.com/builds/win64/dev/ffmpeg-latest-win64-dev.zip && wget --no-verbose https://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-latest-win64-shared.zip && unzip ffmpeg-latest-win64-dev.zip && unzip ffmpeg-latest-win64-shared.zip && cp -r ffmpeg-latest-win64-dev/include/* /usr/local/include && cp -r ffmpeg-latest-win64-dev/lib/* /usr/local/lib && cp -r ffmpeg-latest-win64-shared/bin/* /usr/local/bin && rm -rf ffmpeg-latest-*' - - name: Build GPUJPEG - run: C:\msys64\usr\bin\bash -lc 'cd gpujpeg && nvcc -I. -DGPUJPEG_EXPORTS -o gpujpeg.dll --shared src/gpujpeg_*c src/gpujpeg*cu && cp gpujpeg.lib /usr/local/lib && cp gpujpeg.dll /usr/local/bin && cp -r libgpujpeg /usr/local/include' - - name: Build CineForm - run: C:\msys64\usr\bin\bash -lc "cd cineform-sdk && cmake -DBUILD_STATIC=false -G Visual\ Studio\ 16\ 2019 -A x64 && MSBuild.exe CineFormSDK.sln -property:Configuration=Release && cp Release/CFHDCodec.dll /usr/local/bin && cp Release/CFHDCodec.lib /usr/local/lib && cp Common/* /usr/local/include && cp libcineformsdk.pc /usr/local/lib/pkgconfig" - - name: Install XIMEA - run: | - if (!${env:sdk_pass}) { exit 0 } - $pair = "sdk:${env:sdk_pass}" - $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair)) - $basicAuthValue = "Basic $encodedCreds" - $Headers = @{Authorization = $basicAuthValue} - Invoke-WebRequest -Headers $Headers https://frakira.fi.muni.cz/~xpulec/sdks/ximea.zip -OutFile ximea.zip - Expand-Archive -LiteralPath 'ximea.zip' -DestinationPath 'C:' + - name: Find MSVC + run: .github/scripts/Windows/find_msvc.ps1 + - name: bootsrap + run: .github/scripts/Windows/prepare.ps1 + - name: bootsrap MSYS2 + run: C:\msys64\usr\bin\bash -lc '$GITHUB_WORKSPACE/.github/scripts/Windows/prepare_msys.sh' - name: configure run: C:\msys64\usr\bin\bash -lc "./autogen.sh --enable-aja" - name: make