desktop.toml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # cargo make --profile production task
  2. # Run the task with profile, e.g.
  3. # cargo make --profile development-mac flowy-sdk-dev
  4. # cargo make --profile production-windows-x86 flowy-sdk-dev
  5. [tasks.env_check]
  6. dependencies = ["echo_env", "install_protobuf"]
  7. condition = { env_set = [ "BUILD_FLAG", "RUST_COMPILE_TARGET", "CRATE_TYPE", "TARGET_OS"], channels = ["stable"] }
  8. [tasks.flowy-sdk-dev]
  9. mac_alias = "flowy-sdk-dev-macos"
  10. windows_alias = "flowy-sdk-dev-windows"
  11. linux_alias = "flowy-sdk-dev-linux"
  12. [tasks.flowy-sdk-dev-android]
  13. category = "Build"
  14. dependencies = ["env_check"]
  15. run_task = { name = ["setup-crate-type","sdk-build-android", "restore-crate-type"] }
  16. [tasks.flowy-sdk-dev-macos]
  17. category = "Build"
  18. dependencies = ["env_check"]
  19. run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] }
  20. [tasks.flowy-sdk-dev-windows]
  21. category = "Build"
  22. dependencies = ["env_check"]
  23. run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] }
  24. [tasks.flowy-sdk-dev-linux]
  25. category = "Build"
  26. dependencies = ["env_check"]
  27. run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] }
  28. #
  29. [tasks.sdk-build]
  30. private = true
  31. script = [
  32. """
  33. cd rust-lib/
  34. rustup show
  35. echo cargo build --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FEATURES}"
  36. cargo build --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FEATURES}"
  37. cd ../
  38. """,
  39. ]
  40. script_runner = "@shell"
  41. [tasks.sdk-build-android]
  42. private = true
  43. script = [
  44. """
  45. cd rust-lib/
  46. rustup show
  47. rustup target add aarch64-linux-android \
  48. armv7-linux-androideabi \
  49. i686-linux-android \
  50. x86_64-linux-android
  51. DEST=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/android/app/src/main/jniLibs
  52. rm -rf $DEST/arm64-v8a \
  53. $DEST/armeabi-v7a \
  54. $DEST/x86 \
  55. $DEST/x86_64
  56. cargo ndk \
  57. -t arm64-v8a \
  58. -t armeabi-v7a \
  59. -t x86 \
  60. -t x86_64 \
  61. -o $DEST build
  62. cd ../
  63. """,
  64. ]
  65. script_runner = "@shell"
  66. [tasks.sdk-build.windows]
  67. private = true
  68. script = [
  69. """
  70. cd rust-lib
  71. exec cargo build --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FEATURES}"
  72. cd ..
  73. """,
  74. ]
  75. script_runner = "@duckscript"
  76. #
  77. [tasks.flowy-sdk-release]
  78. description = "Build flowy sdk in release mode"
  79. category = "Build"
  80. dependencies = ["env_check"]
  81. run_task = { name = ["setup-crate-type","sdk-release-build", "post-desktop", "restore-crate-type"] }
  82. #
  83. [tasks.sdk-release-build]
  84. script = [
  85. """
  86. cd rust-lib/
  87. cargo build --${BUILD_FLAG} --package=dart-ffi --target ${RUST_COMPILE_TARGET} --features "${FEATURES}"
  88. cd ../
  89. """,
  90. ]
  91. script_runner = "@shell"
  92. #
  93. [tasks.post-desktop]
  94. mac_alias = "post-desktop-macos"
  95. windows_alias = "post-desktop-windows"
  96. linux_alias = "post-desktop-linux"
  97. [tasks.post-desktop-macos]
  98. private = true
  99. script = [
  100. """
  101. echo "🚀 🚀 🚀 Flowy-SDK(macOS) build success"
  102. dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/${TARGET_OS}
  103. lib = set lib${LIB_NAME}.${SDK_EXT}
  104. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \
  105. ${dart_ffi_dir}/${lib}
  106. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
  107. ${dart_ffi_dir}/Classes/binding.h
  108. """,
  109. ]
  110. script_runner = "@duckscript"
  111. [tasks.post-desktop-windows]
  112. private = true
  113. script = [
  114. """
  115. echo "🚀 🚀 🚀 Flowy-SDK(windows) build success"
  116. dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/windows/flutter/dart_ffi
  117. lib = set ${LIB_NAME}.${SDK_EXT}
  118. # copy dll
  119. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \
  120. ${dart_ffi_dir}/${lib}
  121. # copy binding.h
  122. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
  123. ${dart_ffi_dir}/binding.h
  124. """,
  125. ]
  126. script_runner = "@duckscript"
  127. [tasks.post-desktop-linux]
  128. private = true
  129. script = [
  130. """
  131. echo "🚀 🚀 🚀 Flowy-SDK(linux) build success"
  132. dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/linux/flutter/dart_ffi
  133. lib = set lib${LIB_NAME}.${SDK_EXT}
  134. # copy dll
  135. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \
  136. ${dart_ffi_dir}/${lib}
  137. # copy binding.h
  138. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \
  139. ${dart_ffi_dir}/binding.h
  140. """,
  141. ]
  142. script_runner = "@duckscript"
  143. [tasks.copy-to-sys-tmpdir]
  144. private = true
  145. script = [
  146. """
  147. # Copy the flowy_sdk lib to system temp directory for flutter unit test.
  148. lib = set lib${LIB_NAME}.${SDK_EXT}
  149. dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/.sandbox/${lib}
  150. rm ${dest}
  151. cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \
  152. ${dest}
  153. """,
  154. ]
  155. script_runner = "@duckscript"
  156. [tasks.copy-to-sys-tmpdir.windows]
  157. private = true
  158. script = [
  159. """
  160. # Doesn't work on windows
  161. """,
  162. ]
  163. script_runner = "@duckscript"