cargo_about/licenses/workarounds/
wasmtime.rs

1use super::ClarificationFile;
2use anyhow::Context as _;
3
4pub fn get(krate: &crate::Krate) -> anyhow::Result<Option<super::Clarification>> {
5    if ![
6        "cranelift-bforest",
7        "cranelift-codegen",
8        "cranelift-codegen-meta",
9        "cranelift-codegen-shared",
10        "cranelift-entity",
11        "cranelift-frontend",
12        "cranelift-native",
13        "cranelift-wasm",
14        // This is actually in the bytecodealliance/regalloc.rs repo, but still
15        // has the same license as the core wasmtime repo
16        "regalloc",
17        "target-lexicon",
18        "wasi-cap-std-sync",
19        "wasi-common",
20        // This is actually in the bytecodealliance/wasm-tools repo, but still
21        // has the same license as the core wasmtime repo
22        "wasmparser",
23        "wasmtime",
24        "wasmtime-environ",
25        "wasmtime-jit",
26        "wasmtime-runtime",
27        "wasmtime-types",
28        "wasmtime-wasi",
29        // This is actually in the bytecodealliance/wasm-tools repo, but still
30        // has the same license as the core wasmtime repo
31        "wast",
32        "wiggle",
33        "wiggle-generate",
34        "wiggle-macro",
35        "winx",
36    ]
37    .contains(&krate.name.as_str())
38    {
39        return Ok(None);
40    }
41
42    // fixed in https://github.com/bytecodealliance/wasmtime/commit/b5e289d319b2788bb4b6133792546007f7900443#diff-42013ab1aca14e65a6a2b70d5808c75ea3dd331e7436e2cd8b756fa6b96c3296,
43    // but at the time of writing, unreleased
44    if krate.name == "wasmparser" || krate.name == "wasmtime-types" || krate.name == "wast" {
45        Ok(Some(super::Clarification {
46            license: spdx::Expression::parse("Apache-2.0 WITH LLVM-exception")
47                .context("failed to parse license expression")?,
48            override_git_commit: None,
49            git: vec![ClarificationFile {
50                path: "LICENSE".into(),
51                license: None,
52                checksum: "268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5"
53                    .to_owned(),
54                start: None,
55                end: None,
56            }],
57            files: Vec::new(),
58        }))
59    } else {
60        Ok(Some(super::Clarification {
61            license: spdx::Expression::parse("Apache-2.0 WITH LLVM-exception")
62                .context("failed to parse license expression")?,
63            override_git_commit: None,
64            files: vec![
65                // Both clearlydefined and askalono don't handle license exceptions it seems, so we need to clarify
66                // the file otherwise we will think we won't find the license we expected
67                ClarificationFile {
68                    path: "LICENSE".into(),
69                    license: None,
70                    checksum: "268872b9816f90fd8e85db5a28d33f8150ebb8dd016653fb39ef1f94f2686bc5"
71                        .to_owned(),
72                    start: None,
73                    end: None,
74                },
75            ],
76            git: Vec::new(),
77        }))
78    }
79}