| # |
| # 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. |
| # |
| |
| # 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 |