desktop.toml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. [tasks.desktop]
  2. category = "Build"
  3. dependencies = ["cqrs_gen", "desktop-debug", "desktop-release", "post-desktop"]
  4. description = "Build desktop targets"
  5. [tasks.desktop-debug]
  6. condition = { env_true = ["DEV"] }
  7. env = { DESKTOP_TARGET = "x86_64-apple-darwin" }
  8. private = true
  9. run_task = { name = ["desktop-build", "post-desktop-dylib-to-system"] }
  10. [tasks.desktop-release]
  11. condition = { env_true = ["RELEASE"] }
  12. env = { DESKTOP_TARGET = "x86_64-apple-darwin" }
  13. private = true
  14. run_task = "desktop-build"
  15. [tasks.desktop-build]
  16. # args = ["build", "--target", "${DESKTOP_TARGET}"]
  17. category = "Build"
  18. # command = "cargo"
  19. condition = { platforms = ["mac"], env_true = ["DEV"] }
  20. dependencies = ["export-env", "setup-crate-type-macos"]
  21. description = "Build desktop targets."
  22. script = [
  23. """
  24. cd rust-lib/
  25. cargo build --package=flowy-ffi --target ${DESKTOP_TARGET}
  26. cd ../
  27. """,
  28. ]
  29. [tasks.post-desktop]
  30. condition = { platforms = ["mac"] }
  31. dependencies = ["restore-crate-type"]
  32. script = [
  33. """
  34. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \
  35. ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
  36. """,
  37. """
  38. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
  39. ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_sdk/macos/Classes/binding.h
  40. """,
  41. ]
  42. script_runner = "@duckscript"
  43. [tasks.setup-crate-type-macos]
  44. env = { TARGET_OS = "macos" }
  45. private = true
  46. run_task = "setup-crate-type"
  47. [tasks.export-env]
  48. script = [
  49. """
  50. # Try to fix the issue
  51. # ld: warning: dylib (/Users/vedon/Documents/Private/RustProject/App-Flowy/app_flowy/flutter-lib/packages/flowy_sdk/macos/libflowy_ffi.dylib) was built for newer macOS version (10.15) than being linked (10.11)
  52. # ld: warning: dylib (/Users/vedon/Documents/Private/RustProject/App-Flowy/app_flowy/flutter-lib/packages/flowy_sdk/macos/libflowy_ffi.dylib) was built for newer macOS version (10.15) than being linked (10.11)
  53. # https://users.rust-lang.org/t/compile-rust-binary-for-older-versions-of-mac-osx/38695/3
  54. # https://stackoverflow.com/questions/43216273/object-file-was-built-for-newer-osx-version-than-being-linked
  55. export MACOSX_DEPLOYMENT_TARGET=10.11
  56. """,
  57. ]
  58. script_runner = "@shell"
  59. [tasks.post-desktop-dylib-to-system]
  60. condition = { platforms = ["mac"] }
  61. script = [
  62. """
  63. target_path = set ${TMPDIR}/app_flowy/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
  64. echo "remove old dylib"
  65. rm ${target_path}
  66. echo "copy new dylib to system"
  67. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${target_path}
  68. """,
  69. ]
  70. script_runner = "@duckscript"
  71. [tasks.clean-flowy-sdk]
  72. condition = { platforms = ["mac"] }
  73. script = [
  74. """
  75. cd ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_sdk
  76. flutter clean
  77. """,
  78. ]
  79. script_runner = "@shell"
  80. [tasks.cqrs_gen]
  81. script = [
  82. """
  83. manifest_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/scripts/tool/rust-tool/Cargo.toml
  84. cqrs_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/flowy-store/src/entities/command.rs
  85. output_file=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/flutter-lib/packages/flowy_sdk/lib/cqrs/auto_gen.dart
  86. cargo run --manifest-path ${manifest_path} flutter --cqrs=${cqrs_file} --output=${output_file}
  87. """,
  88. ]
  89. script_runner = "@shell"