github.com/vmware/govmomi@v0.51.0/gen/Makefile (about) 1 # © Broadcom. All Rights Reserved. 2 # The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 # SPDX-License-Identifier: Apache-2.0 4 5 # If you update this file, please follow 6 # https://www.thapaliya.com/en/writings/well-documented-makefiles/ 7 8 # Ensure Make is run with bash shell as some syntax below is bash-specific 9 SHELL := /usr/bin/env bash 10 11 # Print the help/usage when make is executed without any other arguments 12 .DEFAULT_GOAL := help 13 14 # CRI_BIN is the path to the container runtime binary. 15 ifeq (,$(strip $(GITHUB_RUN_ID))) 16 # Prefer podman locally. 17 CRI_BIN := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null) 18 else 19 # Prefer docker in GitHub actions. 20 CRI_BIN := $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null) 21 endif 22 export CRI_BIN 23 24 25 ## -------------------------------------- 26 ## Help 27 ## -------------------------------------- 28 29 .PHONY: help 30 help: ## Display usage 31 @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make [target] \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST) 32 33 34 ## -------------------------------------- 35 ## Image 36 ## -------------------------------------- 37 38 IMAGE_NAME ?= govmomi-gen-types 39 IMAGE_TAG ?= latest 40 IMAGE ?= $(IMAGE_NAME):$(IMAGE_TAG) 41 42 .PHONY: image-build 43 image-build: ## Build the image for generating types 44 $(CRI_BIN) build -t $(IMAGE) . 45 46 47 ## -------------------------------------- 48 ## Generate 49 ## -------------------------------------- 50 51 ABS_PATH_PARENT_DIR := $(abspath $(dir $(shell pwd))) 52 53 # 54 # Please note the use of the .Gemfile.lock.tmp file below. This is to prevent 55 # the container from modifying the local copy of the Gemfile.lock that would 56 # otherwise be bind mounted into the container courtesy of the first bind mount. 57 # 58 59 .PHONY: generate-types 60 generate-types: image-build 61 generate-types: ## Generate the types 62 @cp -f Gemfile.lock .Gemfile.lock.tmp 63 $(CRI_BIN) run -it --rm \ 64 -v $(ABS_PATH_PARENT_DIR):/govmomi \ 65 -v $(ABS_PATH_PARENT_DIR)/gen/.Gemfile.lock.tmp:/govmomi/gen/Gemfile.lock \ 66 $(IMAGE) \ 67 /bin/bash -c 'bundle update --bundler && bundle install && ./gen.sh' 68 69