Skip to content

Commit

Permalink
using crates.io with buck
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Apr 27, 2023
1 parent 024ef54 commit 2abd1ad
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 3 deletions.
2 changes: 1 addition & 1 deletion prelude
2 changes: 1 addition & 1 deletion src/bin/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ rust_binary(
srcs = ["main.rs"],
crate_root = "main.rs",
deps = [
"//src/lib:hello_world",
"//third-party:semver",
],
)
18 changes: 17 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
use semver::{BuildMetadata, Prerelease, Version, VersionReq};

fn main() {
hello_world::print_hello();
let req = VersionReq::parse(">=1.2.3, <1.8.0").unwrap();

// Check whether this requirement matches version 1.2.3-alpha.1 (no)
let version = Version {
major: 1,
minor: 2,
patch: 3,
pre: Prerelease::new("alpha.1").unwrap(),
build: BuildMetadata::EMPTY,
};
assert!(!req.matches(&version));

// Check whether it matches 1.3.0 (yes it does)
let version = Version::parse("1.3.0").unwrap();
assert!(req.matches(&version));
}
39 changes: 39 additions & 0 deletions third-party/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
alias(
name = "semver",
actual = ":semver-1.0.17",
visibility = ["PUBLIC"],
)

http_archive(
name = "semver-1.0.17.crate",
sha256 = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed",
strip_prefix = "semver-1.0.17",
urls = ["https://crates.io/api/v1/crates/semver/1.0.17/download"],
visibility = [],
)

rust_library(
name = "semver-1.0.17",
srcs = [":semver-1.0.17.crate"],
crate = "semver",
crate_root = "semver-1.0.17.crate/src/lib.rs",
edition = "2018",
features = [
"default",
"std",
],
visibility = [],
)

rust_binary(
name = "semver-1.0.17-build-script-build",
srcs = [":semver-1.0.17.crate"],
crate = "build_script_build",
crate_root = "semver-1.0.17.crate/build.rs",
edition = "2018",
features = [
"default",
"std",
],
visibility = [],
)
16 changes: 16 additions & 0 deletions third-party/Cargo.lock

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

15 changes: 15 additions & 0 deletions third-party/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[workspace]

[package]
name = "rust-third-party"
version = "0.0.0"
publish = false
edition = "2021"

# Dummy target to keep Cargo happy
[[bin]]
name = "fake"
path = "/dev/null"

[dependencies]
semver = "1.0.17"
1 change: 1 addition & 0 deletions third-party/reindeer.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor = false
1 change: 1 addition & 0 deletions toolchains/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ system_rust_toolchain(

system_cxx_toolchain(
name = "cxx",
linker = "link.exe",

This comment has been minimized.

Copy link
@steveklabnik

steveklabnik Apr 27, 2023

Author Owner

this change is part of my weird hacks to get msvc rust working, you probably do not want to do this.

visibility = ["PUBLIC"],
)

Expand Down

0 comments on commit 2abd1ad

Please sign in to comment.