Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Static Loader doesn't notice new files when rebuilding #2

Open
ecton opened this issue Jun 10, 2020 · 4 comments
Open

Static Loader doesn't notice new files when rebuilding #2

ecton opened this issue Jun 10, 2020 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ecton
Copy link
Contributor

ecton commented Jun 10, 2020

When I use include_str or similar macros, if I change the referenced file and rebuild, cargo notices the change and rebuilds the source file.

Unfortunately, in my initial testing, I can't seem to get the static_loader! to reload new content without changing some other source file. Is there a way to get the static_loader! macro to notify Cargo that it's depending on those files and to rebuild if they change?

The way I'm testing is I have this snippet:

fluent_templates::static_loader! {
    // Declare our `StaticLoader` named `LOCALES`.
    pub static LOCALES = {
        // The directory of localisations and fluent resources.
        locales: "./shared/src/strings",
        // The language to fallback on if something is not present.
        fallback_language: "en-US",
    };
}

And I load it and render a string out from the referenced LOCALES, and if I run the program once, change the string, cargo run again I don't see the new value. If I cargo clean I do.

Thank you for the great library; it is very easy to use.

@ecton
Copy link
Contributor Author

ecton commented Jun 10, 2020

Just a quick update, a simple workaround for me was to use include_dir to include the directory a second time. However include_dir references the files, it notices when I re-run my project.

I found how this would be accomplished during a build.rs process, but not how it's done inside of a macro.

Good luck and thanks again for the awesome crate. I like the ergonomics a lot.

@ecton
Copy link
Contributor Author

ecton commented Jun 11, 2020

Did a little research, found this relevant thread: https://users.rust-lang.org/t/equivalent-of-cargo-rerun-if-changed-for-procedural-macros/37036

@XAMPPRocky
Copy link
Owner

@XAMPPRocky
Copy link
Owner

I've just pushed a fix to master that should mean that rustc will notice changes to existing files, though you still need a clean build to add files.

@XAMPPRocky XAMPPRocky added the bug Something isn't working label Jun 12, 2020
@XAMPPRocky XAMPPRocky changed the title Static Loader doesn't notice changes when rebuilding Static Loader doesn't notice new files when rebuilding Nov 13, 2020
@XAMPPRocky XAMPPRocky added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants