震惊!kratos的make命令windows下无法使用

Make 命令

kratos想在windows下开发的舒服,各种 命令必须得支持,不然一个protoc就是噩梦,好在官方内置了一些make api这样的命令,坏在windows不支持make命令

MinGw

百度一搜大概是MinGW 这么个东西,这么眼熟呢,装过git-bash的应该都知道这东西了,其实make已经安装好了,只不过它默认是叫mingw32-make.exe,只需要给他重命名成make.exe就可以在命令行欢快的使用了

不能用

本来以为搞定了,一个回车后提示了一堆错误 /usr/bin/sh: C:/: Is a directory,什么玩意

看下文件

	ifeq ($(GOHOSTOS), windows)
		Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git))))
		INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto")
		API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto")
	else
		INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
		API_PROTO_FILES=$(shell find api -name *.proto)
	endif
api:
	protoc --proto_path=./api \
	       --proto_path=./third_party \
 	       --go_out=paths=source_relative:./api \
 	       --go-http_out=paths=source_relative:./api \
 	       --go-grpc_out=paths=source_relative:./api \
	       --openapi_out=fq_schema_naming=true,default_response=false:. \
	       $(API_PROTO_FILES)

可以看得出windows他是获取了bash.exe的路径来执行的命令
打印一下路径' C:/ Files/Git/bin/bash.exe,阿这Program 咋还丢了
看来是空格问题,要怨就怨自己默认安装的git到C盘了

这咋整

空格是吧,去掉不就行了
查看短文件名dir /x "C:\"
震惊!kratos的make命令windows下无法使用_第1张图片
就你叫PROGRA~1

	G_Pth = $(subst Program Files,PROGRA~1, $(shell where git))
	Git_Bash=$(subst \,/,$(subst cmd\git.exe,bin\bash.exe,$(G_Pth)))

直接比着抄一下替换

make 启动!
震惊!kratos的make命令windows下无法使用_第2张图片
文件格式错误!

你可能感兴趣的:(windows,git)