定制开发小程序windows下使用make命令(makefile)

定制开发小程序今天讲一讲windows定制开发小程序下如何使用make命令

在学kratos定制开发小程序时发现有个很好用的命令,即make,比如:

make api

但是你会发现这东西默认只能在linux和Mac上能用,作为windows用户就很难受了,那么要怎么在windows使用make命令呢?,你要是不难受就敲完整命令吧,比如($(API_PROTO_FILES)即你的proto文件路径):

  1. protoc --proto_path=./api \
  2.   --proto_path=./third_party \
  3.   --go_out=paths=source_relative:./api \
  4.   --go-http_out=paths=source_relative:./api \
  5.   --go-grpc_out=paths=source_relative:./api \
  6.   --openapi_out=fq_schema_naming=true,default_response=false:. \
  7.   $(API_PROTO_FILES)

反正我是受不了,为啥别人Mac能用,我不能用,就因为我买不起Mac吗,我不服。

解决方案:

1、首先下载(干什么用的自行百度):

2、点击安装后打开将Base Setup全部mark,然后点击installation->Apply Changes,等待安装完就行(时间可能有点长)。

3、然后将bin目录添加进环境变量,比如我的路径是C:\MinGW\bin,该目录下有一个mingw-get.exe,这就是我上面说的命令可执行文件了。

4、作为有强迫症的我肯定不愿意执行mingw-get这样的命令,我是想用make这样的命令,所以复制一份mingw-get.exe,将其改为make.exe,到此为止就大功告成了。

5、但是有时候你在kratos里执行make api时会发现要报错,他会提示C:\不是内部或外部命令,也不是可运行的程序,这里是因为你的git安装到的是默认目录,即C:\Program Files\Git,因为实际上kratos里的文件里用到了Git_Bash,而这个路径正好是你的git-bash.exe的路径,可能是C:\Program Files\Git这个路径Program Files中空格无法解析的原因(我猜的),我的方法就是将Git重新安装,然后自定义目录,如C:\install\Git,这样就完美解决了。

  1. GOHOSTOS:=$(shell go env GOHOSTOS)
  2. GOPATH:=$(shell go env GOPATH)
  3. VERSION=$(shell git describe --tags --always)
  4. ifeq ($(GOHOSTOS), windows)
  5. #the `find.exe` is different from `find` in bash/shell.
  6. #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find.
  7. #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git.
  8. Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git)))
  9. INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto")
  10. API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto")
  11. else
  12. INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
  13. API_PROTO_FILES=$(shell find api -name *.proto)
  14. endif

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发