-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
41 lines (36 loc) · 1.48 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
PROJECT := ssclient
.DEFAULT_GOAL := ssclient
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
CACHE_BASE ?= $(HOME)/.cache/$(PROJECT)
CACHE := $(CACHE_BASE)/$(UNAME_OS)/$(UNAME_ARCH)
CACHE_BIN := $(CACHE)/bin
CACHE_VERSIONS := $(CACHE)/versions
CACHE_GOBIN := $(CACHE)/gobin
CACHE_GOCACHE := $(CACHE)/gocache
export PATH := $(abspath $(CACHE_BIN)):$(PATH)
SHELL := /usr/bin/env bash -o pipefail
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory
MOCKGEN_VERSION ?= 0.4.0
MOCKGEN := $(CACHE_VERSIONS)/mockgen/$(MOCKGEN_VERSION)
$(MOCKGEN):
@rm -f $(CACHE_BIN)/mockgen
@mkdir -p $(CACHE_BIN)
@env GOBIN=$(CACHE_BIN) go install go.uber.org/mock/mockgen@v$(MOCKGEN_VERSION)
@chmod +x $(CACHE_BIN)/mockgen
@rm -rf $(dir $(MOCKGEN))
@mkdir -p $(dir $(MOCKGEN))
@touch $(MOCKGEN)
.PHONY: examplemocks
examplemocks: $(MOCKGEN)
cd $(CURDIR)/example && mockgen -typed -destination=./adapter/adapter.go -package=adapter github.com/microsoft/kiota-abstractions-go RequestAdapter
.PHONY: ssclient
ssclient:
@which kiota > /dev/null 2>&1 || (echo "kiota not found in PATH, download v1.19.1 from: https://learn.microsoft.com/en-ca/openapi/kiota/install" && exit 1)
kiota generate --language go --clean-output --class-name Client --namespace-name go.artefactual.dev/ssclient/kiota --openapi typespec/tsp-output/@typespec/openapi3/openapi.v1.yaml --output ./kiota
.PHONY: typespec
typespec:
npm --prefix=$(CURDIR)/typespec run compile
.PHONY: gen
gen: typespec ssclient examplemocks