forked from o2sh/onefetch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate license cache at build time
- Loading branch information
Showing
5 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
# nix result from nix-build | ||
result | ||
|
||
# generated license cache | ||
resources/licenses/cache.bin.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extern crate askalono; | ||
|
||
use std::fs::File; | ||
use std::path::Path; | ||
|
||
use askalono::Store; | ||
|
||
const EMBEDDED_CACHE: &str = "resources/licenses/cache.bin.gz"; | ||
|
||
fn main() { | ||
if Path::new(EMBEDDED_CACHE).exists() { | ||
println!("cargo:warning=onefetch license cache file already exists; not re-building"); | ||
return; | ||
} | ||
|
||
let mut store = Store::new(); | ||
store | ||
.load_spdx(Path::new("resources/licenses/spdx/json/details"), false) | ||
.expect("Couldn't create a store from SPDX data"); | ||
|
||
let mut cache = File::create(EMBEDDED_CACHE).unwrap(); | ||
store.to_cache(&mut cache).unwrap(); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters