Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-organize tool installation #127

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ dist/
hydrophone
artifact_go.sh
.DS_Store
/node_modules/
/tools/
47 changes: 42 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
# Clinic Makefile
SHELL = /bin/sh

TOOLS_BIN = tools/bin
NPM_BIN = node_modules/.bin

OAPI_CODEGEN = $(TOOLS_BIN)/oapi-codegen
SWAGGER_CLI = $(NPM_BIN)/swagger-cli

NPM_PKG_SPECS = \
@apidevtools/swagger-cli@^4.0.4


.PHONY: all
all: dist/hydrophone

GENERATED_SRCS = client/types.go client/client.go spec/confirm.v1.yaml

dist/hydrophone: $(GENERATED_SRCS)
GOWORK=off ./build.sh

.PHONY: build
build:
$(MAKE) dist/hydrophone

.PHONY: generate
# Generates client api
generate:
swagger-cli bundle ../TidepoolApi/reference/confirm.v1.yaml -o ./spec/confirm.v1.yaml -t yaml
oapi-codegen -package=api -generate=types spec/confirm.v1.yaml > client/types.go
oapi-codegen -package=api -generate=client spec/confirm.v1.yaml > client/client.go
generate: $(SWAGGER_CLI) $(OAPI_CODEGEN)
$(SWAGGER_CLI) bundle ../TidepoolApi/reference/confirm.v1.yaml -o ./spec/confirm.v1.yaml -t yaml
$(OAPI_CODEGEN) -package=api -generate=types spec/confirm.v1.yaml > client/types.go
$(OAPI_CODEGEN) -package=api -generate=client spec/confirm.v1.yaml > client/client.go
cd client && go generate ./...

.PHONY: test
test:
GOWORK=off ./test.sh

$(OAPI_CODEGEN):
GOBIN=$(shell pwd)/$(TOOLS_BIN) go install github.com/deepmap/oapi-codegen/cmd/[email protected]

$(SWAGGER_CLI):
npm-tools

.PHONY: npm-tools
npm-tools:
# When using --no-save, any dependencies not included will be deleted, so one
# has to install all the packages all at the same time. But it saves us from
# having to muck with packages.json.
npm i --no-save --local $(NPM_PKG_SPECS)
2 changes: 0 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/sh -eu

rm -rf dist
mkdir dist
go build -o dist/hydrophone hydrophone.go