github.com/vmware/govmomi@v0.37.2/gen/Makefile (about)

     1  # Copyright (c) 2023 VMware, Inc. All Rights Reserved.
     2  # SPDX-License-Identifier: Apache-2.0
     3  
     4  # If you update this file, please follow
     5  # https://www.thapaliya.com/en/writings/well-documented-makefiles/
     6  
     7  # Ensure Make is run with bash shell as some syntax below is bash-specific
     8  SHELL := /usr/bin/env bash
     9  
    10  # Print the help/usage when make is executed without any other arguments
    11  .DEFAULT_GOAL := help
    12  
    13  
    14  ## --------------------------------------
    15  ## Help
    16  ## --------------------------------------
    17  
    18  .PHONY: help
    19  help: ## Display usage
    20  	@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)
    21  
    22  
    23  ## --------------------------------------
    24  ## Image
    25  ## --------------------------------------
    26  
    27  IMAGE_NAME ?= govmomi-gen-types
    28  IMAGE_TAG ?= latest
    29  IMAGE ?= $(IMAGE_NAME):$(IMAGE_TAG)
    30  
    31  .PHONY: image-build
    32  image-build: ## Build the image for generating types
    33  	docker build -t $(IMAGE) .
    34  
    35  
    36  ## --------------------------------------
    37  ## Generate
    38  ## --------------------------------------
    39  
    40  ABS_PATH_PARENT_DIR := $(abspath $(dir $(shell pwd)))
    41  
    42  #
    43  # Please note the use of the .Gemfile.lock.tmp file below. This is to prevent
    44  # the container from modifying the local copy of the Gemfile.lock that would
    45  # otherwise be bind mounted into the container courtesy of the first bind mount.
    46  #
    47  
    48  .PHONY: generate-types
    49  generate-types: image-build
    50  generate-types: ## Generate the types
    51  	@cp -f Gemfile.lock .Gemfile.lock.tmp
    52  	docker run -it --rm \
    53  	  -v $(ABS_PATH_PARENT_DIR):/govmomi \
    54  	  -v $(ABS_PATH_PARENT_DIR)/gen/.Gemfile.lock.tmp:/govmomi/gen/Gemfile.lock \
    55  	  $(IMAGE) \
    56  	  /bin/bash -c 'bundle update --bundler && bundle install && ./gen.sh'
    57  
    58