-
Notifications
You must be signed in to change notification settings - Fork 17
Improve support for in-memory compilation, helps wasm use #1796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ore strongly typed
|
In #1684 I made it possible to pass a |
|
I propose we separate input source from the compilation options and restore the ability to generate_font from Before (Rod's PR): pub fn generate_font(args: Args) -> Result<Vec<u8>, Error>
pub fn run(args: Args, timer: JobTimer) -> Result<(), Error>
// where Args contains input: InputAfter: pub fn generate_font(source: Box<dyn Source>, options: Options) -> Result<Vec<u8>, Error> // public library entry point
pub fn run(input: Input, options: Options, timer: JobTimer) -> Result<(), Error> // CLI entry pointI'll make a PR now |
…rce> support Refactor the compile arguments API to: - Rename `fontc::Args` to `fontc::Options` for clarity (avoids confusion with CLI `args::Args`) - Remove `input` field from Options - source is now passed separately - Update `generate_font()` to accept `Box<dyn Source>` + `Options` - Update `run()` to accept `Input` + `Options` This restores the ability to pass custom `Box<dyn Source>` implementations that was added in #1684, which library users need for generating their own IR programmatically. Also: - Add `Default` derive to `Options` for ergonomic in-memory/WASM usage - Rename `cli_args.rs` back to `args.rs` and delete `compile_args.rs` (Options inlined in lib.rs since it's short enough)
see #1797 (which is based on this PR branch, not |
Change require_dir() to use fs::create_dir_all() instead of fs::create_dir() so that nested paths like /tmp/deep/nested/build are created correctly.
…used
When both --emit-ir and --output-file are used, the font is first
written to {ir_dir}/font.ttf by the persistence mechanism. If output_file
differs, we move (rename) the font to the custom output path rather than
leaving it in the IR directory.
We rename (instead of fs::write or fs::copy) as this matches the current
behavior on `main` whereby the font ends up at output_file only and is not
duplicated in the IR directory.
cmyr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been holding off on merging #1775 because I wanted to discuss some of our options in a bit more depth, but I think it also provides an opportunity to simplify some of this logic.
Oh good catch, will fix. |
I fixed it in #1797, please take a look at that before duplicating work, thanks! |
Remove input from fontc::Args, rename as Options; restore `Box<dyn Source>` support
I feel seen :D |
This PR aspires toward #1791's goal of making in-memory compiles for wasm happier by making it clearer how to say don't touch the disk
--flag --hereinto a compile arg