Skip to content

Commit

Permalink
Add include_protos option to generation (#177)
Browse files Browse the repository at this point in the history
* Add include_protos option to generation
  • Loading branch information
crwilcox authored Jan 10, 2019
1 parent df65288 commit 8e95a23
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions synthtool/gcp/gapic_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _generate_code(
config_path=None,
artman_output_name=None,
private=False,
include_protos=False,
):
# map the language to the artman argument and subdir of genfiles
GENERATE_FLAG_LANGUAGE = {
Expand Down Expand Up @@ -129,6 +130,17 @@ def _generate_code(

log.success(f"Generated code into {genfiles}.")

# Get the *.protos files and put them in a protos dir in the output
if include_protos:
import shutil

source_dir = googleapis / config_path.parent
proto_files = source_dir.glob("**/*.proto")
os.mkdir(genfiles / "protos")
for i in proto_files:
shutil.copyfile(i, genfiles / "protos" / i.name)
log.success(f"Placed proto files into {genfiles}/protos.")

metadata.add_client_destination(
source="googleapis" if not private else "googleapis-private",
api_name=service,
Expand Down

0 comments on commit 8e95a23

Please # to comment.