qitab / cl-protobufs

Common Lisp protocol buffer implementation.
MIT License
78 stars 17 forks source link

How to compile all proto files in a folder #352

Closed mdbergmann closed 2 years ago

mdbergmann commented 2 years ago

Hi.

This is more a question as I couldn't find the answer.

I've tried a few variants:

protoc --plugin=protoc-gen-lisp=/usr/local/bin/protoc-gen-lisp \
  --lisp_out="`pwd`/folder/lisp" \
  --proto_path=folder \
  $(find folder -iname "*.proto")

or

protoc --plugin=protoc-gen-lisp=/usr/local/bin/protoc-gen-lisp \
  --lisp_out="`pwd`/folder/lisp" \
  --proto_path=folder \
  folder/*.proto

The cl plugin then responds with:

--lisp_out: protoc-gen-lisp: First file chunk returned by plugin did not specify a file name.

So, I'm not sure if the --lisp_out form is correct as in the documentation it uses output-file, but here it's multiple files.

Any advice?

Manfred

Slids commented 2 years ago

It concatenates the resultants into a file.

Example:

I went to

jgodbou@penguin:~/quicklisp/local-projects/cl-protobufs/google/protobuf

Then I ran:

protoc --plugin=protoc-gen-lisp=/usr/local/bin/protoc-gen-lisp   --lisp_out=output-file=b.lisp:/tmp   --proto_path=.   a*.proto

If you look at b.lisp inside of /tmp we concatenate the different generated files. Running cat /tmp/b.lisp | less you see:

;;; any.proto.lisp
;;;
;;; Generated by the protocol buffer compiler. DO NOT EDIT!

(cl:in-package #:common-lisp-user)

.
.
.

;;; api.proto.lisp
;;;
;;; Generated by the protocol buffer compiler. DO NOT EDIT!

(cl:in-package #:common-lisp-user)
.
.
.
Slids commented 2 years ago

I'd suggest sticking with ASDF and not bothering running protoc manually.

Slids commented 2 years ago

@mdbergmann did this sufficiently answer your question?

mdbergmann commented 2 years ago

Thanks for you answer. Let me try this tonight. I have a folder structure of .proto files so I'd be curious what it does with this. Or should protoc be called on a per folder basis?

What do you mean with 'sticking to ASDF'?

Slids commented 2 years ago

Once everything is installed, you can use protobuf-source-file in your asd file. It will call protoc for you. Check the well-known-types module in the cl-protobufs asd for an example

https://github.com/qitab/cl-protobufs/blob/e0d0a2772a78e29c0e245025271622fddfd9e287/cl-protobufs.asd#L73

I guess this never made it to the readme? Then that should be a documentation bug...

mdbergmann commented 2 years ago

Yeah, would be cool if that could get documented.