@@ -84,10 +84,22 @@ lint: check fmt clippy
8484# Testing
8585# -------
8686
87+ .PHONY : qir-staticlib
88+ qir-staticlib : # # Build the QIR static library (needed for QIR compilation)
89+ cargo rustc -p pecos-qir --lib --crate-type=staticlib
90+
91+ .PHONY : qir-staticlib-if-needed
92+ qir-staticlib-if-needed : # # Build QIR static library only if it doesn't exist in persistent location
93+ @if [ ! -f ~ /.cargo/pecos-qir/libpecos_qir.a ] && [ ! -f ~ /.cargo/pecos-qir/pecos_qir.lib ]; then \
94+ echo " Building QIR static library..." ; \
95+ $(MAKE ) qir-staticlib; \
96+ fi
97+
8798.PHONY : rstest
88- rstest : # # Run Rust tests
99+ rstest : qir-staticlib-if-needed # # Run Rust tests
89100 cargo test --workspace
90101
102+
91103.PHONY : pytest
92104pytest : # # Run tests on the Python package (not including optional dependencies). ASSUMES: previous build command
93105 uv run pytest ./python/tests/ -m " not optional_dependency"
@@ -139,6 +151,8 @@ clean-unix:
139151 @find python -type d -name " target" -exec rm -rf {} +
140152 @# Clean the root workspace target directory
141153 @cargo clean
154+ @# Clean the persistent QIR library directory
155+ @rm -rf ~ /.cargo/pecos-qir/
142156
143157.PHONY : clean-windows-ps
144158clean-windows-ps :
@@ -157,6 +171,8 @@ clean-windows-ps:
157171 @powershell -Command " Get-ChildItem -Path crates -Recurse -Directory -Filter 'target' | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
158172 @powershell -Command " Get-ChildItem -Path python -Recurse -Directory -Filter 'target' | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
159173 @cargo clean
174+ @# Clean the persistent QIR library directory
175+ @powershell -Command " if (Test-Path '$env :USERPROFILE\.cargo\pecos-qir') { Remove-Item -Recurse -Force $env :USERPROFILE\.cargo\pecos-qir }"
160176
161177.PHONY : clean-windows-cmd
162178clean-windows-cmd :
@@ -175,6 +191,8 @@ clean-windows-cmd:
175191 -@for /f " delims=" %%d in (' dir /s /b /ad crates\target 2^>nul' ) do @rd /s /q " %%d" 2> nul
176192 -@for /f " delims=" %%d in (' dir /s /b /ad python\target 2^>nul' ) do @rd /s /q " %%d" 2> nul
177193 -@cargo clean
194+ -@REM Clean the persistent QIR library directory
195+ -@if exist %USERPROFILE%\. cargo\p ecos-qir rd /s /q %USERPROFILE%\. cargo\p ecos-qir
178196
179197.PHONY : pip-install-uv
180198pip-install-uv : # # Install uv using pip and create a venv. (Recommended to instead follow: https://docs.astral.sh/uv/getting-started/installation/
0 commit comments