diff --git a/build.rs b/build.rs index 9c6cd4c..ed566a1 100644 --- a/build.rs +++ b/build.rs @@ -1,54 +1,74 @@ fn main() { - cxx_build::bridge("src/lib.rs") - .file("src/Applet.cpp") - .file("src/BossaObserver.cpp") - .file("src/D2xNvmFlash.cpp") - .file("src/D5xNvmFlash.cpp") - .file("src/Device.cpp") - .file("src/EefcFlash.cpp") - .file("src/EfcFlash.cpp") - .file("src/Flash.cpp") - .file("src/Flasher.cpp") - .file("src/LinuxPortFactory.cpp") - .file("src/PortFactory.cpp") - .file("src/PosixSerialPort.cpp") - .file("src/Samba.cpp") - .file("src/WordCopyApplet.cpp") - .file("src/WordCopyArm.cpp") - //.file("src/") - .flag_if_supported("-std=c++14") - .compile("bossa"); + let cpp_files = vec![ + "src/Applet.cpp", + "src/BossaObserver.cpp", + "src/D2xNvmFlash.cpp", + "src/D5xNvmFlash.cpp", + "src/Device.cpp", + "src/EefcFlash.cpp", + "src/EfcFlash.cpp", + "src/Flash.cpp", + "src/Flasher.cpp", + #[cfg(target_os = "linux")] + "src/LinuxPortFactory.cpp", + #[cfg(target_os = "macos")] + "src/OSXPortFactory.cpp", + "src/PortFactory.cpp", + #[cfg(any(target_os = "linux", target_os = "macos"))] + "src/PosixSerialPort.cpp", + "src/Samba.cpp", + #[cfg(target_os = "windows")] + "src/WinPortFactory.cpp", + #[cfg(target_os = "windows")] + "src/WinSerialPort.cpp", + "src/WordCopyApplet.cpp", + "src/WordCopyArm.cpp", + ]; + let h_files = vec![ + "src/Applet.h", + "src/BossaObserver.h", + "src/D2xNvmFlash.h", + "src/D5xNvmFlash.h", + "src/Device.h", + "src/EefcFlash.h", + "src/EfcFlash.h", + "src/Flash.h", + "src/Flasher.h", + #[cfg(target_os = "linux")] + "src/LinuxPortFactory.h", + #[cfg(target_os = "macos")] + "src/OSXPortFactory.h", + "src/PortFactory.h", + #[cfg(any(target_os = "linux", target_os = "macos"))] + "src/PosixSerialPort.h", + "src/Samba.h", + "src/SerialPort.h", + #[cfg(target_os = "windows")] + "src/WinPortFactory.h", + #[cfg(target_os = "windows")] + "src/WinSerialPort.h", + "src/WordCopyApplet.h", + "src/WordCopyArm.h", + ]; + let rs_files = vec![ + "src/lib.rs", + ]; - // TODO Platform specific files - println!("cargo:rerun-if-changed=src/main.rs"); - println!("cargo:rerun-if-changed=src/Applet.cpp"); - println!("cargo:rerun-if-changed=src/Applet.h"); - println!("cargo:rerun-if-changed=src/BossaObserver.cpp"); - println!("cargo:rerun-if-changed=src/BossaObserver.h"); - println!("cargo:rerun-if-changed=src/D2xNvmFlash.cpp"); - println!("cargo:rerun-if-changed=src/D2xNvmFlash.h"); - println!("cargo:rerun-if-changed=src/D5xNvmFlash.cpp"); - println!("cargo:rerun-if-changed=src/D5xNvmFlash.h"); - println!("cargo:rerun-if-changed=src/Device.cpp"); - println!("cargo:rerun-if-changed=src/Device.h"); - println!("cargo:rerun-if-changed=src/EefcFlash.cpp"); - println!("cargo:rerun-if-changed=src/EefcFlash.h"); - println!("cargo:rerun-if-changed=src/EfcFlash.cpp"); - println!("cargo:rerun-if-changed=src/EfcFlash.h"); - println!("cargo:rerun-if-changed=src/Flash.cpp"); - println!("cargo:rerun-if-changed=src/Flash.h"); - println!("cargo:rerun-if-changed=src/Flasher.cpp"); - println!("cargo:rerun-if-changed=src/Flasher.h"); - println!("cargo:rerun-if-changed=src/LinuxPortFactory.cpp"); - println!("cargo:rerun-if-changed=src/PortFactory.cpp"); - println!("cargo:rerun-if-changed=src/PortFactory.h"); - println!("cargo:rerun-if-changed=src/PosixSerialPort.cpp"); - println!("cargo:rerun-if-changed=src/PosixSerialPort.h"); - println!("cargo:rerun-if-changed=src/Samba.cpp"); - println!("cargo:rerun-if-changed=src/Samba.h"); - println!("cargo:rerun-if-changed=src/SerialPort.h"); - println!("cargo:rerun-if-changed=src/WordCopyApplet.cpp"); - println!("cargo:rerun-if-changed=src/WordCopyApplet.h"); - println!("cargo:rerun-if-changed=src/WordCopyArm.cpp"); - println!("cargo:rerun-if-changed=src/WordCopyArm.h"); + // Setup cxx build + // cpp files to watch + build + // h files to watch + // rs files to watch + let mut build = cxx_build::bridge("src/lib.rs"); + for cpp in cpp_files { + build.file(cpp); + println!("cargo:rerun-if-changed={}", cpp); + } + for h in h_files { + println!("cargo:rerun-if-changed={}", h); + } + for rs in rs_files { + println!("cargo:rerun-if-changed={}", rs); + } + build.flag_if_supported("-std=c++14") + .compile("bossa"); }