blob: d49647add97319d2ab358f2c207d84393efe4782 [file] [log] [blame]
#
# Copyright 2019 Cloudera, Inc. 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.
#
# Check if this is at least GO 1.11 for Go Modules
GO_VERSION := $(shell go version | awk '$$3 ~ /go1.(10|0-9])/ {print $$3}')
ifdef GO_VERSION
$(error Build requires go 1.11 or later)
endif
# Make sure we are in the same directory as the Makefile
BASE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SI_SPEC := scheduler-interface-spec.md
SI_PROTO := si.proto
all:
$(MAKE) -C $(dir $(BASE_DIR)) build
# Generate the proto file from the spec, leave proto untouched if there are no changes
$(SI_PROTO).tmp: $(SI_SPEC)
@echo "// **** DO NOT EDIT\n// **** This code is generated by the buikd process.\n// **** DO NOT EDIT" > $@
cat $< | sed -n -e '/```protobuf$$/,/^```$$/ p' | sed '/^```/d' >> $@
awk '{ if (length > 200) print NR, $$0 }' $@ | diff - /dev/null
(diff $@ $(SI_PROTO) > /dev/null 2>&1 || mv -f $@ $(SI_PROTO)) && \
rm -f $@
# Build the go language bindings from the spec via a generated proto
build: $(SI_PROTO).tmp
$(MAKE) -C lib/go
# Simple clean of generated files only (no local cleanup).
clean:
cd $(BASE_DIR) && \
$(MAKE) -C lib/go $@
# Remove all non versioned files,
# Running this target will trigger a re-install of protoc etc in te next build cycle.
clobber:
cd $(BASE_DIR) && \
$(MAKE) -C lib/go $@
.PHONY: clean clobber