Skip to content

Commit 9a59f28

Browse files
committed
Self-hosted implementation of cargo-cp-artifact:
- 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
1 parent f00b457 commit 9a59f28

File tree

18 files changed

+1111
-451
lines changed

18 files changed

+1111
-451
lines changed

Cargo.lock

Lines changed: 164 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
members = [
33
"crates/*",
44
"test/*",
5+
"pkgs/cargo-cp-artifact",
56
]

crates/cargo-cp-artifact/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "cargo-cp-artifact"
3+
version = "0.2.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[[bin]]
9+
name = "cargo-cp-artifact"
10+
path = "src/bin.rs"
11+
12+
[dependencies]
13+
cargo_metadata = "0.15.3"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[derive(Debug, PartialEq, Eq, Hash)]
2+
pub enum ArtifactKind {
3+
Bin,
4+
CDylib,
5+
Dylib,
6+
}
7+
8+
impl ArtifactKind {
9+
pub fn parse(str: &impl AsRef<str>) -> Option<Self> {
10+
match str.as_ref() {
11+
"bin" => Some(ArtifactKind::Bin),
12+
"cdylib" => Some(ArtifactKind::CDylib),
13+
"dylib" => Some(ArtifactKind::Dylib),
14+
_ => None,
15+
}
16+
}
17+
}
18+
19+
#[derive(Debug, PartialEq, Eq, Hash)]
20+
pub struct Artifact {
21+
pub kind: ArtifactKind,
22+
pub crate_name: String,
23+
}

crates/cargo-cp-artifact/src/bin.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod artifact;
2+
mod cargo;
3+
mod cli;
4+
5+
use cargo::Status;
6+
7+
fn main() {
8+
// Skip the native binary name (argv[0]).
9+
if let Status::Failure = cli::run(1) {
10+
std::process::exit(1);
11+
}
12+
}

0 commit comments

Comments
 (0)