Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

Commit ca8b8e0

Browse files
committed
Add cfg-if-1.0.0 and working process doc
Signed-off-by: Quanyi Ma <eli@patch.sh>
1 parent 2805d66 commit ca8b8e0

File tree

16 files changed

+678
-37
lines changed

16 files changed

+678
-37
lines changed

BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cargo.rust_binary(
99
"//third-party/rust/crates/libc/0.2.169:libc",
1010
"//third-party/rust/crates/shlex/1.3.0:shlex",
1111
"//third-party/rust/crates/zstd-sys/2.0.13+zstd.1.5.6:zstd-sys",
12+
"//third-party/rust/crates/cfg-if/1.0.0:cfg-if",
1213
],
1314
visibility = ["PUBLIC"],
1415
)

third-party/README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,84 @@
1+
## Third-Party Crate Working Process
12

2-
"https://static.crates.io/crates/{crate}/{crate}-{version}.crate"
3+
### Download crate without cargo
4+
5+
The crate URL is `https://static.crates.io/crates/{crate}/{crate}-{version}.crate`, download the crate using `wget` like this:
6+
7+
```bash
8+
wget https://static.crates.io/crates/cfg-if/cfg-if-1.0.0.crate
9+
tar -xvf cfg-if-1.0.0.crate
10+
rm cfg-if-1.0.0.crate
11+
mv cfg-if-1.0.0 1.0.0
12+
pwd
13+
# buck2-rust-third-party/third-party/rust/crates/cfg-if/1.0.0
14+
```
15+
16+
### Add Buck2 configs
17+
18+
Copy `toolchains` folder and `.buckconfig` file from other crate into working directory:
19+
20+
```
21+
cd 1.0.0
22+
mkdir toolchains
23+
cp -r ../../shlex/1.3.0/toolchains .
24+
cp ../../shlex/1.3.0/.buckconfig .
25+
```
26+
27+
### Add crate to project as dependency
28+
29+
Add `//third-party/rust/crates/cfg-if/1.0.0:cfg-if` to `deps` list:
30+
31+
```
32+
load("@prelude//rust:cargo_package.bzl", "cargo")
33+
34+
cargo.rust_binary(
35+
name = "buck2-rust-third-party",
36+
edition = "2021",
37+
srcs = glob(["src/**/*.rs"]),
38+
crate_root = "src/main.rs",
39+
deps = [
40+
"//third-party/rust/crates/libc/0.2.169:libc",
41+
"//third-party/rust/crates/shlex/1.3.0:shlex",
42+
"//third-party/rust/crates/zstd-sys/2.0.13+zstd.1.5.6:zstd-sys",
43+
"//third-party/rust/crates/cfg-if/1.0.0:cfg-if",
44+
],
45+
visibility = ["PUBLIC"],
46+
)
47+
```
48+
49+
### Write BUCK for the crate
50+
51+
```
52+
load("@prelude//rust:cargo_package.bzl", "cargo")
53+
54+
cargo.rust_library(
55+
name = "cfg-if",
56+
srcs = glob(["**/*.rs"]),
57+
edition = "2018",
58+
visibility = ["PUBLIC"],
59+
deps = [],
60+
)
61+
```
62+
63+
### Clean the crate folder
64+
65+
```
66+
cd ..
67+
rm -rf 1.0.0
68+
```
69+
70+
### Clean the crate folder
71+
72+
```
73+
cd ..
74+
rm -rf .github
75+
rm -rf .devcontainer
76+
```
77+
78+
### Tips
79+
80+
For now, I am trying to generate `BUCK` with `Cargo.toml` with Claude, and the promote words in Chinese:
81+
82+
```
83+
84+
```

third-party/TODO.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## TODO
2+
3+
### Not Implemented
4+
5+
[ ] cfg-if `rustc-dep-of-std = ["core", "compiler_builtins"]`
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[cells]
2+
root = .
3+
prelude = prelude
4+
toolchains = toolchains
5+
none = none
6+
7+
[cell_aliases]
8+
config = prelude
9+
ovr_config = prelude
10+
fbcode = none
11+
fbsource = none
12+
fbcode_macros = none
13+
buck = none
14+
15+
# Uses a copy of the prelude bundled with the buck2 binary. You can alternatively delete this
16+
# section and vendor a copy of the prelude to the `prelude` directory of your project.
17+
[external_cells]
18+
prelude = bundled
19+
20+
[parser]
21+
target_platform_detector_spec = target:root//...->prelude//platforms:default
22+
23+
[build]
24+
execution_platforms = prelude//platforms:default
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"git": {
3+
"sha1": "e60fa1efeab0ec6e90c50d93ec526e1410459c23"
4+
}
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
Cargo.lock
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@prelude//rust:cargo_package.bzl", "cargo")
2+
3+
cargo.rust_library(
4+
name = "cfg-if",
5+
srcs = glob(["**/*.rs"]),
6+
edition = "2018",
7+
visibility = ["PUBLIC"],
8+
deps = [],
9+
)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
2+
#
3+
# When uploading crates to the registry Cargo will automatically
4+
# "normalize" Cargo.toml files for maximal compatibility
5+
# with all versions of Cargo and also rewrite `path` dependencies
6+
# to registry (e.g., crates.io) dependencies
7+
#
8+
# If you believe there's an error in this file please file an
9+
# issue against the rust-lang/cargo repository. If you're
10+
# editing this file be aware that the upstream Cargo.toml
11+
# will likely look very different (and much more reasonable)
12+
13+
[package]
14+
edition = "2018"
15+
name = "cfg-if"
16+
version = "1.0.0"
17+
authors = ["Alex Crichton <alex@alexcrichton.com>"]
18+
description = "A macro to ergonomically define an item depending on a large number of #[cfg]\nparameters. Structured like an if-else chain, the first matching branch is the\nitem that gets emitted.\n"
19+
homepage = "https://github.com/alexcrichton/cfg-if"
20+
documentation = "https://docs.rs/cfg-if"
21+
readme = "README.md"
22+
license = "MIT/Apache-2.0"
23+
repository = "https://github.com/alexcrichton/cfg-if"
24+
[dependencies.compiler_builtins]
25+
version = "0.1.2"
26+
optional = true
27+
28+
[dependencies.core]
29+
version = "1.0.0"
30+
optional = true
31+
package = "rustc-std-workspace-core"
32+
33+
[features]
34+
rustc-dep-of-std = ["core", "compiler_builtins"]
35+
[badges.travis-ci]
36+
repository = "alexcrichton/cfg-if"

third-party/rust/crates/cfg-if/1.0.0/Cargo.toml.orig

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

0 commit comments

Comments
 (0)