From 3f3207bc72a595740a2dfc9c3661b8b79259c573 Mon Sep 17 00:00:00 2001 From: evenorog Date: Sat, 13 Apr 2024 20:26:51 +0200 Subject: [PATCH] Remove online build --- Cargo.toml | 7 ------ build.rs | 67 +++++++++++++++--------------------------------------- src/lib.rs | 4 ---- 3 files changed, 18 insertions(+), 60 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 028c0c1..96be273 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,6 @@ categories = ["no-std"] exclude = ["/license-list-data", "!/license-list-data/json"] edition = "2021" -[features] -default = [] -offline = [] - [dependencies] serde = { version = "1", default-features = false, optional = true } @@ -29,6 +25,3 @@ serde_json = "1" [badges] maintenance = { status = "actively-developed" } - -[package.metadata.docs.rs] -features = ["offline"] diff --git a/build.rs b/build.rs index 4eef011..1d4764e 100644 --- a/build.rs +++ b/build.rs @@ -4,7 +4,6 @@ use std::error::Error; use std::fs::{self, File}; use std::io::{BufReader, BufWriter, Write}; use std::path::{Path, PathBuf}; -use std::process::Command; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -60,54 +59,6 @@ impl Exception { } } -fn main() { - let out_dir = env::var_os("OUT_DIR").unwrap(); - let out_dir = PathBuf::from(out_dir); - let licenses_output = out_dir.join("licenses.rs"); - let exceptions_output = out_dir.join("exceptions.rs"); - - if cfg!(feature = "offline") { - // If unable to clone the latest version from git we use the offline files. - build_licenses_from_json( - Path::new("license-list-data/json/details"), - &licenses_output, - ) - .unwrap(); - build_exceptions_from_json( - Path::new("license-list-data/json/exceptions"), - &exceptions_output, - ) - .unwrap(); - } else { - let json_dir = Path::new(&out_dir).join("license-list-data/json"); - - if json_dir.exists() { - build_licenses_from_json(&json_dir.join("details"), &licenses_output).unwrap(); - build_exceptions_from_json(&json_dir.join("exceptions"), &exceptions_output).unwrap(); - } else { - let status = Command::new("git") - .arg("clone") - .arg("--depth") - .arg("1") - .arg("https://github.com/spdx/license-list-data.git") - .current_dir(&out_dir) - .status() - .expect("`git` not found"); - - if status.success() { - build_licenses_from_json(&json_dir.join("details"), &licenses_output).unwrap(); - build_exceptions_from_json(&json_dir.join("exceptions"), &exceptions_output) - .unwrap(); - } else { - match status.code() { - Some(code) => panic!("`git clone --depth 1` failed with exit code `{}`", code), - None => panic!("`git clone --depth 1` was terminated by signal"), - } - } - } - } -} - fn build_licenses_from_json(input: &Path, output: &Path) -> Result<(), Box> { let inner = File::create(output)?; let mut f = BufWriter::with_capacity(4_194_304, inner); @@ -190,5 +141,23 @@ fn build_exceptions_from_json(input: &Path, output: &Path) -> Result<(), Box