Skip to content

Commit

Permalink
Make the microgenerator run under Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jskeet committed Sep 18, 2019
1 parent 118fa35 commit ee270ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
13 changes: 1 addition & 12 deletions generateapis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ fetch_github_repos() {
--config core.eol=lf
fi

if [ -d "gapic-generator-csharp" ]
then
git -C gapic-generator-csharp pull -q
git -C gapic-generator-csharp submodule update
else
git clone --recursive https://github.com/googleapis/gapic-generator-csharp
fi

if [[ "$SYNTHTOOL_GOOGLEAPIS" == "" ]]
then
if [ -d "googleapis" ]
Expand Down Expand Up @@ -237,6 +229,7 @@ generate_api() {
# Entry point

install_protoc
install_microgenerator
install_grpc
fetch_github_repos
GAPIC_GENERATOR_VERSION=$(cat gapic-generator/version.txt)
Expand All @@ -246,10 +239,6 @@ GAPIC_GENERATOR_VERSION=$(cat gapic-generator/version.txt)
# won't be using Gradle at all by the end of 2018, with any luck...
(cd gapic-generator; ./gradlew shadowJar --warning-mode=none)

# Build the microgenerator
(cd gapic-generator-csharp; dotnet publish -c Release --self-contained --runtime=win-x64 Google.Api.Generator)
declare -r GAPIC_PLUGIN=gapic-generator-csharp/Google.Api.Generator/bin/Release/netcoreapp2.2/win-x64/publish/Google.Api.Generator.exe

OUTDIR=tmp
rm -rf $OUTDIR
mkdir $OUTDIR
Expand Down
32 changes: 32 additions & 0 deletions toolversions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,38 @@ install_protoc() {
chmod +x $PROTOC
}

install_microgenerator() {
# TODO: Use a specific tag, or even a NuGet package eventually
if [ -d "gapic-generator-csharp" ]
then
git -C gapic-generator-csharp pull -q
git -C gapic-generator-csharp submodule update
else
git clone --recursive https://github.com/googleapis/gapic-generator-csharp
fi

case "$OSTYPE" in
linux*)
declare -r RUNTIME=linux-x64
declare -r EXTENSION=
;;
darwin*)
echo "Microgenerator not currently supported on MacOSX. Ask jonskeet@ for help."
exit 1
;;
win* | msys* | cygwin*)
declare -r RUNTIME=win-x64
declare -r EXTENSION=.exe
;;
*)
echo "Unknown OSTYPE: $OSTYPE"
exit 1
esac
(cd gapic-generator-csharp; dotnet publish -c Release --self-contained --runtime=$RUNTIME Google.Api.Generator)

export GAPIC_PLUGIN=$REPO_ROOT/gapic-generator-csharp/Google.Api.Generator/bin/Release/netcoreapp2.2/$RUNTIME/publish/Google.Api.Generator$EXTENSION
}

install_grpc() {
install_nuget_package Grpc.Tools $GRPC_VERSION
chmod +x $GRPC_PLUGIN
Expand Down

0 comments on commit ee270ef

Please sign in to comment.