Skip to content
This repository was archived by the owner on Jan 27, 2026. It is now read-only.

Commit b16ea2a

Browse files
authored
Add general.license field to build.toml (#343)
This can be used for card-filling and is added to the kernel build metadata.
1 parent c6c83df commit b16ea2a

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

build2cmake/src/config/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ impl Build {
3535

3636
pub struct General {
3737
pub name: String,
38+
39+
/// Hugging Face Hub license identifier.
40+
pub license: Option<String>,
41+
3842
pub backends: Vec<Backend>,
3943
pub hub: Option<Hub>,
4044
pub python_depends: Option<Vec<String>>,

build2cmake/src/config/v1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl TryFrom<Build> for super::Build {
9898
Ok(Self {
9999
general: super::General {
100100
name: build.general.name,
101+
license: None,
101102
backends,
102103
hub: None,
103104
python_depends: None,

build2cmake/src/config/v2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl General {
163163

164164
super::General {
165165
name: general.name,
166+
license: None,
166167
backends,
167168
cuda,
168169
hub: general.hub.map(Into::into),

build2cmake/src/config/v3.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ pub struct Build {
2121
pub struct General {
2222
pub name: String,
2323

24+
pub license: Option<String>,
25+
2426
pub backends: Vec<Backend>,
2527

2628
pub cuda: Option<CudaGeneral>,
@@ -141,6 +143,7 @@ impl From<General> for super::General {
141143
fn from(general: General) -> Self {
142144
Self {
143145
name: general.name,
146+
license: general.license,
144147
backends: general.backends.into_iter().map(Into::into).collect(),
145148
cuda: general.cuda.map(Into::into),
146149
hub: general.hub.map(Into::into),
@@ -293,6 +296,7 @@ impl From<super::General> for General {
293296
fn from(general: super::General) -> Self {
294297
Self {
295298
name: general.name,
299+
license: general.license,
296300
backends: general.backends.into_iter().map(Into::into).collect(),
297301
cuda: general.cuda.map(Into::into),
298302
hub: general.hub.map(Into::into),

build2cmake/src/metadata.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ use serde::{Deserialize, Serialize};
33
#[derive(Debug, Deserialize, Serialize)]
44
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
55
pub struct Metadata {
6-
python_depends: Vec<String>,
7-
}
8-
9-
impl Metadata {
10-
pub fn new(python_depends: impl Into<Vec<String>>) -> Self {
11-
Self {
12-
python_depends: python_depends.into(),
13-
}
14-
}
6+
#[serde(skip_serializing_if = "Option::is_none")]
7+
pub license: Option<String>,
8+
pub python_depends: Vec<String>,
159
}

build2cmake/src/torch/common.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ pub fn write_metadata(backend: Backend, general: &General, file_set: &mut FileSe
4242
.chain(general.backend_python_depends(backend))
4343
.collect::<Result<Vec<_>>>()?;
4444

45-
let metadata = Metadata::new(python_depends);
45+
let metadata = Metadata {
46+
license: general.license.clone(),
47+
python_depends,
48+
};
4649

4750
serde_json::to_writer(writer, &metadata)?;
4851

examples/silu-and-mul/build.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[general]
22
name = "silu-and-mul"
3+
license = "apache-2.0"
34
backends = [
45
"cpu",
56
"cuda",

0 commit comments

Comments
 (0)