Closed mkroening closed 1 year ago
Are you trying to rewrite generate_table.py
in Rust? If the build.rs
does just what generate_table.py
, I think you should rename build.rs
as generate_tables.rs
for example. build
is too generic.
Are you trying to rewrite
generate_table.py
in Rust? If thebuild.rs
does just whatgenerate_table.py
, I think you should renamebuild.rs
asgenerate_tables.rs
for example.build
is too generic.
build.rs
is a Cargo build script. It has to be called build.rs
. It's executed before compilation of the source files, and I used it to replace generate_table.py
in the first commit, since I deemed it most suitable for migrating to phf
in the second commit.
I rebased on latest master and applied your early suggestions. I pushed it commit by commit to have CI runs for each one of them. I'll also update the description of this PR and mark this as ready for review.
Would you like me to split this PR up or are you okay with keeping it this big?
If the
build.rs
does just whatgenerate_table.py
, I think you should renamebuild.rs
asgenerate_tables.rs
for example.build
is too generic.
I just found, that you can actually use a different name for the build script: package.build
. I have never seen another name than build.rs
before though, and I would find things easier myself, if we keep the name build.rs
for the build script.
It's up to you to decide, though. :)
@mkroening I see, and you can go ahead (you can stick to build.rs
) if you add sufficient comments.
Sorry for taking so long. I addressed your concerns. :)
This change is now available in 1.2.0. Sorry to keep you waiting for a long time.
No worries! Thanks a lot! :)
Sorry I'd like you to use 2.0.0(-beta.1) instead. I found this patch is a breaking change, contrary to my expectations.
Closes https://github.com/tats-u/rust-oem-cp/issues/7.
This PR is structured as follows:
Migrate code generation from
generate_table.py
tobuild.rs
.Before,
generate_table.py
was called once and the generated code was then committed to the repository. Now,build.rs
generates the code fromassets/code_tables.json
on the fly for every user before the compilation. The resulting code is not saved persistently anywhere, and is regenerated aftercargo clean
.This step does not change the generated code or any dependencies.
Migrate to
phf
.This change migrates the code generation for hash maps from the manual
lazy_static
andahash::AHashMap
based code to aphf_codegen
andphf::Map
based one.This commit and the following ones are for supporting
no-std
environments:Enable Rust 2021 to enable Cargo resolver version 2.
Without this,
phf_codegen
inbuild-dependencies
enables thestd
feature forphf_shared
in the normaldependencies
scope as well.See https://doc.rust-lang.org/cargo/reference/features.html#feature-resolver-version-2
The next two commits are for refactoring all functionality that requires an allocator into one module for easier gating.
Move string functions into string module.
Move
TableType
string methods to string module.Add
no_std
support.This makes all functionality depend on the
alloc
crate instead ofstd
, making it suitable forno-std
environments. Additionally, thealloc
functionality can be disabled via Cargo features forno-std
environments withoutalloc
.