go-kratos / kratos-layout

Kratos Project Template
http://go-kratos.dev
MIT License
402 stars 205 forks source link

Makefile optimize #145

Open windzhu0514 opened 2 months ago

windzhu0514 commented 2 months ago

When running the make api in windows git bash , the following error occurs:

/usr/bin/sh: line 1: C:/: Is a directory
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:. \

Missing input file.
make: *** [api] 错误 1

or cmd and powershell:

'C:/' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
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:. \

Missing input file.
make: *** [api] 错误 1

so i make the following changes to the API_PROTO_FILES and API_PROTO_FILES variable

INTERNAL_PROTO_FILES=$(shell find internal -name *.proto)
API_PROTO_FILES=$(shell find api -name *.proto)

ifeq ($(GOHOSTOS), windows)
    ifdef ComSpec
            INTERNAL_PROTO_FILES_FULL_PATH=$(shell cmd /C "dir /S /B internal\*.proto")
            API_PROTO_FILES_FULL_PATH=$(shell cmd /C "dir /S /B api\*.proto")

           CWD := $(shell echo %cd%)
            INTERNAL_PROTO_FILES=$(subst $(CWD)\,,$(INTERNAL_PROTO_FILES_FULL_PATH))
            API_PROTO_FILES=$(subst $(CWD)\,,$(API_PROTO_FILES_FULL_PATH))
    endif
endif