Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the filename used in the protoc command #437

Merged

Conversation

michaeldelago
Copy link
Contributor

This should resolve #431.

This PR makes it so setting PROTO-SOURCE-FILE specifically uses that value as the file name passed into protoc. With this change, lisp files generated from proto files will use the PROTO-SOURCE-FILE as the file_name template var that ultimately gets sent as a key to the *file-descriptors* variable.

For example, if you define a component in your asd file like (:proto-source-file "foo/bar/baz"), the resulting lisp file will contain these lines:

(cl:eval-when (:compile-toplevel :load-toplevel :execute)
(pi:add-file-descriptor #P"foo/bar/baz.proto" 'baz)
)

The upstream HEAD yields this form:

(cl:eval-when (:compile-toplevel :load-toplevel :execute)
(pi:add-file-descriptor #P"baz.proto" 'baz)
)

This is problematic because if another file contains import "foo/bar/baz.proto";, the asdf integration will fail (at validate-imports) since upstream HEAD adds #P"baz.proto" to *file-descriptors*.

Testing on SBCL 2.3.9 with Arch Linux (kernel version 6.9.3-arch1-1) passes.

additional changes

  • show output from protoc in case there's an error.

    • This is useful as it can get unwieldy to copy/paste/enter the command that failed to see what went wrong while dialing in your asd file.
  • the well-known types have been updated to reflect the current upstream protobuf repo.

    • This PR removes the need to change the import statement on google/protobuf/type.proto to only target source_context.proto.
    • We could probably move this to a submodule, if desired.

@michaeldelago
Copy link
Contributor Author

Thanks for kicking off the CI

Haven't had a reason to fiddle with ABCL, hopefully this is fun to fix

@Slids
Copy link
Member

Slids commented Jun 29, 2024

Ignore the ABCL test, it's been failing.

Copy link
Contributor

@cgay cgay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits...

asdf.lisp Outdated
(defun get-search-paths (protobuf-source-file)
"For a given protobuf-source-file, generate the search paths that should be used.
To do this, it generates a search path from the component, as well as the
PROTO-SEACH-PATH specified in the asd component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROTO-SEARCH-PATH or probably better as :proto-search-path ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

asdf.lisp Outdated
@@ -108,6 +108,24 @@ to PARENT-PATH."
(resolve-relative-pathname path parent-path))
search-path))))

(defun get-search-paths (protobuf-source-file)
"For a given protobuf-source-file, generate the search paths that should be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to pass internal Google linting rules the parameter name needs to be all caps, but I'm not sure about this. @Slids will know for sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this will fail presubmits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, thanks.

Are the linting rules public anywhere? Aware of the style guide but not sure if that's the same thing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know of. Maybe we can get @Slids to open source it. :-)

@@ -645,6 +827,17 @@ message EnumOptions {

reserved 5; // javanano_as_lite

// Enable the legacy handling of JSON field name conflicts. This lowercases
// and strips underscored from the fields before comparison in proto3 only.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

underscored, haha. Silly Google. Jon, better get on this! :)

:signal-condition-on-fail t))

(deftest test-all-imports-are-included (deep-import-suite)
"Ensure file imports of the parent structure are properly read and stored with it's file descriptor."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's -> its

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, thanks

asdf.lisp Outdated
@@ -108,6 +108,24 @@ to PARENT-PATH."
(resolve-relative-pathname path parent-path))
search-path))))

(defun get-search-paths (protobuf-source-file)
"For a given protobuf-source-file, generate the search paths that should be used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, this will fail presubmits

cl-protobufs.asd Outdated
:pathname ""
:depends-on ("models" "misc")
:components
((:protobuf-source-file "descriptor"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you update the well known proto files, please do that in a seperate pull.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks

@michaeldelago michaeldelago requested review from cgay and Slids July 3, 2024 13:49
@michaeldelago
Copy link
Contributor Author

Pretty sure I addressed all review notes, thanks for sending those.

Sorry for the delay, a lot going on this and next week

Copy link
Member

@Slids Slids left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready for CI and internal review

@Slids
Copy link
Member

Slids commented Sep 21, 2024

internally we got these errors
CheckLint found errors.
Lines should be under 100 columns. (LINE-TOO-LONG)
//depot/google3/third_party/lisp/cl_protobufs/asdf.lisp:139
Lines should be under 100 columns. (LINE-TOO-LONG)
//depot/google3/third_party/lisp/cl_protobufs/asdf.lisp:143
Lines should be under 100 columns. (LINE-TOO-LONG)
//depot/google3/third_party/lisp/cl_protobufs/asdf.lisp:156
Lines should be under 100 columns. (LINE-TOO-LONG)
//depot/google3/third_party/lisp/cl_protobufs/asdf.lisp:160

@copybara-service copybara-service bot merged commit 8540f07 into qitab:master Sep 26, 2024
5 of 6 checks passed
@Slids
Copy link
Member

Slids commented Sep 26, 2024

Sorry it took so long, and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to compile opentelemetry-proto through asdf
3 participants