2017-05-26 04:48:44 +08:00
#
# include.mk
#
# This source file is part of the FoundationDB open source project
#
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
2018-02-22 02:25:11 +08:00
#
2017-05-26 04:48:44 +08:00
# 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
2018-02-22 02:25:11 +08:00
#
2017-05-26 04:48:44 +08:00
# http://www.apache.org/licenses/LICENSE-2.0
2018-02-22 02:25:11 +08:00
#
2017-05-26 04:48:44 +08:00
# 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.
#
TARGETS += fdb_go fdb_go_tester
CLEAN_TARGETS += fdb_go_clean fdb_go_tester_clean
2017-07-06 05:59:00 +08:00
GOPATH := $( CURDIR) /bindings/go/build
GO_IMPORT_PATH := github.com/apple/foundationdb/bindings/go/src
GO_DEST := $( GOPATH) /src/$( GO_IMPORT_PATH)
2018-03-31 02:16:19 +08:00
.PHONY : fdb_go fdb_go_path fdb_go_fmt fdb_go_fmt_check fdb_go_tester fdb_go_tester_clean
2017-05-26 04:48:44 +08:00
# We only override if the environment didn't set it (this is used by
# the fdbwebsite documentation build process)
GODOC_DIR ?= bindings/go
CGO_CFLAGS := -I$( CURDIR) /bindings/c
CGO_LDFLAGS := -L$( CURDIR) /lib
i f e q ( $( PLATFORM ) , l i n u x )
GOPLATFORM := linux_amd64
e l s e i f e q ( $( PLATFORM ) , o s x )
GOPLATFORM := darwin_amd64
e l s e
$( error Not prepared to compile on platform $( PLATFORM) )
e n d i f
2017-07-06 05:59:00 +08:00
GO_PACKAGE_OUTDIR := $( GOPATH) /pkg/$( GOPLATFORM) /$( GO_IMPORT_PATH)
2017-05-26 04:48:44 +08:00
GO_PACKAGES := fdb fdb/tuple fdb/subspace fdb/directory
GO_PACKAGE_OBJECTS := $( addprefix $( GO_PACKAGE_OUTDIR) /,$( GO_PACKAGES:= .a) )
2018-04-07 02:33:54 +08:00
GO_GEN := $( CURDIR) /bindings/go/src/fdb/generated.go
GO_SRC := $( shell find $( CURDIR) /bindings/go/src -name '*.go' ) $( GO_GEN)
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
fdb_go : $( GO_PACKAGE_OBJECTS ) $( GO_SRC ) fdb_go_fmt_check
2017-05-26 04:48:44 +08:00
2018-01-25 03:30:08 +08:00
fdb_go_fmt : $( GO_SRC )
@echo "Formatting fdb_go"
@gofmt -w $( GO_SRC)
fdb_go_fmt_check : $( GO_SRC )
@echo "Checking fdb_go"
@bash -c 'fmtoutstr=$$(gofmt -l $(GO_SRC)) ; if [[ -n "$${fmtoutstr}" ]] ; then echo "Detected go formatting violations for the following files:" ; echo "$${fmtoutstr}" ; echo "Try running: make fdb_go_fmt"; exit 1 ; fi'
2018-03-21 02:31:49 +08:00
$(GO_DEST)/.stamp : $( GO_SRC )
2017-07-05 14:10:11 +08:00
@echo "Creating fdb_go_path"
2017-07-06 05:59:00 +08:00
@mkdir -p $( GO_DEST)
@cp -r bindings/go/src/* $( GO_DEST)
2018-03-21 02:31:49 +08:00
@touch $( GO_DEST) /.stamp
fdb_go_path : $( GO_DEST ) /.stamp
2017-07-05 14:10:11 +08:00
2017-05-26 04:48:44 +08:00
fdb_go_clean :
@echo "Cleaning fdb_go"
2017-07-06 05:59:00 +08:00
@rm -rf $( GOPATH)
2017-05-26 04:48:44 +08:00
fdb_go_tester : $( GOPATH ) /bin /_stacktester
fdb_go_tester_clean :
@echo "Cleaning fdb_go_tester"
@rm -rf $( GOPATH) /bin
2018-04-07 02:33:54 +08:00
$(GOPATH)/bin/_stacktester : $( GO_DEST ) /.stamp $( GO_SRC ) $( GO_PACKAGE_OBJECTS )
2017-05-26 04:48:44 +08:00
@echo " Compiling $( basename $( notdir $@ ) ) "
2017-07-06 05:59:00 +08:00
@go install $( GO_IMPORT_PATH) /_stacktester
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
$(GO_PACKAGE_OUTDIR)/fdb/tuple.a : $( GO_DEST ) /.stamp $( GO_SRC ) $( GO_PACKAGE_OUTDIR ) /fdb .a
2017-05-26 04:48:44 +08:00
@echo "Compiling fdb/tuple"
2017-07-06 05:59:00 +08:00
@go install $( GO_IMPORT_PATH) /fdb/tuple
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
$(GO_PACKAGE_OUTDIR)/fdb/subspace.a : $( GO_DEST ) /.stamp $( GO_SRC ) $( GO_PACKAGE_OUTDIR ) /fdb .a $( GO_PACKAGE_OUTDIR ) /fdb /tuple .a
2017-05-26 04:48:44 +08:00
@echo "Compiling fdb/subspace"
2017-07-06 05:59:00 +08:00
@go install $( GO_IMPORT_PATH) /fdb/subspace
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
$(GO_PACKAGE_OUTDIR)/fdb/directory.a : $( GO_DEST ) /.stamp $( GO_SRC ) $( GO_PACKAGE_OUTDIR ) /fdb .a $( GO_PACKAGE_OUTDIR ) /fdb /tuple .a $( GO_PACKAGE_OUTDIR ) /fdb /subspace .a
2017-05-26 04:48:44 +08:00
@echo "Compiling fdb/directory"
2017-07-06 05:59:00 +08:00
@go install $( GO_IMPORT_PATH) /fdb/directory
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
$(GO_PACKAGE_OUTDIR)/fdb.a : $( GO_DEST ) /.stamp lib /libfdb_c .$( DLEXT ) $( GO_SRC )
2017-05-26 04:48:44 +08:00
@echo "Compiling fdb"
2017-07-06 05:59:00 +08:00
@go install $( GO_IMPORT_PATH) /fdb
2017-05-26 04:48:44 +08:00
2018-04-07 02:33:54 +08:00
$(GO_GEN) : bindings /go /src /_util /translate_fdb_options .go fdbclient /vexillographer /fdb .options
2017-05-26 04:48:44 +08:00
@echo " Building $@ "
@go run bindings/go/src/_util/translate_fdb_options.go < fdbclient/vexillographer/fdb.options > $@