Skip to content
Myr

printer: make compilation on non-unix, non-windows platforms work

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Some of the new hyperlink work caused ripgrep to stop compiling on non-{Unix,Windows} platforms. The most popular of which is WASI. This commit makes non-{Unix,Windows} compile again. And we add a very basic WASI test in CI to catch regressions. More work is needed to make tests on non-{Unix,Windows} platforms work. And of course, this commit specifically takes the path of disabling hyperlink support for non-{Unix,Windows} platforms.

authored by Nicolas Holzschuch · committed by GitHub · parent 02b47b7 · Browse files · 3 files+24 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+24 added−2 removed

  • other:+24 added−2 removed

3 files+24 added−2 removed

modified:.github/workflows/ci.yml+15 added
187 unmodified lines
188 - name: Print available short flags189 shell: bash190 run: ${{ env.CARGO }} test --bin rg ${{ env.TARGET_FLAGS }} flags::defs::tests::available_shorts -- --nocapture191192 # Setup and compile on the wasm32-wasi target193 wasm:194 runs-on: ubuntu-latest195 steps:196 - name: Checkout repository197 uses: actions/checkout@v4198 - name: Install Rust199 uses: dtolnay/rust-toolchain@master200 with:201 toolchain: stable202 - name: Add wasm32-wasi target203 run: rustup target add wasm32-wasi204 - name: Basic build205 run: cargo build --verbose206207 rustfmt:208 runs-on: ubuntu-latest209 steps:210 - name: Checkout repository
22 unmodified lines
modified:crates/cli/src/hostname.rs+2 added-2 removed
23 unmodified lines
24 gethostname()25 }26 #[cfg(not(any(windows, unix)))]27 {28 io::Error::new(28 Err(io::Error::new(29 io::ErrorKind::Other,30 "hostname could not be found on unsupported platform",31 )31 ))32 }33}3435#[cfg(unix)]
50 unmodified lines
modified:crates/printer/src/hyperlink.rs+7 added
809 unmodified lines
810 let with_slash = format!("/{string}");811 Some(HyperlinkPath::encode(with_slash.as_bytes()))812 }813814 /// For other platforms (not windows, not unix), return None and log a debug message.815 #[cfg(not(any(windows, unix)))]816 pub(crate) fn from_path(original_path: &Path) -> Option<HyperlinkPath> {817 log::debug!("hyperlinks are not supported on this platform");818 None819 }820821 /// Percent-encodes a path.822 ///823 /// The alphanumeric ASCII characters and "-", ".", "_", "~" are unreserved824 /// as per section 2.3 of RFC 3986 (Uniform Resource Identifier (URI):
185 unmodified lines