Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
require (
github.com/livekit/protocol v1.10.1
github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/gomake v0.0.14-alpha.5
github.com/openimsdk/gomake v0.0.15-alpha.11
github.com/openimsdk/protocol v0.0.72
github.com/openimsdk/tools v0.0.50-alpha.65
github.com/redis/go-redis/v9 v9.5.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/gomake v0.0.15-alpha.11 h1:PQudYDRESYeYlUYrrLLJhYIlUPO5x7FAx+o5El9U/Bw=
github.com/openimsdk/gomake v0.0.15-alpha.11/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
github.com/openimsdk/protocol v0.0.72 h1:K+vslwaR7lDXyBzb07UuEQITaqsgighz7NyXVIWsu6A=
github.com/openimsdk/protocol v0.0.72/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.50-alpha.65 h1:BRtxkyWxDWPHuHphSwEyHZj7kJSR98am/fHOH84naK8=
Expand Down
79 changes: 70 additions & 9 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,55 @@
package main

import (
"github.com/openimsdk/gomake/mageutil"
"flag"
"os"
"strings"

"github.com/openimsdk/gomake/mageutil"
)

var Default = Build

var Aliases = map[string]any{
"buildcc": BuildWithCustomConfig,
"startcc": StartWithCustomConfig,
}

var (
customRootDir = "." // workDir in mage, default is "./"(project root directory)
customSrcDir = "cmd" // source code directory, default is "cmd"
customOutputDir = "_output" // output directory, default is "_output"
customConfigDir = "config" // configuration directory, default is "config"
customToolsDir = "tools" // tools source code directory, default is "tools"
)

// Build support specifical binary build.
//
// Example: `mage build chat-api chat-rpc check-component`
func Build() {
platforms := os.Getenv("PLATFORMS")
if platforms == "" {
platforms = mageutil.DetectPlatform()
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}

for _, platform := range strings.Split(platforms, " ") {
mageutil.CompileForPlatform(platform)
mageutil.Build(bin, nil)
}

func BuildWithCustomConfig() {
flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}

config := &mageutil.PathOptions{
RootDir: &customRootDir,
OutputDir: &customOutputDir,
SrcDir: &customSrcDir,
ToolsDir: &customToolsDir,
}

mageutil.PrintGreen("All binaries under cmd and tools were successfully compiled.")
mageutil.Build(bin, config)
}

func Start() {
Expand All @@ -31,7 +62,37 @@ func Start() {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}
mageutil.StartToolsAndServices()

flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}

mageutil.StartToolsAndServices(bin, nil)
}

func StartWithCustomConfig() {
mageutil.InitForSSC()
err := setMaxOpenFiles()
if err != nil {
mageutil.PrintRed("setMaxOpenFiles failed " + err.Error())
os.Exit(1)
}

flag.Parse()
bin := flag.Args()
if len(bin) != 0 {
bin = bin[1:]
}

config := &mageutil.PathOptions{
RootDir: &customRootDir,
OutputDir: &customOutputDir,
ConfigDir: &customConfigDir,
}

mageutil.StartToolsAndServices(bin, config)
}

func Stop() {
Expand Down
Loading