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