Skip to content

Commit

Permalink
Add conditional compilation for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0246 committed Nov 2, 2023
1 parent 0721de4 commit 20e9de5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,41 @@ jobs:
# - name: Ninja Install
# run: pip install ninja
- uses: actions/checkout@v3
- name: Set up environment
run: |
New-Item '.cargo' -ItemType 'directory'
'build.rustflags = [''--cfg'', ''CI'']' | Out-File .cargo/config.toml -Encoding 'utf8'
- name: Build tests
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose
- name: Build examples
run: |
cd examples
cargo build --bins --verbose
run: cargo build --bins --verbose
linux_stable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
run: |
mkdir .cargo
echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml
- name: Build tests
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose
- name: Build examples
run: |
cd examples
cargo build --bins --verbose
run: cargo build --bins --verbose
macos_stable:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
run: |
mkdir .cargo
echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml
- name: Build tests
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose
- name: Build examples
run: |
cd examples
cargo build --bins --verbose
run: cargo build --bins --verbose
12 changes: 12 additions & 0 deletions vulkano/src/swapchain/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ pub struct Surface {
impl Surface {
/// Returns the instance extensions required to create a surface from a window of the given
/// event loop.
#[cfg_attr(CI, allow(unreachable_code, unused))]
pub fn required_extensions(
event_loop: &impl HasDisplayHandle,
) -> Result<InstanceExtensions, HandleError> {
#[cfg(CI)]
return Ok(InstanceExtensions {
khr_surface: true,
ext_headless_surface: true,
..InstanceExtensions::empty()
});

let mut extensions = InstanceExtensions {
khr_surface: true,
..InstanceExtensions::empty()
Expand Down Expand Up @@ -100,10 +108,14 @@ impl Surface {
/// # Safety
///
/// - The given `window` must outlive the created surface.
#[cfg_attr(CI, allow(unreachable_code, unused))]
pub unsafe fn from_window_ref(
instance: Arc<Instance>,
window: &(impl HasWindowHandle + HasDisplayHandle),
) -> Result<Arc<Self>, FromWindowError> {
#[cfg(CI)]
return Self::headless(instance, None).map_err(FromWindowError::CreateSurface);

let window_handle = window
.window_handle()
.map_err(FromWindowError::RetrieveHandle)?;
Expand Down

0 comments on commit 20e9de5

Please sign in to comment.