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

tools: Use Google.Api.Generator from a dotnet tool #13414

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
"commands": [
"generate-sbom"
]
},
"Google.Api.Generator": {
"version": "1.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

We had 1.4.32 before...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, I figured that we'd make the first release as a dotnet tool 1.5.0. But that's very much up for debate :)

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, fine by me, just in case it was left over from you trying things locally.

"commands": [
"google-gapic-generator"
]
}
}
}
36 changes: 9 additions & 27 deletions toolversions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ declare -r DOTCOVER_VERSION=2019.3.4
declare -r REPORTGENERATOR_VERSION=2.4.5.0
declare -r PROTOC_VERSION=3.25.2
declare -r GRPC_VERSION=2.60.0
if [[ $GAPIC_GENERATOR_VERSION == "" ]]
then
declare -r GAPIC_GENERATOR_VERSION=v1.4.32
else
echo "Using GAPIC generator override: ${GAPIC_GENERATOR_VERSION}"
fi

# Tools that only run under Windows (at the moment)
declare -r DOTCOVER=$TOOL_PACKAGES/JetBrains.dotCover.CommandLineTools.$DOTCOVER_VERSION/tools/dotCover.exe
Expand Down Expand Up @@ -102,32 +96,20 @@ install_microgenerator() {

# If the CSHARP_GENERATOR_DIR env variable is set
# we use that as the generator root dir.
if [[ "$CSHARP_GENERATOR_DIR" != "" ]]
then
declare -r GENERATOR_ROOT=$CSHARP_GENERATOR_DIR
else
declare -r GENERATOR_ROOT=$REPO_ROOT/gapic-generator-csharp
fi

export GAPIC_PLUGIN=$GENERATOR_ROOT/Google.Api.Generator/bin/Release/net6.0/$RUNTIME/publish/Google.Api.Generator$EXTENSION

if [[ "$CSHARP_GENERATOR_DIR" != "" ]]
then
echo "Skipping microgenerator fetch: an existing directory for the generator has been specified"
elif [ -d $GENERATOR_ROOT ]
then
git -C $GENERATOR_ROOT fetch -q --tags
git -C $GENERATOR_ROOT checkout -q $GAPIC_GENERATOR_VERSION
(cd $CSHARP_GENERATOR_DIR; \
dotnet restore -v quiet; \
dotnet publish -v quiet -nologo -clp:NoSummary -c Release --self-contained --runtime=$RUNTIME Google.Api.Generator)
export GAPIC_PLUGIN=$CSHARP_GENERATOR_DIR/Google.Api.Generator/bin/Release/net6.0/$RUNTIME/publish/Google.Api.Generator$EXTENSION
else
git clone https://github.com/googleapis/gapic-generator-csharp $GENERATOR_ROOT -q
git -C $GENERATOR_ROOT checkout -q $GAPIC_GENERATOR_VERSION
# We don't just use "dotnet tool restore", as we need it installed in a specific
# path in order to access the executable directly (as it's a protoc plugin).
rm -rf gapic-generator
dotnet tool install Google.Api.Generator --tool-path gapic-generator > /dev/null
export GAPIC_PLUGIN=$REPO_ROOT/gapic-generator/google-gapic-generator$EXTENSION
fi

# The dotnet restore step isn't generally required when cloning from elsewhere,
# but helps when running a local generator. (It does no harm even when not required.)
(cd $GENERATOR_ROOT; \
dotnet restore -v quiet; \
dotnet publish -v quiet -nologo -clp:NoSummary -c Release --self-contained --runtime=$RUNTIME Google.Api.Generator)
}

install_grpc() {
Expand Down