Guest User

Untitled

a guest
Oct 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. cc::Build::new()
  2.     .file("src/foo.c")
  3. .shared_flag(true)
  4. .compile("libfoo.so");
  5.  
  6. # specially recognized by Cargo
  7. cargo:rustc-link-lib=static=foo
  8. cargo:rustc-link-search=native=/path/to/foo
  9. cargo:rustc-cfg=foo
  10. cargo:rustc-env=FOO=bar
  11. # arbitrary user-defined metadata
  12. cargo:root=/path/to/foo
  13. cargo:libdir=/path/to/foo/lib
  14. cargo:include=/path/to/foo/include
  15.  
  16. .
  17. ├── Cargo.toml
  18. ├── build.rs
  19. └── src
  20. └── main.rs
  21.  
  22. [package]
  23. # ...
  24. build = "build.rs"
  25.  
  26. fn main() {
  27. println!("cargo:rustc-link-search=native=/usr/lib");
  28. println!("cargo:rustc-link-lib=static=foo");
  29. }
  30.  
  31. use std::env;
  32. use std::fs;
  33. use std::path::Path;
  34.  
  35. fn main() {
  36.  
  37. // Get the output path
  38. let out_dir = env::var("OUT_DIR").unwrap();
  39.  
  40. // Copy *.dll & .lib to the output path
  41. let dll_src: String = String::from("./platforms/win/DynamsoftBarcodeReaderx64.dll");
  42. let dll_dest_path = Path::new(&out_dir).join("DynamsoftBarcodeReaderx64.dll");
  43. let _dll_result = fs::copy(dll_src, dll_dest_path);
  44.  
  45. let lib_src: String = String::from("./platforms/win/DBRx64.lib");
  46. let lib_dest_path = Path::new(&out_dir).join("DBRx64.lib");
  47. let _lib_result = fs::copy(lib_src, lib_dest_path);
  48.  
  49. println!("cargo:rustc-link-search={}", &out_dir);
  50. println!("cargo:rustc-link-lib=DBRx64");
  51. }
Add Comment
Please, Sign In to add comment