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.5 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
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. cp "github.com/otiai10/copy"
  10. )
  11. const (
  12. BuildDir = "./build"
  13. )
  14. // [配置项]设置编译平台为windows
  15. func Win() {
  16. magefiles.Global.OS = "win"
  17. }
  18. // [配置项]设置编译平台为linux
  19. func Linux() {
  20. magefiles.Global.OS = "linux"
  21. }
  22. // [配置项]设置编译架构为amd64
  23. func AMD64() {
  24. magefiles.Global.Arch = "amd64"
  25. }
  26. func All() error {
  27. if err := Bin(); err != nil {
  28. return err
  29. }
  30. if err := Scripts(); err != nil {
  31. return err
  32. }
  33. if err := Confs(); err != nil {
  34. return err
  35. }
  36. return nil
  37. }
  38. func Bin() error {
  39. if err := Agent(); err != nil {
  40. return err
  41. }
  42. if err := Client(); err != nil {
  43. return err
  44. }
  45. if err := Coordinator(); err != nil {
  46. return err
  47. }
  48. if err := Scanner(); err != nil {
  49. return err
  50. }
  51. return nil
  52. }
  53. func Scripts() error {
  54. scriptsDir := "./common/assets/scripts"
  55. info, err := os.Stat(scriptsDir)
  56. if errors.Is(err, os.ErrNotExist) || !info.IsDir() {
  57. return fmt.Errorf("script directory not exists or is not a directory")
  58. }
  59. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "scripts"))
  60. if err != nil {
  61. return err
  62. }
  63. fmt.Printf("copying scripts to %s\n", fullDirPath)
  64. return cp.Copy(scriptsDir, fullDirPath)
  65. }
  66. func Confs() error {
  67. confDir := "./common/assets/confs"
  68. info, err := os.Stat(confDir)
  69. if errors.Is(err, os.ErrNotExist) || !info.IsDir() {
  70. return fmt.Errorf("conf directory not exists or is not a directory")
  71. }
  72. fullDirPath, err := filepath.Abs(filepath.Join(BuildDir, "confs"))
  73. if err != nil {
  74. return err
  75. }
  76. fmt.Printf("copying confs to %s\n", fullDirPath)
  77. return cp.Copy(confDir, fullDirPath)
  78. }
  79. func Agent() error {
  80. return magefiles.Build(magefiles.BuildArgs{
  81. OutputName: "agent",
  82. OutputDir: "agent",
  83. AssetsDir: "assets",
  84. EntryFile:"agent/main.go",
  85. })
  86. }
  87. func Client() error {
  88. return magefiles.Build(magefiles.BuildArgs{
  89. OutputName: "client",
  90. OutputDir: "client",
  91. AssetsDir: "assets",
  92. EntryFile:"client/main.go",
  93. })
  94. }
  95. func Coordinator() error {
  96. return magefiles.Build(magefiles.BuildArgs{
  97. OutputName: "coordinator",
  98. OutputDir: "coordinator",
  99. AssetsDir: "assets",
  100. EntryFile:"coordinator/main.go",
  101. })
  102. }
  103. func Scanner() error {
  104. return magefiles.Build(magefiles.BuildArgs{
  105. OutputName: "scanner",
  106. OutputDir: "scanner",
  107. AssetsDir: "assets",
  108. EntryFile:"scanner/main.go",
  109. })
  110. }

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