Skip to content

Commit

Permalink
Merge pull request #160 from tnull/2023-08-fix-windows-build
Browse files Browse the repository at this point in the history
Fix build on Windows
  • Loading branch information
tnull authored Aug 28, 2023
2 parents a9bb2e9 + 1440b44 commit db1b7dc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@ name: Continuous Integration Checks

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
platform: [
ubuntu-latest,
macos-latest,
windows-latest,
]
toolchain: [
stable,
beta,
Expand All @@ -15,9 +24,14 @@ jobs:
- toolchain: stable
check-fmt: true
build-uniffi: true
platform: ubuntu-latest
- toolchain: stable
platform: macos-latest
- toolchain: stable
platform: windows-latest
- toolchain: 1.63.0
msrv: true
runs-on: ubuntu-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout source code
uses: actions/checkout@v3
Expand All @@ -44,9 +58,10 @@ jobs:
if: matrix.build-uniffi
run: cargo check --release --features uniffi --verbose --color always
- name: Test on Rust ${{ matrix.toolchain }}
if: "matrix.platform != 'windows-latest'"
run: cargo test
- name: Test with UniFFI support on Rust ${{ matrix.toolchain }}
if: matrix.build-uniffi
if: "matrix.platform != 'windows-latest' && matrix.build-uniffi"
run: cargo test --features uniffi
- name: Check formatting on Rust ${{ matrix.toolchain }}
if: matrix.check-fmt
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ esplora-client = { version = "0.4", default-features = false }
libc = "0.2"
uniffi = { version = "0.23.0", features = ["build"], optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_23_0"] }
electrum-client = "0.12.0"
Expand Down
19 changes: 12 additions & 7 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use lightning::util::ser::Writer;
use chrono::Utc;

use std::fs;
#[cfg(not(target_os = "windows"))]
use std::os::unix::fs::symlink;
use std::path::Path;

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

// Create a symlink to the current log file, with prior cleanup
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
if log_file_symlink.as_path().is_symlink() {
fs::remove_file(&log_file_symlink)
.map_err(|e| eprintln!("ERROR: Failed to remove log file symlink: {}", e))?;
#[cfg(not(target_os = "windows"))]
{
// Create a symlink to the current log file, with prior cleanup
let log_file_symlink = parent_dir.join("ldk_node_latest.log");
if log_file_symlink.as_path().is_symlink() {
fs::remove_file(&log_file_symlink).map_err(|e| {
eprintln!("ERROR: Failed to remove log file symlink: {}", e)
})?;
}
symlink(&log_file_name, &log_file_symlink)
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
}
symlink(&log_file_name, &log_file_symlink)
.map_err(|e| eprintln!("ERROR: Failed to create log file symlink: {}", e))?;
}

Ok(Self { file_path: log_file_path, level })
Expand Down

0 comments on commit db1b7dc

Please sign in to comment.