build.rs 587 B

12345678910111213141516171819
  1. // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
  2. // SPDX-License-Identifier: Apache-2.0
  3. // SPDX-License-Identifier: MIT
  4. // creates a cfg alias if `has_feature` is true.
  5. // `alias` must be a snake case string.
  6. fn alias(alias: &str, has_feature: bool) {
  7. println!("cargo:rustc-check-cfg=cfg({alias})");
  8. if has_feature {
  9. println!("cargo:rustc-cfg={alias}");
  10. }
  11. }
  12. fn main() {
  13. let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
  14. let mobile = target_os == "ios" || target_os == "android";
  15. alias("desktop", !mobile);
  16. alias("mobile", mobile);
  17. }