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

Commit c5aaf1f

Browse files
authored
Merge pull request #5 from genedna/main
Add Windows crates and refacotring build.bzl
2 parents 4011a85 + 558447c commit c5aaf1f

File tree

3,356 files changed

+189905
-114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,356 files changed

+189905
-114
lines changed

BUCK

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ cargo.rust_binary(
66
srcs = glob(["src/**/*.rs"]),
77
crate_root = "src/main.rs",
88
deps = [
9+
# ---
10+
"//third-party/rust/crates/deno-x86_64-pc-windows-msvc/0.23.0:deno-x86_64-pc-windows-msvc",
11+
"//third-party/rust/crates/windows_x86_64_msvc/0.53.0:windows_x86_64_msvc",
12+
"//third-party/rust/crates/windows_x86_64_gnullvm/0.53.0:windows_x86_64_gnullvm",
13+
"//third-party/rust/crates/windows_x86_64_gnu/0.53.0:windows_x86_64_gnu",
14+
"//third-party/rust/crates/windows_i686_msvc/0.53.0:windows_i686_msvc",
15+
"//third-party/rust/crates/windows_i686_gnullvm/0.53.0:windows_i686_gnullvm",
16+
"//third-party/rust/crates/windows_i686_gnu/0.53.0:windows_i686_gnu",
17+
"//third-party/rust/crates/windows_aarch64_msvc/0.53.0:windows_aarch64_msvc",
18+
"//third-party/rust/crates/windows_aarch64_gnullvm/0.53.0:windows_aarch64_gnullvm",
19+
"//third-party/rust/crates/winapi-i686-pc-windows-gnu/0.4.0:winapi-i686-pc-windows-gnu",
20+
"//third-party/rust/crates/winapi-x86_64-pc-windows-gnu/0.4.0:winapi-x86_64-pc-windows-gnu",
21+
"//third-party/rust/crates/winapi/0.3.9:winapi", # --config rust.features=everything,impl-debug,impl-default --config rust.target=i686-pc-windows-gnu
22+
# ---
23+
24+
# rand_core
25+
"//third-party/rust/crates/rand_core/0.3.1:rand_core",
26+
"//third-party/rust/crates/rand_core/0.4.0:rand_core",
27+
928
# autocfg
1029
"//third-party/rust/crates/autocfg/1.4.0:autocfg",
1130

@@ -76,15 +95,15 @@ cargo.rust_binary(
7695
"//third-party/rust/crates/static_assertions/1.1.0:static_assertions",
7796

7897
# syn
79-
# "//third-party/rust/crates/syn/2.0.81",
98+
# "//third-party/rust/crates/syn/2.0.81:syn",
8099
# ---
81100

82101
# Serde
83-
# "//third-party/rust/crates/serde/1.0.60:serde",
102+
#"//third-party/rust/crates/serde/1.0.60:serde",
84103
# ---
85104

86105
# Serde_derive
87-
# "//third-party/rust/crates/serde_derive/1.0.218:serde_derive",
106+
#"//third-party/rust/crates/serde_derive/1.0.218:serde_derive",
88107
# ---
89108

90109
# foreign-types

third-party/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ rm -rf .devcontainer
8080
For now, I am trying to generate `BUCK` with `Cargo.toml` with Claude, and the promote words in Chinese:
8181

8282

83-
编写附件 Cargo.toml 对应功能的 BUCK 文件,满足 Buck2 编译的需求,要求包括:
83+
编写附件 Cargo.toml 和 build.rs 对应功能的 BUCK 文件,满足 Buck2 编译的需求,要求包括:
8484

8585
* BUCK 文件中的注释使用英文;
8686
* 交互过程使用中文;
8787
* 使用 `load("@prelude//toolchains:rust.bzl", "system_rust_toolchain")`;
8888
* BUCK 文件中没有 `version``licenses` 字段;
89-
* BUCK 文件中 `edition` 字段固定使用 `2021`
89+
* BUCK 文件中 `edition` 字段固定使用 Cargo.toml 中的 `edition`
9090
* 如果有依赖存在,请使用 `//third-party/rust/crates/<crate_name>/<crate_version>:<crate_name>` 来替换;
9191
* 如果有 Feature, 采用通过 `--config` 传入构建参数,加入以下函数设计:
9292
```

third-party/rust/crates/anstyle/1.0.10/BUCK

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@prelude//toolchains:rust.bzl", "system_rust_toolchain")
2-
load("//build.bzl", "get_rust_features")
2+
load("//third-party/rust/crates/anstyle/1.0.10:build.bzl", "get_rust_features")
33

44
rust_library(
55
name = "anstyle",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Build configuration module for zstd-sys crate.
2+
3+
This module provides functionality for configuring Rust features and standard library
4+
support for the zstd-sys crate build process. It handles feature flag management and
5+
platform-specific configurations.
6+
"""
7+
8+
def get_rust_features():
9+
features_config = read_config("rust", "features", "")
10+
11+
if features_config == "":
12+
return ["legacy", "zdict_builder"] # Default features
13+
return [f.strip() for f in features_config.split(",") if f.strip()]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@prelude//toolchains:rust.bzl", "system_rust_toolchain")
2+
load("//third-party/rust/crates/deno-x86_64-pc-windows-msvc/0.23.0:build.bzl", "get_rustc_flags")
3+
4+
# This rust_library is for deno-x86_64-pc-windows-msvc binaries
5+
# It implements the functionality from the original Cargo.toml and build.rs
6+
rust_library(
7+
name = "deno-x86_64-pc-windows-msvc",
8+
# Using fixed edition as per requirements
9+
# Note: original Cargo.toml doesn't specify edition, defaulting to 2015
10+
edition = "2021",
11+
srcs = glob(["src/**/*.rs"]),
12+
crate_root = "src/lib.rs",
13+
features = [],
14+
# Conditionally add rustc flags based on target triple
15+
rustc_flags = get_rustc_flags(),
16+
env = {},
17+
deps = [],
18+
visibility = ["PUBLIC"],
19+
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
name = "deno-x86_64-pc-windows-msvc"
15+
version = "0.23.0"
16+
authors = ["The deno authors <bertbelder@nodejs.org>"]
17+
build = "build.rs"
18+
include = ["src/*", "lib/*", "Cargo.toml", "build.rs"]
19+
description = "Binary dependencies for the 'deno' crate"
20+
license = "MIT"
21+
repository = "https://github.com/denoland/deno"

third-party/rust/crates/deno-x86_64-pc-windows-msvc/0.23.0/Cargo.toml.orig

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def get_rustc_flags():
2+
"""
3+
Determine rustc flags based on target platform.
4+
5+
This mimics the build.rs logic which only sets the library search path
6+
when the target is x86_64-pc-windows-msvc.
7+
"""
8+
# Get target platform from config
9+
target = read_config("rust", "target", "")
10+
11+
# Only add link search path for x86_64-pc-windows-msvc target
12+
if target == "x86_64-pc-windows-msvc":
13+
return [
14+
"-L",
15+
"native=lib",
16+
]
17+
return []
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
fn main() {
3+
use std::env::var;
4+
use std::path::Path;
5+
if var("TARGET")
6+
.map(|target| target == "x86_64-pc-windows-msvc")
7+
.unwrap_or(false)
8+
{
9+
let dir = var("CARGO_MANIFEST_DIR").unwrap();
10+
println!(
11+
"cargo:rustc-link-search=native={}",
12+
Path::new(&dir).join("lib").display()
13+
);
14+
}
15+
}
Binary file not shown.

0 commit comments

Comments
 (0)