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

How to configure Ethercat master in build.rs? #44

Open
rise0chen opened this issue May 11, 2023 · 5 comments
Open

How to configure Ethercat master in build.rs? #44

rise0chen opened this issue May 11, 2023 · 5 comments

Comments

@rise0chen
Copy link

I want to configure Ethercat master in build.rs of my project.

fn main() -> Result<(), Box<dyn std::error::Error>> {
    use std::process::Command;
    use std::{env, fs};
    let dir = fs::canonicalize("./vendor/etherlab")?;
    env::set_var("ETHERCAT_PATH", &dir);
    env::set_current_dir(&dir)?;
    Command::new(format!("{}/bootstrap", dir.display())).current_dir(&dir).status().unwrap();
    Command::new(format!("{}/configure", dir.display()))
        .current_dir(&dir)
        .arg("--disable-8139too")
        .arg("--enable-igb")
        .arg("--enable-cycles")
        .arg("--enable-rtdm")
        .arg("--enable-hrtimer")
        .arg("--with-rtai-dir=/usr/realtime")
        .arg("--with-linux-dir=/usr/src/linux")
        .status()
        .unwrap();
    Ok(())
}

It should run build.rs of my project first, and then run build.rs of ethercat-sys.
But in fact, build.rs of ethercat-sys is first.
Do you have any suggestions?

@birkenfeld
Copy link
Member

Hi, not really, other than that you could use the pregenerated-bindings (make sure you use the compatible version of the master), then the master is not needed at all.

@rise0chen
Copy link
Author

No, I not want to use pregenerated-bindings.

I have success to run this project by manual configure.
I run bootstrap , configure and set ETHERCAT_PATH env, then run cargo run, it can work.
I just wat to configure it by build.rs.

@birkenfeld
Copy link
Member

As far as I know, there is no way to have build.rs or anything else run before the dependencies build.rs.

@rise0chen
Copy link
Author

Can I call ethercat-sys/build.rs in my build.rs?

@birkenfeld
Copy link
Member

That wouldn't help since at that time ethercat-sys/build.rs already has run.

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

No branches or pull requests

2 participants