Skip to content

Commit

Permalink
Merge pull request #42 from drdo/windows-support
Browse files Browse the repository at this point in the history
Initial Windows Support
  • Loading branch information
drdo authored Jul 8, 2024
2 parents 5325803 + 473016e commit 681ee68
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 5 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
build-linux-amd64:
build-linux-x86_64:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +35,7 @@ jobs:
run: cargo install cross
- name: Build
run: cross build --target aarch64-unknown-linux-musl --verbose
build-darwin-amd64:
build-darwin-x86_64:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
Expand All @@ -47,3 +47,19 @@ jobs:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
build-windows-x86_64:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --target=x86_64-pc-windows-msvc --verbose
- name: Run tests
run: cargo test --verbose
build-windows-arm64:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Add aarch64-pc-windows-msvc target
run: rustup target add aarch64-pc-windows-msvc
- name: Build
run: cargo build --target=aarch64-pc-windows-msvc --verbose
63 changes: 63 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,66 @@ jobs:
uses: diamondburned/action-upload-release@v0.0.1
with:
files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-darwin-arm64.bz2
build-windows-x86_64:
needs: set-env
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --release --verbose
- name: Run tests
run: cargo test --verbose
- name: Compress
run: >
Compress-Archive
target/release/${{needs.set-env.outputs.name}}.exe
${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-x86_64-release
path: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip
upload-windows-x86_64:
needs: [set-env, build-windows-x86_64]
runs-on: ubuntu-24.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: windows-x86_64-release
- name: Upload
uses: diamondburned/action-upload-release@v0.0.1
with:
files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip
build-windows-arm64:
needs: set-env
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Add aarch64-pc-windows-msvc target
run: |
rustup target add aarch64-pc-windows-msvc
- name: Build
run: cargo build --release --target=aarch64-pc-windows-msvc --verbose
- name: Compress
run: >
Compress-Archive
target/aarch64-pc-windows-msvc/release/${{needs.set-env.outputs.name}}.exe
${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-arm64-release
path: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip
upload-windows-arm64:
needs: [set-env, build-windows-arm64]
runs-on: ubuntu-24.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: windows-arm64-release
- name: Upload
uses: diamondburned/action-upload-release@v0.0.1
with:
files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ flexi_logger = "0.28"
humansize = "2"
indicatif = "0.17"
log = "0.4"
nix = { version = "0.28", features = ["process"] }
rand = "0.8"
ratatui = { version = "0.26", features = ["unstable-rendered-line-info", "unstable-widget-ref"] }
rusqlite = { version = "0.31", features = ["bundled", "functions", "trace"] }
Expand All @@ -30,9 +29,11 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"
unicode-segmentation = "1"

uuid = { version = "1", features = ["v4"], optional = true }

[target.'cfg(unix)'.dependencies]
nix = { version = "0.28", features = ["process"] }

[lib]
path = "src/lib.rs"

Expand Down
4 changes: 3 additions & 1 deletion src/restic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#[cfg(not(target_os = "windows"))]
use std::os::unix::process::CommandExt;
use std::{
borrow::Cow,
ffi::OsStr,
fmt::{Display, Formatter},
io::{BufRead, BufReader, Lines, Read},
iter::Step,
marker::PhantomData,
os::unix::process::CommandExt,
process::{Child, ChildStdout, Command, ExitStatusError, Stdio},
str::Utf8Error,
};
Expand Down Expand Up @@ -179,6 +180,7 @@ impl Restic {
) -> Result<Child, LaunchError> {
let mut cmd = Command::new("restic");
// Need to detach process from terminal
#[cfg(not(target_os = "windows"))]
unsafe {
cmd.pre_exec(|| {
nix::unistd::setsid()?;
Expand Down

0 comments on commit 681ee68

Please sign in to comment.