jabber-tools / cognitive-services-speech-sdk-rs

Apache License 2.0
24 stars 15 forks source link

Add support for Windows #14

Closed wangfu91 closed 5 months ago

wangfu91 commented 5 months ago

https://github.com/rust-lang/rust-bindgen/issues/1966

bindgen generate different type for enums on Windows, i32 vs the u32 on Linux & macOS, so I have to use conditional compilation, e.g.

#[cfg(not(target_os = "windows"))]
 let compressed_format = compressed_format.to_u32();
#[cfg(target_os = "windows")]
let compressed_format = compressed_format.to_i32();
adambezecny commented 5 months ago

hi,

on windows download function must be extended with --ssl-no-revoke otherwise getting error, see here:

https://stackoverflow.com/questions/54938026/curl-unknown-error-0x80092012-the-revocation-function-was-unable-to-check-r

so something like

fn download_file(url: &str, dst: &str) {
    Command::new("curl")
        .args(["-SL", url, "-o", dst, "--ssl-no-revoke"])
        .status()
        .expect("failed to download Speech SDK!");
}
adambezecny commented 5 months ago

now getting this error

image

Seems unziping nuget package did not work, sdk_output folder is empty. then it fails on trying to include header files.

PS C:\Users\adamb\dev\cognitive-services-speech-sdk-rs> cargo build
   Compiling cognitive-services-speech-sdk-rs v0.3.0 (C:\Users\adamb\dev\cognitive-services-speech-sdk-rs)
error: failed to run custom build command for `cognitive-services-speech-sdk-rs v0.3.0 (C:\Users\adamb\dev\cognitive-services-speech-sdk-rs)`                                                            

Caused by:
  process didn't exit successfully: `C:\Users\adamb\dev\cognitive-services-speech-sdk-rs\target\debug\build\cognitive-services-speech-sdk-rs-393b2365d58666af\build-script-build` (exit code: 101)        
  --- stdout
  cargo:rustc-link-search=native=C:\Users\adamb\dev\cognitive-services-speech-sdk-rs\target\debug\build\cognitive-services-speech-sdk-rs-b9c946c378fbb4f1\out\sdk_output\build\native\x64\Release
  cargo:rustc-link-lib=dylib=Microsoft.CognitiveServices.Speech.core

  --- stderr
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
100   201    0   201    0     0    270      0 --:--:-- --:--:-- --:--:--   271
100 95.8M  100 95.8M    0     0  4433k      0  0:00:22  0:00:22 --:--:-- 3791k
  c_api/wrapper.h:7:10: fatal error: 'speechapi_c.h' file not found
  thread 'main' panicked at build.rs:286:10:
  Unable to generate bindings: ClangDiagnostic("c_api/wrapper.h:7:10: fatal error: 'speechapi_c.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PS C:\Users\adamb\dev\cognitive-services-speech-sdk-rs>
wangfu91 commented 5 months ago

Seems unziping nuget package did not work, sdk_output folder is empty. then it fails on trying to include header files.

Could you please try cargo clean then cargo build again? I suspect that the NuGet package was not fully downloaded.

adambezecny commented 5 months ago

you are right, cargo clean did help, just don't forget to include , "--ssl-no-revoke" in download_file function.

adambezecny commented 5 months ago

other than that this looks good, give me couple of days to run some tests. I will try to merge this within one week time. thanks! really excited about having windows support finally.

wangfu91 commented 5 months ago

just don't forget to include , "--ssl-no-revoke" in download_file function.

Done.