build.rs 537 B

123456789101112131415161718
  1. // Copyright 2019-2024 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. if has_feature {
  8. println!("cargo:rustc-cfg={alias}");
  9. }
  10. }
  11. fn main() {
  12. let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
  13. let mobile = target_os == "ios" || target_os == "android";
  14. alias("desktop", !mobile);
  15. alias("mobile", mobile);
  16. }