Giter VIP home page Giter VIP logo

form's People

Contributors

abt8601 avatar burrbull avatar dbrgn avatar djmcgill avatar jacobrosenthal avatar michalfita avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

form's Issues

New release?

#6 is working great and were hoping to release a crate based on this.

Any chance of a point release?

Thanks!

CI build and integration test

Now that this crate is seeing some use (and contributions!) by people other than myself, the lack of any CI setup to build and test it isn't really ideal.

Ideally the integration test would run form given a checked-in and pregenerated output from svd2rust and then check that it produces that something cargo will accept.

`form` panics when parsing empty modules

Problem

Consider the following two source files in the same directory, lib.rs and foo.rs:

lib.rs:

use foo::*;
pub mod foo;

foo.rs:

struct Bar;

When trying to split them, form panics because it attempts to unwrap a None value:

William@DESKTOP-H0PMN4M MINGW64 ~/Projects/MCVE/form-mod
$ form -i lib.rs -o src/
[2021-04-14T16:45:09Z INFO  form::util] Started parsing the input as Rust. This can take a minute or two.
[2021-04-14T16:45:09Z INFO  form::util] Finished parsing
[2021-04-14T16:45:09Z INFO  form::util] Prepared target directory src/
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/760ce94c69ca510d44087291c311296f6d9ccdf5\src\libcore\macros\mod.rs:10:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Use Case

The actual use case I have for this is a patch I want to submit to svd2rust to support its -g option a bit better. The -g option emits a separate file called generic.rs to split the generic code from the peripherals.

Right now the -g option requires a user to manually add something like the following lines to lib.rs (preferably after form has been run :)):

use generic::*;
pub mod generic;

Otherwise compilation will fail with errors like the following:

     error[E0433]: failed to resolve: maybe a missing crate `FieldReader`?
   --> src\port_1_2\p2ifg.rs:111:25
    |
111 |         P2IFG2_R(crate::FieldReader::new(bits))
    |                         ^^^^^^^^^^^ maybe a missing crate `FieldReader`?

My patch would automate adding the above code, but since my patch causes form to panic, I'd rather wait to submit my patch. I could fix this myself (ignore mod declarations without a body), but I wanted to open an issue in case you wanted to override/had a better idea :).

Option to create a cargo workspace, instead of a single crate

I often use form for large amounts of generated code. Unfortunately, a single crate will only ever use a single compilation unit. This is a problem when that crate holds 100kloc-1000kloc. Specifically I have one that I am working on with just over a million lines generated.

It would be nice to have a flag that would generate a cargo workspace, instead of a single crate with modules. This would allow parallel compilation to speed compile times, and hopefully hold less RAM at any single point in time.

Instead of:

mod_a/mod.rs
mod_b/mod.rs
lib.rs

this would instead create

mod_a/lib.rs
mod_a/Cargo.toml
mod_b/lib.rs
mod_b/Cargo.toml
mod_root/lib.rs
mod_root/Cargo.toml
./Cargo.toml

Where mod_root would be the only crate you would expect to use (all would have to be published, though).

I may attempt to implement this, but I wanted to open an issue to see if you would be interested in supporting two different modes.

Polyglot disease?

In README.md:

It's advised (but not necessary) to use scalafmt afterwards.

๐Ÿ˜„

less mod.rs

Rust now supports easier module path structure.

Already works on stable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.