Skip to content

Commit 0ebc098

Browse files
committed
centralize output folder computation
1 parent 496c742 commit 0ebc098

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

library_generation/generate_library.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ shift # past argument or value
5454
done
5555

5656
script_dir=$(dirname "$(readlink -f "$0")")
57-
output_folder="$(pwd)/output"
58-
# source utility functions
5957
source "${script_dir}"/utilities.sh
58+
output_folder="$(get_output_folder)"
59+
# source utility functions
6060

6161
if [ -z "${protobuf_version}" ]; then
6262
protobuf_version=$(get_protobuf_version "${gapic_generator_version}")

library_generation/test/generate_library_integration_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ done
4545
script_dir=$(dirname "$(readlink -f "$0")")
4646
source "${script_dir}/../utilities.sh"
4747
library_generation_dir="${script_dir}"/..
48-
output_folder="$(pwd)/output"
48+
output_folder="$(get_output_folder)"
4949
mkdir -p "${output_folder}"
5050
pushd "${output_folder}"
5151
# checkout the master branch of googleapis/google (proto files) and WORKSPACE

library_generation/utilities.sh

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22

33
set -xeo pipefail
4+
utilities_script_dir=$(echo "${BASH_SOURCE}" | rev | cut -d/ -f2- | rev)
5+
46

57
# define utility functions
68

@@ -275,3 +277,10 @@ get_version_from_versions_txt() {
275277
version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is snapshot
276278
echo "${version}"
277279
}
280+
281+
# gets the output folder where all sources and dependencies will be located. It
282+
# relies on utilities_script_dir which points to the same location as
283+
# `generate_library.sh`
284+
get_output_folder() {
285+
echo "${utilities_script_dir}/output"
286+
}

0 commit comments

Comments
 (0)