Skip to content

Commit

Permalink
Self-hosted implementation of cargo-cp-artifact:
Browse files Browse the repository at this point in the history
- Core functionality implemented in crates/cargo-cp-artifact as a regular crate
- crates/cargo-cp-artifact also has a bin so it can be used to build the self-hosted JS package
- pkgs/cargo-cp-artifact has a Neon implementation that depends on crates/cargo-cp-artifact
- pkgs/cargo-cp-artifact/package.json uses `cargo run -p cargo-cp-artifact` to build itself from the monorepo
  • Loading branch information
dherman committed Feb 28, 2023
1 parent f00b457 commit 9a59f28
Show file tree
Hide file tree
Showing 18 changed files with 1,111 additions and 451 deletions.
174 changes: 164 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
members = [
"crates/*",
"test/*",
"pkgs/cargo-cp-artifact",
]
13 changes: 13 additions & 0 deletions crates/cargo-cp-artifact/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "cargo-cp-artifact"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]
name = "cargo-cp-artifact"
path = "src/bin.rs"

[dependencies]
cargo_metadata = "0.15.3"
23 changes: 23 additions & 0 deletions crates/cargo-cp-artifact/src/artifact.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#[derive(Debug, PartialEq, Eq, Hash)]
pub enum ArtifactKind {
Bin,
CDylib,
Dylib,
}

impl ArtifactKind {
pub fn parse(str: &impl AsRef<str>) -> Option<Self> {
match str.as_ref() {
"bin" => Some(ArtifactKind::Bin),
"cdylib" => Some(ArtifactKind::CDylib),
"dylib" => Some(ArtifactKind::Dylib),
_ => None,
}
}
}

#[derive(Debug, PartialEq, Eq, Hash)]
pub struct Artifact {
pub kind: ArtifactKind,
pub crate_name: String,
}
12 changes: 12 additions & 0 deletions crates/cargo-cp-artifact/src/bin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mod artifact;
mod cargo;
mod cli;

use cargo::Status;

fn main() {
// Skip the native binary name (argv[0]).
if let Status::Failure = cli::run(1) {
std::process::exit(1);
}
}
Loading

0 comments on commit 9a59f28

Please sign in to comment.