Skip to content

Commit d0bfedc

Browse files
committed
Windows support
1 parent 7e076cd commit d0bfedc

20 files changed

Lines changed: 933 additions & 1019 deletions

File tree

.github/workflows/build.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,32 @@ jobs:
3333
target: x86_64-unknown-linux-gnu
3434
artifact-name: darn-linux-x86_64
3535
cargo-flags: ""
36+
binary-ext: ""
3637
- os: ubuntu-latest
3738
target: x86_64-unknown-linux-musl
3839
artifact-name: darn-linux-x86_64-musl
3940
cargo-flags: "--no-default-features --features rustls"
41+
binary-ext: ""
4042
- os: ubuntu-24.04-arm
4143
target: aarch64-unknown-linux-gnu
4244
artifact-name: darn-linux-aarch64
4345
cargo-flags: ""
46+
binary-ext: ""
4447
- os: ubuntu-24.04-arm
4548
target: aarch64-unknown-linux-musl
4649
artifact-name: darn-linux-aarch64-musl
4750
cargo-flags: "--no-default-features --features rustls"
51+
binary-ext: ""
4852
- os: macos-latest
4953
target: aarch64-apple-darwin
5054
artifact-name: darn-macos-aarch64
5155
cargo-flags: ""
56+
binary-ext: ""
57+
- os: windows-latest
58+
target: x86_64-pc-windows-msvc
59+
artifact-name: darn-windows-x86_64
60+
cargo-flags: ""
61+
binary-ext: ".exe"
5262

5363
runs-on: ${{ matrix.os }}
5464

@@ -79,13 +89,13 @@ jobs:
7989
shell: bash
8090
run: |
8191
mkdir -p dist
82-
cp target/${{ matrix.target }}/release/darn dist/${{ matrix.artifact-name }}-${{ env.VERSION }}
92+
cp target/${{ matrix.target }}/release/darn${{ matrix.binary-ext }} dist/${{ matrix.artifact-name }}-${{ env.VERSION }}${{ matrix.binary-ext }}
8393
8494
- name: Upload CLI artifact
8595
uses: actions/upload-artifact@v4
8696
with:
8797
name: ${{ matrix.artifact-name }}-${{ env.VERSION }}
88-
path: dist/${{ matrix.artifact-name }}-${{ env.VERSION }}
98+
path: dist/${{ matrix.artifact-name }}-${{ env.VERSION }}${{ matrix.binary-ext }}
8999
retention-days: 90
90100

91101
build-nix:
@@ -149,6 +159,7 @@ jobs:
149159
darn-linux-aarch64 \
150160
darn-linux-aarch64-musl \
151161
darn-macos-aarch64 \
162+
darn-windows-x86_64 \
152163
; do
153164
dir="artifacts/${name}-${VERSION}"
154165
if [ ! -d "$dir" ]; then
@@ -157,7 +168,11 @@ jobs:
157168
fi
158169
find "$dir" -type f | while read -r file; do
159170
cp "$file" "release/$(basename "$file")"
160-
chmod +x "release/$(basename "$file")"
171+
# Make non-Windows binaries executable
172+
case "$file" in
173+
*.exe) ;;
174+
*) chmod +x "release/$(basename "$file")" ;;
175+
esac
161176
done
162177
done
163178
@@ -198,6 +213,7 @@ jobs:
198213
| Linux aarch64 | \`darn-linux-aarch64-${VERSION}\` |
199214
| Linux aarch64 (static) | \`darn-linux-aarch64-musl-${VERSION}\` |
200215
| macOS aarch64 (Apple Silicon) | \`darn-macos-aarch64-${VERSION}\` |
216+
| Windows x86_64 | \`darn-windows-x86_64-${VERSION}.exe\` |
201217
EOF
202218
)" \
203219
release/*

.github/workflows/release.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,32 @@ jobs:
3232
target: x86_64-unknown-linux-gnu
3333
artifact-name: darn-linux-x86_64
3434
cargo-flags: ""
35+
binary-ext: ""
3536
- os: ubuntu-latest
3637
target: x86_64-unknown-linux-musl
3738
artifact-name: darn-linux-x86_64-musl
3839
cargo-flags: "--no-default-features --features rustls"
40+
binary-ext: ""
3941
- os: ubuntu-24.04-arm
4042
target: aarch64-unknown-linux-gnu
4143
artifact-name: darn-linux-aarch64
4244
cargo-flags: ""
45+
binary-ext: ""
4346
- os: ubuntu-24.04-arm
4447
target: aarch64-unknown-linux-musl
4548
artifact-name: darn-linux-aarch64-musl
4649
cargo-flags: "--no-default-features --features rustls"
50+
binary-ext: ""
4751
- os: macos-latest
4852
target: aarch64-apple-darwin
4953
artifact-name: darn-macos-aarch64
5054
cargo-flags: ""
55+
binary-ext: ""
56+
- os: windows-latest
57+
target: x86_64-pc-windows-msvc
58+
artifact-name: darn-windows-x86_64
59+
cargo-flags: ""
60+
binary-ext: ".exe"
5161

5262
runs-on: ${{ matrix.os }}
5363

@@ -78,13 +88,13 @@ jobs:
7888
shell: bash
7989
run: |
8090
mkdir -p dist
81-
cp target/${{ matrix.target }}/release/darn dist/${{ matrix.artifact-name }}-${{ env.VERSION }}
91+
cp target/${{ matrix.target }}/release/darn${{ matrix.binary-ext }} dist/${{ matrix.artifact-name }}-${{ env.VERSION }}${{ matrix.binary-ext }}
8292
8393
- name: Upload CLI artifact
8494
uses: actions/upload-artifact@v4
8595
with:
8696
name: ${{ matrix.artifact-name }}-${{ env.VERSION }}
87-
path: dist/${{ matrix.artifact-name }}-${{ env.VERSION }}
97+
path: dist/${{ matrix.artifact-name }}-${{ env.VERSION }}${{ matrix.binary-ext }}
8898
retention-days: 90
8999

90100
release:
@@ -114,6 +124,7 @@ jobs:
114124
darn-linux-aarch64 \
115125
darn-linux-aarch64-musl \
116126
darn-macos-aarch64 \
127+
darn-windows-x86_64 \
117128
; do
118129
dir="artifacts/${name}-${VERSION}"
119130
if [ ! -d "$dir" ]; then
@@ -122,7 +133,11 @@ jobs:
122133
fi
123134
find "$dir" -type f | while read -r file; do
124135
cp "$file" "release/$(basename "$file")"
125-
chmod +x "release/$(basename "$file")"
136+
# Make non-Windows binaries executable
137+
case "$file" in
138+
*.exe) ;;
139+
*) chmod +x "release/$(basename "$file")" ;;
140+
esac
126141
done
127142
done
128143

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
test:
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, macos-latest]
16+
os: [ubuntu-latest, macos-latest, windows-latest]
1717

1818
runs-on: ${{ matrix.os }}
1919

darn_cli/src/commands.rs

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn format_paths_as_tree(paths: &[std::path::PathBuf]) -> String {
112112
}
113113

114114
/// Initialize a new `darn` workspace.
115+
#[allow(clippy::unused_async)] // Called from async context, keeping signature uniform
115116
pub(crate) async fn init(path: &Path, out: Output) -> eyre::Result<()> {
116117
out.intro("darn init")?;
117118

@@ -121,52 +122,7 @@ pub(crate) async fn init(path: &Path, out: Output) -> eyre::Result<()> {
121122

122123
out.success(&format!("Initialized workspace at {}", root.display()))?;
123124

124-
// Open workspace to track .darnignore
125-
let darn = Darn::open(&root).await?;
126-
let mut manifest = darn.load_manifest()?;
127-
128-
// Track .darnignore if it exists
129-
let darnignore_path = root.join(".darnignore");
130-
if darnignore_path.exists() {
131-
// Create File from .darnignore
132-
let doc = darn_core::file::File::from_path(&darnignore_path)?;
133-
let file_type = darn_core::file::file_type::FileType::Text;
134-
135-
// Convert to Automerge
136-
let mut am_doc = doc.into_automerge()?;
137-
138-
// Generate random SedimentreeId (16-byte for automerge-repo compatibility)
139-
let sedimentree_id = darn_core::generate_sedimentree_id();
140-
141-
// Store as sedimentree commits
142-
darn_core::sedimentree::store_document(darn.subduction(), sedimentree_id, &mut am_doc)
143-
.await?;
144-
145-
// Add to root directory
146-
darn_core::sedimentree::add_file_to_directory(
147-
darn.subduction(),
148-
manifest.root_directory_id(),
149-
".darnignore",
150-
sedimentree_id,
151-
)
152-
.await?;
153-
154-
// Compute digests
155-
let file_system_digest = darn_core::manifest::content_hash::hash_file(&darnignore_path)?;
156-
let sedimentree_digest =
157-
darn_core::sedimentree::compute_digest(darn.subduction(), sedimentree_id).await?;
158-
159-
// Add to manifest
160-
let entry = darn_core::manifest::tracked::Tracked::new(
161-
sedimentree_id,
162-
std::path::PathBuf::from(".darnignore"),
163-
file_type,
164-
file_system_digest,
165-
sedimentree_digest,
166-
);
167-
manifest.track(entry);
168-
darn.save_manifest(&manifest)?;
169-
}
125+
let manifest = Manifest::load(&initialized.manifest_path())?;
170126

171127
if out.is_porcelain() {
172128
let root_dir_url = sedimentree_id_to_url(manifest.root_directory_id());
@@ -430,7 +386,7 @@ async fn clone_directory_recursive_with_sync(
430386
Ok(file_count)
431387
}
432388

433-
/// Add patterns to .darnignore.
389+
/// Add ignore patterns to the `.darn` config.
434390
pub(crate) fn ignore(patterns: &[String], out: Output) -> eyre::Result<()> {
435391
let darn = Darn::open_without_subduction(Path::new("."))?;
436392
let root = darn.root();
@@ -461,13 +417,13 @@ pub(crate) fn ignore(patterns: &[String], out: Output) -> eyre::Result<()> {
461417
}
462418

463419
if !out.is_porcelain() && added_count > 0 {
464-
out.info(&format!("{added_count} pattern(s) added to .darnignore"))?;
420+
out.info(&format!("{added_count} pattern(s) added to .darn ignore list"))?;
465421
}
466422

467423
Ok(())
468424
}
469425

470-
/// Remove patterns from .darnignore.
426+
/// Remove ignore patterns from the `.darn` config.
471427
pub(crate) fn unignore(patterns: &[String], out: Output) -> eyre::Result<()> {
472428
let darn = Darn::open_without_subduction(Path::new("."))?;
473429
let root = darn.root();
@@ -488,7 +444,7 @@ pub(crate) fn unignore(patterns: &[String], out: Output) -> eyre::Result<()> {
488444
if out.is_porcelain() {
489445
out.kv("not_found", pattern)?;
490446
} else {
491-
out.warning(&format!("Not in .darnignore: {pattern}"))?;
447+
out.warning(&format!("Not in ignore list: {pattern}"))?;
492448
}
493449
}
494450
Err(e) => {
@@ -499,7 +455,7 @@ pub(crate) fn unignore(patterns: &[String], out: Output) -> eyre::Result<()> {
499455

500456
if !out.is_porcelain() && removed_count > 0 {
501457
out.info(&format!(
502-
"{removed_count} pattern(s) removed from .darnignore"
458+
"{removed_count} pattern(s) removed from .darn ignore list"
503459
))?;
504460
}
505461

darn_cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ enum Commands {
105105
path: std::path::PathBuf,
106106
},
107107

108-
/// Add patterns to .darnignore (excluded from sync)
108+
/// Add ignore patterns (excluded from sync)
109109
Ignore {
110110
/// Patterns to ignore (gitignore syntax)
111111
#[arg(required = true)]
112112
patterns: Vec<String>,
113113
},
114114

115-
/// Remove patterns from .darnignore
115+
/// Remove ignore patterns
116116
Unignore {
117117
/// Patterns to stop ignoring
118118
#[arg(required = true)]

0 commit comments

Comments
 (0)