-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Embed full python protobuf library (#1438)
This embeds the full python protobuf library into the output in pssh-box-protos, which is used by installation targets and Docker images. Without this, the installed pssh-box.py tool would depend on a separate installation of the python protobuf library. Closes #1436
- Loading branch information
1 parent
4bf8b5e
commit f07fd0d
Showing
4 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright 2022 Google LLC. All rights reserved. | ||
# | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file or at | ||
# https://developers.google.com/open-source/licenses/bsd | ||
|
||
# Build generated python sources for the protobuf library. | ||
set(protobuf_py_proto_path ${CMAKE_CURRENT_SOURCE_DIR}/source/src) | ||
set(protobuf_py_library_path ${CMAKE_CURRENT_SOURCE_DIR}/source/python) | ||
set(protobuf_py_output_path ${CMAKE_CURRENT_BINARY_DIR}/py) | ||
|
||
# Copy the library without the generated sources. | ||
add_custom_command( | ||
DEPENDS | ||
${protobuf_py_proto_path} | ||
OUTPUT | ||
${protobuf_py_output_path}/google | ||
COMMAND | ||
${CMAKE_COMMAND} -E copy_directory | ||
${CMAKE_CURRENT_SOURCE_DIR}/source/python/google | ||
${protobuf_py_output_path}/google) | ||
|
||
# This list was taken from packager/third_party/protobuf/source/python/setup.py | ||
set(protobuf_py_filenames | ||
google/protobuf/descriptor | ||
google/protobuf/compiler/plugin | ||
google/protobuf/any | ||
google/protobuf/api | ||
google/protobuf/duration | ||
google/protobuf/empty | ||
google/protobuf/field_mask | ||
google/protobuf/source_context | ||
google/protobuf/struct | ||
google/protobuf/timestamp | ||
google/protobuf/type | ||
google/protobuf/wrappers) | ||
|
||
# For each proto in the list, generate a _pb2.py file to add to the library. | ||
set(protobuf_py_outputs "") | ||
foreach (filename ${protobuf_py_filenames}) | ||
set(proto_path "${protobuf_py_proto_path}/${filename}.proto") | ||
set(output_path "${protobuf_py_output_path}/${filename}_pb2.py") | ||
|
||
list(APPEND protobuf_py_outputs "${output_path}") | ||
|
||
add_custom_command( | ||
DEPENDS | ||
protoc | ||
${proto_path} | ||
${protobuf_py_output_path}/google | ||
OUTPUT | ||
${output_path} | ||
COMMAND | ||
protoc | ||
ARGS | ||
-I${protobuf_py_proto_path} | ||
--python_out=${protobuf_py_output_path} | ||
${proto_path}) | ||
endforeach () | ||
|
||
# The entire python protobuf library (repo source and generated) to the output | ||
# folder. | ||
add_custom_target(protobuf_py ALL DEPENDS ${protobuf_py_outputs}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters