2019-07-01 23:10:24 +03:00
|
|
|
ROOT=$(shell pwd)
|
2019-07-03 00:37:42 +03:00
|
|
|
SPECROOT=$(ROOT)/specs
|
2019-07-01 23:10:24 +03:00
|
|
|
GENROOT=$(ROOT)/generated
|
|
|
|
GOSRC=$(GENROOT)/go/src
|
|
|
|
TFROOT=$(GOSRC)/github.com/terraform-providers
|
|
|
|
TFGITURL=https://github.com/VSChina/terraform-provider-azurerm.git
|
|
|
|
TFREPO=terraform-provider-azurerm
|
|
|
|
ASGITURL=https://github.com/VSChina/ansible.git
|
|
|
|
ASREPO=ansible
|
|
|
|
MMROOT=$(ROOT)/tools/magic-modules
|
|
|
|
|
|
|
|
# Environment variables.
|
|
|
|
export GOPATH=$(GENROOT)/go
|
|
|
|
export GO111MODULE=on
|
|
|
|
export GOFLAGS=-mod=vendor
|
|
|
|
|
|
|
|
default: init
|
|
|
|
|
|
|
|
all: clean init build format-terraform
|
|
|
|
|
|
|
|
init:
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> creating folders for code generation..."
|
|
|
|
@if [ ! -d "$(TFROOT)" ]; then \
|
2019-07-01 23:10:24 +03:00
|
|
|
mkdir -p "$(TFROOT)"; \
|
|
|
|
fi
|
|
|
|
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> cloning repository for terraform..."
|
|
|
|
@if [ ! -d "$(TFROOT)/$(TFREPO)" ]; then \
|
2019-07-01 23:10:24 +03:00
|
|
|
git clone $(TFGITURL) $(TFROOT)/$(TFREPO); \
|
|
|
|
fi
|
|
|
|
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> cloning repository for ansible..."
|
|
|
|
@if [ ! -d "$(GENROOT)/$(ASREPO)" ]; then \
|
2019-07-01 23:10:24 +03:00
|
|
|
git clone $(ASGITURL) $(GENROOT)/$(ASREPO); \
|
|
|
|
fi
|
|
|
|
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> initializing submodules..."
|
|
|
|
@git submodule update --init
|
|
|
|
|
|
|
|
@echo "==> installing gem packages..."
|
|
|
|
@cd $(MMROOT) && \
|
2019-07-01 23:10:24 +03:00
|
|
|
gem install bundler && \
|
|
|
|
bundle install --retry=3 --jobs=4
|
|
|
|
|
|
|
|
clean:
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> cleaning code generation folder..."
|
|
|
|
@rm -rf $(GENROOT)
|
2019-07-01 23:10:24 +03:00
|
|
|
|
|
|
|
build: build-terraform build-ansible
|
|
|
|
|
|
|
|
build-terraform:
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> Generating source code for terraform..."
|
|
|
|
@if [ -z "$(RESOURCE)" ]; then \
|
|
|
|
echo "==> Generating source code for terraform from resource list..."; \
|
|
|
|
cd $(MMROOT) && \
|
2019-08-06 12:25:28 +03:00
|
|
|
sh $(ROOT)/list_resources.sh $(SOURCE_BRANCH) | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e terraform -c azure -o $(TFROOT)/$(TFREPO)/; \
|
2019-07-02 21:59:42 +03:00
|
|
|
else \
|
|
|
|
echo "==> Generating source code for terraform from given name..."; \
|
|
|
|
cd $(MMROOT) && \
|
2019-07-24 23:00:08 +03:00
|
|
|
bundle exec compiler -d -p $(SPECROOT)/$(RESOURCE) -e terraform -c azure -o $(TFROOT)/$(TFREPO)/; \
|
2019-07-02 21:59:42 +03:00
|
|
|
fi
|
2019-07-01 23:10:24 +03:00
|
|
|
|
|
|
|
format-terraform:
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> Importing packages and formatting code for terraform..."
|
|
|
|
@cd $(TFROOT)/$(TFREPO) && \
|
2019-07-01 23:10:24 +03:00
|
|
|
goimports -w azurerm && \
|
|
|
|
make fmt
|
|
|
|
|
|
|
|
build-ansible:
|
2019-07-02 21:59:42 +03:00
|
|
|
@echo "==> Generating source code for ansible..."
|
|
|
|
@if [ -z "$(RESOURCE)" ]; then \
|
|
|
|
echo "==> Generating source code for ansible from resource list..."; \
|
|
|
|
cd $(MMROOT) && \
|
2019-08-06 12:25:28 +03:00
|
|
|
sh $(ROOT)/list_resources.sh $(SOURCE_BRANCH) | xargs -I '{}' bundle exec compiler -d -p $(SPECROOT)/'{}' -e ansible -c azure -o $(GENROOT)/$(ASREPO)/; \
|
2019-07-02 21:59:42 +03:00
|
|
|
else \
|
|
|
|
echo "==> Generating source code for ansible from given name..."; \
|
|
|
|
cd $(MMROOT) && \
|
2019-07-24 23:00:08 +03:00
|
|
|
bundle exec compiler -d -p $(SPECROOT)/$(RESOURCE) -e ansible -c azure -o $(GENROOT)/$(ASREPO)/; \
|
2019-07-02 21:59:42 +03:00
|
|
|
fi
|
2019-07-01 23:10:24 +03:00
|
|
|
|
|
|
|
.PHONY: init clean build build-terraform format-terraform build-ansible
|