diff --git a/.ci/scripts/unittest-windows.ps1 b/.ci/scripts/unittest-windows.ps1 new file mode 100644 index 00000000000..9c0e7c073ed --- /dev/null +++ b/.ci/scripts/unittest-windows.ps1 @@ -0,0 +1,15 @@ +Set-PSDebug -Trace 1 +$ErrorActionPreference = 'Stop' +$PSNativeCommandUseErrorActionPreference = $true + +conda create --yes --quiet -n et python=3.12 +conda activate et + +install_executorch.bat +if ($LASTEXITCODE -ne 0) { + Write-Host "Installation was unsuccessful. Exit code: $LASTEXITCODE." + exit $LASTEXITCODE +} + +# Run pytest with coverage +pytest -n auto --cov=./ --cov-report=xml diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index 63f5e6693b7..47681add8ce 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -52,3 +52,12 @@ jobs: # This is needed to get the prebuilt PyTorch wheel from S3 ${CONDA_RUN} --no-capture-output pip install awscli==1.37.21 .ci/scripts/unittest-macos.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}" + + windows: + uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + with: + submodules: 'recursive' + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + script: | + conda init powershell + powershell .ci/scripts/unittest-windows.ps1 diff --git a/backends/xnnpack/CMakeLists.txt b/backends/xnnpack/CMakeLists.txt index 028709fcedc..6c28a3d8c70 100644 --- a/backends/xnnpack/CMakeLists.txt +++ b/backends/xnnpack/CMakeLists.txt @@ -62,7 +62,7 @@ endforeach() if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") set(MV_COMMAND powershell -Command - "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs}" + "Move-Item -Path ${_xnnpack_flatbuffer__outputs} -Destination ${_xnnpack_schema__outputs} -Force" ) else() set(MV_COMMAND mv ${_xnnpack_flatbuffer__outputs} ${_xnnpack_schema__outputs}) diff --git a/install_executorch.py b/install_executorch.py index a6cb89dd587..f64d9539d36 100644 --- a/install_executorch.py +++ b/install_executorch.py @@ -195,11 +195,6 @@ def main(args): return cmake_args = [os.getenv("CMAKE_ARGS", "")] - # Use ClangCL on Windows. - # ClangCL is an alias to Clang that configures it to work in an MSVC-compatible - # mode. Using it on Windows to avoid compiler compatibility issues for MSVC. - if os.name == "nt": - cmake_args.append("-T ClangCL") os.environ["CMAKE_ARGS"] = " ".join(cmake_args) check_and_update_submodules() diff --git a/setup.py b/setup.py index 69f59a2a2d5..7908f97bf34 100644 --- a/setup.py +++ b/setup.py @@ -672,6 +672,10 @@ def run(self): # noqa C901 f"-DCMAKE_BUILD_TYPE={cmake_build_type}", ] + # Use ClangCL on Windows. + if _is_windows(): + cmake_configuration_args += ["-T ClangCL"] + # Allow adding extra cmake args through the environment. Used by some # tests and demos to expand the set of targets included in the pip # package. @@ -795,7 +799,8 @@ def run(self): # noqa C901 dependent_cmake_flags=["EXECUTORCH_BUILD_EXTENSION_TRAINING"], ), BuiltExtension( - src="codegen/tools/selective_build.*", + src_dir="%CMAKE_CACHE_DIR%/codegen/tools/%BUILD_TYPE%/", + src="selective_build.cp*" if _is_windows() else "selective_build.*", modpath="executorch.codegen.tools.selective_build", dependent_cmake_flags=["EXECUTORCH_BUILD_PYBIND"], ),