From cf66ce1a33e9d077b0b7c3ba083b943dc37687d9 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Mon, 21 Sep 2020 18:12:18 -0700 Subject: [PATCH 1/2] fix: add new Bazel workflow to docs This will work once [this PR](https://github.com/googleapis/googleapis/pull/620) is in. --- DEVELOPMENT.md | 63 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 80a3ab67d5..aa7cf33b4d 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -18,33 +18,60 @@ below are temporary and better ones will be coming. 1. Clone [googleapis](https://github.com/googleapis/googleapis) and [gapic-showcase](https://github.com/googleapis/gapic-showcase/) and install protoc. + 2. Copy the protos from Showcase into googleapis/google/showcase. ```sh cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta ``` - -3. Export tool paths. - - ```sh - PROTOC_INCLUDE_DIR=/usr/local/include/google/protobuf/ - GOOGLEAPIS_DIR=/usr/local/google/home/$USER/dev/googleapis - YOUR_PROTO_DIR=/usr/local/google/home/$USER/dev/googleapis/google/showcase/v1beta +3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel` file + as follows: + + ```python + load( + "@com_google_googleapis_imports//:imports.bzl", + # Existing rules here. + # The left-side name is simply an alias, we can use anything here. + java_microgen_gapic_assembly_gradle_pkg = "java_microgenerator_gapic_assembly_gradle_pkg", + java_microgen_gapic_library = "java_microgenerator_gapic_library", + java_microgen_gapic_test = "java_microgenerator_gapic_test", + ) + + # This should either replace the existing monolith target or have a unique name + # that includes "java_gapic". + java_microgen_gapic_library( + name = "showcase_java_gapic", + srcs = [":showcase_proto_with_info"], + # The gapic_yaml file is needed only for APIs that have batching configs. + gapic_yaml = "showcase_gapic.yaml", + grpc_service_config = "showcase_grpc_service_config.json", + package = "google.showcase.v1beta1", + service_yaml = "showcase.yaml", + test_deps = [ + ":showcase_java_grpc", + ], + deps = [ + ":showcase_java_proto", + ], + ) + + java_microgen_gapic_assembly_gradle_pkg( + name = "google-cloud-showcase-v1beta1-java-microgen", + deps = [ + # This is the new microgen target above. + ":showcase_java_gapic", + # The following targets already exist. + ":showcase_java_grpc", + ":showcase_java_proto", + ":showcase_proto", + ], + ) ``` -4. Build this plugin. +4. Build the new target. ```sh - bazel build :protoc-gen-java_gapic - ``` - -5. Run the plugin. At this stage, it will not do anything except write - hardcoded Java into two files. - - ``` - protoc -I=${PROTOC_INCLUDE_DIR} -I=${GOOGLEAPIS_DIR} -I=${YOUR_PROTO_DIR} \ - --plugin=bazel-bin/protoc-gen-java_gapic ~/dev/googleapis/google/showcase/v1test/*.proto \ - --gapic-java_out=/tmp/test + bazel build google/showcase/v1beta1:showcase_java_gapic ``` ## Code Formatting From 57f5429f9b8a3cf4da2343b328e3eb26485d251e Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Wed, 23 Sep 2020 16:40:15 -0700 Subject: [PATCH 2/2] fix: update steps --- DEVELOPMENT.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index aa7cf33b4d..026cfbdfcd 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -24,29 +24,26 @@ below are temporary and better ones will be coming. ```sh cp gapic-showcase/schema/google/showcase/v1beta1 googleapis/google/showcase/v1beta ``` -3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel` file - as follows: - + +3. Add the new microgenerator rules to the protobuf directory's `BUILD.bazel` + file as follows: + ```python load( "@com_google_googleapis_imports//:imports.bzl", # Existing rules here. - # The left-side name is simply an alias, we can use anything here. - java_microgen_gapic_assembly_gradle_pkg = "java_microgenerator_gapic_assembly_gradle_pkg", - java_microgen_gapic_library = "java_microgenerator_gapic_library", - java_microgen_gapic_test = "java_microgenerator_gapic_test", + "java_gapic_assembly_gradle_pkg2", + "java_gapic_library2", ) # This should either replace the existing monolith target or have a unique name # that includes "java_gapic". - java_microgen_gapic_library( + java_gapic_library2( name = "showcase_java_gapic", srcs = [":showcase_proto_with_info"], # The gapic_yaml file is needed only for APIs that have batching configs. - gapic_yaml = "showcase_gapic.yaml", grpc_service_config = "showcase_grpc_service_config.json", package = "google.showcase.v1beta1", - service_yaml = "showcase.yaml", test_deps = [ ":showcase_java_grpc", ], @@ -55,8 +52,9 @@ below are temporary and better ones will be coming. ], ) - java_microgen_gapic_assembly_gradle_pkg( - name = "google-cloud-showcase-v1beta1-java-microgen", + java_gapic_assembly_gradle_pkg2( + # This name should be unique from the existing target name. + name = "google-cloud-showcase-v1beta1-java", deps = [ # This is the new microgen target above. ":showcase_java_gapic",