Skip to content

Commit e16474f

Browse files
committed
Add conditional compilation for CI
1 parent 0721de4 commit e16474f

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

.github/workflows/rust.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,41 @@ jobs:
1919
# - name: Ninja Install
2020
# run: pip install ninja
2121
- uses: actions/checkout@v3
22+
- name: Setup environment
23+
run: |
24+
New-Item '.cargo' -ItemType 'directory'
25+
'build.rustflags = [''--cfg'', ''CI'']' | Out-File .cargo/config.toml -Encoding 'utf8'
2226
- name: Build tests
2327
run: cargo build --tests --verbose
2428
- name: Run tests
2529
run: cargo test --verbose
2630
- name: Build examples
27-
run: |
28-
cd examples
29-
cargo build --bins --verbose
31+
run: cargo build --bins --verbose
3032
linux_stable:
3133
runs-on: ubuntu-latest
3234
steps:
3335
- uses: actions/checkout@v3
36+
- name: Setup environment
37+
run: |
38+
mkdir .cargo
39+
echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml
3440
- name: Build tests
3541
run: cargo build --tests --verbose
3642
- name: Run tests
3743
run: cargo test --verbose
3844
- name: Build examples
39-
run: |
40-
cd examples
41-
cargo build --bins --verbose
45+
run: cargo build --bins --verbose
4246
macos_stable:
4347
runs-on: macos-latest
4448
steps:
4549
- uses: actions/checkout@v3
50+
- name: Setup environment
51+
run: |
52+
mkdir .cargo
53+
echo 'build.rustflags = ["--cfg", "CI"]' > .cargo/config.toml
4654
- name: Build tests
4755
run: cargo build --tests --verbose
4856
- name: Run tests
4957
run: cargo test --verbose
5058
- name: Build examples
51-
run: |
52-
cd examples
53-
cargo build --bins --verbose
59+
run: cargo build --bins --verbose

vulkano/src/swapchain/surface.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ pub struct Surface {
6161
impl Surface {
6262
/// Returns the instance extensions required to create a surface from a window of the given
6363
/// event loop.
64+
#[cfg_attr(CI, allow(unreachable_code, unused))]
6465
pub fn required_extensions(
6566
event_loop: &impl HasDisplayHandle,
6667
) -> Result<InstanceExtensions, HandleError> {
68+
#[cfg(CI)]
69+
return Ok(InstanceExtensions {
70+
khr_surface: true,
71+
ext_headless_surface: true,
72+
..InstanceExtensions::empty()
73+
});
74+
6775
let mut extensions = InstanceExtensions {
6876
khr_surface: true,
6977
..InstanceExtensions::empty()
@@ -100,10 +108,14 @@ impl Surface {
100108
/// # Safety
101109
///
102110
/// - The given `window` must outlive the created surface.
111+
#[cfg_attr(CI, allow(unreachable_code, unused))]
103112
pub unsafe fn from_window_ref(
104113
instance: Arc<Instance>,
105114
window: &(impl HasWindowHandle + HasDisplayHandle),
106115
) -> Result<Arc<Self>, FromWindowError> {
116+
#[cfg(CI)]
117+
return Self::headless(instance, None).map_err(FromWindowError::CreateSurface);
118+
107119
let window_handle = window
108120
.window_handle()
109121
.map_err(FromWindowError::RetrieveHandle)?;

0 commit comments

Comments
 (0)