|
1 | 1 | //! XML and auxiliary header loading. Default mode uses compile-time-embedded |
2 | 2 | //! bundled copies; `--fetch` downloads from remote Khronos URLs. |
3 | 3 |
|
| 4 | +// In case we built without features=fetch |
| 5 | +#![allow(dead_code, unused)] |
| 6 | + |
4 | 7 | use anyhow::{Context, Result}; |
5 | 8 |
|
6 | 9 | use crate::bundled; |
@@ -36,14 +39,15 @@ pub struct SpecSources { |
36 | 39 | // --------------------------------------------------------------------------- |
37 | 40 |
|
38 | 41 | pub fn load_spec(spec_name: &str, use_fetch: bool) -> Result<SpecSources> { |
| 42 | + #[cfg(feature = "fetch")] |
39 | 43 | if use_fetch { |
40 | | - fetch_spec(spec_name) |
41 | | - } else { |
42 | | - bundled_spec(spec_name) |
| 44 | + return fetch_spec(spec_name); |
43 | 45 | } |
| 46 | + bundled_spec(spec_name) |
44 | 47 | } |
45 | 48 |
|
46 | 49 | pub fn load_auxiliary_header(path: &str, use_fetch: bool) -> Result<String> { |
| 50 | + #[cfg(feature = "fetch")] |
47 | 51 | if use_fetch { |
48 | 52 | if let Some(url) = auxiliary_url(path) { |
49 | 53 | return fetch_text(&url) |
@@ -116,6 +120,7 @@ fn bundled_auxiliary(path: &str) -> Result<&'static str> { |
116 | 120 | // Fetch mode |
117 | 121 | // --------------------------------------------------------------------------- |
118 | 122 |
|
| 123 | +#[cfg(feature = "fetch")] |
119 | 124 | fn fetch_spec(spec_name: &str) -> Result<SpecSources> { |
120 | 125 | let primary_url = match spec_name { |
121 | 126 | "gl" => format!("{}gl.xml", BASE_GL), |
@@ -160,6 +165,7 @@ fn auxiliary_url(path: &str) -> Option<String> { |
160 | 165 | } |
161 | 166 | } |
162 | 167 |
|
| 168 | +#[cfg(feature = "fetch")] |
163 | 169 | fn fetch_text(url: &str) -> Result<String> { |
164 | 170 | let resp = reqwest::blocking::get(url) |
165 | 171 | .with_context(|| format!("GET {}", url))? |
|
0 commit comments