forked from googleapis/google-api-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildGenerated.sh
executable file
·68 lines (58 loc) · 1.76 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
#!/bin/bash
# Builds an already-generated set of API libraries, as specified
# by command-line arguments. The libraries to build can be
# specified as multiple arguments (one per library), or as a single
# file containing a list of files/directories, using the "@" prefix.
# Each file/directory should be one of:
# - A project file
# - A directory containing a project
# - A JSON file - the Discovery doc for the service to be built
#
# Common examples:
#
# In autorelease.sh:
# ./BuildGenerated @tmp/ApisToGenerate.sh
#
# After regenerating everything:
# ./BuildGenerated.sh DiscoveryJson/*.json
#
# Just to build all projects that currently exist:
# ./BuildGenerate.sh Src/Generated/*
set -e
# Final output directory of NuPkgs.
NUPKG_DIR=$(pwd)/NuPkgs/Generated
rm -rf $NUPKG_DIR
if [[ $1 == "" ]]
then
echo "Usage options:"
echo " BuildGenerated.sh <file1> [file2]"
echo " BuildGenerated.sh @file-with-paths"
echo "Each file (either in file-with-paths or specified directly)"
echo "should be a directory containing a project file, or a Discovery doc"
exit 1
fi
if [[ $1 == @* ]]
then
file=${1:1}
if [[ ! -f $file ]]
then
echo "Error: $file does not exist"
exit 1
fi
if [[ ! -s $file ]]
then
echo "$file is empty; assuming nothing needs building."
exit 0
fi
fi
echo "Creating solution"
# First argument is the generation directory, used for when Discovery docs have been specified.
PROJECTS=$(dotnet run --project Src/Tools/BuildGeneratedArgumentTranslator -- Src/Generated $*)
rm -rf Generated.sln
dotnet new sln --name Generated
echo $PROJECTS | xargs dotnet sln Generated.sln add
echo "Building/packing"
export CI=true
export DeterministicSourcePaths=true
dotnet pack Generated.sln -c Release -o $NUPKG_DIR
echo "Build complete"