-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial support for building embedded ceph and calling it from a go cmd
- Loading branch information
Bassam Tabbara
committed
Jul 25, 2016
1 parent
b19e51f
commit fa4dc4e
Showing
10 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
bin/ | ||
tools/ | ||
vendor/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[submodule "ceph"] | ||
path = ceph | ||
url = [email protected]:quantum/ceph | ||
branch = wip-embedded-ceph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
ifeq ($(origin VERSION), undefined) | ||
VERSION != git describe --dirty --always | ||
endif | ||
|
||
REPOPATH = github.com/quantum/castle | ||
|
||
GOOS=$(shell go env GOOS) | ||
GOARCH=$(shell go env GOARCH) | ||
|
||
NPROCS:=1 | ||
ifeq ($(GOOS),linux) | ||
NPROCS:=$(shell grep -c ^processor /proc/cpuinfo) | ||
endif | ||
|
||
build: vendor ceph/build/lib/libcephd.a | ||
@for i in castled; do \ | ||
go build -o bin/$$i -installsuffix cgo -ldflags "-extldflags '-static' -linkmode external -X $(REPOPATH)/version.Version=$(VERSION)" ./cmd/$$i; \ | ||
done | ||
|
||
ceph/build/Makefile: | ||
git submodule update --init --recursive | ||
cd ceph && ./do_cmake.sh -DWITH_EMBEDDED=ON -DWITH_FUSE=OFF | ||
|
||
ceph/build/lib/libcephd.a: ceph/build/Makefile | ||
cd ceph/build && make -j$(NPROCS) cephd | ||
|
||
test: tools/glide | ||
go test --race $(shell ./tools/glide novendor) | ||
|
||
vet: tools/glide | ||
go vet $(shell ./tools/glide novendor) | ||
|
||
fmt: tools/glide | ||
go fmt $(shell ./tools/glide novendor) | ||
|
||
clean: | ||
rm -rf ./bin | ||
cd ceph/build && make clean | ||
|
||
cleanall: clean | ||
rm -rf bin tools vendor | ||
|
||
vendor: tools/glide | ||
./tools/glide install | ||
|
||
tools/glide: | ||
@echo "Downloading glide" | ||
mkdir -p tools | ||
curl -L https://github.com/Masterminds/glide/releases/download/v0.11.1/glide-v0.11.1-$(GOOS)-$(GOARCH).tar.gz | tar -xz -C tools | ||
mv tools/$(GOOS)-$(GOARCH)/glide tools/glide | ||
rm -r tools/$(GOOS)-$(GOARCH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Castle - Software Defined Storage | ||
|
Submodule ceph
updated
from c4da56 to d43b87
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package main | ||
|
||
// #cgo CFLAGS: -I${SRCDIR}/../../ceph/src/include | ||
// #cgo LDFLAGS: -L${SRCDIR}/../../ceph/build/lib -lcephd -lstdc++ | ||
// #include "cephd/libcephd.h" | ||
import "C" | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/quantum/castle/version" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func CephVersion() (string) { | ||
var c_major, c_minor, c_patch C.int | ||
return C.GoString(C.ceph_version(&c_major,&c_minor,&c_patch)) | ||
} | ||
|
||
func main() { | ||
|
||
var cmdVersion = &cobra.Command{ | ||
Use: "version", | ||
Short: "print castle version", | ||
Long: `prints the version of castle.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Printf("castled version %v (ceph version %v)\n", version.Version, CephVersion()) | ||
}, | ||
} | ||
|
||
var rootCmd = &cobra.Command{Use: "castled"} | ||
rootCmd.AddCommand(cmdVersion) | ||
rootCmd.Execute() | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package: github.com/quantum/castle | ||
import: | ||
- package: github.com/spf13/cobra | ||
subpackages: | ||
- cobra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package version | ||
|
||
var Version = "0.0.0" |