Skip to content
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

IDF_TARGET not set #345

Closed
hhy50 opened this issue Oct 24, 2024 · 7 comments
Closed

IDF_TARGET not set #345

hhy50 opened this issue Oct 24, 2024 · 7 comments

Comments

@hhy50
Copy link

hhy50 commented Oct 24, 2024

After adding this parameter to Cargo.toml, the build failed

[lib]
proc-macro = true

build log:

--- stdout
  cargo:rerun-if-env-changed=ESP_IDF_TOOLS_INSTALL_DIR
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG
  cargo:rerun-if-env-changed=ESP_IDF_SDKCONFIG_DEFAULTS
  cargo:rerun-if-env-changed=MCU
  cargo:rerun-if-env-changed=ESP_IDF_SYS_ROOT_CRATE
  cargo:rerun-if-env-changed=ESP_IDF_VERSION
  cargo:rerun-if-env-changed=ESP_IDF_REPOSITORY
  cargo:rerun-if-env-changed=ESP_IDF_CMAKE_GENERATOR
  cargo:rerun-if-env-changed=IDF_PATH
  cargo:rerun-if-env-changed=EXTRA-COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENTS
  cargo:rerun-if-env-changed=ESP_IDF_COMPONENT_MANAGER

  --- stderr
  Build configuration: BuildConfig {
      esp_idf_tools_install_dir: Some(
          Global,
      ),
      esp_idf_sdkconfig: None,
      esp_idf_sdkconfig_defaults: None,
      mcu: Some(
          "esp32c3",
      ),
      native: NativeConfig {
          esp_idf_version: Some(
              Tag(
                  "v5.2",
              ),
          ),
          esp_idf_repository: None,
          esp_idf_cmake_generator: None,
          idf_path: None,
          extra_components: [],
          esp_idf_components: None,
          esp_idf_component_manager: None,
      },
      esp_idf_sys_root_crate: None,
  }
  Error: Unsupported target 'x86_64-apple-darwin'
warning: build failed, waiting for other jobs to finish...
@ivmarkov
Copy link
Collaborator

ivmarkov commented Oct 24, 2024

What do you expect? You are declaring a proc-macro library. These run on the host.

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Oct 24, 2024
@hhy50
Copy link
Author

hhy50 commented Oct 24, 2024

[[bin]]
name = "billiards_esp32"
harness = false # do not use the built in cargo test harness -> resolve rust-analyzer errors

[lib]
proc-macro = true

but, I also have a bin crate

@ivmarkov
Copy link
Collaborator

It does not work like that. You are chasing rust restrictions, misinterpreting the error and then opening as bug here. What IDG_TARGET? Look at the error output.

Error: Unsupported target 'x86_64-apple-darwin'

It is rustc and cargo themselves who are not picking your esp32 target, not esp-idf-sys. You are compiling for the host.

@hhy50
Copy link
Author

hhy50 commented Oct 24, 2024

It does not work like that. You are chasing rust restrictions, misinterpreting the error and then opening as bug here. What IDG_TARGET? Look at the error output.

Error: Unsupported target 'x86_64-apple-darwin'

It is rustc and cargo themselves who are not picking your esp32 target, not esp-idf-sys. You are compiling for the host.

[lib]
proc-macro = true

The target is specified in. cargo/config
Without this, it can operate normally

@hhy50
Copy link
Author

hhy50 commented Oct 24, 2024

@ivmarkov
You can find an example project and try adding it

@ivmarkov
Copy link
Collaborator

OK I give it one last try: what you are trying to do (mixing a proc-macro crate together in another, non-proc-macro crate) is just NOT possible in Rust.

This is not a problem of esp-idf-sys.
This is a restriction of Rust. And if you think about it, it does make sense!

Try to do what you are trying to do with any other embedded framework - be it esp-hal or embassy and you'll see it is simply impossible.

The only solution is to have your proc-macros in a separate, dedicated proc-macro crate. As everybody else does. Google the internet for that.

@hhy50
Copy link
Author

hhy50 commented Oct 24, 2024

OK I give it one last try: what you are trying to do (mixing a proc-macro crate together in another, non-proc-macro crate) is just NOT possible in Rust.

This is not a problem of esp-idf-sys. This is a restriction of Rust. And if you think about it, it does make sense!

Try to do what you are trying to do with any other embedded framework - be it esp-hal or embassy and you'll see it is simply impossible.

The only solution is to have your proc-macros in a separate, dedicated proc-macro crate. As everybody else does. Google the internet for that.

Thank you very much for your patient answer, I have now placed it in a separate crate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants