esp-rs / embuild

Build support for embedded Rust: Cargo integration with other embedded build ecosystems & tools, like PlatformIO, CMake and kconfig.
Apache License 2.0
139 stars 40 forks source link

embuild fails to compile with Rust 1.57 or older #46

Closed kevin-june closed 2 years ago

kevin-june commented 2 years ago

If embuild is compiled with:

then compilation fails with:

% cargo build --features espidf
# .. snip
   Compiling embuild v0.29.1 (/Users/kevin/src/embuild)
error: there is no argument named `IDF_PATH_VAR`
   --> src/espidf.rs:140:65
    |
140 |             FromEnvError::NoRepo(anyhow!("environment variable `{IDF_PATH_VAR}` not found"))
    |                                                                 ^^^^^^^^^^^^^^

error: there is no argument named `IDF_PATH_VAR`
   --> src/espidf.rs:177:36
    |
177 |                          given by ${IDF_PATH_VAR} ('{}')",
    |                                    ^^^^^^^^^^^^^^

error: there is no argument named `v`
   --> src/espidf.rs:262:32
    |
262 |             Ok(v) => format!("v{v}"),
    |                                ^^^

error: there is no argument named `MANAGED_ESP_IDF_REPOS_DIR_BASE`
   --> src/espidf.rs:321:22
    |
321 |             format!("{MANAGED_ESP_IDF_REPOS_DIR_BASE}-{hash}")
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: there is no argument named `hash`
   --> src/espidf.rs:321:55
    |
321 |             format!("{MANAGED_ESP_IDF_REPOS_DIR_BASE}-{hash}")
    |                                                       ^^^^^^

error: there is no argument named `IDF_PYTHON_ENV_PATH_VAR`
   --> src/espidf.rs:482:58
    |
482 |                     let python_env_var_prefix = format!("{IDF_PYTHON_ENV_PATH_VAR}=");
    |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^

error: there is no argument named `IDF_PYTHON_ENV_PATH_VAR`
   --> src/espidf.rs:490:72
    |
490 | ...                   "`idf_tools.py export` result contains no `{IDF_PYTHON_ENV_PATH_VAR}` item \
    |                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0277]: expected a `Fn<(char,)>` closure, found `[char; 2]`
   --> src/espidf.rs:375:45
    |
375 |         let mut ref_name = ref_name.replace(&['/', '\\'], "-");
    |                                     ------- ^^^^^^^^^^^^ expected an `Fn<(char,)>` closure, found `[char; 2]`
    |                                     |
    |                                     required by a bound introduced by this call
    |
    = help: the trait `Fn<(char,)>` is not implemented for `[char; 2]`
    = note: required because of the requirements on the impl of `FnOnce<(char,)>` for `&[char; 2]`
    = note: required because of the requirements on the impl of `Pattern<'_>` for `&[char; 2]`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `embuild` due to 8 previous errors

This is because embuild uses captured identifiers in format strings, and support for this was added in Rust 1.58.

Ideally compilation would require the correct toolchain or fail early and with a clear error message.

I am aware of two approaches to improve this:

I've added a PR for the rust-version field here: #45.

ivmarkov commented 2 years ago

Closed via merging #45