|
| 1 | +use std::path::PathBuf; |
1 | 2 | use std::process::Command;
|
2 | 3 |
|
3 | 4 | use crate::builder::{Builder, RunConfig, ShouldRun, Step};
|
@@ -189,3 +190,65 @@ impl Step for Miri {
|
189 | 190 | builder.run(&mut miri);
|
190 | 191 | }
|
191 | 192 | }
|
| 193 | + |
| 194 | +#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] |
| 195 | +pub struct CollectLicenseMetadata; |
| 196 | + |
| 197 | +impl Step for CollectLicenseMetadata { |
| 198 | + type Output = PathBuf; |
| 199 | + const ONLY_HOSTS: bool = true; |
| 200 | + |
| 201 | + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
| 202 | + run.path("src/tools/collect-license-metadata") |
| 203 | + } |
| 204 | + |
| 205 | + fn make_run(run: RunConfig<'_>) { |
| 206 | + run.builder.ensure(CollectLicenseMetadata); |
| 207 | + } |
| 208 | + |
| 209 | + fn run(self, builder: &Builder<'_>) -> Self::Output { |
| 210 | + let Some(reuse) = &builder.config.reuse else { |
| 211 | + panic!("REUSE is required to collect the license metadata"); |
| 212 | + }; |
| 213 | + |
| 214 | + // Temporary location, it will be moved to src/etc once it's accurate. |
| 215 | + let dest = builder.out.join("license-metadata.json"); |
| 216 | + |
| 217 | + let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata); |
| 218 | + cmd.env("REUSE_EXE", reuse); |
| 219 | + cmd.env("DEST", &dest); |
| 220 | + builder.run(&mut cmd); |
| 221 | + |
| 222 | + dest |
| 223 | + } |
| 224 | +} |
| 225 | + |
| 226 | +#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] |
| 227 | +pub struct GenerateCopyright; |
| 228 | + |
| 229 | +impl Step for GenerateCopyright { |
| 230 | + type Output = PathBuf; |
| 231 | + const ONLY_HOSTS: bool = true; |
| 232 | + |
| 233 | + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
| 234 | + run.path("src/tools/generate-copyright") |
| 235 | + } |
| 236 | + |
| 237 | + fn make_run(run: RunConfig<'_>) { |
| 238 | + run.builder.ensure(GenerateCopyright); |
| 239 | + } |
| 240 | + |
| 241 | + fn run(self, builder: &Builder<'_>) -> Self::Output { |
| 242 | + let license_metadata = builder.ensure(CollectLicenseMetadata); |
| 243 | + |
| 244 | + // Temporary location, it will be moved to the proper one once it's accurate. |
| 245 | + let dest = builder.out.join("COPYRIGHT.md"); |
| 246 | + |
| 247 | + let mut cmd = builder.tool_cmd(Tool::GenerateCopyright); |
| 248 | + cmd.env("LICENSE_METADATA", &license_metadata); |
| 249 | + cmd.env("DEST", &dest); |
| 250 | + builder.run(&mut cmd); |
| 251 | + |
| 252 | + dest |
| 253 | + } |
| 254 | +} |
0 commit comments