Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Rust
on:
pull_request:
branches: main
release:
types: published
env:
CARGO_TERM_COLOR: always
jobs:
bench:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
# package:
# runs-on: ubuntu-latest
# steps:
# - name: checkout
# uses: actions/checkout@v4
# - name: cleanup
# run: rm -fr book/ sandbox/ tests/
# - name: package
# run: cargo package
# - name: login
# if: github.event_name == 'release'
# run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
# - name: publish
# if: github.event_name == 'release'
# run: cargo publish
test:
if: github.event_name != 'release'
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
toolchain:
- beta
- stable
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
# components: clippy, rustfmt
default: true
toolchain: ${{ matrix.toolchain }}
- name: build
run: cargo build --features arcwelder --release
# - name: clippy
# run: cargo clippy -- -D warnings
# - name: clippy
# run: cargo clippy --tests
# - name: doc
# run: cargo rustdoc --release -- --html-in-header docs/katex.html
# - name: fmt
# run: cargo fmt --all -- --check
- name: test
run: cargo test --features arcwelder --release
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/arcwelderlib-sys/vendor/ArcWelderLib
/target
Cargo.lock
*.gcode

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ clap = { version = "4.5.16", features = ["derive"] }
serde = { version = "1.0.213", features = ["derive"] }
serde_json = "1.0.132"
stl_io = "0.8.2"

[dependencies.arcwelderlib-sys]
optional = true
path = "arcwelderlib-sys"

[features]
default = []
arcwelder = ["arcwelderlib-sys"]

[workspace]
members = ["arcwelderlib-sys"]
8 changes: 8 additions & 0 deletions arcwelderlib-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "arcwelderlib-sys"
version = "0.1.0"
edition = "2024"

[build-dependencies]
cmake = "0.1.54"
git2 = "0.20.2"
32 changes: 32 additions & 0 deletions arcwelderlib-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use git2::Repository;
use std::env;
use std::fs;
use std::path::PathBuf;

fn main() {
let arcwelder_src = PathBuf::from("vendor/ArcWelderLib");

if !arcwelder_src.exists() {
println!("Cloning ArcWelderLib...");
Repository::clone("https://github.com/fieldOfView/ArcWelderLib.git", &arcwelder_src)
.expect("Failed to clone ArcWelderLib");
}

// This assumes ArcWelderConsole is the name of the CMake target
let dst = cmake::Config::new(&arcwelder_src)
.build_target("ArcWelderConsole")
.build();

// Typical output location is build/ArcWelderConsole
let exe_path = dst.join("build")
.join("ArcWelderConsole")
.join("ArcWelder");

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let target_path = out_dir.join("ArcWelderConsole");

fs::copy(&exe_path, &target_path).expect("Failed to copy ArcWelder executable");

println!("cargo:rerun-if-changed=vendor/ArcWelderLib");
println!("cargo:rustc-env=ARCWELDER_PATH={}", target_path.display());
}
15 changes: 15 additions & 0 deletions arcwelderlib-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::path::PathBuf;

/// Returns the path to the built ArcWelder executable
fn arcwelder_exe_path() -> PathBuf {
PathBuf::from(env!("ARCWELDER_PATH"))
}

/// publicly callable command.
pub fn arcwelder(input_file: &str, output_file: &str) -> () {
let arcwelder = arcwelder_exe_path();
let status = std::process::Command::new(arcwelder)
.args([input_file, output_file])
.status()
.expect("Failed to execute ArcWelder");
}
21 changes: 20 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(feature = "arcwelder")]
use arcwelderlib_sys::arcwelder;

use clap::Parser;
use slicey::{
geometry::STLMesh,
Expand All @@ -18,7 +21,10 @@ struct CLIArgs {
stl_files: Vec<String>,
/// Path to settings file
#[arg(long)]
settings_file: String
settings_file: String,
/// Whether or not to use arcwelder. Requires cargo build --features arcwelder
#[arg(long)]
arcwelder: bool
}

fn main() {
Expand All @@ -31,4 +37,17 @@ fn main() {
.collect();
let slicer = Slicer::new(settings, stl_meshes);
let _ = slicer.slice(&args.gcode_file);

// arcwelder stuff
let arcwelder_enabled = cfg!(feature = "arcwelder");
if arcwelder_enabled {
println!("ArcWelder feature is enabled.");
} else {
println!("ArcWelder feature is NOT enabled.");
}

#[cfg(feature = "arcwelder")]
if args.arcwelder {
arcwelder(&args.gcode_file, &args.gcode_file)
}
}
Loading