diff --git a/.github/workflows/tox_matrix.yml b/.github/workflows/tox_matrix.yml index c0a717ae..04ee5d71 100644 --- a/.github/workflows/tox_matrix.yml +++ b/.github/workflows/tox_matrix.yml @@ -15,19 +15,11 @@ jobs: env: PIP_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}} UV_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}} + UV_CONSTRAINT: requirements-dev.txt strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-2019] + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] - include: - - os: macos-latest - compiler_version: 14 - compiler_libcxx: libc++ - - os: ubuntu-latest - compiler_version: 11.4 - compiler_libcxx: libstdc++11 - - os: windows-2019 - compiler_version: 16 fail-fast: false name: Python ${{ matrix.python-version }} ${{ matrix.os }} build @@ -37,7 +29,7 @@ jobs: with: result-encoding: string script: | - if ('${{matrix.os}}' === 'windows-2019'){ + if ('${{matrix.os}}' === 'windows-latest'){ return 'C:/Users/runneradmin' } if ('${{matrix.os}}' === 'ubuntu-latest'){ @@ -68,24 +60,12 @@ jobs: requirements/requirements-*.txt - name: Install dependencies run: | - pip install -r requirements-dev.txt - - name: Ensure conan settings has current compiler as valid - if: "!contains(matrix.os, 'windows')" - env: - CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" - run: | - conan config init - python ci/docker/linux/shared/ensure_compiler_support_by_conan.py $(conan config home)/settings.yml $(cc -dumpfullversion -dumpversion | grep -oE "^([0-9]+(\.)?)([0-9]+?)") - conan profile update settings.compiler.version=${{matrix.compiler_version}} default - - - name: Remove Strawberry Perl (Windows only) - if: contains(matrix.os, 'windows') - run: Remove-Item –path C:\\Strawberry –recurse –force + pip install uv - name: Cache Conan id: cache-conan uses: actions/cache@v3 with: - path: "${{steps.conan-path-script.outputs.result}}/.conan" + path: "${{steps.conan-path-script.outputs.result}}/.conan2" key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.py') }} - name: Prebuild Conan packages (Windows) @@ -95,39 +75,37 @@ jobs: env: CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - conan profile new default --detect - conan install . --build missing --no-import + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 && uvx --with cmake conan profile detect --exist-ok + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 && uvx --with cmake conan install conanfile.py --build missing -of %TEMP%\ciwheelbuilder -pr:b=default - name: Prebuild Conan packages env: CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" if: "!contains(matrix.os, 'windows') && steps.cache-conan.outputs.cache-hit != 'true'" run: | - conan install . --build missing --no-import + uvx --with cmake conan profile detect --exist-ok + uvx --with cmake conan install conanfile.py --build missing -of /tmp/ciwheelbuilder -pr:b=default + - name: Run Tox (Windows) if: contains(matrix.os, 'windows') shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - tox run + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 && uvx --with tox-uv tox run env: TOX_ENV: "${{ steps.tox-env.outputs.result }}" CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" - name: Run Tox if: "!contains(matrix.os, 'windows')" - run: cc --version && cc -dumpfullversion -dumpversion && tox run -vvv + run: cc --version && cc -dumpfullversion -dumpversion && uvx --with tox-uv tox run -vvv env: TOX_ENV: "${{ steps.tox-env.outputs.result }}" CONAN_USER_HOME: "${{steps.conan-path-script.outputs.result}}" - CONAN_COMPILER_VERSION: ${{ matrix.compiler_version }} - CONAN_COMPILER_LIBCXX: ${{ matrix.compiler_libcxx }} # CIBW_SOME_OPTION: value - uses: actions/upload-artifact@v4 if: ${{ inputs.save }} with: - name: uiucprescon.ocr-wheels + name: uiucprescon.imagevalidate-wheels path: ./wheelhouse/*.whl diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1b690ac8..ce0d8e9c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -9,18 +9,11 @@ jobs: env: PIP_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}} UV_EXTRA_INDEX_URL: ${{vars.PIP_EXTRA_INDEX_URL}} + UV_CONSTRAINT: "requirements/requirements-cibuildwheel.txt" strategy: matrix: os: [ - ubuntu-20.04, - windows-2019, macos-13] - include: - - os: macos-13 - compiler_version: 13 - - os: ubuntu-20.04 - compiler_version: 10.2 - - os: windows-2019 - compiler_version: 16 + ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 @@ -28,19 +21,15 @@ jobs: # Used to host cibuildwheel - uses: actions/setup-python@v3 - name: Install cibuildwheel - run: python -m pip install -r requirements/requirements-cibuildwheel.txt + run: python -m pip install uv - name: Build wheels if: contains(matrix.os, 'windows') shell: cmd run: | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - python -m cibuildwheel --output-dir wheelhouse + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=amd64 && uvx cibuildwheel --output-dir wheelhouse env: CONAN_COMPILER_VERSION: ${{ matrix.compiler_version }} - name: Build wheels if: "!contains(matrix.os, 'windows')" - run: python -m cibuildwheel --output-dir wheelhouse - env: - CONAN_COMPILER_VERSION: ${{ matrix.compiler_version }} - # CIBW_SOME_OPTION: value + run: uvx cibuildwheel --output-dir wheelhouse diff --git a/Jenkinsfile b/Jenkinsfile index 0f5515ad..171a4983 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -851,13 +851,15 @@ pipeline { node('docker && linux'){ try{ checkout scm - docker.image('python').inside{ - sh(script: 'python3 -m venv venv && venv/bin/pip install --disable-pip-version-check uv') - envs = sh( - label: 'Get tox environments', - script: './venv/bin/uvx --quiet --constraint requirements-dev.txt --with tox-uv tox list -d --no-desc', - returnStdout: true, - ).trim().split('\n') + timeout(10){ + docker.image('python').inside{ + sh(script: 'python3 -m venv venv && venv/bin/pip install --disable-pip-version-check uv') + envs = sh( + label: 'Get tox environments', + script: './venv/bin/uvx --quiet --constraint requirements-dev.txt --with tox-uv tox list -d --no-desc', + returnStdout: true, + ).trim().split('\n') + } } } finally{ sh "${tool(name: 'Default', type: 'git')} clean -dfx" @@ -873,24 +875,28 @@ pipeline { node('docker && linux'){ def image checkout scm - lock("${env.JOB_NAME} - ${env.NODE_NAME}"){ - image = docker.build(UUID.randomUUID().toString(), '-f ci/docker/linux/tox/Dockerfile --build-arg PIP_EXTRA_INDEX_URL --build-arg PIP_INDEX_URL --build-arg UV_EXTRA_INDEX_URL --build-arg UV_INDEX_URL --build-arg PIP_DOWNLOAD_CACHE=/.cache/pip --build-arg UV_CACHE_DIR=/.cache/uv --build-arg CONAN_CENTER_PROXY_V1_URL .') + timeout(60){ + lock("${env.JOB_NAME} - ${env.NODE_NAME}"){ + image = docker.build(UUID.randomUUID().toString(), '-f ci/docker/linux/tox/Dockerfile --build-arg PIP_EXTRA_INDEX_URL --build-arg PIP_INDEX_URL --build-arg UV_EXTRA_INDEX_URL --build-arg UV_INDEX_URL --build-arg PIP_DOWNLOAD_CACHE=/.cache/pip --build-arg UV_CACHE_DIR=/.cache/uv --build-arg CONAN_CENTER_PROXY_V1_URL .') + } } try{ - image.inside{ - try{ - sh( label: 'Running Tox', - script: """python3 -m venv /tmp/venv && /tmp/venv/bin/pip install --disable-pip-version-check uv - . /tmp/venv/bin/activate - uvx -p ${version} --constraint requirements-dev.txt --with tox-uv tox run -e ${toxEnv} -vvv - """ - ) - } catch(e) { - sh(script: '''. ./venv/bin/activate - uv python list - ''' + timeout(30){ + image.inside{ + try{ + sh( label: 'Running Tox', + script: """python3 -m venv /tmp/venv && /tmp/venv/bin/pip install --disable-pip-version-check uv + . /tmp/venv/bin/activate + uvx -p ${version} --constraint requirements-dev.txt --with tox-uv tox run -e ${toxEnv} -vvv + """ ) - throw e + } catch(e) { + sh(script: '''. ./venv/bin/activate + uv python list + ''' + ) + throw e + } } } } finally { @@ -923,13 +929,15 @@ pipeline { node('docker && windows'){ try{ checkout scm - docker.image(env.DEFAULT_PYTHON_DOCKER_IMAGE ? env.DEFAULT_PYTHON_DOCKER_IMAGE: 'python').inside("--mount source=${SHARED_PIP_CACHE_VOLUME_NAME},target=${env:PIP_CACHE_DIR} --mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){ - bat(script: 'python -m venv venv && venv\\Scripts\\pip install --disable-pip-version-check uv') - envs = bat( - label: 'Get tox environments', - script: '@.\\venv\\Scripts\\uvx --quiet --constraint requirements-dev.txt --with tox-uv tox list -d --no-desc', - returnStdout: true, - ).trim().split('\r\n') + timeout(10){ + docker.image(env.DEFAULT_PYTHON_DOCKER_IMAGE ? env.DEFAULT_PYTHON_DOCKER_IMAGE: 'python').inside("--mount source=${SHARED_PIP_CACHE_VOLUME_NAME},target=${env:PIP_CACHE_DIR} --mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){ + bat(script: 'python -m venv venv && venv\\Scripts\\pip install --disable-pip-version-check uv') + envs = bat( + label: 'Get tox environments', + script: '@.\\venv\\Scripts\\uvx --quiet --constraint requirements-dev.txt --with tox-uv tox list -d --no-desc', + returnStdout: true, + ).trim().split('\r\n') + } } } finally{ bat "${tool(name: 'Default', type: 'git')} clean -dfx" @@ -945,18 +953,22 @@ pipeline { node('docker && windows'){ def image checkout scm - lock("${env.JOB_NAME} - ${env.NODE_NAME}"){ - image = docker.build(UUID.randomUUID().toString(), '-f scripts/resources/windows/Dockerfile --build-arg PIP_EXTRA_INDEX_URL --build-arg PIP_INDEX_URL --build-arg CHOCOLATEY_SOURCE --build-arg chocolateyVersion --build-arg PIP_DOWNLOAD_CACHE=c:/users/ContainerUser/appdata/local/pip --build-arg UV_INDEX_URL --build-arg UV_EXTRA_INDEX_URL --build-arg UV_CACHE_DIR=c:/users/ContainerUser/appdata/local/uv' + (env.DEFAULT_DOCKER_DOTNET_SDK_BASE_IMAGE ? " --build-arg CONAN_CENTER_PROXY_V1_URL --build-arg FROM_IMAGE=${env.DEFAULT_DOCKER_DOTNET_SDK_BASE_IMAGE} ": ' ') + '.') + timeout(60){ + lock("${env.JOB_NAME} - ${env.NODE_NAME}"){ + image = docker.build(UUID.randomUUID().toString(), '-f scripts/resources/windows/Dockerfile --build-arg PIP_EXTRA_INDEX_URL --build-arg PIP_INDEX_URL --build-arg CHOCOLATEY_SOURCE --build-arg chocolateyVersion --build-arg PIP_DOWNLOAD_CACHE=c:/users/ContainerUser/appdata/local/pip --build-arg UV_INDEX_URL --build-arg UV_EXTRA_INDEX_URL --build-arg UV_CACHE_DIR=c:/users/ContainerUser/appdata/local/uv' + (env.DEFAULT_DOCKER_DOTNET_SDK_BASE_IMAGE ? " --build-arg CONAN_CENTER_PROXY_V1_URL --build-arg FROM_IMAGE=${env.DEFAULT_DOCKER_DOTNET_SDK_BASE_IMAGE} ": ' ') + '.') + } } try{ checkout scm try{ - image.inside("--mount source=${SHARED_PIP_CACHE_VOLUME_NAME},target=${env:PIP_CACHE_DIR} --mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){ - powershell(label: 'Running Tox', - script: """uv python install cpython-${version} - uvx -p ${version} --constraint requirements-dev.txt --with tox-uv tox run -e ${toxEnv} - """ - ) + timeout(30){ + image.inside("--mount source=${SHARED_PIP_CACHE_VOLUME_NAME},target=${env:PIP_CACHE_DIR} --mount source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){ + powershell(label: 'Running Tox', + script: """uv python install cpython-${version} + uvx -p ${version} --constraint requirements-dev.txt --with tox-uv tox run -e ${toxEnv} + """ + ) + } } } finally{ bat "${tool(name: 'Default', type: 'git')} clean -dfx" diff --git a/pyproject.toml b/pyproject.toml index cf3299d7..3692ce65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,54 +82,47 @@ skip = [ ] build-verbosity = 1 environment-pass = ["CONAN_COMPILER_LIBCXX", "CONAN_COMPILER_VERSION", "CONAN_USER_HOME", "PIP_EXTRA_INDEX_URL", "UV_EXTRA_INDEX_URL", "UV_INDEX_STRATEGY"] - +environment = { UV_CONSTRAINT = "requirements-dev.txt"} [tool.cibuildwheel.windows] before-all = [ - "pip install wheel", - "pip install -r requirements-dev.txt uv", - "conan profile new default --detect --force", - "conan profile update settings.compiler.version=%CONAN_COMPILER_VERSION% default", - "conan install ./ --build missing", + "python -m venv %TEMP\\cibuildwheelvenv", + "%TEMP\\cibuildwheelvenv\\Scripts\\pip install --disable-pip-version-check uv", + "%TEMP\\cibuildwheelvenv\\Scripts\\uvx --with cmake conan profile detect --exist-ok", + "%TEMP\\cibuildwheelvenv\\Scripts\\uvx --with cmake conan install conanfile.py --build missing -of=%TEMP\\conandelme", ] [tool.cibuildwheel.windows.environment] CONAN_USER_HOME="$TEMP/conan" [tool.cibuildwheel.macos] before-all = [ - "pip3 install -r requirements-dev.txt uv", - "conan profile new $ENVTMPDIR/.conan/profiles/default --detect --force", - "if [ -z \"$CONAN_COMPILER_VERSION\" ]; then : ; else conan profile update settings.compiler.version=$CONAN_COMPILER_VERSION default; fi", - "conan install ./ --build missing --install-folder=$CONAN_BUILD_INFO_DIR" + "python3 -m venv /tmp/cibuildwheelvenv", + "/tmp/cibuildwheelvenv/bin/pip install --disable-pip-version-check uv", + "/tmp/cibuildwheelvenv/bin/uvx --with 'cmake<4.0' conan profile detect --exist-ok", + "trap 'rm -rf /tmp/conandelme' EXIT && /tmp/cibuildwheelvenv/bin/uvx --with 'cmake<4.0' conan install conanfile.py --build missing -of=/tmp/conandelme" ] environment-pass = ["CONAN_COMPILER_VERSION", "CONAN_USER_HOME"] repair-wheel-command = [ - "delocate-listdeps {wheel}", - "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}", + "/tmp/cibuildwheelvenv/bin/uvx --from delocate delocate-listdeps {wheel}", + "/tmp/cibuildwheelvenv/bin/uvx --from delocate delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}", ] [tool.cibuildwheel.macos.environment] ENVTMPDIR="/tmp/conan" CONAN_USER_HOME="/tmp/conan" -CONAN_DEFAULT_PROFILE_PATH="/tmp/conan/.conan/profiles/default" -CONAN_BUILD_INFO_DIR="/tmp/conan/build/" [tool.cibuildwheel.linux] +manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64" +manylinux-aarch64-image = "quay.io/pypa/manylinux_2_28_aarch64" repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}" before-all = [ "cc --version", "cc -dumpfullversion -dumpversion", - "uvx --index-strategy=unsafe-first-match --with $(grep ^conan requirements-dev.txt) conan profile new /tmp/conan/.conan/profiles/default --detect", - "if [ -z \"$CONAN_COMPILER_LIBCXX\" ]; then : ; else uvx --index-strategy=unsafe-first-match --with $(grep ^conan requirements-dev.txt) conan profile update settings.compiler.libcxx=$CONAN_COMPILER_LIBCXX default; fi", - "if [ -z \"$CONAN_COMPILER_VERSION\" ]; then : ; else uvx --index-strategy=unsafe-first-match --with $(grep ^conan requirements-dev.txt) conan profile update settings.compiler.version=$CONAN_COMPILER_VERSION default; fi", - "uvx --index-strategy=unsafe-first-match --with $(grep ^conan requirements-dev.txt) conan profile show default", - "uvx --index-strategy=unsafe-first-match --with $(grep ^conan requirements-dev.txt) conan install ./ --build missing -pr:b=default", - + "uvx --with cmake conan profile detect --exist-ok", + "trap 'rm -rf /tmp/conandelme' EXIT && uvx --with 'cmake<4.0' conan install conanfile.py --build missing -pr:b=default -of /tmp/conandelme", ] [tool.cibuildwheel.linux.environment] CONAN_USER_HOME="/tmp/conan" -CONAN_DEFAULT_PROFILE_PATH="/tmp/conan/.conan/profiles/default" -CONAN_BUILD_INFO_DIR="/tmp/conan/build/" PYTHONFAULTHANDLER="True" [tool.uv] -cache-keys = [{ file = "pyproject.toml" }, { file = "requirements-dev.txt" }, { file = "setup.py" }, { dir = "/Users/hborcher/CLionProjects/henryborchers/uiucprescon_build" }] \ No newline at end of file +cache-keys = [{ file = "pyproject.toml" }, { file = "requirements-dev.txt" }, { file = "setup.py" }] \ No newline at end of file diff --git a/scripts/resources/windows/Dockerfile b/scripts/resources/windows/Dockerfile index 191602f3..496f3aa0 100644 --- a/scripts/resources/windows/Dockerfile +++ b/scripts/resources/windows/Dockerfile @@ -19,7 +19,7 @@ ARG chocolateyVersion FROM ${FROM_IMAGE} AS certsgen RUN certutil -generateSSTFromWU roots.sst -FROM ${FROM_IMAGE} AS CHOCOLATEY_BASE +FROM ${FROM_IMAGE} AS chocolatey_base SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] @@ -37,9 +37,12 @@ ARG ChocolateyEnvironmentDebug=false ARG chocolateyVersion COPY scripts/resources/windows/chocolatey/install.ps1 c:/choco/install.ps1 COPY scripts/resources/windows/chocolatey/get_latest_chocolatey_url.ps1 c:/choco/get_latest_chocolatey_url.ps1 +COPY scripts/resources/windows/chocolatey/packages.config choco/packages.config +COPY scripts/resources/windows/chocolatey/verifyenv.ps1 c:/verifyenv.ps1 RUN Set-ExecutionPolicy Bypass -Scope Process -Force; ` $chocolateyDownloadUrl = c:/choco/get_latest_chocolatey_url.ps1 -packageRepo $env:CHOCOLATEY_SOURCE; ` c:/choco/install.ps1 -ChocolateyDownloadUrl $chocolateyDownloadUrl;` + . $profile;` if( -not ([string]::IsNullOrEmpty($Env:CHOCOLATEY_SOURCE ))) ` { ` Write-Host "Adding $env:CHOCOLATEY_SOURCE to chocolatey sources" ; ` @@ -47,25 +50,19 @@ RUN Set-ExecutionPolicy Bypass -Scope Process -Force; ` }; ` Write-Host "Disabling Showing Download Progress" ; ` choco feature disable -n=showDownloadProgress ; ` - choco cache remove --confirm - - -COPY scripts/resources/windows/chocolatey/packages.config choco/packages.config -RUN C:\ProgramData\chocolatey\bin\choco.exe sources ; ` - C:\ProgramData\chocolatey\bin\choco.exe install -y --stoponfirstfailure --no-progress --verbose choco/packages.config ;` + choco sources ; ` + choco install -y --stoponfirstfailure --no-progress --verbose choco/packages.config ;` refreshenv ; ` choco cache remove --confirm;` - if (!(Test-Path 'C:\Program Files\nasm\nasm.exe')) ` - { ` - throw 'nasm.exe not found' ; ` - }; ` - Write-Host "Finished install packages with Chocolatey" + Write-Host "Finished install packages with Chocolatey"; ` + Write-Host "Verifying installed packages" ;` + c:/verifyenv.ps1 RUN New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" ` -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force -FROM CHOCOLATEY_BASE AS CONAN_BUILDER +FROM chocolatey_base AS CONAN_BUILDER ARG CONAN_HOME ARG PIP_INDEX_URL @@ -96,7 +93,7 @@ RUN uvx --with cmake conan profile detect --exist-ok ; ` } # ============================================================================== -FROM CHOCOLATEY_BASE +FROM chocolatey_base COPY --from=certsgen c:/roots.sst roots.sst RUN certutil -addstore -f root roots.sst ; ` del roots.sst diff --git a/scripts/resources/windows/chocolatey/verifyenv.ps1 b/scripts/resources/windows/chocolatey/verifyenv.ps1 index ae91854d..56384ee9 100644 --- a/scripts/resources/windows/chocolatey/verifyenv.ps1 +++ b/scripts/resources/windows/chocolatey/verifyenv.ps1 @@ -1,4 +1,2 @@ -Get-Command git -Get-Command wget cmd /S /C '"C:\Program Files\NASM\nasm" --version' if ($LASTEXITCODE -eq 1) { throw "Exit code is 1" } \ No newline at end of file diff --git a/scripts/resources/windows/msvc/install_msvc.ps1 b/scripts/resources/windows/msvc/install_msvc.ps1 index 7404692c..c224217c 100644 --- a/scripts/resources/windows/msvc/install_msvc.ps1 +++ b/scripts/resources/windows/msvc/install_msvc.ps1 @@ -10,6 +10,109 @@ $VSBUILDTOOLS_URLS = @{ '2019' = 'https://aka.ms/vs/16/release/vs_buildtools.exe' } +function CreateHelloWorldSource { + param( + [Parameter(Mandatory=$true)][string]$Location + ) + + $local:content = @" + #include + using namespace std; + int main(){ + cout << "Hello world\n"; + return 0; + } +"@ + Set-Content -Path $Location -Value $local:content +} + +function TestCompileWithCmd { + param( + [Parameter(Mandatory=$true)][string]$SampleFile + ) + $local:command_description = 'Testing compile hello world in cmd' + + $local:tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $((New-Guid).ToString("N")) + New-Item -ItemType Directory -Path $local:tempDir | Out-Null + + $local:buildDir = Join-Path $local:tempDir "build" + New-Item -ItemType Directory -Path $local:buildDir | Out-Null + + $local:binDir = Join-Path $local:tempDir "bin" + New-Item -ItemType Directory -Path $local:binDir | Out-Null + + Write-Host "Testing compile hello world in cmd" + + $local:compileArgs = @( + '/S', '/C', + 'cl', + '/EHsc', + "/Fo${local:buildDir}", + "/Fe${local:binDir}\helloworld_cmd", + $SampleFile + ) + $local:testClProcess = Start-Process -FilePath cmd -ArgumentList $local:compileArgs -NoNewWindow -PassThru + Wait-Process -InputObject $local:testClProcess + if ($local:testClProcess.ExitCode -ne 0) + { + throw "${$local:command_description} - Failed" + } + Write-Host "${$local:command_description} - Success" + + Write-Host "Test running hello world" + $local:testRun = Start-Process -FilePath "${local:binDir}\helloworld_cmd.exe" -NoNewWindow -PassThru -RedirectStandardOutput "NUL" -Wait + if ($local:testRun.ExitCode -ne 0) + { + throw "Test running hello world - Failed" + } + Write-Host "Test running hello world - Success" + Remove-Item -Path $local:tempDir -Recurse +} + +function TestCompileWithPowershell { + param( + [Parameter(Mandatory=$true)][string]$SampleFile + ) + $local:command_description = 'Testing compile hello world in powershell' + + $local:tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $((New-Guid).ToString("N")) + New-Item -ItemType Directory -Path $local:tempDir | Out-Null + + $local:buildDir = Join-Path $local:tempDir "build" + New-Item -ItemType Directory -Path $local:buildDir | Out-Null + + $local:binDir = Join-Path $local:tempDir "bin" + New-Item -ItemType Directory -Path $local:binDir | Out-Null + + Write-Host "Testing compile hello world in cmd" + + $local:compileArgs = @( + '-Command', + 'cl', + '/EHsc', + "/Fo${local:buildDir}", + "/Fe${local:binDir}\helloworld_ps", + $SampleFile + ) + $local:testClProcess = Start-Process -FilePath powershell -ArgumentList $local:compileArgs -NoNewWindow -PassThru + Wait-Process -InputObject $local:testClProcess + if ($local:testClProcess.ExitCode -ne 0) + { + throw "${local:command_description} - Failed" + } + Write-Host "${local:command_description} - Success" + + Write-Host "Test running hello world" + $local:testRun = Start-Process -FilePath "${local:binDir}\helloworld_ps.exe" -NoNewWindow -PassThru -RedirectStandardOutput "NUL" -Wait + if ($local:testRun.ExitCode -ne 0) + { + throw "Test running hello world - Failed" + } + Write-Host "Test running hello world - Success" + Remove-Item -Path $local:tempDir -Recurse +} + + function TestInstalledProperty { param ([Parameter(Mandatory=$true)][String]$InstallPath) @@ -219,13 +322,22 @@ function AddStartupScripts{ # ========== Cmd startup ========== Write-Host "Setting up compiler environment to run every time a command is run from CMD" AddVsStudioToCMD -VSInstallPath $VSInstallPath -DevCmdArguments $DevCmdArguments + + $newDirPath = Join-Path $([System.IO.Path]::GetTempPath()) $((New-Guid).ToString("N")) + $sourceFile = Join-Path $newDirPath "helloworld.cpp" + New-Item -ItemType Directory -Path $newDirPath | Out-Null + CreateHelloWorldSource -Location $sourceFile + TestCompileWithCmd -SampleFile $sourceFile Write-Host "Setting up compiler environment to run every time a command is run from CMD - Done" # ========== Powershell Profile ========== Write-Host "Adding setup Visual Studio development environment scripts to Powershell Profile" AddVsStudioToPowershell -VSInstallPath $VSInstallPath -DevCmdArguments $DevPowershellArguments + TestCompileWithPowershell -SampleFile $sourceFile Write-Host "Adding setup Visual Studio development environment scripts to Powershell Profile - Done" + Remove-Item -Path $local:newDirPath -Recurse + } # ========== Main ========== diff --git a/scripts/resources/windows/msvc/visual_studio_config.json b/scripts/resources/windows/msvc/visual_studio_config.json index ef87d436..a9ecb10c 100644 --- a/scripts/resources/windows/msvc/visual_studio_config.json +++ b/scripts/resources/windows/msvc/visual_studio_config.json @@ -2,7 +2,7 @@ "version": "1.0", "components": [ "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", - "Microsoft.VisualStudio.Component.Windows10SDK.18362" + "Microsoft.VisualStudio.Component.Windows10SDK.19041" ], "extensions": [] } \ No newline at end of file