From a75fe4d85e75887251cd52ad5bf1cfc0cb4499ca Mon Sep 17 00:00:00 2001 From: Mervin Date: Wed, 11 Mar 2020 13:11:26 +0800 Subject: [PATCH] Add: init package and build script for cli tool Signed-off-by: Mervin --- Makefile | 13 ++++++++++--- build/build.sh | 26 ++++++++++++++++++++++---- cli/main.go | 19 +++++++++++++++++++ master/mocktest/data_server.go | 14 ++++++++++++++ master/mocktest/meta_server.go | 14 ++++++++++++++ 5 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 cli/main.go diff --git a/Makefile b/Makefile index df8cfe274..bc33eb532 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BIN_SERVER := $(BIN_PATH)/cfs-server BIN_CLIENT := $(BIN_PATH)/cfs-client BIN_CLIENT2 := $(BIN_PATH)/cfs-client2 BIN_AUTHTOOL := $(BIN_PATH)/cfs-authtool +BIN_CLI := $(BIN_PATH)/cfs-cli COMMON_SRC := build/build.sh Makefile COMMON_SRC += $(wildcard storage/*.go util/*/*.go util/*.go repl/*.go raftstore/*.go proto/*.go) @@ -13,6 +14,7 @@ SERVER_SRC := $(wildcard cmd/*.go authnode/*.go datanode/*.go master/*.go metano CLIENT_SRC := $(wildcard client/*.go client/fs/*.go sdk/*.go) CLIENT2_SRC := $(wildcard clientv2/*.go clientv2/fs/*.go sdk/*.go) AUTHTOOL_SRC := $(wildcard authtool/*.go) +CLI_SRC := $(wildcard cli/*.go) RM := $(shell [ -x /bin/rm ] && echo "/bin/rm -rf" || echo "/usr/bin/rm -rf" ) @@ -21,8 +23,8 @@ default: all phony := all all: build -phony += build server authtool client client2 -build: server authtool client +phony += build server authtool client client2 cli +build: server authtool client cli server: $(BIN_SERVER) @@ -32,7 +34,9 @@ client2: $(BIN_CLIENT2) authtool: $(BIN_AUTHTOOL) -$(BIN_SERVER): $(COMMON_SRC) ${SERVER_SRC} +cli: $(BIN_CLI) + +$(BIN_SERVER): $(COMMON_SRC) $(SERVER_SRC) @build/build.sh server $(BIN_CLIENT): $(COMMON_SRC) $(CLIENT_SRC) @@ -44,6 +48,9 @@ $(BIN_CLIENT2): $(COMMON_SRC) $(CLIENT2_SRC) $(BIN_AUTHTOOL): $(COMMON_SRC) $(AUTHTOOL_SRC) @build/build.sh authtool +$(BIN_CLI): $(COMMON_SRC) $(CLI_SRC) + @build/build.sh cli + phony += clean clean: @$(RM) build/bin diff --git a/build/build.sh b/build/build.sh index 346b87a64..8273ccaad 100755 --- a/build/build.sh +++ b/build/build.sh @@ -19,7 +19,14 @@ GCC_LIBRARY_PATH="/lib /lib64 /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib6 cgo_cflags="" cgo_ldflags="-lstdc++ -lm" -[ $(uname -s) != "Linux" ] && { echo "ChubaoFS only support Linux os"; exit 1; } +case $(uname -s | tr 'A-Z' 'a-z') in + "linux"|"darwin") + ;; + *) + echo "Current platform $(uname -s) not support"; + exit1; + ;; +esac build_snappy() { found=$(find ${GCC_LIBRARY_PATH} -name libsnappy.a -o -name libsnappy.so 2>/dev/null | wc -l) @@ -101,7 +108,7 @@ run_test() { build_server() { pre_build pushd $SrcPath >/dev/null - echo -n "build cfs-server " + echo -n "build cfs-server " go build $MODFLAGS -ldflags "${LDFlags}" -o ${BuildBinPath}/cfs-server ${SrcPath}/cmd/*.go && echo "success" || echo "failed" popd >/dev/null } @@ -109,7 +116,7 @@ build_server() { build_client() { pre_build pushd $SrcPath >/dev/null - echo -n "build cfs-client " + echo -n "build cfs-client " go build $MODFLAGS -ldflags "${LDFlags}" -o ${BuildBinPath}/cfs-client ${SrcPath}/client/*.go && echo "success" || echo "failed" popd >/dev/null } @@ -117,7 +124,7 @@ build_client() { build_client2() { pre_build pushd $SrcPath >/dev/null - echo -n "build cfs-client2 " + echo -n "build cfs-client2 " go build $MODFLAGS -ldflags "${LDFlags}" -o ${BuildBinPath}/cfs-client2 ${SrcPath}/clientv2/*.go && echo "success" || echo "failed" popd >/dev/null } @@ -130,6 +137,14 @@ build_authtool() { popd >/dev/null } +build_cli() { + pre_build + pushd $SrcPath >/dev/null + echo -n "build cfs-cli " + go build $MODFLAGS -ldflags "${LDFlags}" -o ${BuildBinPath}/cfs-cli ${SrcPath}/cli/*.go && echo "success" || echo "failed" + popd >/dev/null +} + clean() { rm -rf ${BuildBinPath} } @@ -161,6 +176,9 @@ case "$cmd" in "authtool") build_authtool ;; + "cli") + build_cli + ;; "clean") clean ;; diff --git a/cli/main.go b/cli/main.go new file mode 100644 index 000000000..0b06bc234 --- /dev/null +++ b/cli/main.go @@ -0,0 +1,19 @@ +// Copyright 2018 The Chubao Authors. +// +// 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 main + +func main() { + +} diff --git a/master/mocktest/data_server.go b/master/mocktest/data_server.go index 3fd0e12dd..073335d49 100644 --- a/master/mocktest/data_server.go +++ b/master/mocktest/data_server.go @@ -1,3 +1,17 @@ +// Copyright 2018 The Chubao Authors. +// +// 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 mocktest import ( diff --git a/master/mocktest/meta_server.go b/master/mocktest/meta_server.go index b8beaa25e..514b2a212 100644 --- a/master/mocktest/meta_server.go +++ b/master/mocktest/meta_server.go @@ -1,3 +1,17 @@ +// Copyright 2018 The Chubao Authors. +// +// 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 mocktest import (