From c3e721f1450dbcc7d2c097a7bac75c5e14d8c727 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com>
Date: Fri, 18 Aug 2023 14:33:49 +0800
Subject: [PATCH] feat: save build scripts
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
---
scripts/build-all-service.sh | 16 +++++-----------
scripts/template/head.md.tmpl | 6 +++---
tools/changelog/changelog.go | 2 +-
tools/changelog/doc.go | 15 ---------------
tools/infra/doc.go | 15 ---------------
tools/infra/infra.go | 2 +-
tools/ncpu/doc.go | 15 ---------------
tools/ncpu/ncpu.go | 2 +-
tools/ncpu/ncpu_test.go | 2 +-
tools/yamlfmt/doc.go | 15 ---------------
tools/yamlfmt/yamlfmt.go | 2 +-
tools/yamlfmt/yamlfmt_test.go | 2 +-
12 files changed, 14 insertions(+), 80 deletions(-)
delete mode 100644 tools/changelog/doc.go
delete mode 100644 tools/infra/doc.go
delete mode 100644 tools/ncpu/doc.go
delete mode 100644 tools/yamlfmt/doc.go
diff --git a/scripts/build-all-service.sh b/scripts/build-all-service.sh
index ca3051534..ab35ad9b5 100755
--- a/scripts/build-all-service.sh
+++ b/scripts/build-all-service.sh
@@ -33,17 +33,11 @@ source "${OPENIM_ROOT}/scripts/lib/init.sh"
# Check the system type
system_type=$(uname)
-if [[ "$system_type" == "Darwin" ]]; then
- # macOS (using sysctl)
- cpu_count=$(sysctl -n hw.ncpu)
-elif [[ "$system_type" == "Linux" ]]; then
- # Linux (using lscpu)
- cpu_count=$(lscpu --parse | grep -E '^([^#].*,){3}[^#]' | sort -u | wc -l)
-else
- echo "Unsupported operating system: $system_type"
- exit 1
-fi
-echo -e "${GREEN_PREFIX}======> cpu_count=$cpu_count${COLOR_SUFFIX}"
+pushd "${OPENIM_ROOT}/tools/ncpu" >/dev/null
+ cpu_count=$(go run .)
+popd >/dev/null
+
+openim::color::echo ${GREEN_PREFIX} "======> cpu_count=$cpu_count"
openim::log::info "Building OpenIM, Parallel compilation compile=$cpu_count"
compile_count=$((cpu_count / 2))
diff --git a/scripts/template/head.md.tmpl b/scripts/template/head.md.tmpl
index 45414709b..4aba97556 100644
--- a/scripts/template/head.md.tmpl
+++ b/scripts/template/head.md.tmpl
@@ -17,7 +17,7 @@ Learn more about versions of OpenIM:
-
+
@@ -27,5 +27,5 @@ Learn more about versions of OpenIM:
> **Note**
> @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively.
> Thanks to the @openimsdk/openim team for all their hard work on this release.
-> Thank you to all the [💕developers and contributors](https://github.com/OpenIMSDK/Open-IM-Server/graphs/contributors), people from all over the world, OpenIM brings us together
-> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/OpenIMSDK/Open-IM-Server/blob/main/CONTRIBUTING.md) for details.
\ No newline at end of file
+> Thank you to all the [💕developers and contributors](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/graphs/contributors), people from all over the world, OpenIM brings us together
+> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/CONTRIBUTING.md) for details.
\ No newline at end of file
diff --git a/tools/changelog/changelog.go b/tools/changelog/changelog.go
index d6e855a22..7428db5fa 100644
--- a/tools/changelog/changelog.go
+++ b/tools/changelog/changelog.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package changelog
+package main
import (
"fmt"
diff --git a/tools/changelog/doc.go b/tools/changelog/doc.go
deleted file mode 100644
index 7f5e13e28..000000000
--- a/tools/changelog/doc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package changelog // import "github.com/OpenIMSDK/Open-IM-Server/tools/changelog"
diff --git a/tools/infra/doc.go b/tools/infra/doc.go
deleted file mode 100644
index 369d4dd8b..000000000
--- a/tools/infra/doc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package infra // import "github.com/OpenIMSDK/Open-IM-Server/tools/infra"
diff --git a/tools/infra/infra.go b/tools/infra/infra.go
index 8068c85ca..cc20a17c7 100644
--- a/tools/infra/infra.go
+++ b/tools/infra/infra.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package infra
+package main
import (
"fmt"
diff --git a/tools/ncpu/doc.go b/tools/ncpu/doc.go
deleted file mode 100644
index 5a4243b5c..000000000
--- a/tools/ncpu/doc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package ncpu // import "github.com/OpenIMSDK/Open-IM-Server/tools/ncpu"
diff --git a/tools/ncpu/ncpu.go b/tools/ncpu/ncpu.go
index 2604d87b2..7ca3dff5e 100644
--- a/tools/ncpu/ncpu.go
+++ b/tools/ncpu/ncpu.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package ncpu
+package main
import (
"fmt"
diff --git a/tools/ncpu/ncpu_test.go b/tools/ncpu/ncpu_test.go
index 0c5bb9a70..f24203226 100644
--- a/tools/ncpu/ncpu_test.go
+++ b/tools/ncpu/ncpu_test.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package ncpu
+package main
import "testing"
diff --git a/tools/yamlfmt/doc.go b/tools/yamlfmt/doc.go
deleted file mode 100644
index 2a1276a53..000000000
--- a/tools/yamlfmt/doc.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright © 2023 OpenIM. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package yamlfmt // import "github.com/OpenIMSDK/Open-IM-Server/tools/yamlfmt"
diff --git a/tools/yamlfmt/yamlfmt.go b/tools/yamlfmt/yamlfmt.go
index dc7c2076d..4bad00fca 100644
--- a/tools/yamlfmt/yamlfmt.go
+++ b/tools/yamlfmt/yamlfmt.go
@@ -13,7 +13,7 @@
// limitations under the License.
// OPENIM plan on prow tools
-package yamlfmt
+package main
import (
"flag"
diff --git a/tools/yamlfmt/yamlfmt_test.go b/tools/yamlfmt/yamlfmt_test.go
index 85017e449..481eee2bc 100644
--- a/tools/yamlfmt/yamlfmt_test.go
+++ b/tools/yamlfmt/yamlfmt_test.go
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package yamlfmt
+package main
import (
"bufio"