Skip to content

Commit db1b7dc

Browse files
authored
Merge pull request #160 from tnull/2023-08-fix-windows-build
Fix build on Windows
2 parents a9bb2e9 + 1440b44 commit db1b7dc

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ name: Continuous Integration Checks
22

33
on: [push, pull_request]
44

5+
concurrency:
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
59
jobs:
610
build:
711
strategy:
812
matrix:
13+
platform: [
14+
ubuntu-latest,
15+
macos-latest,
16+
windows-latest,
17+
]
918
toolchain: [
1019
stable,
1120
beta,
@@ -15,9 +24,14 @@ jobs:
1524
- toolchain: stable
1625
check-fmt: true
1726
build-uniffi: true
27+
platform: ubuntu-latest
28+
- toolchain: stable
29+
platform: macos-latest
30+
- toolchain: stable
31+
platform: windows-latest
1832
- toolchain: 1.63.0
1933
msrv: true
20-
runs-on: ubuntu-latest
34+
runs-on: ${{ matrix.platform }}
2135
steps:
2236
- name: Checkout source code
2337
uses: actions/checkout@v3
@@ -44,9 +58,10 @@ jobs:
4458
if: matrix.build-uniffi
4559
run: cargo check --release --features uniffi --verbose --color always
4660
- name: Test on Rust ${{ matrix.toolchain }}
61+
if: "matrix.platform != 'windows-latest'"
4762
run: cargo test
4863
- name: Test with UniFFI support on Rust ${{ matrix.toolchain }}
49-
if: matrix.build-uniffi
64+
if: "matrix.platform != 'windows-latest' && matrix.build-uniffi"
5065
run: cargo test --features uniffi
5166
- name: Check formatting on Rust ${{ matrix.toolchain }}
5267
if: matrix.check-fmt

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ esplora-client = { version = "0.4", default-features = false }
7070
libc = "0.2"
7171
uniffi = { version = "0.23.0", features = ["build"], optional = true }
7272

73+
[target.'cfg(windows)'.dependencies]
74+
winapi = { version = "0.3", features = ["winbase"] }
75+
7376
[dev-dependencies]
7477
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
7578
electrum-client = "0.12.0"

src/logger.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use lightning::util::ser::Writer;
77
use chrono::Utc;
88

99
use std::fs;
10+
#[cfg(not(target_os = "windows"))]
1011
use std::os::unix::fs::symlink;
1112
use std::path::Path;
1213

@@ -31,14 +32,18 @@ impl FilesystemLogger {
3132
.open(log_file_path.clone())
3233
.map_err(|e| eprintln!("ERROR: Failed to open log file: {}", e))?;
3334

34-
// Create a symlink to the current log file, with prior cleanup
35-
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
36-
if log_file_symlink.as_path().is_symlink() {
37-
fs::remove_file(&log_file_symlink)
38-
.map_err(|e| eprintln!("ERROR: Failed to remove log file symlink: {}", e))?;
35+
#[cfg(not(target_os = "windows"))]
36+
{
37+
// Create a symlink to the current log file, with prior cleanup
38+
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
39+
if log_file_symlink.as_path().is_symlink() {
40+
fs::remove_file(&log_file_symlink).map_err(|e| {
41+
eprintln!("ERROR: Failed to remove log file symlink: {}", e)
42+
})?;
43+
}
44+
symlink(&log_file_name, &log_file_symlink)
45+
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
3946
}
40-
symlink(&log_file_name, &log_file_symlink)
41-
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
4247
}
4348

4449
Ok(Self { file_path: log_file_path, level })

0 commit comments

Comments
 (0)