forked from googleapis/google-api-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildGenerated.sh
executable file
·112 lines (104 loc) · 2.95 KB
/
BuildGenerated.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -e
# "nuget restore" fails if local package source directories don't exist.
mkdir -p NuPkgs/Support
# Final output directory of NuPkgs.
NUPKG_DIR=$(pwd)/NuPkgs/Generated
# Build configuration to build/pack.
BUILD_CONFIGURATION=Release
# Directory in which to download discovery docs.
DISCOVERY_DOC_DIR=$(pwd)/DiscoveryJson
# Code generation directory
CODE_GENERATION_DIR=$(pwd)/Src/Generated
# Directory containing tools used during the build.
TOOLS_DIR=$(pwd)/Src/Tools
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--skipdownload)
SKIPDOWNLOAD=TRUE
;;
--skipgenerate)
SKIPDOWNLOAD=TRUE
SKIPGENERATE=TRUE
;;
--skipbuild)
SKIPDOWNLOAD=TRUE
SKIPGENERATE=TRUE
SKIPBUILD=TRUE
;;
--skippack)
SKIPDOWNLOAD=TRUE
SKIPGENERATE=TRUE
SKIPBUILD=TRUE
SKIPPACK=TRUE
;;
--onlydownload)
SKIPGENERATE=TRUE
SKIPBUILD=TRUE
SKIPPACK=TRUE
;;
--onlygenerate)
SKIPDOWNLOAD=TRUE
SKIPBUILD=TRUE
SKIPPACK=TRUE
;;
--onlybuild)
SKIPDOWNLOAD=TRUE
SKIPGENERATE=TRUE
SKIPPACK=TRUE
;;
--onlypack)
SKIPDOWNLOAD=TRUE
SKIPGENERATE=TRUE
SKIPBUILD=TRUE
;;
*)
echo ERROR: Invalid argument to BuildGenerated.sh: \'$key\'
exit 1
esac
shift
done
if [ -z ${SKIPDOWNLOAD+x} ]; then
# Delete all discovery docs
echo Deleting existing \'$DISCOVERY_DOC_DIR\' directory...
rm -rf $DISCOVERY_DOC_DIR
# Download all discovery docs
python -u get_discovery_documents.py --destination_dir $DISCOVERY_DOC_DIR
# Patch discovery docs
dotnet restore $TOOLS_DIR/DiscoveryDocPatcher/DiscoveryDocPatcher.csproj
dotnet run --project $TOOLS_DIR/DiscoveryDocPatcher/DiscoveryDocPatcher.csproj -- $DISCOVERY_DOC_DIR
fi
if [ -z ${SKIPGENERATE+x} ]; then
# Delete all generated code
echo Deleting existing \'$CODE_GENERATION_DIR\' directory...
rm -rf $CODE_GENERATION_DIR
# Generate API projects from discovery docs
export PYTHONPATH=$(pwd)/ClientGenerator/src
for jsonfile in $DISCOVERY_DOC_DIR/*.json; do
IFS='/'; names=($jsonfile); unset IFS
name=${names[-1]}
case $name in
identitytoolkit_v3.json|oauth2_v1.json)
echo Ignoring: \'$name\'
;;
*)
echo Generating: \'$name\'
python -uR $(pwd)/ClientGenerator/src/googleapis/codegen/generate_library.py --input="$jsonfile" --language=csharp --output_dir="$CODE_GENERATION_DIR"
;;
esac
done
fi
if [ -z ${SKIPBUILD+x} ]; then
rm -f Generated.sln
dotnet new sln --name Generated
dotnet sln Generated.sln add $CODE_GENERATION_DIR/*/*.csproj
dotnet restore Generated.sln
dotnet build Generated.sln --configuration $BUILD_CONFIGURATION
fi
if [ -z ${SKIPPACK+x} ]; then
# Delete all generated nupkgs
echo Deleting existing \'$NUPKG_DIR\' directory...
rm -rf $NUPKG_DIR
dotnet pack Generated.sln --configuration $BUILD_CONFIGURATION --no-build --output $NUPKG_DIR
fi