-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #852 from googlefonts/bulk-compile
Checkpoint: bulk compilation abilities
- Loading branch information
Showing
16 changed files
with
538 additions
and
79 deletions.
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 |
---|---|---|
|
@@ -51,4 +51,5 @@ members = [ | |
"fea-rs", | ||
"fea-lsp", | ||
"otl-normalizer", | ||
"fontc_crater", | ||
] |
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
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
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
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
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,22 @@ | ||
[package] | ||
name = "fontc_crater" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MIT/Apache-2.0" | ||
description = "A compiler for fonts." | ||
repository = "https://github.com/googlefonts/fontc" | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
fontc = { version = "0.0.1", path = "../fontc" } | ||
|
||
google-fonts-sources = "0.1.0" | ||
write-fonts.workspace = true | ||
serde.workspace = true | ||
thiserror.workspace = true | ||
clap.workspace = true | ||
serde_yaml.workspace = true | ||
serde_json.workspace = true | ||
tempfile.workspace = true | ||
env_logger.workspace = true | ||
|
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,32 @@ | ||
# `fontc_crater` | ||
|
||
The `fontc_crater` crate (named after [rust-lang/crater]) is a tool for | ||
performing compilation and related actions across a large number of source | ||
fonts. | ||
|
||
|
||
|
||
```sh | ||
$ cargo run --release --p=fontc_crater -- compile FONT_CACHE --fonts-repo GOOGLE/FONTS -o results.json | ||
``` | ||
|
||
This is a binary for executing font compilation (and possibly other tasks) in | ||
bulk. | ||
|
||
Discovery of font sources is managed by a separate tool, | ||
[google-fonts-sources][]; this tool checks out the | ||
[github.com/google/fonts][google/fonts] repository and looks for fonts with | ||
known source repos. You can use the `--fonts-repo` argument to pass the path to | ||
an existing checkout of this repository, which saves time. | ||
|
||
Once sources are identified, they are checked out into the `FONT_CACHE` | ||
directory, where they can be reused between runs. | ||
|
||
## output | ||
|
||
For detailed output, use the `-o/--out` flag to specify a path where we should | ||
dump a json dictionary containing the outcome for each source. | ||
|
||
[google-fonts-sources]: https://github.com/googlefonts/google-fonts-sources | ||
[google/fonts]: https://github.com/google/fonts | ||
[rust-lang/crater]: https://github.com/rust-lang/crater |
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,30 @@ | ||
//! CLI args | ||
use std::path::PathBuf; | ||
|
||
use clap::{Parser, ValueEnum}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Parser)] | ||
#[command(about = "compile multiple fonts and report the results")] | ||
pub(super) struct Args { | ||
/// The task to perform with each font | ||
pub(super) command: Tasks, | ||
/// Directory to store font sources. | ||
/// | ||
/// Reusing this directory saves us having to clone all the repos on each run. | ||
/// | ||
/// This directory is also used to write cached results during repo discovery. | ||
pub(super) font_cache: PathBuf, | ||
/// Path to local checkout of google/fonts repository | ||
#[arg(short, long)] | ||
pub(super) fonts_repo: Option<PathBuf>, | ||
/// Optional path to write out results (as json) | ||
#[arg(short = 'o', long = "out")] | ||
pub(super) out_path: Option<PathBuf>, | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, ValueEnum)] | ||
pub(super) enum Tasks { | ||
Compile, | ||
// this will expand to include at least 'ttx_diff' | ||
} |
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,21 @@ | ||
use std::path::PathBuf; | ||
|
||
use thiserror::Error; | ||
|
||
#[derive(Debug, Error)] | ||
pub(super) enum Error { | ||
#[error("Failed to load input file: '{0}'")] | ||
InputFile(std::io::Error), | ||
#[error("Failed to write file '{path}': '{error}'")] | ||
WriteFile { | ||
path: PathBuf, | ||
#[source] | ||
error: std::io::Error, | ||
}, | ||
#[error("Failed to parse input json: '{0}'")] | ||
InputJson(#[source] serde_json::Error), | ||
#[error("Failed to encode json: '{0}'")] | ||
OutputJson(#[source] serde_json::Error), | ||
#[error("Failed to create cache directory: '{0}'")] | ||
CacheDir(std::io::Error), | ||
} |
Oops, something went wrong.