0

How to translate (I just want to create a separate deploy-backend-local-win) the following snippet in a MAKEFILE so that it runs on Windows (I use VSCode if that matters)?

deploy-backend-local: cd go-svr; \ LOCAL=true PORT=3002 TOKEN_FILE="../sample_service_token.json" COLLECTION_NAME="blabla_test_users" GRPC_TARGET="some.target" GCP_PROJECT=some_project go run main.go

adam.k
  • 324
  • 3
  • 14

1 Answers1

0

Using target specific variables and exporting the variables to the environment:

deploy-backend-local: export LOCAL=true
deploy-backend-local: export PORT=3002
deploy-backend-local: export TOKEN_FILE=../sample_service_token.json
deploy-backend-local: export COLLECTION_NAME=blabla_test_users
deploy-backend-local: export GRPC_TARGET=some.target
deploy-backend-local: export GCP_PROJECT=some_project

# if cd and go-srv really are prerequisites
deploy-backend-local: cd go-svr
    go run main.go

# if typo in the question
#deploy-backend-local:
#    cd go-svr; \
#    go run main.go

Andreas
  • 5,086
  • 3
  • 16
  • 36
  • 1
    That quote is misleading. That section of the manual is talking about variables make receives from its caller and saying that those variables are passed through to recipes that are invoked by make. It's not true that every variable defined in a makefile is ALSO passed to commands invoked by make. See for example: https://stackoverflow.com/a/23845391/939557 – MadScientist Apr 27 '22 at 13:23
  • @MadScientist You're right, my bad. Edited. – Andreas Apr 27 '22 at 13:53
  • @Andreas when I typed it like you proposed I got ``the system cannot find the path specified.` – adam.k Apr 28 '22 at 07:20
  • @adam.k Try remove the `cd go-srv; \ ` line. Optionally append `cd go-srv` to the `deploy-backend-local:` line. Figured your question had a typo in it since suggesting the `deploy-backend-local` target has prerequisites `cd` and `go-srv`, rather than changing directory to go-srv, but maybe that was actually what you wanted to do. – Andreas Apr 28 '22 at 08:37