You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.go 2.1 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //go:build mage
  2. package main
  3. import (
  4. "errors"
  5. "fmt"
  6. "os"
  7. "path/filepath"
  8. "gitlink.org.cn/cloudream/common/magefiles"
  9. //mage:import
  10. _ "gitlink.org.cn/cloudream/common/magefiles/targets"
  11. cp "github.com/otiai10/copy"
  12. )
  13. const (
  14. BuildDir = "./build"
  15. )
  16. func All() error {
  17. if err := Bin(); err != nil {
  18. return err
  19. }
  20. if err := Scripts(); err != nil {
  21. return err
  22. }
  23. if err := Confs(); err != nil {
  24. return err
  25. }
  26. return nil
  27. }
  28. func Bin() error {
  29. if err := Hub(); err != nil {
  30. return err
  31. }
  32. if err := Client(); err != nil {
  33. return err
  34. }
  35. if err := Coordinator(); err != nil {
  36. return err
  37. }
  38. return nil
  39. }
  40. func Scripts() error {
  41. scriptsDir := "./common/assets/scripts"
  42. info, err := os.Stat(scriptsDir)
  43. if errors.Is(err, os.ErrNotExist) {
  44. fmt.Printf("no scripts.\n")
  45. return nil
  46. }
  47. if !info.IsDir() {
  48. return fmt.Errorf("scripts is not a directory")
  49. }
  50. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "scripts"))
  51. if err != nil {
  52. return err
  53. }
  54. fmt.Printf("copying scripts to %s\n", fullDirPath)
  55. return cp.Copy(scriptsDir, fullDirPath)
  56. }
  57. func Confs() error {
  58. confDir := "./common/assets/confs"
  59. info, err := os.Stat(confDir)
  60. if errors.Is(err, os.ErrNotExist) {
  61. fmt.Printf("no confs.\n")
  62. return nil
  63. }
  64. if !info.IsDir() {
  65. return fmt.Errorf("confs is not a directory")
  66. }
  67. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "confs"))
  68. if err != nil {
  69. return err
  70. }
  71. fmt.Printf("copying confs to %s\n", fullDirPath)
  72. return cp.Copy(confDir, fullDirPath)
  73. }
  74. func Hub() error {
  75. return magefiles.Build(magefiles.BuildArgs{
  76. OutputName: "hub",
  77. OutputDir: "hub",
  78. AssetsDir: "assets",
  79. EntryFile: "hub/main.go",
  80. })
  81. }
  82. func Client() error {
  83. return magefiles.Build(magefiles.BuildArgs{
  84. OutputName: "client",
  85. OutputDir: "client",
  86. AssetsDir: "assets",
  87. EntryFile: "client/main.go",
  88. })
  89. }
  90. func Coordinator() error {
  91. return magefiles.Build(magefiles.BuildArgs{
  92. OutputName: "coordinator",
  93. OutputDir: "coordinator",
  94. AssetsDir: "assets",
  95. EntryFile: "coordinator/main.go",
  96. })
  97. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。