forked from googleapis/google-api-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSharpGeneratorFunctions.sh
43 lines (39 loc) · 1.5 KB
/
CSharpGeneratorFunctions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This is intended to be imported using the "source" function
# from any script that wants to invoke the C#-based generator.
TMP_CSHARP_GENERATOR_DIR=tmp-gapic-generator-csharp
if [[ $CSHARP_GENERATOR_DIR == "" ]]
then
CSHARP_GENERATOR_DIR=$TMP_CSHARP_GENERATOR_DIR
fi
# Installs the C# generator in a tmp-gapic-generator-csharp directory,
# unless it an existing generator directory is specified via the
# CSHARP_GENERATOR_DIR environment variable.
# When installing, if the directory already exists, it is deleted first.
install_csharp_generator() {
if [[ $CSHARP_GENERATOR_DIR == $TMP_CSHARP_GENERATOR_DIR ]]
then
echo "Installing C# generator in $CSHARP_GENERATOR_DIR"
rm -rf $CSHARP_GENERATOR_DIR
git clone --quiet --recursive --depth=1 \
https://github.com/googleapis/gapic-generator-csharp.git \
$CSHARP_GENERATOR_DIR
else
echo "Using C# generator in $CSHARP_GENERATOR_DIR"
fi
echo 'Building C# generator'
(cd $CSHARP_GENERATOR_DIR && \
dotnet build -c Release -nologo -clp:NoSummary -v quiet Google.Api.Generator.Rest)
echo 'Generator build complete'
}
# Runs the C# generator, which is expected to be installed in
# tmp-gapic-generator-csharp as per install_csharp_generator()
# Expected arguments:
# - Discovery doc
# - Output directory (a subdirectory will be created under this)
# - Features file
# - Enum storage file
run_csharp_generator() {
dotnet run --no-build -c Release \
-p $CSHARP_GENERATOR_DIR/Google.Api.Generator.Rest \
-- "$1" "$2" "$3" "$4"
}