Skip to content

Commit

Permalink
Fix compile errors for esp-idf master
Browse files Browse the repository at this point in the history
Added patch `i2s_types_master.diff` because bindgen generates two `i2s_channel_t` types with the same name,
once for the enum and once for the forward declared struct.
  • Loading branch information
N3xed committed Aug 9, 2022
1 parent 9b1dfdc commit 8a0e928
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions build/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ pub const V_4_3_2_PATCHES: &[&str] = &[
"patches/pthread_destructor_fix.diff",
];

#[allow(dead_code)]
pub const MASTER_PATCHES: &[&str] = &["patches/i2s_types_master.diff"];

const TOOLS_WORKSPACE_INSTALL_DIR: &str = ".embuild";

pub struct EspIdfBuildOutput {
Expand Down
14 changes: 8 additions & 6 deletions build/native/cargo_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use embuild::{bindgen, build, cargo, cmake, espidf, git, kconfig, path_buf};
use self::chip::Chip;
use crate::common::{
self, list_specific_sdkconfigs, manifest_dir, workspace_dir, EspIdfBuildOutput,
EspIdfComponents, InstallDir, V_4_3_2_PATCHES,
EspIdfComponents, InstallDir, MASTER_PATCHES, V_4_3_2_PATCHES,
};
use crate::config::{BuildConfig, ESP_IDF_GLOB_VAR_PREFIX, ESP_IDF_TOOLS_INSTALL_DIR_VAR};

Expand Down Expand Up @@ -77,6 +77,12 @@ pub fn build() -> Result<EspIdfBuildOutput> {
Ok(tools)
};

// The `kconfig.cmake` script looks at this variable if it should compile `mconf` on
// windows. `idf_tools.py` also fails when this variable is set because it thinks
// we're using msys/cygwin.
// But this variable is also present when using git-bash.
env::remove_var("MSYSTEM");

// Get the install dir location from the build config, or use
// [`crate::config::DEFAULT_TOOLS_INSTALL_DIR`] if unset.
let (install_dir, allow_from_env) = config.esp_idf_tools_install_dir()?;
Expand Down Expand Up @@ -159,7 +165,7 @@ pub fn build() -> Result<EspIdfBuildOutput> {
// master branch
_ if idf.repository.get_default_branch()? == idf.repository.get_branch_name()? => &[],
Ok((4, 4, _)) => &[],
Ok((4, 3, patch)) if patch > 2 => &[],
Ok((4, 3, patch)) if patch > 2 => MASTER_PATCHES,
Ok((4, 3, patch)) if patch == 2 => V_4_3_2_PATCHES,
Ok((major, minor, patch)) => {
cargo::print_warning(format_args!(
Expand All @@ -182,10 +188,6 @@ pub fn build() -> Result<EspIdfBuildOutput> {

env::set_var("PATH", &idf.exported_path);

// The `kconfig.cmake` script looks at this variable if it should compile `mconf` on windows.
// But this variable is also present when using git-bash which doesn't have gcc.
env::remove_var("MSYSTEM");

// Remove the sdkconfig file generated by the esp-idf so that potential changes
// in the user provided sdkconfig and sdkconfig.defaults don't get ignored.
// TODO: I'm really not sure why we have to do this.
Expand Down
16 changes: 16 additions & 0 deletions patches/i2s_types_master.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/components/driver/include/driver/i2s_types.h b/components/driver/include/driver/i2s_types.h
index 84cd39241b40eed7885378da73771d418d75c331..f09a6fc06831992c7819e04a3cdf4b98867b4f56 100644
--- a/components/driver/include/driver/i2s_types.h
+++ b/components/driver/include/driver/i2s_types.h
@@ -63,7 +63,11 @@ typedef struct {
*/
} i2s_event_data_t;

+#ifdef __bindgen
+typedef void *i2s_chan_handle_t; /*!< i2s channel handle, the control unit of the i2s driver*/
+#else
typedef struct i2s_channel_t *i2s_chan_handle_t; /*!< i2s channel handle, the control unit of the i2s driver*/
+#endif

/**
* @brief I2S event callback

0 comments on commit 8a0e928

Please sign in to comment.